Detecting system theme changes on platforms #159
PhantomGamers
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Windows
On Windows you can subscribe to
Microsoft.Win32.SystemEvents.UserPreferenceChangedfrom https://www.nuget.org/packages/Microsoft.Win32.SystemEvents/ as long as your app is targeting .net 5 or higher.See https://github.com/PhantomGamers/SFP/blob/ead9c6f3765adbfb3574934bdbbea7c2facbc0fd/SFP_UI/Views/MainWindow.axaml.cs#L93-L109= for an example
Linux
On Linux, similar to how FluentAvalonia uses
gsettings get org.gnome.desktop.interface gtk-themeto detect the theme, we can launch a process that runsgsettings monitor org.gnome.desktop.interface gtk-themeto determine when that changes.See https://github.com/PhantomGamers/SFP/blob/f3e6c0114ce079c7a13d1eeb355666e4c26474eb/SFP_UI/Models/ThemeChangeDetection/Linux.cs for an example of this
OSX
Now this I'm not sure about. Is there an easy way to monitor for defaults settings changes on OSX? Looking online it doesn't seem like defaults has a monitor argument like gsettings does.
Beta Was this translation helpful? Give feedback.
All reactions