dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

[BUG] Cannot switch theming in Gnome applications nautilus, calculator and gnome-text-editor

Open eljejer opened this issue 5 months ago • 9 comments

Describe the bug

My theming is "dark" When I open either one of the apps nautilus, calculator or gnome-text-editor, the theming is "light". Also when I switch theming back and forth, these applications do not change theming

Steps to reproduce

  1. current theming is set to "dark"
  2. open ML4W side bar SUIPER + CTRL + S
  3. open ML4W Welcome app
  4. open Menu -> Settings -> Input
  5. new window with gnome-text-editor shows input.lua is opened with "light" theming"
  6. switch from "dark" to "light" using the top left sun icon in the ML4W Sidebar
  7. switch back from "light" to "dark"
  8. theming remains "light"

Expected behavior

I would expect the gnome-text-editor would have "dark" theme after step 7

Screenshots

No response

Distribution

Other (please specify below)

If Other, specify

CachyOS

Additional context

Apart from gnome-text-editor described above, I open nautilus with Rofi and calculator with standard keybind CTRL + SUPER + C

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

eljejer avatar Jun 20 '26 09:06 eljejer

Hi, I ran into the exact same issue on CachyOS after migrating to the Lua configs. The issue specifically affects GTK4/Libadwaita apps (Nautilus, Gnome Calculator, Gnome Text Editor) because they query the color scheme (prefer-dark/prefer-light) from xdg-desktop-portal. Under Hyprland, this usually fails for two reasons:

  1. The systemd service xdg-desktop-portal.service requires graphical-session.target by default. Since Hyprland doesn't start this target, the portal service stays inactive and the apps fall back to their default look (Light Mode).
  2. Even if the portal is running, it often lacks the necessary environment variables (WAYLAND_DISPLAY, XDG_CURRENT_DESKTOP) because it starts too early. Here is how I fixed it:

1. Override the systemd portal service

You need to get rid of the requisite dependency on graphical-session.target. To do this, create or override ~/.config/systemd/user/xdg-desktop-portal.service with this:

[Unit]
Description=Portal service
[Service]
Type=dbus
BusName=org.freedesktop.portal.Desktop
ExecStart=/usr/lib/xdg-desktop-portal
Slice=session.slice

Then reload systemd and start the service:

systemctl --user daemon-reload
systemctl --user start xdg-desktop-portal

In the new Lua config (e.g. in your custom.lua), you can restart the portals on startup so they pick up the environment variables properly:

hl.on("hyprland.start", function()
    -- Export variables to systemd
    hl.exec_cmd("dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP")
    
    -- Restart portals so they catch the environment
    hl.exec_cmd("systemctl --user stop xdg-desktop-portal xdg-desktop-portal-hyprland")
    hl.exec_cmd("systemctl --user start xdg-desktop-portal-hyprland xdg-desktop-portal")
end)

(If you are still using the old .conf format, you can just add these as a normal exec-once in your custom.conf.) After doing this, the portals run reliably and dark/light mode switching works in real-time. Hope this helps!

tetam01 avatar Jun 21 '26 00:06 tetam01

I can confirm the issue. I will look into it.

mylinuxforwork avatar Jun 21 '26 11:06 mylinuxforwork

@tetam01 I have added your script to the hypr/conf/ml4w.lua on the rolling release.

Can you test again?

mylinuxforwork avatar Jun 21 '26 15:06 mylinuxforwork

Hi, thanks for adding the script!

Just wanted to check – did you also include the systemd override for xdg-desktop-portal.service, or only the Lua event handler?

The Lua handler alone won't work without removing the graphical-session.target dependency from the portal service. Hyprland never starts that target, so the service stays inactive.

The fix needs both parts:

  • The Lua handler to export env variables and restart portals
  • A systemd override (or custom unit) without the graphical-session.target dependency

Could you confirm if both are included in the rolling branch? Thanks!

tetam01 avatar Jun 21 '26 18:06 tetam01

Thanks for your reply. I have only added the lua script so far.

mylinuxforwork avatar Jun 21 '26 20:06 mylinuxforwork

@tetam01 Moved the command to https://github.com/mylinuxforwork/dotfiles/blob/main/dotfiles/.config/hypr/conf/autostart.lua

On my system, everything works fine. I can switch between light and dark mode and GTK apps like Obsidian, Gnome Editor and Files + Code are following, after restarting them.

mylinuxforwork avatar Jun 22 '26 05:06 mylinuxforwork

@tetam01 Moved the command to https://github.com/mylinuxforwork/dotfiles/blob/main/dotfiles/.config/hypr/conf/autostart.lua

On my system, everything works fine. I can switch between light and dark mode and GTK apps like Obsidian, Gnome Editor and Files + Code are following, after restarting them.

In rolling already too, Stephan?

eljejer avatar Jun 22 '26 07:06 eljejer

@tetam01 Moved the command to https://github.com/mylinuxforwork/dotfiles/blob/main/dotfiles/.config/hypr/conf/autostart.lua On my system, everything works fine. I can switch between light and dark mode and GTK apps like Obsidian, Gnome Editor and Files + Code are following, after restarting them.

In rolling already too, Stephan?

On my system, the theming switches "on the fly", i.e. without restarting the app. So, in the already opened app

eljejer avatar Jun 22 '26 09:06 eljejer

Great. I pushed many fixes in the last hours.

mylinuxforwork avatar Jun 22 '26 12:06 mylinuxforwork