SchildiChat / schildichat-desktop

Matrix client / Element Web/Desktop fork
https://schildi.chat
Apache License 2.0
371 stars 42 forks source link

Light / Dark theme: Switch between themes in sync with the system's dark mode setting #110

Closed sam9032 closed 2 years ago

sam9032 commented 2 years ago

Hey there, it would be amazing, if the client changes the theme as soon as the OS changes its preference. As far as I can see, the client gets the OS preference only at program start and not if it changes later.

The Electron native interface changes its appearance as soon as the OS changes its preference so maybe there is a way to subscribe to this information from electron?

su-ex commented 2 years ago

I assume you are on Linux and using the desktop variant (with the web version in Firefox it'd work)?!? See the section "Linux system theme detection workaround" here: https://github.com/SchildiChat/schildichat-desktop/releases/tag/v1.8.4-sc1

sam9032 commented 2 years ago

Oh wow.. Yes, I use Linux with the desktop variant. Thank you so much! The workaround works for schildichat and the Plugin in my OS which switches from day to night even has the option to fire a command as it switches. The Element Client seems to work different there, the command doesn't work.

I'm following some discussions about the dark mode implementation in various apps and have never heard of the Chromium bug, so thanks for pointing me to this! Since there are also electron apps that manage the switch without problems, I didn't expect a bug.

So schildichat relies on the CSS prefers-color-scheme media query?

su-ex commented 2 years ago

That's a workaround I've added to SchildiChat since this non-adjustment to light/dark got on my nerves, so Element doesn't have it of course. 😁 Light/dark switch was broken with VSCodium (another electron app) some versions ago as well and only recently has this working. I assume they either ship a patched chromium/electron now or they watch some files in the filesystem. Both these options have been too much work for me to implement, that's why I have externalized this issue and exposed cli arguments. Yes, Element and therefore SchildiChat as well listens to changes of prefers-color-scheme. This is fine by itself as it works in Firefox but also with electron on Windows and macOS. There was some movement with the chromium issue recently so I hope this will eventually get fixed on Linux. In the meantime I'm fine with my workaround. 🙃

sam9032 commented 2 years ago

Thanks for that! :rocket: According to the vscode issue https://github.com/microsoft/vscode/issues/102795 electron 13 fixes the problem. Maybe it really has been fixed and will work for all electron apps on Linux, that would be great.

su-ex commented 2 years ago

We're already using electron 13, so that's weird. But websites in chromium don't switch light/dark theme as well and the issue is still open in their bugtracker. So I think this will eventually get fixed for electron only once chromium has this fixed.