Repository navigation
On Screen Keyboard and Auto Rotation
Two independent helpers: an OSK toggle and an auto-rotate daemon. Take either, both, or neither. Both work on stock niri too: nothing in them depends on the patchset.
# OSK: any touchscreen device, no sensors involved
cp scripts/niri-osk.sh ~/.local/bin/
# auto-rotate: only for devices with an accelerometer
cp scripts/niri-rotate.sh ~/.local/bin/
cp scripts/niri-rotate.service ~/.config/systemd/user/
systemctl --user enable --now niri-rotate.serviceEdit OUTPUT/heights at the top of the scripts for your device.
Toggles wvkbd. On Arch, install the AUR
package wvkbd-git, which provides the wvkbd-deskintl binary the
script launches; python3 must be installed (it parses the output transform).
The script reads the transform from niri itself, not from sensors: in portrait
it doubles the keyboard height, and if you use a two-group xkb layout like
"pt,us" it flips the active group on toggle (the OSK is US-labelled; with a
single-group layout the flip is a no-op, so a US-only machine needs nothing
special).
The two-group layout, if you want it, lives in your input config:
input {
keyboard {
xkb {
layout "pt,us" // your layout first, us second
}
}
}Off-Arch, build wvkbd from source; extras/wvkbd/ in the repo carries a
PKGBUILD variant if you prefer building the package yourself.
The shipped edge-swipe config ties these together: a one-finger swipe up from
the bottom edge runs ~/.local/bin/niri-osk.sh
(Configuration#touchscreen-edge-swipe).
Follows the accelerometer via
iio-sensor-proxy and sets
niri msg output <name> transform as the tablet turns; it also resizes a
running keyboard. Enable it with the user unit above.
Only useful with a real accelerometer. Check yours with:
monitor-sensor # after starting iio-sensor-proxy.serviceMany touch laptops have none, in which case skip this helper: nothing else depends on it.
On convertibles the helper follows the tablet-mode switch and stays idle while the device is used as a laptop: no rotation happens, and folding the screen back returns the output to the normal orientation. Flipping into tablet mode catches up to the angle the accelerometer already reports. Machines without a switch (plain laptops, pure tablets) are untouched: the gate only engages when a switch is found.
The switch is a sysfs file printing 0 in laptop mode and 1 in tablet mode.
ThinkPad Yogas (thinkpad_acpi) and HP convertibles (hp-wmi) are detected
automatically; for anything else, find your device's file and export the
path (a systemd unit drop-in, environment.d, or editing the script):
NIRI_ROTATE_TABLET_MODE_SYSFS=/sys/devices/platform/your-driver/tablet_modeRelated knobs:
-
NIRI_ROTATE_TABLET_MODE_ONLY=auto(default): gate only when a switch is found.yesinsists on the gate and warns if no switch can be read;nodisables the gate entirely. -
NIRI_ROTATE_OUTPUToverrides the output name, same asOUTPUTin the script.
Why a sysfs file and not the input layer or iio-sensor-proxy: reading
SW_TABLET_MODE straight from /dev/input needs root or the input
group, which a systemd user service does not have, and iio-sensor-proxy
has no tablet-mode API at all. Vendor sysfs files are world-readable, so
the helper needs no extra privileges.