Audio: hardware volume keys, chandra-ctl volume, and an OSD pill
CI / test (push) Failing after 51s

- Map VolumeUp, VolumeDown, and Mute keys to wpctl (PipeWire) or pactl, run asynchronously so the compositor never blocks
- Hold a volume key to repeat it; volume keys also work while the screen is off, without waking it
- Keep volume keys as the shutter when chandra-camera has focus; Mute still toggles system audio
- Add `chandra-ctl volume [up|down|mute|unmute|toggle|PCT|status]` and a transient Volume OSD
- Add volume-up, volume-down, and volume-mute entries to the shortcut table
This commit is contained in:
nandi committed 2026-11-28 20:01:58 -08:00
1 parent ebdd330eb5
commit 68912f6d64
11 files changed
+909 -1

No files matched your search

+30
View File
@@ -302,6 +302,7 @@ pub fn ChandraCompositor::control_command(self : ChandraCompositor, line : Strin
"rotate [cw|ccw|flip|0|90|180|270|status] rotate or flip the display",
"screen [on|off|toggle|status] blank or wake the display",
"brightness [PCT|status] read or set display backlight percent (5..100)",
"volume [up|down|mute|unmute|toggle|PCT|status] read or adjust audio volume",
"osk [on|off|toggle|status] enable, disable, or query the on-screen keyboard",
"refresh schedule a full frame redraw",
"status report geometry, rotation, screen power, brightness, pointer, OSK",
@@ -548,6 +549,35 @@ pub fn ChandraCompositor::control_command(self : ChandraCompositor, line : Strin
}
}
}
"volume" => {
let arg = if words.length() >= 2 { words[1] } else { "status" }
if words.length() > 2 {
return (["error usage: volume [up|down|mute|unmute|toggle|PCT|status]"], false)
}
let (cmd, show_osd) : (VolCmd, Bool) = match arg {
"status" => (VolCmd::Query, false)
"up" => (VolCmd::Up, !(self.screen_off || self.manual_screen_off))
"down" => (VolCmd::Down, !(self.screen_off || self.manual_screen_off))
"mute" => (VolCmd::SetMute(true), !(self.screen_off || self.manual_screen_off))
"unmute" => (VolCmd::SetMute(false), !(self.screen_off || self.manual_screen_off))
"toggle" => (VolCmd::MuteToggle, !(self.screen_off || self.manual_screen_off))
_ =>
match parse_int_opt(arg) {
Some(v) if v >= 0 =>
(VolCmd::SetPercent(v), !(self.screen_off || self.manual_screen_off))
_ =>
return (
["error usage: volume [up|down|mute|unmute|toggle|PCT|status]"],
false,
)
}
}
match self.run_volume_control(cmd, show_osd) {
Ok((pct, muted)) =>
(["ok " + pct.to_string() + (if muted { " muted" } else { "" })], true)
Err(msg) => (["error " + msg], false)
}
}
"settings" => {
let arg = if words.length() >= 2 { words[1] } else { "session" }
if words.length() > 2 {