Class Input
Input management.
This module provides utilities to set key- and mousebinds as well as change keyboard settings.
Fields
mouse_button_values
mouse_button_values
: table
key
key
= require("pinnacle.input.keys")
Functions
function keybind
function Input.keybind(mods: Modifier[], key: Key | string, action: fun(), keybind_info?: KeybindInfo)
Set a keybind. If called with an already existing keybind, it gets replaced.
You must provide three arguments:
mods
: An array ofModifier
s. If you don't want any, provide an empty table.key
: The key that will triggeraction
. You can provide three types of key:- Something from the
Key
table inInput.key
, which lists every xkbcommon key. The naming pattern is the xkbcommon key without theKEY_
prefix, unless that would make it start with a number or the reserved lua keywordfunction
, in which case theKEY_
prefix is included. - A single character representing your key. This can be something like "g", "$", "~", "1", and so on.
- A string of the key's name. This is the name of the xkbcommon key without the
KEY_
prefix.
- Something from the
action
: The function that will be run when the keybind is pressed.
It is important to note that "a"
is different than "A"
. Similarly, key.a
is different than key.A
. Usually, it's best to use the non-modified key to prevent confusion and unintended behavior.
Input.keybind({ "shift" }, "a", function() end) -- This is preferred
Input.keybind({ "shift" }, "A", function() end) -- over this
-- This keybind will only work with capslock on.
Input.keybind({}, "A", function() end)
-- This keybind won't work at all because to get `@` you need to hold shift,
-- which this keybind doesn't accept.
Input.keybind({ "ctrl" }, "@", function() end)
Example
-- Set `super + Return` to open Alacritty
Input.keybind({ "super" }, Input.key.Return, function()
Process.spawn("alacritty")
end)
Parameters
mods
: Modifier[]
- The modifiers that need to be held down for the bind to triggerkey
: Key | string
- The key used to trigger the bindaction
: fun()
- The function to run when the bind is triggeredkeybind_info?
: KeybindInfo
function mousebind
function Input.mousebind(mods: Modifier[], button: MouseButton, edge: MouseEdge, action: fun())
Set a mousebind. If called with an already existing mousebind, it gets replaced.
You must specify whether the keybind happens on button press or button release.
Example
-- Set `super + left mouse button` to move a window on press
Input.mousebind({ "super" }, "btn_left", "press", function()
Window.begin_move("btn_left")
end)
Parameters
mods
: Modifier[]
- The modifiers that need to be held down for the bind to triggerbutton
: MouseButton
- The mouse button used to trigger the bindedge
: MouseEdge
- "press" or "release" to trigger on button press or releaseaction
: fun()
- The function to run when the bind is triggered
function keybind_descriptions
function Input.keybind_descriptions()
-> KeybindDescription[]
Get all keybinds along with their descriptions
Returns
function set_xkb_config
function Input.set_xkb_config(xkb_config: XkbConfig)
Set the xkbconfig for your keyboard.
Fields not present will be set to their default values.
Read xkeyboard-config(7)
for more information.
Example
Input.set_xkb_config({
layout = "us,fr,ge",
options = "ctrl:swapcaps,caps:shift"
})
Parameters
xkb_config
: XkbConfig
- The new xkbconfig
function set_repeat_rate
function Input.set_repeat_rate(rate: integer, delay: integer)
Set the keyboard's repeat rate and delay.
Example
Input.set_repeat_rate(100, 1000) -- Key must be held down for 1 second, then repeats 10 times per second.
Parameters
rate
: integer
- The time between repeats in millisecondsdelay
: integer
- The duration a key needs to be held down before repeating starts in milliseconds
function set_libinput_settings
function Input.set_libinput_settings(settings: LibinputSettings)
Set a libinput setting.
This includes settings for pointer devices, like acceleration profiles, natural scroll, and more.
Example
Input.set_libinput_settings({
accel_profile = "flat",
natural_scroll = true,
})
Parameters
settings
: LibinputSettings
function set_xcursor_theme
function Input.set_xcursor_theme(theme: string)
Sets the current xcursor theme.
Pinnacle reads $XCURSOR_THEME
on startup to set the theme. This allows you to set it at runtime.
Parameters
theme
: string
function set_xcursor_size
function Input.set_xcursor_size(size: integer)
Sets the current xcursor size.
Pinnacle reads $XCURSOR_SIZE
on startup to set the cursor size. This allows you to set it at runtime.
Parameters
size
: integer