From 45142d2596f72c6861e149a47635ba342d10c4f6 Mon Sep 17 00:00:00 2001 From: Ronald1985 Date: Tue, 17 Oct 2023 21:37:45 +0100 Subject: [PATCH] Added dark mode. Also ensure naming is consistent in icon packages. --- .../darkmusicicon.png} | Bin .../darkmusicicon_unix.go} | 34 +++++++------- icons/lightmusicicon/lightmusicicon.png | Bin 0 -> 164 bytes icons/lightmusicicon/lightmusicicon_unix.go | 23 ++++++++++ main.go | 42 +++++++++++------- 5 files changed, 67 insertions(+), 32 deletions(-) rename icons/{musicicon/music_icon.png => darkmusicicon/darkmusicicon.png} (100%) rename icons/{musicicon/music_icon.go => darkmusicicon/darkmusicicon_unix.go} (81%) create mode 100644 icons/lightmusicicon/lightmusicicon.png create mode 100644 icons/lightmusicicon/lightmusicicon_unix.go diff --git a/icons/musicicon/music_icon.png b/icons/darkmusicicon/darkmusicicon.png similarity index 100% rename from icons/musicicon/music_icon.png rename to icons/darkmusicicon/darkmusicicon.png diff --git a/icons/musicicon/music_icon.go b/icons/darkmusicicon/darkmusicicon_unix.go similarity index 81% rename from icons/musicicon/music_icon.go rename to icons/darkmusicicon/darkmusicicon_unix.go index 200f4dc..352ffbe 100644 --- a/icons/musicicon/music_icon.go +++ b/icons/darkmusicicon/darkmusicicon_unix.go @@ -1,23 +1,23 @@ -//+build linux darwin +//go:build linux || darwin +// +build linux darwin // File generated by 2goarray v0.1.0 (http://github.com/cratonica/2goarray) -package icon +package darkmusicicon var Data []byte = []byte{ - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, - 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, - 0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7a, 0x7a, 0xf4, 0x00, 0x00, 0x00, - 0x66, 0x49, 0x44, 0x41, 0x54, 0x58, 0x85, 0xed, 0x94, 0xc1, 0x0a, 0xc0, - 0x30, 0x08, 0x43, 0xd3, 0xb2, 0xff, 0xff, 0x65, 0x7b, 0x2d, 0xe2, 0xc1, - 0x05, 0x45, 0xd8, 0xf2, 0x8e, 0xa5, 0xb6, 0x21, 0x6a, 0x00, 0x21, 0xc4, - 0xdf, 0x59, 0x44, 0x8d, 0x15, 0xbd, 0x03, 0x00, 0xd8, 0x6c, 0xa1, 0x23, - 0x12, 0xd5, 0x86, 0x05, 0x1f, 0x46, 0x67, 0x29, 0xaa, 0x1c, 0xb8, 0x85, - 0x8c, 0x08, 0x18, 0x9f, 0x01, 0x9a, 0x4a, 0x01, 0x94, 0x0b, 0xd5, 0x0e, - 0xbc, 0x16, 0xf1, 0xa9, 0x16, 0x50, 0x3c, 0xc9, 0x7b, 0x6d, 0x41, 0x93, - 0x71, 0xa0, 0x35, 0xe5, 0xc6, 0x5b, 0x20, 0x01, 0xd9, 0xbd, 0xf5, 0x73, - 0x40, 0x47, 0xaf, 0x10, 0x42, 0x78, 0x0e, 0x53, 0x84, 0x0a, 0x1a, 0xfa, - 0x5d, 0x0e, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, - 0x42, 0x60, 0x82, + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, + 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, + 0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7a, 0x7a, 0xf4, 0x00, 0x00, 0x00, + 0x66, 0x49, 0x44, 0x41, 0x54, 0x58, 0x85, 0xed, 0x94, 0xc1, 0x0a, 0xc0, + 0x30, 0x08, 0x43, 0xd3, 0xb2, 0xff, 0xff, 0x65, 0x7b, 0x2d, 0xe2, 0xc1, + 0x05, 0x45, 0xd8, 0xf2, 0x8e, 0xa5, 0xb6, 0x21, 0x6a, 0x00, 0x21, 0xc4, + 0xdf, 0x59, 0x44, 0x8d, 0x15, 0xbd, 0x03, 0x00, 0xd8, 0x6c, 0xa1, 0x23, + 0x12, 0xd5, 0x86, 0x05, 0x1f, 0x46, 0x67, 0x29, 0xaa, 0x1c, 0xb8, 0x85, + 0x8c, 0x08, 0x18, 0x9f, 0x01, 0x9a, 0x4a, 0x01, 0x94, 0x0b, 0xd5, 0x0e, + 0xbc, 0x16, 0xf1, 0xa9, 0x16, 0x50, 0x3c, 0xc9, 0x7b, 0x6d, 0x41, 0x93, + 0x71, 0xa0, 0x35, 0xe5, 0xc6, 0x5b, 0x20, 0x01, 0xd9, 0xbd, 0xf5, 0x73, + 0x40, 0x47, 0xaf, 0x10, 0x42, 0x78, 0x0e, 0x53, 0x84, 0x0a, 0x1a, 0xfa, + 0x5d, 0x0e, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, + 0x42, 0x60, 0x82, } - diff --git a/icons/lightmusicicon/lightmusicicon.png b/icons/lightmusicicon/lightmusicicon.png new file mode 100644 index 0000000000000000000000000000000000000000..ee959f7bf0f5996abefd38df6ac351d27b82505c GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJY)==*kcif|S1xiLP~c#_AoKfw z{J!c)0n-ycg4b;O0}C&15>c|6yGD+o;i1sPr`4-YS8ezzs>Ktx*;IEr*A~YhrX~9u zW%C%B478TP M)78&qol`;+01yy4;Q#;t literal 0 HcmV?d00001 diff --git a/icons/lightmusicicon/lightmusicicon_unix.go b/icons/lightmusicicon/lightmusicicon_unix.go new file mode 100644 index 0000000..5aa719e --- /dev/null +++ b/icons/lightmusicicon/lightmusicicon_unix.go @@ -0,0 +1,23 @@ +//go:build linux || darwin +// +build linux darwin + +// File generated by 2goarray v0.1.0 (http://github.com/cratonica/2goarray) + +package lightmusicicon + +var Data []byte = []byte{ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, + 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, + 0x08, 0x06, 0x00, 0x00, 0x00, 0x73, 0x7a, 0x7a, 0xf4, 0x00, 0x00, 0x00, + 0x6b, 0x49, 0x44, 0x41, 0x54, 0x58, 0x85, 0xed, 0xd4, 0xd1, 0x0a, 0xc0, + 0x20, 0x08, 0x05, 0xd0, 0x1c, 0xfb, 0xff, 0x5f, 0xbe, 0x7b, 0x59, 0x10, + 0x35, 0xc8, 0x4c, 0x11, 0xd6, 0x3d, 0x8f, 0x51, 0x71, 0xd1, 0xb2, 0x14, + 0x22, 0x3a, 0x9d, 0xac, 0x1e, 0x00, 0x80, 0xe1, 0x12, 0x91, 0xe5, 0x7b, + 0xaa, 0xcb, 0x7a, 0xb0, 0xf5, 0x15, 0x2a, 0x0c, 0x5e, 0xb3, 0x35, 0x2d, + 0x97, 0x0a, 0xb4, 0x41, 0x52, 0x02, 0xa4, 0xbf, 0x81, 0x1d, 0x6e, 0x01, + 0xac, 0x55, 0x70, 0xad, 0x80, 0x25, 0xc4, 0x7f, 0x5a, 0x60, 0x75, 0x6b, + 0x36, 0x45, 0x0e, 0x9a, 0x69, 0x05, 0xa2, 0xa7, 0x5c, 0x7a, 0x0b, 0x18, + 0x40, 0xf5, 0x6f, 0xfb, 0x77, 0xb0, 0x33, 0x7a, 0x89, 0x88, 0x7a, 0x0f, + 0x85, 0x57, 0x28, 0x0b, 0x38, 0xcb, 0x41, 0x93, 0x00, 0x00, 0x00, 0x00, + 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +} diff --git a/main.go b/main.go index 60a3fc5..ce80f0d 100644 --- a/main.go +++ b/main.go @@ -11,9 +11,10 @@ import ( "strings" "time" + darkmusicicon "gitea.ronald1985.uk/ronald1985/Eye-Reminder/icons/darkmusicicon" disabledicon "gitea.ronald1985.uk/ronald1985/Eye-Reminder/icons/disabledicon" enabledicon "gitea.ronald1985.uk/ronald1985/Eye-Reminder/icons/enabledicon" - musicicon "gitea.ronald1985.uk/ronald1985/Eye-Reminder/icons/musicicon" + lightmusicicon "gitea.ronald1985.uk/ronald1985/Eye-Reminder/icons/lightmusicicon" "github.com/gen2brain/beeep" "github.com/gen2brain/malgo" @@ -26,13 +27,14 @@ import ( const ( DEFAULT_TIME_INBETWEEN_NOTIFICATIONS = 20 * time.Minute EYE_REMINDER_ICON_URL = "https://gitea.ronald1985.uk/ronald1985/Eye-Reminder/raw/branch/master/assets/Eye-Reminder-Icon.png" - DEFAULT_CONFIG_FILE = "Interval: 20\nSoundEnabled: false\nMP3File: \"\"" + DEFAULT_CONFIG_FILE = "Interval: 20\nSoundEnabled: false\nMP3File: \"\"\nDarkTheme: true" ) type Config struct { Interval int `yaml:"Interval"` SoundEnabled bool `yaml:"SoundEnabled"` WAVFile string `yaml:"MP3File"` + darkTheme bool `yaml:"DarkTheme"` imageLocation string } @@ -199,6 +201,10 @@ func systrayOnReady() { "Sound enabled", "Whether sound is played", ProgramConfig.SoundEnabled, ) systray.AddSeparator() + mDarkThemeEnabled := systray.AddMenuItemCheckbox( + "Dark mode enabled", "Whether the dark theme icons are used", ProgramConfig.darkTheme, + ) + systray.AddSeparator() mQuitOrig := systray.AddMenuItem("Quit", "Quit the whole app") go func() { @@ -223,7 +229,11 @@ func systrayOnReady() { mStopSound.Enable() - systray.SetIcon(musicicon.Data) + if ProgramConfig.darkTheme { + systray.SetIcon(lightmusicicon.Data) + } else { + systray.SetIcon(darkmusicicon.Data) + } PlayWAVFile(ProgramConfig.WAVFile, &stopSound) @@ -243,43 +253,45 @@ func systrayOnReady() { for { select { case <-mEnabled.ClickedCh: + enabled = !enabled + if mEnabled.Checked() { mEnabled.Uncheck() - enabled = false - currentIcon = disabledicon.Data systray.SetIcon(currentIcon) } else { mEnabled.Check() - enabled = true - currentIcon = enabledicon.Data systray.SetIcon(currentIcon) } case <-mNotificationsEnabled.ClickedCh: + notificationsEnabled = !notificationsEnabled + if mNotificationsEnabled.Checked() { mNotificationsEnabled.Uncheck() - - notificationsEnabled = false } else { mNotificationsEnabled.Check() - - notificationsEnabled = true } case <-mSoundEnabled.ClickedCh: + soundEnabled = !soundEnabled + if mSoundEnabled.Checked() { mSoundEnabled.Uncheck() - - soundEnabled = false } else { mSoundEnabled.Check() - - soundEnabled = false } case <-mStopSound.ClickedCh: stopSound = true + case <-mDarkThemeEnabled.ClickedCh: + ProgramConfig.darkTheme = !ProgramConfig.darkTheme + + if mDarkThemeEnabled.Checked() { + mDarkThemeEnabled.Uncheck() + } else { + mDarkThemeEnabled.Check() + } } } }()