Skip to content

feat: support Linux CLI battery queries with sudo - #16

Merged
softmaxe merged 1 commit into
mainfrom
t3/linux-cli-support
Nov 7, 2026
Merged

softmaxe merged 1 commit into
mainfrom
t3/linux-cli-support

Conversation

@softmaxe

@softmaxe softmaxe commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Summary

Add Linux CLI support with native hidraw access and sudo-based battery queries. Document why the device needs read/write access and show sudo commands for source builds and installed binaries.

Linux: sudo gbat -> native hidraw -> HID++ -> battery status
macOS: gbat      -> shared HID   -> HID++ -> battery status

Use platform-specific hidapi features, deduplicate Linux device paths, reject incomplete report writes, and explain sudo usage on permission errors. Device permissions remain managed by the system; the CLI does not install udev rules.

Evidence

  • Before: cargo build --locked on Ubuntu failed with Unable to find libudev.
    After: Linux builds with linux-native-basic-udev, without libudev development files.
  • Before: A regular-user battery query failed with an unexplained permission error.
    After: It exits with status 1 and a sudo hint; sudo ./target/release/gbat exits with status 0 and reads Battery: 56% (charging) from a connected Logitech receiver (046d:c547). Device nodes were restored to root:root 0600 before this test.
  • gbat --version succeeds without sudo.
  • Linux validation passed: cargo fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo test --locked (27 tests), and cargo build --release --locked.
  • macOS validation runs in the existing required Check job.

Merge Danger

Door: two-way

Reversible code and documentation changes; no device configuration or data migration.

Blast Radius: CLI

Linux selects a new HID backend. macOS retains its existing backend; complete-write validation also applies to macOS.

@softmaxe
softmaxe merged commit df85f93 into main Nov 7, 2026
4 checks passed
@softmaxe
softmaxe deleted the t3/linux-cli-support branch November 7, 2026 14:29
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.

1 participant