Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packaging/linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,28 @@ echo "Installing udev rules …"
sudo install -Dm644 "${SCRIPT_DIR}/udev/70-openlogi.rules" \
/etc/udev/rules.d/70-openlogi.rules

# The rule grants /dev/uinput with TAG+="uaccess", which logind applies in
# response to a device event. A host that has never loaded the uinput module has
# no such device, so the trigger below matches nothing and the node stays
# root-owned — the hook then cannot create its virtual device and button
# remapping silently does nothing. Load it now, and register it for every boot.
echo "Loading the uinput module …"
sudo install -Dm644 "${SCRIPT_DIR}/modules-load/openlogi.conf" \
/etc/modules-load.d/openlogi.conf
if command -v modprobe >/dev/null 2>&1; then
sudo modprobe uinput || true
fi
Comment thread
greptile-apps[bot] marked this conversation as resolved.

if command -v udevadm >/dev/null 2>&1; then
echo "Reloading udev rules …"
sudo udevadm control --reload-rules
sudo udevadm trigger --subsystem-match=hidraw
sudo udevadm trigger --subsystem-match=input
sudo udevadm trigger --subsystem-match=misc --attr-match=name=uinput 2>/dev/null || true
# trigger only queues the events. Without settle the script can return before
# udev has applied the uaccess ACLs, so the next thing the user does — start
# the agent — still hits EACCES on a correctly configured system.
sudo udevadm settle 2>/dev/null || true
fi

# ── systemd user unit ─────────────────────────────────────────────────────────
Expand Down
11 changes: 11 additions & 0 deletions packaging/linux/modules-load/openlogi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Load uinput at boot for OpenLogi.
#
# 70-openlogi.rules grants access to /dev/uinput with TAG+="uaccess", which
# systemd-logind applies in response to a device event. A machine that has never
# loaded the uinput module has no such device: OPTIONS+="static_node=uinput"
# creates the node so that opening it can autoload the module, but the node is
# created with default permissions and no ACL, and opening it is precisely what
# the missing permission forbids.
#
# Loading the module makes the device appear, which lets the rule tag it.
uinput
15 changes: 12 additions & 3 deletions packaging/linux/nfpm-scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/bin/sh
set -eu

# /etc/modules-load.d/openlogi.conf loads uinput from the next boot on; load it
# now so the first session after installing works too. Without the module there
# is no uinput device for the rule's uaccess tag to apply to — the node exists
# via static_node= but stays root-owned, so the agent's hook cannot open it and
# button remapping silently does nothing while HID++ keeps working.
if command -v modprobe >/dev/null 2>&1; then
modprobe uinput || true
fi

# Reload udev rules and wait for the new uaccess tags to be applied.
# udevadm trigger is asynchronous — settle ensures the tags are in place
# before the script exits so the agent can open /dev/hidraw* and the mouse's
# /dev/input/event* node immediately, even for a device connected before the
# install.
# before the script exits so the agent can open /dev/hidraw*, /dev/uinput and
# the mouse's /dev/input/event* node immediately, even for a device connected
# before the install.
if command -v udevadm >/dev/null 2>&1; then
udevadm control --reload-rules
udevadm trigger --subsystem-match=hidraw
Expand Down
8 changes: 8 additions & 0 deletions packaging/linux/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ contents:
file_info:
mode: 0644

# ── uinput module load ──────────────────────────────────────────────────────
# The udev rule alone cannot grant /dev/uinput on a machine that has never
# loaded the module; see the file's own comment.
- src: packaging/linux/modules-load/openlogi.conf
dst: /etc/modules-load.d/openlogi.conf
file_info:
mode: 0644
Comment thread
greptile-apps[bot] marked this conversation as resolved.

# ── systemd user unit ───────────────────────────────────────────────────────
- src: packaging/linux/systemd/openlogi-agent.service
dst: /usr/lib/systemd/user/openlogi-agent.service
Expand Down
8 changes: 8 additions & 0 deletions packaging/linux/nixos-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ in
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];

# The udev rule grants /dev/uinput with TAG+="uaccess", which logind applies
# in response to a device event — and a host that has never loaded the
# uinput module has no such device, so the node stays root-owned and the
# agent cannot create the virtual device button remapping needs. The other
# packaging paths ship /etc/modules-load.d/openlogi.conf for this; on NixOS
# the equivalent is asking for the module here.
boot.kernelModules = [ "uinput" ];

systemd.user.services.openlogi-agent = {
description = "OpenLogi background agent";
wantedBy = lib.optionals cfg.launchAtLogin [ "graphical-session.target" ];
Expand Down
3 changes: 3 additions & 0 deletions packaging/linux/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ sudo rm -f "${BINDIR}/openlogi" "${BINDIR}/openlogi-desktop" \

echo "Removing udev rules …"
sudo rm -f /etc/udev/rules.d/70-openlogi.rules
# Leave the module loaded: other software may be using it by now. Only stop
# asking for it at boot.
sudo rm -f /etc/modules-load.d/openlogi.conf
if command -v udevadm >/dev/null 2>&1; then
sudo udevadm control --reload-rules
sudo udevadm trigger --subsystem-match=hidraw
Expand Down