How to properly keybind scripts on Qtile?

Hello, everyone. First post here.

I’ve been using the Qtile edition since a few days and I wanted to bind the Rofi powermenu script that
is located at ~/.config/rofi/ to a certain key (this is the same script that runs when you click the powermenu widget on the bar, nothing changed on it and it works when clicked or called through the terminal). I thought adding something like

Key([mod], "q", lazy.spawn("~/.config/rofi/"), desc="powermenu")

to ~/.config/qtile/modules/ would be enough but it doesn’t work. I tried a couple of other things like putting the full path /home/user/.config/rofi/ instead of just ~ but that also didn’t work. Calling

rofi -show drun -modi drun

(which is usually how Rofi menus are called) before giving the path the script also doesn’t work, so I don’t know how to do it.

I asked the same thing on Reddit but had no answer there. I have also a couple of personal Rofi scripts I would want to bind, so this is important.

Thanks in advance!

Is the script executable?

Yes. It executes normally from the widget and the terminal.

grep "\[mod\], \"q\"" *

Run the above in the modules directory to see if mod+q is defined twice.

This works for me:

Key([mod], "q", lazy.spawn("/home/xircon/.config/rofi/"), desc="powermenu"), 


import os
Key([mod], "q", lazy.spawn(os.path.expanduser("~/.config/rofi/")), desc="powermenu"), 

It is down to the fact that python does not expand paths, you have to do it explicitly :scream:

1 Like

OK, this worked also after importing os to I was in doubt if I had to import it again since call it as well.

Thanks a lot.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.