Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/blocks/sound/alsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,32 @@ pub(super) struct Device {
volume: u32,
muted: bool,
monitor: ChildStdout,
#[expect(
dead_code,
reason = "Only used in drop to trigger kill and reap of child process"
)]
process: tokio::process::Child,
}

impl Device {
pub(super) fn new(name: String, device: String, natural_mapping: bool) -> Result<Self> {
let mut process = Command::new("alsactl")
.arg("monitor")
.kill_on_drop(true)
.stdout(Stdio::piped())
.spawn()
.error("Failed to start alsactl monitor")?;
Ok(Device {
name,
device,
natural_mapping,
volume: 0,
muted: false,
monitor: Command::new("alsactl")
.arg("monitor")
.stdout(Stdio::piped())
.spawn()
.error("Failed to start alsactl monitor")?
monitor: process
.stdout
.take()
.error("Failed to pipe alsactl monitor output")?,
process,
})
}
}
Expand Down