volume 0 when muted
This commit is contained in:
parent
87a657fe81
commit
3805929479
@ -20,23 +20,25 @@ pub async fn get_volume() -> ThreadsData {
|
|||||||
.get_playback_volume(selem_chan_id)
|
.get_playback_volume(selem_chan_id)
|
||||||
.expect("Failed to get raw_volume");
|
.expect("Failed to get raw_volume");
|
||||||
|
|
||||||
|
let muted = selem
|
||||||
|
.get_playback_switch(selem_chan_id)
|
||||||
|
.expect("Failed to get playback state")
|
||||||
|
== 0;
|
||||||
|
|
||||||
let range = max - min;
|
let range = max - min;
|
||||||
let vol = if range == 0 {
|
let vol = if muted || range == 0 {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
raw_volume -= min;
|
raw_volume -= min;
|
||||||
((raw_volume as f64 / range as f64) * 100.) as u64
|
((raw_volume as f64 / range as f64) * 100.) as u64
|
||||||
};
|
};
|
||||||
|
|
||||||
let muted = selem
|
|
||||||
.get_playback_switch(selem_chan_id)
|
|
||||||
.expect("Failed to get playback state");
|
|
||||||
|
|
||||||
let icon = match muted {
|
let icon = match muted {
|
||||||
0 => &CONFIG.volume.icon_muted,
|
true => &CONFIG.volume.icon_muted,
|
||||||
_ => if vol < 50 { &CONFIG.volume.icon_low } else { &CONFIG.volume.icon_high }
|
false => if vol < 50 { &CONFIG.volume.icon_low } else { &CONFIG.volume.icon_high }
|
||||||
};
|
};
|
||||||
|
|
||||||
let data = format!(" {} {}% {}", icon, vol, CONFIG.seperator);
|
|
||||||
|
let data = format!(" {} {:>2}% {}", icon, vol, CONFIG.seperator);
|
||||||
ThreadsData::Sound(data)
|
ThreadsData::Sound(data)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user