Mouse¶
The mouse
config file variable defines a set of global mouse actions, and
is a list of [libqtile.config.Click
] and libqtile.config.Drag
objects, which define what to do when a window is clicked or dragged.
Default Mouse Bindings¶
By default, holding your mod
key and left-clicking (and holding) a window will
allow you to drag it around as a floating window. Holding your mod
key and right-clicking
(and holding) a window will resize the window (and also make it float if it is not already floating).
Example¶
from libqtile.config import Click, Drag
mouse = [
Drag([mod], "Button1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
Drag([mod], "Button3", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
Click([mod], "Button2", lazy.window.bring_to_front())
]
The above example can also be written more concisely with the help of
the EzClick
and EzDrag
helpers:
from libqtile.config import EzClick as Click, EzDrag as Drag
mouse = [
Drag("M-1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
Drag("M-3", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
Click("M-2", lazy.window.bring_to_front())
]
Reference¶
Click
¶
Bases: Mouse
Bind commands to a clicking action.
Parameters:
-
modifiers
(list[str]
) –A list of modifier specifications. Modifier specifications are one of:
"shift"
,"lock"
,"control"
,"mod1"
,"mod2"
,"mod3"
,"mod4"
,"mod5"
. -
button
(str
) –The button used, e.g.
"Button1"
. -
commands
(LazyCall
, default:()
) –A list [
LazyCall
][LazyCall] objects to evaluate in sequence upon using the button.
Drag
¶
Drag(
modifiers: list[str],
button: str,
*commands: LazyCall,
start: LazyCall | None = None,
warp_pointer: bool = False
)
Bases: Mouse
Bind commands to a dragging action.
On each motion event the bound commands are executed with two additional parameters specifying the x and y offset from the previous position.
Parameters:
-
modifiers
(list[str]
) –A list of modifier specifications. Modifier specifications are one of:
"shift"
,"lock"
,"control"
,"mod1"
,"mod2"
,"mod3"
,"mod4"
,"mod5"
. -
button
(str
) –The button used to start dragging e.g.
"Button1"
. -
commands
(LazyCall
, default:()
) –A list [
LazyCall
][LazyCall] objects to evaluate in sequence upon drag. -
start
(LazyCall | None
, default:None
) –A [
LazyCall
][LazyCall] object to be evaluated when dragging begins. (Optional) -
warp_pointer
(bool
, default:False
) –A
bool
indicating if the pointer should be warped to the bottom right of the window at the start of dragging. (Default:False
)