Lazy objects
Lazy objects are a way of executing any of the commands available in Qtile's commands API.
The name "lazy" refers to the fact that the commands are not executed at the time of the call. Instead, the lazy object creates a reference to the relevant command and this is only executed when the relevant event is triggered (e.g. on a keypress).
Typically, for config files, the commands are used to manipulate windows, layouts and groups as well application commands like exiting, restarting, reloading the config file etc.
Example
from libqtile.config import Key
from libqtile.lazy import lazy
keys = [
Key(
["mod1"], "k",
lazy.layout.down()
),
Key(
["mod1"], "j",
lazy.layout.up()
)
]
Note
As noted above, lazy
calls do not call the
relevant command but only create a reference to it. While this makes it
ideal for binding commands to key presses and mouse_callbacks
for
widgets, it also means that lazy
calls cannot be included
in user-defined functions.
Lazy functions
This is overview of the commonly used functions for the key bindings. These functions can be called from commands on the REPLACE object or on another object in the command tree.
Some examples are given below. For a complete list of available commands, please refer to Commands API.
General functions
function |
description |
---|---|
|
Run the |
|
Open command prompt on the bar. See prompt widget. |
|
Reload the config. |
|
Restart Qtile. In X11, it won't close your windows. |
|
Close the whole Qtile |
Group functions
function |
description |
---|---|
|
Use next layout on the actual group |
|
Use previous layout on the actual group |
|
Move to the group on the right |
|
Move to the group on the left |
|
Move to the last visited group |
|
Switch window focus to next window in group |
|
Switch window focus to previous window in group |
|
Move to the group called |
|
Increase the space for master window at the expense of slave windows |
|
Decrease the space for master window in the advantage of slave windows |
Window functions
function |
description |
---|---|
|
Close the focused window |
|
Switch window focus to other pane(s) of stack |
|
Move focused window to the group called |
|
Put the focused window to/from floating mode |
|
Put the focused window to/from fullscreen mode |
|
Move the window above the next window in the stack. |
|
Move the window below the previous window in the stack. |
|
Move the window above all other windows with similar priority
(i.e. a "normal" window will not be moved above a |
|
Move the window below all other windows with similar priority
(i.e. a "normal" window will not be moved below a |
|
Keep window above other windows. |
|
Keep window below other windows. |
|
Bring window above all other windows. Ignores |
Screen functions
function |
description |
---|---|
|
Set the wallpaper to the specificied image. Possible modes: |
ScratchPad DropDown functions
function |
description |
---|---|
|
Toggles the visibility of the specified DropDown window. On first use, the configured process is spawned. |
|
Hides all DropDown windows. |
|
Update the configuration of the named DropDown. |
User-defined functions
function |
description |
---|---|
|
Calls |
Examples
lazy.function
can also be used as a decorator for functions.
from libqtile.config import Key
from libqtile.lazy import lazy
@lazy.function
def my_function(qtile):
...
keys = [
Key(
["mod1"], "k",
my_function
)
]
Additionally, you can pass arguments to user-defined function in one of two ways:
In-line definition
Arguments can be added to the lazy.function
call.
from libqtile.config import Key
from libqtile.lazy import lazy
from libqtile.log_utils import logger
def multiply(qtile, value, multiplier=10):
logger.warning(f"Multiplication results: {value * multiplier}")
keys = [
Key(
["mod1"], "k",
lazy.function(multiply, 10, multiplier=2)
)
]
Decorator
Arguments can also be passed to the decorated function.
from libqtile.config import Key
from libqtile.lazy import lazy
from libqtile.log_utils import logger
@lazy.function
def multiply(qtile, value, multiplier=10):
logger.warning(f"Multiplication results: {value * multiplier}")
keys = [
Key(
["mod1"], "k",
multiply(10, multiplier=2)
)
]