Nheko (Qt): Obey system dark theme

12 replies [Last post]
calher

I am a member!

Offline
Joined: 06/19/2015

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.

jxself
Offline
Joined: 09/13/2010

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.

calher

I am a member!

Offline
Joined: 06/19/2015

It didn't work. I even rebooted and re-ran the dark commands.

jxself
Offline
Joined: 09/13/2010

"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?

calher

I am a member!

Offline
Joined: 06/19/2015

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.)

jxself
Offline
Joined: 09/13/2010

Does Nheko comes up dark with this?
sudo apt install qt6-gtk-platformtheme
QT_QPA_PLATFORMTHEME=gtk3 nheko
Purely for a test.

calher

I am a member!

Offline
Joined: 06/19/2015

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.

jxself
Offline
Joined: 09/13/2010

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

calher

I am a member!

Offline
Joined: 06/19/2015

"Trisquel"

"prefer-dark"

jxself
Offline
Joined: 09/13/2010

Not Trisquel-dark? What if you change it? Try this:

gsettings set org.gnome.desktop.interface gtk-theme 'Trisquel-dark'
QT_QPA_PLATFORMTHEME=gtk3 nheko

calher

I am a member!

Offline
Joined: 06/19/2015

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.

jxself
Offline
Joined: 09/13/2010

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.

calher

I am a member!

Offline
Joined: 06/19/2015

Thanks! It works!