Sweets
Configuration

Input

Configure libinput pointer devices globally or per device

sweets.input configures physical pointer devices. Call it without a selector for every device, or with one to target a subset.

sweets.input({
  accel_speed = 0.0,
})

sweets.input("touchpad", {
  tap = true,
  natural_scroll = true,
  disable_while_typing = true,
})

sweets.input("mouse", {
  natural_scroll = false,
  accel_profile = "flat",
})

sweets.input("name:ELAN", {
  accel_speed = -0.25,
  click_method = "clickfinger",
  tap_button_map = "lmr",
  scroll_factor = { horizontal = 0.4, vertical = 0.6 },
})

Settings are applied in order: libinput defaults, then the global block, then each matching selector block as declared. This happens at startup, on reload, and when a device connects.

Selectors

SelectorMatches
pointerAny physical pointer device
touchpadTapping-capable pointers, normally laptop touchpads
mousePointers that are not touchpads
name:TEXTCase-insensitive substring of the device name

Options

FieldTypeDefaultDescription
enabledboolean or stringtruefalse stops the device sending any input; "disabled_on_external_mouse" stops it only while a mouse is plugged in
tapbooleanlibinputTap to click
tap_dragbooleanlibinputTap and drag
tap_drag_lockbooleanlibinputTap-drag lock
tap_button_mapstringlibinputTwo- and three-finger tap: "lrm" is right, middle; "lmr" is middle, right
click_methodstringlibinput"button_areas" or "clickfinger" (clickpads)
natural_scrollbooleanlibinputReverse scroll direction
scroll_methodstringlibinput"two_finger", "edge", "on_button_down" or "none"
scroll_buttonstringlibinputButton held for on_button_down, such as "BTN_MIDDLE"
scroll_button_lockbooleanlibinputClick the scroll button once to start scrolling, again to stop
scroll_factornumber or table1.0Scroll speed multiplier, 0.01 to 10.0, for both axes or per axis
left_handedbooleanlibinputSwap left and right buttons
middle_emulationbooleanlibinputMiddle click from left+right
disable_while_typingbooleanlibinputIgnore the touchpad while typing
disable_while_trackpointingbooleanlibinputIgnore the touchpad while a trackpoint moves
accel_speednumberlibinputPointer acceleration, -1.0 to 1.0
accel_profilestringlibinput"adaptive" or "flat"

scroll_button accepts BTN_LEFT, BTN_RIGHT, BTN_MIDDLE, BTN_SIDE, BTN_EXTRA, BTN_FORWARD, BTN_BACK and BTN_TASK.

Unsupported options are ignored per device, so one block can cover a mouse, a touchpad, and a trackpoint. Virtual and nested devices are skipped.

The mouse selector never matches a touchpad, so it rejects touchpad-only options: the tap options, click_method, disable_while_trackpointing, and the two_finger and edge scroll methods.

Trackballs and trackpoints

These devices have no wheel. Hold a button and move the ball to scroll:

sweets.input("name:Trackball", {
  scroll_method = "on_button_down",
  scroll_button = "BTN_SIDE",
  scroll_button_lock = true,
})

With scroll_button_lock, you click the button once instead of holding it.

Scroll speed

scroll_factor scales how far applications scroll. It does not change scroll bindings: one wheel notch still fires a binding once.

A number scales both axes. A table scales the axes it names and leaves the other one alone, which is useful when a touchpad scrolls sideways too fast:

sweets.input("touchpad", {
  scroll_factor = { horizontal = 0.4 },
})

Turning a device off

sweets.input("name:SynPS/2 Synaptics TouchPad", { enabled = false })

The device still appears in sweets msg inputs, so a reload with the block removed turns it back on.

To turn the touchpad off only while a mouse is plugged in:

sweets.input("touchpad", { enabled = "disabled_on_external_mouse" })

libinput offers this mode on built-in touchpads. A device without it stays enabled and lists enabled in unsupported_settings.

To turn a device off and on from the keyboard, bind toggle_input to an input selector:

sweets.bind("XF86TouchpadToggle", "toggle_input", "touchpad")

A second press restores the configured value, and so does any reload.

Touchpad swipe gestures

Bind a physical touchpad swipe with sweets.gesture:

sweets.gesture({ fingers = 3, direction = "horizontal", action = "workspace" })
sweets.gesture({ fingers = 3, direction = "vertical", action = "scroll_strip" })
sweets.gesture({ fingers = 4, direction = "up", action = "special_toggle" })
sweets.gesture({ fingers = 4, direction = "down", action = "spawn", command = { "fuzzel" } })

workspace previews an adjacent numbered workspace one-to-one, then commits or returns at release. scroll_strip moves a scrolling layout with the fingers. Other key-binding actions are discrete: they run once when the swipe crosses the cancel ratio. move_window and resize_window are excluded because they require a pointer button grab. Use argument for an action argument; spawn also accepts command. Optional mods = "MOD+Shift" restricts a declaration.

Direction can be left, right, up, down, horizontal, or vertical. After 16 units of movement it locks for the rest of the sequence. An exact direction takes precedence over an axis-wide declaration. An unmatched swipe is forwarded completely to the focused application.

sweets.gestures({
  swipe_distance = 300,
  cancel_ratio = 0.5,
  min_speed_to_force = 30,
  natural = true,
})
FieldRangeDefaultMeaning
swipe_distance50–2000300Travel that reaches full progress
cancel_ratio0–10.5Progress that commits or fires
min_speed_to_force0–10030Release speed in units/ms that commits below the ratio
naturalbooleantrueLeft/up advances; strip content follows the fingers

Reloads affect the next swipe, not one already in progress. A swipe beginning during session lock, a pointer grab, shortcut inhibition, or a visible special workspace is never acted on. Compositor-owned swipes stay on their start output.

enabled = false in the global block or under pointer turns off every mouse and touchpad. Your keyboard still works, so you can fix the file and reload.

Listing devices

sweets msg inputs            # every device, with its settings
sweets msg input INPUT_ID    # one device

Use these to find the exact name for a name: selector, and to check which settings a device actually supports.

On this page