mirror of
https://github.com/Xpl0itU/WiiUDownloader.git
synced 2025-06-06 17:51:21 -04:00
Add dark mode
This commit is contained in:
parent
d056005725
commit
cbf0e0346c
2 changed files with 40 additions and 0 deletions
34
cmd/WiiUDownloader/darkMode.go
Normal file
34
cmd/WiiUDownloader/darkMode.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func isDarkMode() bool {
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
cmd := exec.Command("defaults", "read", "-g", "AppleInterfaceStyle")
|
||||
output, err := cmd.Output()
|
||||
if err == nil && strings.TrimSpace(string(output)) == "Dark" {
|
||||
return true
|
||||
}
|
||||
|
||||
case "windows":
|
||||
cmd := exec.Command("reg", "query", "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", "/v", "AppsUseLightTheme")
|
||||
output, err := cmd.Output()
|
||||
if err == nil && strings.Contains(string(output), "REG_DWORD") && strings.Contains(string(output), "0x0") {
|
||||
return true
|
||||
}
|
||||
|
||||
case "linux":
|
||||
cmd := exec.Command("gsettings", "get", "org.gnome.desktop.interface", "gtk-theme")
|
||||
output, err := cmd.Output()
|
||||
if err == nil && strings.TrimSpace(string(output)) == "'Adwaita-dark'" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
|
@ -43,6 +43,12 @@ type MainWindow struct {
|
|||
func NewMainWindow(entries []wiiudownloader.TitleEntry, logger *wiiudownloader.Logger) *MainWindow {
|
||||
gtk.Init(nil)
|
||||
|
||||
gSettings, err := gtk.SettingsGetDefault()
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
}
|
||||
gSettings.SetProperty("gtk-application-prefer-dark-theme", isDarkMode())
|
||||
|
||||
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
|
||||
if err != nil {
|
||||
logger.Fatal("Unable to create window:", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue