dotfiles/home/r0r5chach/.config/eww/widgets/volume/volume.yuck

28 lines
1.2 KiB
Plaintext

(defwidget volume_button []
(eventbox
:onscroll "widgets/volume/setvolume {}"
:onclick "amixer sset Master ${mute_save} && ${muted ? '${update_mute_save}\'0%\' && ${update_muted}false' : '${update_mute_save}${volume_percent} && ${update_muted}true' }"
(box :class "volume_button"
(circular-progress :class "scale"
:value {replace(volume_percent, "%", "")}
:start-at 75
:thickness 2.5
:clockwise true
:width 24
(image
:image-width 16
:path {replace(volume_percent, "%", "") == 100 ? vol_high_icon : replace(volume_percent, "%", "") <= 0 ? vol_mute_icon : replace(volume_percent, "%", "") <= 25 ? vol_low_icon : replace(volume_percent, "%", "") <= 75 ? vol_mid_icon : vol_high_icon})))))
(defpoll volume_percent :interval "0.1s" "awk -F\"[][]\" '/Left:/ { print $2 }' <(amixer sget Master)")
(defvar mute_save "0%")
(defvar muted false)
(defvar update_mute_save "eww update mute_save=")
(defvar update_muted "eww update muted=")
(defvar vol_high_icon "widgets/volume/high-icon.png")
(defvar vol_mute_icon "widgets/volume/mute-icon.png")
(defvar vol_low_icon "widgets/volume/low-icon.png")
(defvar vol_mid_icon "widgets/volume/mid-icon.png")