QT applications does not start in dark mode when lauched from .config/autostart in Gnome

I want KeepassXC to launch in dark mode on startup. Currently, I solve launch on startup by checking the box in KeepassXC which places a desktop file in ~/.config/autostart/. As I understand it, this file is then started on boot according to the xdg-standard by the Gnome session manager. The problem is that it is started in a light color theme mode and not in dark mode as I want. If I kill that instance off KeepassXC and instead start it from the terminal, it starts with a dark mode, which is exactly what I want.

I believe the reason that it start with a darkmode from the terminal is that I have set this in my config

qt.platformTheme = "gtk2";
qt.style = "gtk2";

which from my understanding sets the environment variables $QT_STYLE_OVERRIDE and $QT_QPA_PLATFORMTHEME to “gtk2” which should make qt applications emulate the look of the current GTK theme. And since my GTK them is dark, them my QT theme should also be dark.

The issue seems to be that these variables are not set during the starting of .config/autostart which I have confirmed by creating my own desktop file there and printing all the environmental variables.

So from this it seems to me like there is a bug in how variables are propagated to the Gnome session manager during startup. Or have I missed something trivial?

Did you find a solution to this? I’m facing a similar issue.

In my case I did not set anything qt-style related in the config. I have my gnome theme set to dark, and a hidpi monitor. When I launch qt apps (such as KeePassXC, Nextcloud client, …) manually, they follow the dark theme are rendered at a proper scale. When they are started automatically (through ~/.config/autostart), they don’t follow the dark theme are rendered way to tiny.

Should we maybe open an issue on GitHub?

I don’t know if the OP still has this issue, but for KeepassXC you can manually change the theme to Dark in KeepassXC -> View -> Theme -> Dark. You can also set it to Classic (Platform-Native) if you have a theme installed and you want it to follow that.

Edit: Probably unrelated
Another thing you can try is use another qt.platformTheme. I use qtct with home-manager and it works without issues. You just need to set the correct theme and icons in qt5ct and qt6ct.

You can have a look at this post which might help you in the right direction:

I did not find a solution that I was happy with so I stopped caring and I do not autostart keepass anymore :crazy_face: . Feel free to file a bug report and would be happy to hear if you find a solution

1 Like

I thought changing the platformTheme fixes it, but apparently this issue has already been raised in the KeepassXC repo and it might not be a NixOS-related bug. The proposed solutions are:

  • Forcing theme to View > Theme > Dark
  • Using darkman
  • Delaying the startup time