Listening for OS theme change #2035
-
Hi everyone, Quick rundown, I have an electron app I'm converting to use Wails. On the Electron side, there's a module that allows you to subscribe to system preferences changes using Apple's "NSDistributedNotificationCenter" API. With this I can listen for when the OS changes to Dark mode or Light mode and emit an event to have my CSS change up to match the colors better depending on the theme. Right now with Wails, if the OS theme changes, colors tend to disappear when you have white text with the Light theme and vice versa. Is there a way in Wails to listen for this change yet? I tried playing around with the Appearance Options but couldn't get anything to output from there. Would rather make these changes during the startup somehow. I tried emitting an event during the Go startup function as well, but the JS side doesn't seem to be up and listening yet for the event when it gets sent so it never sees it. It's possible I'm doing something wrong as well. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi 👋 It exists on a branch so we could bring it in at some point. There's a nuance that on Windows you have an additional "high contrast" mode per theme. What do you think the API would look like? I definitely think you should open an enhancement ticket with the suggestions 👍 On a side note, we need to shore up system eventing. |
Beta Was this translation helpful? Give feedback.
-
I was thinking something like the electron API, just not sure how feasible that would be for other platforms like Windows/Linux:
I don't know how hard or if even possible to listen to these types of events on other OS's. I can definitely open an enhancement request though. Thanks for responding! |
Beta Was this translation helpful? Give feedback.
Hi 👋 It exists on a branch so we could bring it in at some point. There's a nuance that on Windows you have an additional "high contrast" mode per theme. What do you think the API would look like? I definitely think you should open an enhancement ticket with the suggestions 👍
On a side note, we need to shore up system eventing.