Skip to content

Commit

Permalink
Fall back to old Gnome prefer-dark if first try fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Aug 7, 2024
1 parent a9536c1 commit e8b340b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion settings/appearance/appearance.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Package appearance is a helper package for reading appearance settings.
package appearance

const appearanceNamespace = "org.freedesktop.appearance"
const (
appearanceNamespace = "org.freedesktop.appearance"
gnomeInterfaceNamespace = "org.gnome.desktop.interface"
)
16 changes: 15 additions & 1 deletion settings/appearance/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
func GetColorScheme() (ColorScheme, error) {
value, err := settings.ReadOne(appearanceNamespace, "color-scheme")
if err != nil {
return NoPreference, err
return getGnomeInterfacePreference() // Fallback if new interface does not exist.
}

result := value.(uint32)
Expand Down Expand Up @@ -74,3 +74,17 @@ func GetAccentColor() (*color.RGBA, error) {
A: uint8(alpha),
}, nil
}

func getGnomeInterfacePreference() (ColorScheme, error) {
value, err := settings.ReadOne(gnomeInterfaceNamespace, "color-scheme")
if err != nil {
return NoPreference, err
}

result := value.(string)
if result == "prefer-dark" {
return Dark, nil
}

return NoPreference, nil
}

0 comments on commit e8b340b

Please sign in to comment.