xfangfang / wiliwili

第三方B站客户端,目前可以运行在PC全平台、PSVita、PS4 、Xbox 和 Nintendo Switch上
https://xfangfang.github.io/wiliwili
GNU General Public License v3.0
3.11k stars 145 forks source link

[Feature Request]: Linux: theme: auto switch #181

Open yuioto opened 1 year ago

yuioto commented 1 year ago

Discussed in https://github.com/xfangfang/wiliwili/discussions/177

Originally posted by **yuioto** July 27, 2023 # wiliwili 的自动暗黑模式不在Linux工作 原讨论大致为wiliwili不支持在Linux下识别主题。只能通过启动时读取环境变量或配置文件overwrite。
yuioto commented 1 year ago

Support org.freedesktop.appearance.color-scheme to retreive system dark mode

There is now a desktop environment independent way to query the system dark mode: The org.freedesktop.appearance.color-scheme key in the XDG desktop portal.

It's also possible to be notified during runtime as soon as the dark mode preference changes.

Example desktop environments that have support for this key are:

More info

Example apps and implementations that already support this key

On Linux shell get dbus message

gdbus call --session --timeout=1000 \ 
--dest=org.freedesktop.portal.Desktop \ 
--object-path /org/freedesktop/portal/desktop \ 
--method org.freedesktop.portal.Settings.Read org.freedesktop.appearance color-scheme

Copy from: https://unix.stackexchange.com/questions/701432/command-for-detecting-whether-the-system-is-using-a-dark-or-light-desktop-theme