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,
})| Field | Default | Effect |
|---|---|---|
layout | system default | Keyboard layout, or a list like "us,lv" |
variant | system default | Layout variant. Leave an entry empty to skip it: ",apostrophe" |
options | system default | XKB options, comma-separated |
model | system default | Keyboard model, usually pc105 |
rules | system default | Usually evdev |
repeat_rate | 25 | Key repeats per second, 0 turns repeat off |
repeat_delay | 200 | Milliseconds before a held key repeats |
numlock | true | Turn 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,
})| Field | Default | Effect |
|---|---|---|
theme | system default | Cursor theme name |
size | 24 | Cursor size, 1–256 |
hide_on_key_press | false | Hide the cursor while you type |
inactive_timeout | 0 | Hide 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 24Apps 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" })| Switch | When |
|---|---|
lid:closed, lid:open | The lid closes or opens |
tablet_mode:on, tablet_mode:off | Tablet 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 })| Field | Default | Use when |
|---|---|---|
disable_cursor_plane | false | The cursor is missing, glitched, or the wrong size |
disable_direct_scanout | false | Fullscreen apps or games flicker or show glitches |
These settings work independently. A visible software cursor may still prevent fullscreen direct scanout.