Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement org.freedesktop.appearance.color-scheme support on Linux #7422

Merged
merged 1 commit into from
Feb 18, 2022

Conversation

vimpostor
Copy link
Contributor

@vimpostor vimpostor commented Feb 16, 2022

This finally allows us to follow the system theme without restart in a reliable and desktop-environment independent way.

This uses the new standardized org.freedesktop.appearance.color-scheme key to accomplish this.

The following DEs already support this in the respective version:

  • KDE Plasma since version 5.24 (Released 2022-02-08)
  • Gnome since version 42 (Unreleased as of now)

In addition to that, the xdg-deskop-portal user service needs to be running.

Relevant blog post: https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/

Properly fixes #7146 (was closed as it was basically impossible to implement this in a reliable way a few years back)

Note that if the user does not have xdg-desktop-portal or is missing support for that specific key, the previous behaviour is unchanged.

Short demo:

demo.mp4

Type of change

  • ✅ New feature (change that adds functionality)

The new org.freedesktop.appearance.color-scheme key allows us to do this
in a reliable way.

Recently freedesktop standardized the system dark mode preference in a
desktop environment independent way in the xdg-desktop-portal
specification.

The specification can be seen here: https://github.com/flatpak/xdg-desktop-portal/blob/d7a304a00697d7d608821253cd013f3b97ac0fb6/data/org.freedesktop.impl.portal.Settings.xml#L33-L45

KDE supports this since KDE Plasma 5.24 and Gnome supports this since
Gnome 42.

Relevant blog post: https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/

Fixes keepassxreboot#7146
@droidmonkey
Copy link
Member

Awesome!

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2022

Codecov Report

Merging #7422 (19f08c3) into develop (58615d7) will increase coverage by 0.01%.
The diff coverage is 70.59%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #7422      +/-   ##
===========================================
+ Coverage    64.33%   64.33%   +0.01%     
===========================================
  Files          339      339              
  Lines        43199    43216      +17     
===========================================
+ Hits         27788    27802      +14     
- Misses       15411    15414       +3     
Impacted Files Coverage Δ
src/gui/osutils/nixutils/NixUtils.h 50.00% <ø> (ø)
src/gui/osutils/nixutils/NixUtils.cpp 33.53% <70.59%> (+4.12%) ⬆️
src/core/Entry.cpp 82.76% <0.00%> (+0.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58615d7...19f08c3. Read the comment docs.

@droidmonkey droidmonkey merged commit d10c5a4 into keepassxreboot:develop Feb 18, 2022
@vimpostor
Copy link
Contributor Author

vimpostor commented Feb 21, 2022

FYI I think Gnome might be violating their own spec, i.e. they return "No preference" instead of "Prefers light theme" when the user explicitly chooses a light theme. I am not completely sure about this, and since Gnome 42 hasn't been released yet, it can still change, but it is something to keep in mind.
Feel free to ping me, if such an issue ever comes up.

The problem would be easy to fix (just interpet "No preference" as light preference), however I think Gnome should just report the correct preference ("prefers light theme") in the first place instead of shipping such a broken Portal implementation.

@droidmonkey
Copy link
Member

Have you filed a bug report with them?

@vimpostor
Copy link
Contributor Author

Have you filed a bug report with them?

Well not yet, as I am not sure if my assumption is even true. I only assume this, because their blog post was hinting towards this, I yet have to await the Gnome release to see if it's actually the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support live theme switching for Linux
3 participants