Nheko (Qt): Obey system dark theme
When I switch to Trisquel-dark theme, every app except my Qt app (package "nheko") obeys the dark theme. How do I make Nheko follow the system dark/light theme?
(I switch between dark and light based on time of day. I also tried setting a cron job to change the themes automatically, but it did not work.)
crontab:
# m h dom mon dow command
0 0-6 * * * gsettings set org.gnome.desktop.interface color-scheme prefer-dark
0 7-17 * * * gsettings set org.gnome.desktop.interface color-scheme prefer-light
0 18-23 * * * gsettings set org.gnome.desktop.interface color-scheme prefer-dark
Themes do not change at all. The commands above, when entered manually, do not change MATE apps.
sudo apt install qt5-gtk-platformtheme
sudo sh -c 'echo "QT_QPA_PLATFORMTHEME=gtk3" >> /etc/environment'
Logout or restart
Set Nheko's own theme to "system".
For the other, do:
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
gsettings set org.mate.interface gtk-theme 'Trisquel-dark'
gsettings set org.mate.interface icon-theme 'Trisquel-dark'
gsettings set org.mate.Marco.general theme 'Trisquel-dark'
But if you use a systemd user timer instead of cron, the session bus is already there so you could get rid of the DBUS_SESSION_BUS_ADDRESS/DISPLAY stuff.
It didn't work. I even rebooted and re-ran the dark commands.
"It didn't work" could mean different things. After the reboot, was the desktop itself dark - panels, file manager, other apps - with only Nheko still light? Or was nothing dark, including the rest of the desktop?
Oh, and one question to add: Was everything installed via apt from Trisquel or from one of those Snap-O-Flat-App-Nix-A-Mage things?
By the way, the icon theme is "trisquel" and not "Trisquel". When you use "Trisquel", the Trisquel logo is replaced by the Debian logo.
Sorry for being vague.
After reboot: Desktop still dark, only Nheko is light. Nheko is set to System theme.
Everything except Gajim (Flatpak) and Delta Chat (Flatpak) were installed through the Trisquel APT repos. Gajim and Delta Chat go dark just fine.
(Gajim moves fast and the version in Trisquel is not suitable for daily usage. The calls functionality is broken, for example.)
(Delta Chat is not in the repos, and moves faster than even Gajim.)
Does Nheko comes up dark with this?
sudo apt install qt6-gtk-platformtheme
QT_QPA_PLATFORMTHEME=gtk3 nheko
Purely for a test.
Installed.
Closed Nheko.
Launched Nheko with environment variable QT_QPA_PLATFORMTHEME set to gtk3.
Nheko appears in light theme, even though everything else is in dark.
Interesting. Could you confirm something? What do these say?
gsettings get org.gnome.desktop.interface gtk-theme
gsettings get org.gnome.desktop.interface color-scheme
caleb@calebs-elitebook:~$ gsettings get org.gnome.desktop.interface gtk-theme
'Trisquel-dark'
caleb@calebs-elitebook:~$ gsettings get org.gnome.desktop.interface color-scheme
'prefer-dark'
caleb@calebs-elitebook:~$ gsettings set org.gnome.desktop.interface gtk-theme 'Trisquel-dark'
caleb@calebs-elitebook:~$ QT_QPA_PLATFORMTHEME=gtk3 nheko
Nheko still light.
Okay so that means editing ~/.config/nheko/nheko.conf and changing the theme to dark. The editing of the config file can be done as part of your script via cron. Something like:
[user]
theme=dark
I'll send you an email with a script for it all.
Thanks! It works!

