Harden HDMI recovery and add tested user installer release tooling
This commit is contained in:
1 parent
73e727ef4c
commit
d963224cb7
17 files changed
+903
-646
No files matched your search
+54
-17
@@ -1,35 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
START_SERVICE=0
|
||||
case "${1:-}" in
|
||||
'') ;;
|
||||
--start) START_SERVICE=1 ;;
|
||||
--help) printf 'Usage: %s [--start]\nInstall for the current user; --start also enables and restarts the service.\n' "$0"; exit 0 ;;
|
||||
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 2 ;;
|
||||
esac
|
||||
(( $# <= 1 )) || { printf 'Too many arguments\n' >&2; exit 2; }
|
||||
if (( EUID == 0 )); then
|
||||
printf 'Run this installer as the desktop user, without sudo.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BIN_DIR="$HOME/.local/bin"
|
||||
SYSTEMD_DIR="$HOME/.config/systemd/user"
|
||||
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/revive-monitor"
|
||||
|
||||
mkdir -p "$BIN_DIR" "$SYSTEMD_DIR" "$CONFIG_DIR"
|
||||
LIB_DIR="$HOME/.local/lib/hyprland-hdmi-revive"
|
||||
CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
[[ "$CONFIG_HOME" == /* ]] || { printf 'XDG_CONFIG_HOME must be absolute\n' >&2; exit 1; }
|
||||
SYSTEMD_DIR="$CONFIG_HOME/systemd/user"
|
||||
CONFIG_DIR="$CONFIG_HOME/revive-monitor"
|
||||
LOGTAG=revive-monitor-install
|
||||
# shellcheck source=lib/common.sh
|
||||
source "$REPO_ROOT/lib/common.sh"
|
||||
require_commands systemctl udevadm stdbuf timeout loginctl hyprctl jq flock sudo stat install || exit 1
|
||||
[[ -x /usr/bin/chvt ]] || { printf 'Missing /usr/bin/chvt (Arch package: kbd)\n' >&2; exit 1; }
|
||||
# Validate existing config before overwriting any installed files.
|
||||
load_config || exit 1
|
||||
if (( START_SERVICE )); then
|
||||
[[ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]] || {
|
||||
printf 'Use --start from a terminal inside Hyprland.\n' >&2; exit 1;
|
||||
}
|
||||
fi
|
||||
|
||||
# Avoid replacing Bash files while a running watcher/recovery is reading them.
|
||||
if systemctl --user is-active --quiet revive-monitor-drm-watch.service; then
|
||||
systemctl --user stop revive-monitor-drm-watch.service
|
||||
fi
|
||||
mkdir -p -- "$BIN_DIR" "$LIB_DIR" "$SYSTEMD_DIR" "$CONFIG_DIR"
|
||||
install -m 0755 "$REPO_ROOT/scripts/revive-monitor-fix.sh" "$BIN_DIR/revive-monitor-fix"
|
||||
install -m 0755 "$REPO_ROOT/scripts/revive-monitor-drm-watch.sh" "$BIN_DIR/revive-monitor-drm-watch"
|
||||
install -m 0644 "$REPO_ROOT/lib/common.sh" "$LIB_DIR/common.sh"
|
||||
install -m 0644 "$REPO_ROOT/systemd/user/revive-monitor-drm-watch.service" "$SYSTEMD_DIR/revive-monitor-drm-watch.service"
|
||||
|
||||
if [[ ! -e "$CONFIG_DIR/config.env" ]]; then
|
||||
install -m 0644 "$REPO_ROOT/config/revive-monitor.env.example" "$CONFIG_DIR/config.env"
|
||||
install -m 0600 "$REPO_ROOT/config/revive-monitor.env.example" "$CONFIG_DIR/config.env"
|
||||
printf 'Created %s\n' "$CONFIG_DIR/config.env"
|
||||
printf 'Edit MONITOR before using the service if your output is not HDMI-A-2.\n'
|
||||
else
|
||||
printf 'Keeping existing config: %s\n' "$CONFIG_DIR/config.env"
|
||||
fi
|
||||
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now revive-monitor-drm-watch.service
|
||||
|
||||
if (( START_SERVICE )); then
|
||||
systemctl --user import-environment HYPRLAND_INSTANCE_SIGNATURE
|
||||
# Keep the service and installer on the same configuration root.
|
||||
export XDG_CONFIG_HOME="$CONFIG_HOME"
|
||||
systemctl --user import-environment XDG_CONFIG_HOME
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable revive-monitor-drm-watch.service
|
||||
systemctl --user restart revive-monitor-drm-watch.service
|
||||
systemctl --user is-active --quiet revive-monitor-drm-watch.service
|
||||
else
|
||||
printf 'Files installed. Activation is explicit; follow README.md before starting.\n'
|
||||
fi
|
||||
cat <<'MSG'
|
||||
|
||||
Installed successfully.
|
||||
|
||||
Next steps:
|
||||
1. Verify ~/.config/revive-monitor/config.env
|
||||
2. Configure /etc/sudoers.d/revive-monitor-chvt using one of the templates in sudoers/
|
||||
3. Test with: systemctl --user status revive-monitor-drm-watch.service
|
||||
4. Watch logs: journalctl --user -u revive-monitor-drm-watch.service -f
|
||||
1. Set MONITOR in ${XDG_CONFIG_HOME:-$HOME/.config}/revive-monitor/config.env
|
||||
2. Configure chvt permission with visudo using the sudoers/ templates.
|
||||
3. Add the Hyprland environment/start hook documented in README.md.
|
||||
4. Run ./scripts/install.sh --start from Hyprland to activate or update.
|
||||
5. Check: journalctl --user -u revive-monitor-drm-watch.service -b
|
||||
MSG
|
||||
Reference in new issue
Block a user