Enable, disable or toggle devices such as the mouse, touchpad, etc…
Specify devices using cl-ppcre regular expressions:
https://edicl.github.io/cl-ppcre/.
This module depends on xinput which is part of the X.Org suite of tools.
Add something like the following to your ~/.stumpwmrc:
(load "xinput-toggle")
;; disable all devices whose names match the regex "touchpad".
(xinput-toggle:xinput-disable-devices "touchpad")
;; enable all devices whose names match the regex "wireless mouse".
(xinput-toggle:xinput-enable-devices "wireless mouse")
;; bind a key to toggle all devices whose names match the regex "touchpad"
(define-key *top-map* (kbd "XF86TouchpadToggle")
"xinput-toggle-devices touchpad")touchpad and wireless mouse are regular expressions matching device names.
On my system the touchpad device name is FTCS1000:00 2808:0101 Touchpad. The
regex touchpad matches it.
xinput-toggle:*case-insensitive-regex* allows case-insensitive matching. By
default its value is T and can be set to NIL for case-sensitive matching.
To specify a device you need its name. Hence the first step is to discover the device name. You can then decide suitable regular expressions.
One way to discover device names is to run the command (StumpWM command (colon))
xinput-list-devices passing NAME-REGEX as an argument. It lists devices whose
names match NAME-REGEX.
List all devices:
xinput-list-devices ""
List all devices whose names matche mouse or touchpad:
xinput-list-devices "mouse|touchpad"
Alternatively list devices using the xinput program via the command line:
xinput list --name-only
See https://linux.die.net/man/1/xinput.
The following example would have disabled all devices including keyboards. However if keyboards get disabled by mistake, there might be no way to interact with StumpWM.
Hence there is a guard in place to exclude device names containing “keyboard”.
(xinput-toggle:xinput-disable-devices "")xinput:*exclude-keyboards* acts as a guard against disabling keyboards by
mistake. By default its value is T during which xinput-toggle excludes
devices whose name contains the string keyboard (always case insensitive). It
can be set to NIL to disable the guard.
The below will not list keyboard devices as the guard is enabled.
(xinput-toggle:xinput-list-devices "keyboard")This below lists device names matching “keyboard” as we disable the guard.
(let ((xinput-toggle:*exclude-keyboards* NIL))
(xinput-toggle:xinput-list-devices "keyboard"))