aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config/volume.rs8
-rw-r--r--src/types.rs4
-rw-r--r--src/utils/volume.rs11
3 files changed, 19 insertions, 4 deletions
diff --git a/src/config/volume.rs b/src/config/volume.rs
index c660912..13c384f 100644
--- a/src/config/volume.rs
+++ b/src/config/volume.rs
@@ -3,7 +3,9 @@ use std::default::Default;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Volume {
- pub icon: String,
+ pub icon_high: String,
+ pub icon_low: String,
+ pub icon_muted: String,
pub enabled: bool,
pub delay: f64,
pub card: String,
@@ -12,7 +14,9 @@ pub struct Volume {
impl Default for Volume {
fn default() -> Self {
Volume {
- icon: String::from(""),
+ icon_high: String::from("🕪"),
+ icon_low: String::from("🕩"),
+ icon_muted: String::from("🔇"),
enabled: false,
delay: 0.17,
card: String::from("ALSA"),
diff --git a/src/types.rs b/src/types.rs
index 7f6da2e..3e11cbd 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -60,7 +60,9 @@ pub struct Disk {
}
#[derive(Clone)]
pub struct Volume {
- pub icon: String,
+ pub icon_muted: String,
+ pub icon_high: String,
+ pub icon_low: String,
pub enabled: bool,
pub delay: f64,
pub card: String,
diff --git a/src/utils/volume.rs b/src/utils/volume.rs
index 47b4ed3..5c6d3e1 100644
--- a/src/utils/volume.rs
+++ b/src/utils/volume.rs
@@ -28,6 +28,15 @@ pub async fn get_volume() -> ThreadsData {
((raw_volume as f64 / range as f64) * 100.) as u64
};
- let data = format!(" {} {}% {}", CONFIG.volume.icon, vol, CONFIG.seperator);
+ let muted = selem
+ .get_playback_switch(selem_chan_id)
+ .expect("Failed to get playback state");
+
+ let icon = match muted {
+ 0 => &CONFIG.volume.icon_muted,
+ _ => if vol < 50 { &CONFIG.volume.icon_low } else { &CONFIG.volume.icon_high }
+ };
+
+ let data = format!(" {} {}% {}", icon, vol, CONFIG.seperator);
ThreadsData::Sound(data)
}