[BUG] Cannot switch theming in Gnome applications nautilus, calculator and gnome-text-editor
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
- current theming is set to "dark"
- open ML4W side bar SUIPER + CTRL + S
- open ML4W Welcome app
- open Menu -> Settings -> Input
- new window with gnome-text-editor shows input.lua is opened with "light" theming"
- switch from "dark" to "light" using the top left sun icon in the ML4W Sidebar
- switch back from "light" to "dark"
- 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
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:
- The systemd service
xdg-desktop-portal.servicerequiresgraphical-session.targetby default. Since Hyprland doesn't start this target, the portal service stays inactive and the apps fall back to their default look (Light Mode). - 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!
I can confirm the issue. I will look into it.
@tetam01 I have added your script to the hypr/conf/ml4w.lua on the rolling release.
Can you test again?
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!
Thanks for your reply. I have only added the lua script so far.
@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.
@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?
@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
Great. I pushed many fixes in the last hours.