multi user qtile fiddling

multi user qtile fiddling

This post is going to detail how I solved a very particular problem I had created for myself. First, a quick description of the problem. I use home-manager on nixos to declaratively configure what happens on my computer. In the cases where home-manager does not expose sufficient configuration options for my liking (qtile for example), I instead link a configuration file from my nixos config to where it belongs in my home using xdg.configFile. This is what I do with my qtile I use qtile on my desktop and laptop but I dont want an identical setup on the two machines. I have jumped through many different slightly silly hoops in my nixos config sort of solving this problem until the other day it occured to me this could all be achieved with my python in my qtile config.


I basically just want the config to work out which computer it’’s on and then change some things accordingly. This can be achieved by getting the hostname with the socket module:

if socket.gethostname() == 'baron':
    # some stuff i want to happen on my desktop
elif socket.gethostname() == 'countess':
    # some stuff i want to happen on my laptop 

There are three main things that I like to differ between my two computers:


My current solution for this is to define to separate lists of widgets and then point to each one when I make my bar for each computer. This isn’t perfect; it would be nice to have a list of all common widgets and then add to that with the unique ones. I haven’t worked out a way to add the additional widgets without just plopping them all at the end of the bar which isn’t necessarily where I want them (thinking about this now I think I might be able to use the insert method with a little for loop).

countess_widgets = [
    # all the great widgets i want on my laptop

screens = [
	    top = bar.Bar(
		    widgets = countess_widgets


For keybindings I use extend to add some additional bindings to my global ones. This is mainly useful for the ones I use to change brightness on my laptop.

countess_keys = [
    Key([m], 'Up',
        lazy.spawn('light -A 5'),
        desc='backlight up'
    Key([m], 'Down',
        lazy.spawn('light -U 5'),
        desc='backlight down'


You could even change a specific global binding on one computer if you knew its index in the list:

keys[420] = Key([m], 'd',
                desc = 'dmenu'


Finally, I use this to autostart different programs which I want to change on each computer. For example I use an xrandr command to make sure my desktop monitor is at 144hz. It looks like this:

def autostart():
    processes = [
    for p in processes:

Of course, there are many ways that this could all be achievd but I think it’s quite neat having it all in my one qtile config. That’s about it for today. lots of love x