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

**URL:** https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851
**Category:** Help
**Created:** [July 23, 2023, 5:24pm UTC](https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851 "2023-07-23T17:24:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![crazyminecuber](https://discourse.nixos.org/user_avatar/discourse.nixos.org/crazyminecuber/32/8979_2.png) [@crazyminecuber](https://discourse.nixos.org/u/crazyminecuber)
#### Post date: [July 23, 2023, 5:24pm UTC](https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851/1 "2023-07-23T17:24:52Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

### Author: ![robfuscator](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/r/d26b3c/32.png) [@robfuscator](https://discourse.nixos.org/u/robfuscator)
#### Post date: [April 8, 2024, 4:36pm UTC](https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851/2 "2024-04-08T16:36:02Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![eljamm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/eljamm/32/16466_2.png) [@eljamm](https://discourse.nixos.org/u/eljamm)
#### Post date: [April 8, 2024, 6:47pm UTC](https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851/3 "2024-04-08T18:47:16Z")

</div>

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](https://mynixos.com/search?q=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:~~

> [@Struggling to configure GTk/QT theme on laptop](https://discourse.nixos.org/t/struggling-to-configure-gtk-qt-theme-on-laptop/42268/4):
>
> This was literally me a few days ago, except I went full catppuccin cat I’m running Gnome under Wayland, so I’m not sure how well this applies to Sway, but I hope this helps you in the right direction. Also, if there is a better way to do this then I hope someone corrects me. PS: This is all done using home-manager, so you only need to edit your home.nix. With Breeze leavesFirst add the required packages, the rest will be specified later within options: home.packages = with pkgs; [ …

> [@Struggling to configure GTk/QT theme on laptop](https://discourse.nixos.org/t/struggling-to-configure-gtk-qt-theme-on-laptop/42268/10):
>
> AHA! Got it working! I manually wrote the configuration files for qt5ct and qt6ct this way: xdg.configFile = lib.mkIf hasSeat { kvantum = { target = "Kvantum/kvantum.kvconfig"; text = lib.generators.toINI { } { General.theme = "Catppuccin-Mocha-Blue"; }; }; qt5ct = { target = "qt5ct/qt5ct.conf"; text = lib.generators.toINI { } { Appearance = { icon\_theme = "Papirus-Dark"; }; }; }; qt6ct = { targ…

---

<div class="post-metadata">

### Author: ![crazyminecuber](https://discourse.nixos.org/user_avatar/discourse.nixos.org/crazyminecuber/32/8979_2.png) [@crazyminecuber](https://discourse.nixos.org/u/crazyminecuber)
#### Post date: [April 8, 2024, 7:12pm UTC](https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851/4 "2024-04-08T19:12:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![eljamm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/eljamm/32/16466_2.png) [@eljamm](https://discourse.nixos.org/u/eljamm)
#### Post date: [April 9, 2024, 4:10pm UTC](https://discourse.nixos.org/t/qt-applications-does-not-start-in-dark-mode-when-lauched-from-config-autostart-in-gnome/30851/5 "2024-04-09T16:10:29Z")

</div>

I thought changing the platformTheme fixes it, but apparently this issue has already been raised in the [KeepassXC repo](https://github.com/keepassxreboot/keepassxc/issues/9892) and it might not be a NixOS-related bug. The proposed solutions are:

- Forcing theme to `View > Theme > Dark`
- Using [darkman](https://search.nixos.org/packages?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=darkman)
- Delaying the startup time
