Add mute playback to CLI app

This commit is contained in:
Lennard Kittner
2025-10-19 14:12:04 +02:00
parent b0265629a4
commit 8350c25cc0

View File

@@ -52,6 +52,13 @@ fn main() {
.help("Enables surround sound. This may be on by default and cannot be changed on your device.") .help("Enables surround sound. This may be on by default and cannot be changed on your device.")
.value_parser(clap::value_parser!(bool)), .value_parser(clap::value_parser!(bool)),
) )
.arg(
Arg::new("mute_playback")
.long("mute_playback")
.required(false)
.help("Mute or unmute playback.")
.value_parser(clap::value_parser!(bool)),
)
.get_matches(); .get_matches();
let mut device = match connect_compatible_device() { let mut device = match connect_compatible_device() {
@@ -153,6 +160,17 @@ fn main() {
} }
} }
if let Some(mute_playback) = matches.get_one::<bool>("mute_playback") {
if let Some(packet) = device.set_silent_mode_packet(*mute_playback) {
device.prepare_write();
if let Err(err) = device.get_device_state().hid_device.write(&packet) {
println!("Failed to mute playback with error: {:?}", err)
}
} else {
println!("Can't mute playback on this device")
}
}
std::thread::sleep(Duration::from_secs_f64(0.5)); std::thread::sleep(Duration::from_secs_f64(0.5));
println!("State after potentially setting some stuff"); println!("State after potentially setting some stuff");