The Predator key sends keyboard usage 0xC9, which lies outside the logical range the keyboard declares, so the kernel never emits an input event for it. It is also reported on vendor report 4 of USB interface 2 (04 81 ff on press). predatord now listens there and opens the app in the active graphical session via the user's systemd manager. The action is configurable on the System page: open the app, switch to the next performance mode, or do nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
5.3 KiB
Bash
Executable File
109 lines
5.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# Predator Control installer.
|
||
# sudo ./install.sh install / upgrade
|
||
# sudo ./install.sh --no-deps skip package installation (non-Arch distros)
|
||
set -euo pipefail
|
||
|
||
VERSION="1.3.0"
|
||
MODULE="predator-wmi"
|
||
SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PREFIX="/usr"
|
||
LIBDIR="$PREFIX/lib/predator-control"
|
||
INSTALL_DEPS=1
|
||
[[ "${1:-}" == "--no-deps" ]] && INSTALL_DEPS=0
|
||
|
||
c_ok() { printf '\e[32m✔\e[0m %s\n' "$*"; }
|
||
c_info() { printf '\e[36m→\e[0m %s\n' "$*"; }
|
||
c_warn() { printf '\e[33m!\e[0m %s\n' "$*"; }
|
||
die() { printf '\e[31m✘ %s\e[0m\n' "$*" >&2; exit 1; }
|
||
|
||
[[ $EUID -eq 0 ]] || die "Please run as root: sudo ./install.sh"
|
||
|
||
if ! grep -qi acer /sys/class/dmi/id/sys_vendor 2>/dev/null; then
|
||
c_warn "This does not look like an Acer laptop ($(cat /sys/class/dmi/id/sys_vendor 2>/dev/null))."
|
||
read -rp "Continue anyway? [y/N] " a; [[ "$a" =~ ^[yY] ]] || exit 1
|
||
fi
|
||
|
||
# ------------------------------------------------------------------ dependencies
|
||
if [[ $INSTALL_DEPS -eq 1 ]]; then
|
||
if command -v pacman >/dev/null; then
|
||
KPKG="$(pacman -Qoq "/usr/lib/modules/$(uname -r)/vmlinuz" 2>/dev/null || echo linux)"
|
||
PKGS=(python pyside6 dkms base-devel "${KPKG}-headers")
|
||
grep -q clang /proc/version && PKGS+=(clang lld llvm)
|
||
c_info "Installing dependencies: ${PKGS[*]}"
|
||
pacman -S --needed --noconfirm "${PKGS[@]}"
|
||
else
|
||
c_warn "Not an Arch-based system – install manually: python3, PySide6, dkms, kernel headers, make, gcc/clang"
|
||
fi
|
||
fi
|
||
|
||
# ------------------------------------------------------------------ kernel module
|
||
c_info "Building kernel module predator_wmi"
|
||
if lsmod | grep -q '^predator_wmi'; then modprobe -r predator_wmi || true; fi
|
||
if command -v dkms >/dev/null; then
|
||
for v in $(dkms status -m "$MODULE" 2>/dev/null | sed -n 's|^[^/]*/\([^,:]*\).*|\1|p' | sort -u); do
|
||
dkms remove -m "$MODULE" -v "$v" --all >/dev/null 2>&1 || true
|
||
done
|
||
rm -rf "/usr/src/$MODULE-$VERSION"
|
||
install -d "/usr/src/$MODULE-$VERSION"
|
||
install -m644 "$SRC"/kernel/{predator_wmi.c,Makefile,dkms.conf} "/usr/src/$MODULE-$VERSION/"
|
||
dkms add -m "$MODULE" -v "$VERSION"
|
||
dkms install -m "$MODULE" -v "$VERSION" || die "DKMS build failed – see /var/lib/dkms/$MODULE/$VERSION/build/make.log"
|
||
c_ok "Module installed via DKMS (rebuilt automatically on kernel updates)"
|
||
else
|
||
make -C "$SRC/kernel" clean >/dev/null 2>&1 || true
|
||
make -C "$SRC/kernel"
|
||
install -Dm644 "$SRC/kernel/predator_wmi.ko" "/lib/modules/$(uname -r)/updates/predator_wmi.ko"
|
||
depmod -a
|
||
c_warn "DKMS not found – module installed for the running kernel only. Re-run after kernel updates."
|
||
fi
|
||
install -Dm644 "$SRC/data/modules-load-predator-control.conf" /etc/modules-load.d/predator-control.conf
|
||
if ! modprobe predator_wmi; then
|
||
c_warn "Could not load predator_wmi. If Secure Boot is enabled, the module must be signed."
|
||
c_warn "Fan control, lightbar and battery features need this module; keyboard RGB and profiles work without it."
|
||
fi
|
||
|
||
# ------------------------------------------------------------------ application
|
||
c_info "Installing application"
|
||
rm -rf "$LIBDIR"
|
||
install -d "$LIBDIR/predator_control/gui"
|
||
install -m644 "$SRC"/predator_control/*.py "$LIBDIR/predator_control/"
|
||
install -m644 "$SRC"/predator_control/gui/*.py "$LIBDIR/predator_control/gui/"
|
||
python3 -m compileall -q "$LIBDIR" || true
|
||
for b in predatord predatorctl predator-control; do install -Dm755 "$SRC/bin/$b" "$PREFIX/bin/$b"; done
|
||
install -Dm644 "$SRC/data/predator-control.svg" "$PREFIX/share/icons/hicolor/scalable/apps/predator-control.svg"
|
||
install -Dm644 "$SRC/data/predator-control.desktop" "$PREFIX/share/applications/predator-control.desktop"
|
||
install -Dm644 "$SRC/data/predatord.service" "$PREFIX/lib/systemd/system/predatord.service"
|
||
install -Dm755 "$SRC/data/system-sleep-predator-control" "$PREFIX/lib/systemd/system-sleep/predator-control"
|
||
|
||
PLASMOID="$PREFIX/share/plasma/plasmoids/org.predatorcontrol.panel"
|
||
rm -rf "$PLASMOID"
|
||
install -d "$PLASMOID/contents/ui"
|
||
install -m644 "$SRC/plasmoid/org.predatorcontrol.panel/metadata.json" "$PLASMOID/"
|
||
install -m644 "$SRC/plasmoid/org.predatorcontrol.panel/contents/ui/"*.qml "$PLASMOID/contents/ui/"
|
||
gtk-update-icon-cache -q -t "$PREFIX/share/icons/hicolor" 2>/dev/null || true
|
||
c_ok "Application, panel widget and service files installed"
|
||
|
||
# ------------------------------------------------------------------ service
|
||
systemctl daemon-reload
|
||
systemctl enable predatord.service >/dev/null 2>&1
|
||
systemctl restart predatord.service
|
||
sleep 1
|
||
systemctl is-active --quiet predatord.service && c_ok "Service predatord is running" \
|
||
|| c_warn "predatord failed to start – check: journalctl -u predatord"
|
||
|
||
USER_NAME="${SUDO_USER:-}"
|
||
if [[ -n "$USER_NAME" ]] && ! id -nG "$USER_NAME" | tr ' ' '\n' | grep -qx wheel; then
|
||
c_warn "User '$USER_NAME' is not in group 'wheel' – only wheel members may control the daemon."
|
||
c_warn "Add yourself with: sudo usermod -aG wheel $USER_NAME (then log out and back in)"
|
||
fi
|
||
|
||
cat <<MSG
|
||
|
||
$(c_ok "Predator Control $VERSION installed")
|
||
• App: start "Predator Control" from the application menu (or run: predator-control)
|
||
• Panel widget: right-click the panel → "Add or Manage Widgets…" → search "Predator Control"
|
||
(if it does not show up yet: log out and back in, or run: plasmashell --replace &)
|
||
• CLI: predatorctl status
|
||
MSG
|