Skip to content

fix: use ~/.config/vader5/config.toml as default config path - #27

Merged
BANANASJIM merged 4 commits into
mainfrom
fix/config-default-path
Mar 13, 2026
Merged

fix: use ~/.config/vader5/config.toml as default config path#27
BANANASJIM merged 4 commits into
mainfrom
fix/config-default-path

Conversation

@BANANASJIM

@BANANASJIM BANANASJIM commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • default_path() now checks ~/.config/vader5/config.toml first before falling back to relative config/config.toml
  • Remove incorrect sudo systemctl enable --now vader5d from README — service is auto-started by udev rules
  • Refactor: replace 10 suppress bools with SuppressState struct, extract duplicate stick processing into lambdas

Closes #24

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated Quick Start instructions to clarify systemd service auto-start behavior.
    • Configuration documentation now specifies file location search order: XDG_CONFIG_HOME, user config directory, system-wide path, and local fallback.
    • Added guidance for specifying custom configuration file paths.
  • Features

    • Configuration files are automatically searched in standard system locations during startup.
    • System configuration file is automatically provisioned during installation.

@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8db9a352-bdaf-4e02-8cd6-aeada2c12f8c

📥 Commits

Reviewing files that changed from the base of the PR and between ad18293 and 872a2a3.

📒 Files selected for processing (2)
  • include/vader5/gamepad.hpp
  • src/gamepad.cpp

📝 Walkthrough

Walkthrough

Updated docs and install script; added filesystem-aware config path resolution; refactored gamepad suppression state into a single SuppressState struct with a new apply(...) method and consolidated suppression logic across poll/emission paths.

Changes

Cohort / File(s) Summary
Docs / Quickstart & Config
README.md, docs/configuration.md
Adjusted Quick Start wording (systemd auto-start note removed), added explicit ordered search description for config file locations and an example for -c/--config.
Installer
install/install.sh
Pre-install: ensure /etc/vader5/config.toml exists (create/copy if missing); uninstall: remove /etc/vader5/config.toml and attempt to remove directory.
Config path resolution
src/config.cpp
Added and ; implement ordered config path search (XDG_CONFIG_HOME, HOME/.config, /etc/vader5, fallback config/config.toml).
Gamepad suppression refactor
include/vader5/gamepad.hpp, src/gamepad.cpp
Replaced multiple per-flag booleans with SuppressState (five fields) and SuppressState::apply(GamepadState&). Centralized suppression application across polling and emission, consolidated movement/accumulation logic, removed scattered suppression flags and prev_* booleans. Added apply method to the nested type.

Sequence Diagram(s)

(omitted — changes are internal refactors and docs/install updates; no multi-component sequential flow requiring a diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Review effort 3/5

Poem

🐇
I hopped through code with eager paws,
bundled flags into tidy laws.
Configs found their proper place,
install scripts tidy up the space.
A little stomp — the patch is done, hooray!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The suppression state refactoring (booleans to struct) is unrelated to #24 requirements and appears to be an independent code quality improvement outside the scope of fixing installation issues. Remove the SuppressState refactoring changes from this PR and address them in a separate, dedicated pull request focused on code quality improvements.
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: updating default config path to ~/.config/vader5/config.toml with XDG/per-user fallback logic.
Linked Issues check ✅ Passed PR addresses the main coding requirements from #24: implements sensible per-user config path resolution and corrects README service startup documentation; however, does not directly address cmake build dependency issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/config-default-path
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

@BANANASJIM
BANANASJIM marked this pull request as ready for review March 13, 2026 10:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install/install.sh`:
- Line 74: The uninstall script currently runs the destructive command "sudo rm
-rf /etc/vader5"; replace that with a safe cleanup that does not recursively
delete user files: maintain a list/variable of the specific installed files and
config names the installer created (referenced by the uninstall/remove block in
install/install.sh), remove only those entries, or move the whole directory to a
timestamped backup and prompt for explicit user confirmation (or require a
--force flag) before deleting; also check ownership and only remove files owned
by the package/install user to avoid deleting third‑party/user data.

In `@src/config.cpp`:
- Around line 186-190: The current else-if using std::getenv("XDG_CONFIG_HOME")
and else if std::getenv("HOME") causes HOME/.config to be skipped when
XDG_CONFIG_HOME exists but doesn't contain the file; change the logic so you
first set base to XDG_CONFIG_HOME if present (using
std::getenv("XDG_CONFIG_HOME") and the variable base) but still attempt
HOME/.config (std::getenv("HOME")) as a fallback if the file is not found under
XDG_CONFIG_HOME — i.e., don't use else if, instead build a search order (try
base = XDG_CONFIG_HOME, then base = HOME + "/.config") or check file existence
under XDG_CONFIG_HOME and only then fall back to HOME/.config; apply the same
change to the similar block around the code referenced at 192-197.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb9a23ed-03c3-4c02-a77d-b2caacfc3adb

📥 Commits

Reviewing files that changed from the base of the PR and between a978121 and 734bfc6.

📒 Files selected for processing (4)
  • README.md
  • docs/configuration.md
  • install/install.sh
  • src/config.cpp

Comment thread install/install.sh Outdated
Comment thread src/config.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@install/install.sh`:
- Around line 54-58: The installer currently writes /etc/vader5/config.toml when
missing but the uninstall path always deletes it; change install/install.sh to
create a marker file (e.g. /etc/vader5/.vader5_installed) whenever the script
copies config (the block that runs the sudo cp "$PROJECT_DIR/config/config.toml"
... and calls success "System config created at /etc/vader5/config.toml") and
update the uninstall logic (the block that removes /etc/vader5/config.toml) to
only remove /etc/vader5/config.toml if that marker exists, then remove the
marker when deleting; this ensures pre-existing configs are preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9e1272fd-d938-4758-9419-0ee23003de5e

📥 Commits

Reviewing files that changed from the base of the PR and between 734bfc6 and 12795dd.

📒 Files selected for processing (2)
  • install/install.sh
  • src/config.cpp

Comment thread install/install.sh
Comment on lines +54 to +58
if [[ ! -f /etc/vader5/config.toml ]]; then
sudo mkdir -p /etc/vader5
sudo cp "$PROJECT_DIR/config/config.toml" /etc/vader5/config.toml
success "System config created at /etc/vader5/config.toml"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Do not delete pre-existing system config on uninstall.

Line 54 only creates /etc/vader5/config.toml when absent, but Line 74 always deletes it. This can remove a config that existed before install.

Suggested fix (track installer-owned config with a marker)
 install_systemd() {
     info "Installing systemd service (requires sudo)..."
     if [[ ! -f /etc/vader5/config.toml ]]; then
         sudo mkdir -p /etc/vader5
         sudo cp "$PROJECT_DIR/config/config.toml" /etc/vader5/config.toml
+        sudo touch /etc/vader5/.managed-by-vader5-installer
         success "System config created at /etc/vader5/config.toml"
     fi
@@
 uninstall() {
@@
-    sudo rm -f /etc/vader5/config.toml
-    sudo rmdir /etc/vader5 2>/dev/null || true
+    if [[ -f /etc/vader5/.managed-by-vader5-installer ]]; then
+        sudo rm -f /etc/vader5/config.toml /etc/vader5/.managed-by-vader5-installer
+        sudo rmdir /etc/vader5 2>/dev/null || true
+    fi

Also applies to: 74-75

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@install/install.sh` around lines 54 - 58, The installer currently writes
/etc/vader5/config.toml when missing but the uninstall path always deletes it;
change install/install.sh to create a marker file (e.g.
/etc/vader5/.vader5_installed) whenever the script copies config (the block that
runs the sudo cp "$PROJECT_DIR/config/config.toml" ... and calls success "System
config created at /etc/vader5/config.toml") and update the uninstall logic (the
block that removes /etc/vader5/config.toml) to only remove
/etc/vader5/config.toml if that marker exists, then remove the marker when
deleting; this ensures pre-existing configs are preserved.

default_path() now checks ~/.config/vader5/config.toml first before
falling back to the relative config/config.toml. This fixes the
systemd service not finding the config since its working directory
is not the project root.

Also fix README: remove incorrect systemctl enable instruction since
the service is auto-started by udev rules.

Closes #24
Search order: XDG_CONFIG_HOME → ~/.config → /etc/vader5 → relative.
Install systemd service config to /etc/vader5/config.toml so the
daemon finds it when HOME is unset. Update docs to document the
search order.
- Check XDG_CONFIG_HOME and ~/.config as separate fallbacks so both
  paths are tried even when XDG_CONFIG_HOME is set
- Handle XDG_CONFIG_HOME="" per XDG spec (treat as unset)
- Use rm -f + rmdir instead of rm -rf to preserve user files
@BANANASJIM
BANANASJIM force-pushed the fix/config-default-path branch from 12795dd to ad18293 Compare March 13, 2026 21:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

78-78: ⚠️ Potential issue | 🟠 Major

Document the new default config path and search order.

The PR title and description highlight that the default config path now checks ~/.config/vader5/config.toml first before falling back to config/config.toml, but this README still only documents the old relative path. Users following the Quick Start won't discover the per-user config location.

Consider adding a brief note here about the config search order (e.g., ~/.config/vader5/config.toml/etc/vader5/config.tomlconfig/config.toml) or at least mention that multiple locations are checked. This would improve discoverability of the new user-friendly default path that is central to this PR.

📝 Suggested documentation improvement
 ## Configuration
 
-Config: `config/config.toml`
+The daemon searches for config files in this order:
+1. `~/.config/vader5/config.toml` (per-user)
+2. `/etc/vader5/config.toml` (system-wide)
+3. `config/config.toml` (repository fallback)
+
+Or specify a custom path with `-c`:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` at line 78, Update the README entry that currently shows only
"Config: `config/config.toml`" to document the new default per-user location and
full search order: mention `~/.config/vader5/config.toml` as the primary
default, then `/etc/vader5/config.toml`, and finally the repository-local
`config/config.toml`, or at minimum add a short sentence stating that multiple
locations are searched in that order; edit the line containing "Config:
`config/config.toml`" (or the surrounding paragraph) to include this note so
users discover the new per-user config path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@README.md`:
- Line 78: Update the README entry that currently shows only "Config:
`config/config.toml`" to document the new default per-user location and full
search order: mention `~/.config/vader5/config.toml` as the primary default,
then `/etc/vader5/config.toml`, and finally the repository-local
`config/config.toml`, or at minimum add a short sentence stating that multiple
locations are searched in that order; edit the line containing "Config:
`config/config.toml`" (or the surrounding paragraph) to include this note so
users discover the new per-user config path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09525e00-3788-47e5-8843-0cc9632023fe

📥 Commits

Reviewing files that changed from the base of the PR and between 12795dd and ad18293.

📒 Files selected for processing (4)
  • README.md
  • docs/configuration.md
  • install/install.sh
  • src/config.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
  • install/install.sh
  • src/config.cpp
  • docs/configuration.md

Extract duplicate left/right stick processing into lambdas.
@BANANASJIM
BANANASJIM merged commit 53e123a into main Mar 13, 2026
6 checks passed
@BANANASJIM
BANANASJIM deleted the fix/config-default-path branch March 13, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install fail on bazzite

1 participant