Sweets

Input Devices

Keyboard layout, key repeat, cursor, and lid switch

For mice, touchpads, and gestures, see Input.

sweets.keyboard

sweets.keyboard({
  layout = "us,lv",
  variant = ",apostrophe",
  options = "grp:alt_shift_toggle,caps:escape",
  repeat_rate = 25,
  repeat_delay = 600,
})
FieldDefaultEffect
layoutsystem defaultKeyboard layout, or a list like "us,lv"
variantsystem defaultLayout variant. Leave an entry empty to skip it: ",apostrophe"
optionssystem defaultXKB options, comma-separated
modelsystem defaultKeyboard model, usually pc105
rulessystem defaultUsually evdev
repeat_rate25Key repeats per second, 0 turns repeat off
repeat_delay200Milliseconds before a held key repeats
numlocktrueTurn Num Lock on at start
track_layout"global""window" remembers the layout per window

A layout with a typo is rejected, and your current keyboard keeps working.

Switching layout

sweets.bind("MOD+Alt+space", "keyboard_layout", "next")
sweets.bind("MOD+F1", "keyboard_layout", 1)
sweets.bind("MOD+F2", "keyboard_layout", 2)

keyboard_layout takes next, prev, or a position in your layout list, up to 4. Your bindings keep working in every layout.

To give each window its own layout:

sweets.keyboard({ layout = "us,lv", track_layout = "window" })

keyboard_layout bindings don't work on the lock screen. To switch layout there, use an XKB option such as options = "grp:alt_shift_toggle".

sweets.cursor

sweets.cursor({
  theme = "Adwaita",
  size = 24,
  hide_on_key_press = true,
  inactive_timeout = 5,
})
FieldDefaultEffect
themesystem defaultCursor theme name
size24Cursor size, 1–256
hide_on_key_pressfalseHide the cursor while you type
inactive_timeout0Hide the cursor after this many seconds without mouse use. 0 never hides

Moving the mouse, clicking, or scrolling shows the cursor again.

Some apps read the cursor theme from GSettings. If one shows the wrong cursor, set it there too:

gsettings set org.gnome.desktop.interface cursor-theme 'Adwaita'
gsettings set org.gnome.desktop.interface cursor-size 24

Apps started before a change may keep the old cursor until restarted.

Hiding the cursor

Hide the cursor once, without changing the automatic settings:

sweets.bind("MOD+Ctrl+F6", "hide_cursor")
sweets.bind("MOD+Ctrl+F7", "show_cursor")

Moving the mouse, clicking, or scrolling shows it again.

sweets.bind_switch

Run a command when the laptop lid or tablet mode changes:

sweets.bind_switch("lid:closed", "spawn", { "veila", "lock" })
sweets.bind_switch("tablet_mode:on", "spawn", { "wvkbd-mobintl" })
sweets.bind_switch("tablet_mode:off", "spawn", { "pkill", "wvkbd-mobintl" })
SwitchWhen
lid:closed, lid:openThe lid closes or opens
tablet_mode:on, tablet_mode:offTablet mode turns on or off

Only spawn works here. Switch bindings also run on the lock screen.

To turn off the laptop screen when the lid closes, see lid_switch.

sweets.native

Workarounds for graphics driver problems:

sweets.native({ disable_cursor_plane = true })
FieldDefaultUse when
disable_cursor_planefalseThe cursor is missing, glitched, or the wrong size
disable_direct_scanoutfalseFullscreen apps or games flicker or show glitches

These settings work independently. A visible software cursor may still prevent fullscreen direct scanout.

On this page