blog

My personal blog.
Log | Files | Refs

theming-qt-on-sway.md (2565B)


      1 `((title . "Theming QT apps on Sway using Kvantum and lxqt-qtplugin") (date . "2025-08-20"));`
      2 This took me an uncomfortable amount of time to figure out.
      3 
      4 Long story short, QT doesn't really have a built-in mechanism to handle themes
      5 or icons. You have to use a style engine to change how applications look.
      6 [Kvantum](https://github.com/tsujan/Kvantum/tree/master/Kvantum) is great for
      7 this purpose and has a lot of nice built in themes. Once installed, you can
      8 simply set `QT_STYLE_OVERRIDE=kvantum` and QT apps will start using the theme.
      9 
     10 However, this still doesn't handle icons. Icons have to be handled through the
     11 `QT_QPA_PLATFORMTHEME` variable. Most DEs provide a weird plugin of their own
     12 that does some kind of black magic which can only be configured through a GUI.
     13 qt6ct/qt5ct are often advertised a fix for this, but they're both archived for
     14 some reason. Fortunately, [lxqt-qtplugin](https://github.com/lxqt/lxqt-qtplugin)
     15 works regardless of DE and has a simple configuration file format. This isn't
     16 really documented or advertised, but I did some digging into its code and I
     17 figured out how to use it. I'm personally using it alongside Sway, but it should
     18 work alongside any WM of your choice.
     19 
     20 It's two simple steps.
     21 
     22 1. Create `~/.config/Kvantum/kvantum.kvconfig` and modify it.
     23 
     24 This is self-explanatory.
     25 
     26 ```
     27 [General]
     28 theme=KvSimplicityDark
     29 ```
     30 
     31 Just put the name of your Kvantum theme there. If you want to select or preview
     32 the available themes with a fancy GUI, `kvantummanager` and `kvantumpreview`
     33 should be available (if you installed Kvantum, of course).
     34 
     35 2. Create `~/.config/lxqt/lxqt.conf` and modify it.
     36 
     37 This is mostly self-explanatory. 
     38 
     39 ```
     40 [General]
     41 icon_theme=Papirus-Dark
     42 
     43 [Qt]
     44 font="Sans Serif,12,-1,5,400,0,0,0,0,0,0,0,0,0,0,1"
     45 ```
     46 
     47 If you're wondering about the weird font formatting, look up QFont. It's how QT
     48 reads font data. To make it simple, just copy this value, replacing "Sans Serif"
     49 with your desired font and "12" with your desired point size.
     50 
     51 2. Set `QT_QPA_PLATFORMTHEME=lxqt`.
     52 
     53 And you're done!
     54 
     55 Obviously, make sure lxqt-qtplugin and Kvantum are installed. Now everything
     56 will look nice and pretty. If you're curious how I manage this on GNU Guix,
     57 check out my personal set of Guix configurations,
     58 [orchard](https://git.loquat.dev/orchard/).
     59 
     60 Here's how [pavucontrol-qt](https://github.com/lxqt/pavucontrol-qt) looks on my
     61 system with this configuration.
     62 
     63 Before:
     64 ![Screenshot](/img/pavucontrol-qt-unthemed.webp)
     65 
     66 After:
     67 ![Screenshot](/img/pavucontrol-qt-themed.webp)
     68 
     69 Isn't that better?
     70 
     71 In Christ,
     72 
     73 Luke