added a volume widget

This commit is contained in:
mpuchstein
2025-03-08 07:32:28 +01:00
parent 5019df965c
commit df4ae637d5
6 changed files with 32 additions and 1 deletions

11
eww/widgets/volume.scss Normal file
View File

@@ -0,0 +1,11 @@
.sourcevol{
background: steelblue;
color: black;
}
.sinkvol{
background: slateblue;
color: black;
}
.muted{
background: tomato;
}

17
eww/widgets/volume.yuck Normal file
View File

@@ -0,0 +1,17 @@
(defpoll sourcevol :interval "1s" `wpctl get-volume @DEFAULT_SOURCE@ | awk -F ' ' '{print $2}'`)
(defpoll sourcemute :interval "1s" `wpctl get-volume @DEFAULT_SOURCE@ | awk -F ' ' '{print $3}'`)
(defpoll sinkvol :interval "1s" `wpctl get-volume @DEFAULT_SINK@ | awk -F ' ' '{print $2}'`)
(defpoll sinkmute :interval "1s" `wpctl get-volume @DEFAULT_SINK@ | awk -F ' ' '{print $3}'`)
(defwidget volume []
(box
:space-evenly false
:spacing 3
(eventbox
:class "sourcevol${sourcemute == "[MUTED]" ? " muted" : ""}"
:onclick "wpctl set-mute @DEFAULT_SOURCE@ toggle"
(label :text "${sourcemute == "[MUTED]" ? "󰍭" : "󰍬"} ${sourcevol}"))
(eventbox
:class "sinkvol${sinkmute == "[MUTED]" ? " muted" : ""}"
:onclick "wpctl set-mute @DEFAULT_SINK@ toggle"
(label :text "${sinkmute == "[MUTED]" ? "󰟎" : "󰋋"} ${sinkvol}"))))