SmartestHome/hosts/thin-client/live-build/config/hooks/normal/1000-ydotool.hook.chroot

29 lines
1.5 KiB
Bash

#!/bin/sh
# Input injection for the HA mobile-app browser remote (project-plan Phase 11,
# follow-up: text field + mouse buttons).
#
# ydotool writes to /dev/uinput as a virtual input device rather than talking to a
# display-server protocol (see thinclient_agent/input_control.py) — that device node is
# root-owned by default, which is what ydotoold (present in ydotool >= 1.0) exists to
# broker: it runs as a system service and the client talks to it over a socket instead
# of opening /dev/uinput itself. Debian bookworm's ydotool version, and therefore
# whether ydotoold even exists, decides which of the two paths below applies —
# InputControl already detects this the same way (shutil.which("ydotoold")).
set -eu
. /etc/thinclient-agent/config.env
apt-get install -y --no-install-recommends ydotool
if systemctl list-unit-files ydotoold.service >/dev/null 2>&1; then
systemctl enable ydotoold
echo "1000-ydotool: enabled ydotoold.service (modern ydotool)."
else
echo "1000-ydotool: no ydotoold.service shipped with this package (legacy ydotool that"
echo " opens /dev/uinput directly). It needs to run as root or have a udev rule"
echo " granting the '${KIOSK_USERNAME}' user access to /dev/uinput — 0100-user-setup"
echo " already put that account in the 'input' group, which covers the common udev"
echo " rule pattern (GROUP=\"input\") if this Debian release ships one for uinput;"
echo " add one by hand if the input-control buttons in Home Assistant do nothing."
fi