feat: add --no-volume, --no-brightness, --no-active-app disable flags
Each flag prevents the corresponding monitor thread from being spawned, saving the polling overhead and any associated system calls for users who don't need that feature: --no-volume skip pactl polling (CMD_VOLUME) --no-brightness skip /sys/class/backlight polling (CMD_BRIGHTNESS) --no-active-app skip the active-app monitor (CMD_ACTIVE_APP, stub today) A disabled monitor logs a single info message at startup so the user knows it was intentionally skipped rather than silently missing.
This commit is contained in:
+39
-8
@@ -16,11 +16,14 @@
|
||||
//! # Usage
|
||||
//!
|
||||
//! ```
|
||||
//! qmk-host # info-level output (connections, value changes)
|
||||
//! qmk-host -v # debug-level: log every packet cmd/src/flags
|
||||
//! qmk-host -vv # trace-level: full 32-byte hex dump of every packet
|
||||
//! qmk-host -q # quiet: errors only
|
||||
//! RUST_LOG=debug qmk-host # env var still works as an override
|
||||
//! qmk-host # info-level output (connections, value changes)
|
||||
//! qmk-host -v # debug: log every packet cmd/src/flags
|
||||
//! qmk-host -vv # trace: full 32-byte hex dump of every packet
|
||||
//! qmk-host -q # quiet: errors only
|
||||
//! qmk-host --no-volume # skip pactl polling
|
||||
//! qmk-host --no-brightness # skip /sys/class/backlight polling
|
||||
//! qmk-host --no-active-app # skip active-app monitor (stub today)
|
||||
//! RUST_LOG=debug qmk-host # env var still works as an override
|
||||
//! ```
|
||||
//!
|
||||
//! # Permissions
|
||||
@@ -75,6 +78,28 @@ struct Args {
|
||||
/// Suppress all output except errors.
|
||||
#[arg(short, long)]
|
||||
quiet: bool,
|
||||
|
||||
/// Disable system volume monitoring.
|
||||
///
|
||||
/// When set, no CMD_VOLUME packets are sent to keyboards and the pactl
|
||||
/// polling thread is never started.
|
||||
#[arg(long)]
|
||||
no_volume: bool,
|
||||
|
||||
/// Disable screen brightness monitoring.
|
||||
///
|
||||
/// When set, no CMD_BRIGHTNESS packets are sent to keyboards and the
|
||||
/// /sys/class/backlight polling thread is never started.
|
||||
#[arg(long)]
|
||||
no_brightness: bool,
|
||||
|
||||
/// Disable active-application monitoring.
|
||||
///
|
||||
/// When set, the active-app monitor thread is never started. This flag
|
||||
/// is a no-op today (the monitor is a stub) but is provided so it can be
|
||||
/// toggled off once the feature is implemented.
|
||||
#[arg(long)]
|
||||
no_active_app: bool,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
@@ -178,7 +203,9 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
// Volume monitor: polls pactl, pushes CMD_VOLUME to all keyboards.
|
||||
{
|
||||
if args.no_volume {
|
||||
info!("Volume monitoring disabled (--no-volume)");
|
||||
} else {
|
||||
let kbds = keyboards.clone();
|
||||
thread::Builder::new()
|
||||
.name("volume-monitor".into())
|
||||
@@ -187,7 +214,9 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
// Brightness monitor: polls /sys, pushes CMD_BRIGHTNESS to all keyboards.
|
||||
{
|
||||
if args.no_brightness {
|
||||
info!("Brightness monitoring disabled (--no-brightness)");
|
||||
} else {
|
||||
let kbds = keyboards.clone();
|
||||
thread::Builder::new()
|
||||
.name("brightness-monitor".into())
|
||||
@@ -196,7 +225,9 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
// Active-app monitor: stub, does nothing until implemented.
|
||||
{
|
||||
if args.no_active_app {
|
||||
info!("Active-app monitoring disabled (--no-active-app)");
|
||||
} else {
|
||||
let kbds = keyboards.clone();
|
||||
thread::Builder::new()
|
||||
.name("app-monitor".into())
|
||||
|
||||
Reference in New Issue
Block a user