Using Adwaita Dark on another compositor

I am not using GNOME, but I admire the aesthetics choices of the GNOME team and libadwaita. There was a recent update that caused my GTK to stop using the dark variant and the gtk-application-prefer-dark-theme setting stopped working for libadwaita. I realize this was due to a new implementation that was made, so I am wondering what the appropriate method for setting Adwaita to the dark color-scheme globally is now. Thank you for the time you guys have put in on this theme. It’s been my favorite GTK theme for a some time now.

1 Like
gsettings set org.gnome.desktop.interface color-scheme prefer-dark
2 Likes

Thank you for your response. I had previously set this in my compositor’s settings, and it seemed to be working just fine before the recent updates to both libadwaita and gnome-calculator. I tried this just now and it remains on the light setting. Not sure if this is a gnome-calculator issue or a libadwaita one. I try running this manually in the terminal to no avail.

I’ve also tried using GTK_THEME=Adwaita:dark for debugging and it renders gnome-calculator to have the default blue accents instead of its own default orange used by the particular application when running the dark color-scheme. If I run with gtk-application-prefer-dark-theme=1, I get this warning:

(gnome-calculator:69729): Adwaita-WARNING **: 14:39:06.173: Using GtkSettings:gtk-application-prefer-dark-theme with libadwaita is unsupported. %

This is why I’m here. I’m confused as to how to implement the dark setting on gnome-calculator (which i use often). When I open up gnome-tweaks, it does seem to be taking the dark color-scheme right now though. What all can I do to test or debug this issue? Thank you for your help.

1 Like

Does it work if you run calculator with ADW_DISABLE_PORTAL=1?

1 Like

Sure does, my friend. Thank you. Is that a temporary fix? I’m not sure how the code is being handled by libadwaita now that it’s been updated. Also, what’s the best way to implement this fix?

You need to run xdg-desktop-portal-gtk, or provide a portal implementation for your own desktop environment. Adwaita always goes through the portal, as it’s the only portable API for the dark style setting.

1 Like

It’s not a fix, but a way of figuring out what’s going on.

It means that libadwaita uses the preferred source of the setting, which is the settings portal. How to configure it depends on the implementation that is in use; apparently it’s not xdg-desktop-portal-gtk or xdg-desktop-portal-gnome, which would use the GSetting.

Is there a “dark style/theme” preference in the settings of your desktop environment?

1 Like

I have it installed, also xdg-desktop-portal-gnome, and xdg-desktop-portal-hyprland. Would any of these be in conflict? I’m using the Hyprland Wayland compositor. Everything was working as expected until the libadwaita update a few weeks ago, then gnome-calculator as well. I had previously downgraded my packages to maintain the dark color scheme, but I was hoping there was a way to fix this instead of just never updating. Thank you for your response.

Hyprland’s documentation says to run xdg-desktop-portal-gtk along side xdg-desktop-portal-hyprland, as per this page:

I’m not exactly sure if it’s supposed to be handled by the gtk portal instead, but I want to say so. All my other GTK apps are taking the dark theme, except of gnome-calculator. I’m not sure why that would happen.

You have been careful in not telling us the versions of every component.

I assume, since you’re talking about upgrades, that you have installed xdg-desktop-portal 1.18? In which case you need to configure the portal to include the GTK portal, i.e. put this in $HOME/.config/xdg-desktop-portal/portals.conf

[preferred]
default=hyprland;gtk

and make sure to restart xdg-desktop-portal and/or your session.

1 Like

If all your “other GTK apps” are GTK3, they will use the GTK_THEME environment variable or the setting; gnome-calculator is using libadwaita, which overrides the theme as it provides its own, and uses the Settings portal to be notified when the dark style is enabled.

1 Like

I’m using these portals:

  1. xdg-desktop-portal-1.18.0-2
  2. xdg-desktop-portal-gtk-1.14.1-3
  3. xdg-desktop-portal-gnome-45.0-1
  4. xdg-desktop-portal-hyprland-1.2.1-2

That makes sense. I don’t know why I thought gnome-tweaks was using gtk4. I went ahead and added the configuration in $HOME/.config/xdg-desktop-portal/portals.conf and it appears the situation is still the same. I logged out to TTY, restarted my session, and ran gsettings set org.gnome.desktop.interface color-scheme prefer-dark, and it doesn’t seem to change the setting. Thank you helping with this.

1 Like

If I’ve fulfilled all these requirements, should my libadwaita be functioning properly for GTK4 applications? I may be missing something else, but I’m not sure what it is. I’ve temporarily created a custom .desktop file to run gnome-calculator, but I don’t like shutting off features this way. I’d much rather use the software as it was intended. Please let me know if anyone else has any ideas of what I could do to troubleshoot this. I want to thank the GNOME team for building libadwaita and a very solid ecosystem.

Yes, it should. Unfortunately, since I have no idea how hyprland works or how your system is set up, I’m not entirely sure how to fix your issue.

At most, I can tell you to check whether xdg-desktop-portal-gtk is actually running, and whether xdg-desktop-portal is collecting the various settings. You can use:

G_MESSAGES_DEBUG=all xdg-desktop-portal --replace

to see the debugging messages for the portal.

1 Like

It appears the xdg-desktop-portal packaged by Arch Linux doesn’t come with a command with the equivalent name. I ran this:

ps aux | grep xdg-desktop-portal

and

journalctl | grep xdg-desktop-portal

Both gave me an output confirming it’s running. Journalctl showed me from the logs this morning that xdg-desktop-portal-gtk was having issues with a broken pipe:

Oct 12 07:11:32 user systemd[972]: Starting Portal service (GTK/GNOME implementation)...
Oct 12 07:11:32 user systemd[972]: Started Portal service (GTK/GNOME implementation).
Oct 12 07:17:17 user xdg-desktop-por[1355]: Error reading events from display: Broken pipe
Oct 12 07:17:17 user systemd[972]: xdg-desktop-portal-gtk.service: Main process exited, code=exited, status=1/FAILURE
Oct 12 07:17:17 user systemd[972]: xdg-desktop-portal-gtk.service: Failed with result 'exit-code'.
Oct 12 07:17:26 user systemd[972]: Starting Portal service (GTK/GNOME implementation)...
Oct 12 07:17:26 user systemd[972]: Started Portal service (GTK/GNOME implementation).

I went to the Hyprland docs where it discusses xdg-desktop-portal-hyprland and its use with xdg-desktop-portal-gtk and found out how to make it work with the compositor.

If you’re on Arch Linux and you’re having trouble with this precise issue, add this line to your hyprland.conf and it should fix it, so long as you also have xdg-desktop-portal-gtk installed and running:

exec-once = dbus-update-activation-environment --systemd --all 

Thank you for your help in narrowing this down, ebassi, and for your contributions to GNOME. I know open source doesn’t hear it enough. You guys really do make the Linux world go 'round.

1 Like

Hi, I would like to add for reference that this was the solution to my issues as well. I had the same exact issue using Ubuntu 23.10 ( upgraded from 23.04 ) and Sway WM. Everything was working fine in Ubuntu 23.04 and stopped after the upgrade. Having installed packages:
xdg-desktop-portal xdg-desktop-portal-gtk and xdg-desktop-portal-wlr

and then adding the file $HOME/.config/xdg-desktop-portal/portals.conf with :
[preferred]
default=gtk;wlr

solved all the issues.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.