Qtile provides a mechanism for subscribing to certain events in
To subscribe to a hook in your configuration, simply decorate a function with
the hook you wish to subscribe to.
See Built-in Hooks for a listing of available hooks.
Automatic floating dialogs¶
Let’s say we wanted to automatically float all dialog windows (this code is not
actually necessary; Qtile floats all dialogs by default). We would subscribe to
client_new hook to tell us when a new window has opened and, if the
type is “dialog”, as can set the window to float. In our configuration file it
would look something like this:
from libqtile import hook @hook.subscribe.client_new def floating_dialogs(window): dialog = window.window.get_wm_type() == 'dialog' transient = window.window.get_wm_transient_for() if dialog or transient: window.floating = True
A list of available hooks can be found in the Built-in Hooks reference.
If you want to run commands or spawn some applications when Qtile starts, you’ll
want to look at the
emitted every time Qtile starts (including restarts), whereas
is only emitted on the very first startup.
Let’s create a file
~/.config/qtile/autostart.sh that will set our desktop
wallpaper and start a few programs when Qtile first runs.
#!/bin/sh feh --bg-scale ~/images/wallpaper.jpg & pidgin & dropbox start &
We can then subscribe to
startup_once to run this script:
import os import subprocess @hook.subscribe.startup_once def autostart(): home = os.path.expanduser('~') subprocess.call([home + '/.config/qtile/autostart.sh'])