diff --git a/packaging/nfpm.yaml b/packaging/nfpm.yaml index f0a426a..fbc4204 100644 --- a/packaging/nfpm.yaml +++ b/packaging/nfpm.yaml @@ -54,6 +54,16 @@ contents: file_info: mode: 0644 + # Ubuntu/Debian's ydotool & ydotoold packages ship the binaries but not a + # systemd unit, so the drop-in above has nothing to drop into. Ship a base + # ydotool.service ourselves on deb only — Fedora's ydotool package already + # provides one (we'd conflict if we shipped it on rpm too). + - src: ./systemd/ydotool.service + dst: /usr/lib/systemd/system/ydotool.service + file_info: + mode: 0644 + packager: deb + - src: ../scripts/download-model.sh dst: /usr/share/utter/download-model.sh file_info: @@ -80,6 +90,7 @@ overrides: deb: depends: - ydotool + - ydotoold - alsa-utils - wl-clipboard - libnotify-bin diff --git a/packaging/scripts/postinstall.sh b/packaging/scripts/postinstall.sh index 6fab277..cf5d638 100755 --- a/packaging/scripts/postinstall.sh +++ b/packaging/scripts/postinstall.sh @@ -6,7 +6,28 @@ set -e # get added after install. if command -v udevadm >/dev/null 2>&1; then udevadm control --reload-rules || true - udevadm trigger --subsystem-match=input || true + # `change` action so logind re-evaluates ACLs on already-plugged devices + # rather than only firing for new device adds. + udevadm trigger --subsystem-match=input --action=change || true +fi + +# Belt-and-suspenders: the udev/uaccess rule above grants ACL access to +# the active-seat user without requiring `input` group membership, which +# is great when it works — but on some session configurations (no local +# seat assigned, headless, certain Wayland compositors) logind never +# applies the ACL. Add the installing user to `input` as a fallback so +# utter-watcher works after a re-login even when uaccess silently fails. +INSTALL_USER="${SUDO_USER:-}" +if [ -z "$INSTALL_USER" ] && [ -n "${PKEXEC_UID:-}" ]; then + INSTALL_USER="$(getent passwd "$PKEXEC_UID" | cut -d: -f1 || true)" +fi +if [ -n "$INSTALL_USER" ] && [ "$INSTALL_USER" != "root" ] \ + && getent group input >/dev/null 2>&1 \ + && ! id -nG "$INSTALL_USER" 2>/dev/null | tr ' ' '\n' | grep -qx input +then + if usermod -aG input "$INSTALL_USER" 2>/dev/null; then + ADDED_INPUT_GROUP=1 + fi fi # Install & start ydotool (the system service that drives /dev/uinput). @@ -43,6 +64,23 @@ To start the services in your current session without logging out: Then hold Right Cmd (or the key you configured) and speak. +To change the PTT key (default: rightmeta), run: + + utter set-key + +…then press and hold the key you want and release. The watcher restarts +automatically. + EOM +if [ "${ADDED_INPUT_GROUP:-0}" = "1" ]; then + cat <