Mouse Bindings
Bind mouse buttons and scroll directions to Sweets actions
sweets.bind_mouse binds a mouse button. sweets.bind_scroll binds a wheel
direction. Both take the same actions as
key bindings, plus cooldown,
description, allow_when_locked, all_modes, and context.
sweets.bind_mouse("MOD+BTN_LEFT", "move_window")
sweets.bind_mouse("MOD+BTN_RIGHT", "resize_window")
sweets.bind_mouse("MOD+BTN_MIDDLE", "close")
sweets.bind_scroll("MOD+ScrollDown", "focus_next", { cooldown = 150 })
sweets.bind_scroll("MOD+ScrollUp", "focus_prev", { cooldown = 150 })A bound button acts on the window under the pointer. The app never sees the click.
Names
| Kind | Names |
|---|---|
| Buttons | BTN_LEFT, BTN_RIGHT, BTN_MIDDLE, BTN_SIDE, BTN_EXTRA, BTN_FORWARD, BTN_BACK, BTN_TASK |
| Scroll | ScrollUp, ScrollDown, ScrollLeft, ScrollRight |
Mouse bindings are single combinations. Sequences like MOD+B f don't work
here.
Desktop bindings
Use context = "desktop" to keep app clicks and scrolling available:
sweets.bind_mouse("BTN_RIGHT", "spawn", { "fuzzel" }, { context = "desktop" })
sweets.bind_scroll("ScrollDown", "workspace_relative_next", { context = "desktop" })| Field | Default | Effect |
|---|---|---|
context | "all" | "desktop" runs only over exposed desktop space |
Wallpaper that accepts no input counts as desktop. Windows, panels, popups, borders, tabs and Overview do not.
A desktop binding wins over an otherwise identical all binding on the desktop.
To remove only the desktop binding:
sweets.unbind("BTN_RIGHT", { context = "desktop" })Move and resize
These work by default, even without a config:
| Binding | Action |
|---|---|
MOD+BTN_LEFT | move_window: drag the window |
MOD+BTN_RIGHT | resize_window: resize the window |
Rebind them to swap buttons, or remove one:
sweets.unbind("MOD+BTN_LEFT")Binding MOD+BTN_LEFT to another action removes window dragging.
Maximized and fullscreen windows can't be dragged until you restore them.
Resize options
By default, resize_window resizes from the corner nearest the pointer. Pass a
third argument to change that:
sweets.bind_mouse("MOD+Shift+BTN_RIGHT", "resize_window", "keep_aspect")
sweets.bind_mouse("MOD+BTN_SIDE", "resize_window", "bottom_right")
sweets.bind_mouse("MOD+Ctrl+BTN_RIGHT", "resize_window", { mode = "horizontal" })
sweets.bind_mouse("MOD+Alt+BTN_RIGHT", "resize_window",
{ corner = "bottom_right", keep_aspect = true })| Argument | Effect |
|---|---|
"keep_aspect" | Keep the window's shape |
"top_left", "top_right", "bottom_left", "bottom_right" | Always resize that corner |
"horizontal" | Width only |
"vertical" | Height only |
"directional" | Edges resize one side, corners resize both |
Corners and modes apply to floating windows. Tiled windows always resize from the nearest layout edge.
To resize by grabbing a window's border without a modifier, turn on
resize_on_border.
Dragging windows
Tiled windows stay tiled by default. The others make room as you drag, and the window drops into the slot under the pointer. Dropping on another monitor moves it there.
drag_toggle_floatinglets a right-click switch between tiled and floating placement during a move.drag_center_cursorcenters the window under the pointer.reorder_ratiosets how far you drag into another tile before they swap.
Floating windows move freely and stay partly on screen. Turn on
snap to snap them to screen edges and
other windows.
Resizing tiled windows
Tiled windows resize along the edges their layout allows:
| Layout | Resizable edges |
|---|---|
| Tile | Master/stack split, and between stack windows |
| Centered | Master width, or inside one side stack |
| Grid | Rows and columns |
| Columns | Between columns or rows |
| Deck | Master/stack split only |
| Dwindle | The nearest split |
| Monocle | None |
Scroll bindings
Scroll bindings work with a mouse wheel, not a touchpad. Each notch runs the
binding once. Use cooldown to slow down a fast wheel:
sweets.bind_scroll("MOD+ScrollDown", "workspace_relative_next", { cooldown = 200 })Holding a modifier with a scroll binding stops app scrolling with that
modifier, even in directions you didn't bind. A scroll binding
with no modifier takes plain scrolling away from every app. Use
context = "desktop" to limit this to desktop space.
Sweets has no default scroll bindings.
See also
- Key Bindings for the full action list
- Input for scroll speed and acceleration