Conversation
Refactor install script to support multiple files and improve download handling.
There was a problem hiding this comment.
Pull request overview
This PR refactors the Valve Index HID reboot workaround to be driven by systemd (service + system-sleep hook) instead of running an inline shell command from the udev rule, and updates the installer to deploy the additional artifacts.
Changes:
- Replace udev
RUN+=...logic with a systemd-triggered templated unit onhidrawdevice add. - Add a dedicated reboot script and a systemd sleep hook to re-apply the reset after resume.
- Extend
install.shto install all required files and reload systemd/udev.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/99-valve-index-reboot.rules | Switches to SYSTEMD_WANTS to start a systemd service on device add. |
| src/valve-index-hid-reboot@.service | Adds a oneshot systemd unit that runs the reboot script (guarded by a flag). |
| src/valve-index-hid-reboot.sh | Introduces a standalone script to locate the device and issue the HID reset. |
| src/valve-index-hid-reboot | Adds a systemd sleep hook to reset after resume (and reset the flag). |
| src/install.sh | Installs the rule, script, unit, and sleep hook; reloads systemd and udev. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| warn "File $filename not found locally, downloading from GitHub…" >&2 | ||
| local tmp_file | ||
| tmp_file="$(mktemp "/tmp/${filename}.XXXXXX")" | ||
|
|
||
| if command -v curl &>/dev/null; then | ||
| curl -fsSL "$RULE_RAW_URL" -o "$tmp_rule" || die "Failed to download rule file from GitHub." | ||
| curl -fsSL "$url" -o "$tmp_file" || die "Failed to download $filename." | ||
| elif command -v wget &>/dev/null; then | ||
| wget -qO "$tmp_rule" "$RULE_RAW_URL" || die "Failed to download rule file from GitHub." | ||
| wget -qO "$tmp_file" "$url" || die "Failed to download $filename." | ||
| else | ||
| die "Rule file not found locally and neither curl nor wget is available." | ||
| die "Neither curl nor wget is available to download $filename." | ||
| fi | ||
|
|
||
| [[ -s "$tmp_rule" ]] || die "Downloaded rule file is empty." | ||
| printf '%s\n' "$tmp_rule" | ||
| [[ -s "$tmp_file" ]] || die "Downloaded $filename is empty." | ||
| printf '%s\n' "$tmp_file" |
There was a problem hiding this comment.
@copilot apply changes based on this feedback
cleanup tmp files with trap
There was a problem hiding this comment.
Done in commit 15febe9. Added a _TMP_FILES array that records each temp path immediately after mktemp, and an EXIT trap calling _cleanup_tmp to rm -f all tracked files when the script exits (normally or via die).
| step "Reloading systemd and udev…" | ||
| $SUDO systemctl daemon-reload | ||
| $SUDO udevadm control --reload-rules | ||
| $SUDO udevadm trigger --action=add --subsystem-match=hidraw |
There was a problem hiding this comment.
@copilot apply changes based on this feedback
- Detect systemctl and show a clear error if not present
- Skip systemd steps when systemctl is missing
There was a problem hiding this comment.
Done in commit ffefdba. Added a systemctl check at the top of install_manual() — if systemctl is not found, the script dies early with a clear error message explaining that systemd is required (due to SYSTEMD_WANTS in the udev rule), which also skips all systemd-dependent steps.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MiguVT/fixvr/sessions/7933e0e5-9995-4c53-be16-711f1d2b279f Co-authored-by: MiguVT <71216796+MiguVT@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MiguVT/fixvr/sessions/8d23d6f6-7500-4700-aa66-c67629d20163 Co-authored-by: MiguVT <71216796+MiguVT@users.noreply.github.com>
This pull request refactors the Valve Index HID reboot fix to use systemd services and hooks instead of ad-hoc shell commands in udev rules. The new approach improves maintainability, reliability, and cross-distro compatibility. It introduces dedicated scripts and service files, and updates the installer to handle these files. The most important changes are:
Migration to systemd-based reboot logic:
99-valve-index-reboot.rules) now triggers a systemd service (valve-index-hid-reboot@.service) on device add, replacing the previous inline shell command.valve-index-hid-reboot@.service) that runs the reboot script safely, only if needed.valve-index-hid-reboot.sh) to encapsulate the device reset logic, improving clarity and testability.valve-index-hid-reboot) to ensure the device is reset after resume from sleep.Installer improvements:
install.sh) now installs all required files (udev rule, script, service, and sleep hook), downloading them as needed, and reloads both systemd and udev to apply changes. [1] [2] [3] [4]Documentation and messaging: