dotfiles/.config/eww/modules/volume.yuck
2025-04-07 12:12:15 -06:00

112 lines
3.5 KiB
Common Lisp

;; -*-lisp-*-
(deflisten volume--data
`~/.config/eww/scripts/volume.py`)
(defwidget volume-h []
(box :orientation "h"
:halign "start"
:class "module ${volume--data['mute'] ? 'offline' : ''}"
:space-evenly false
:spacing 0
(label :visible {!volume--data["mute"]} :text "")
(label :visible { volume--data["mute"]} :text "")
(label :text " ${volume--data['volume']}")))
(defwidget audio []
(box :orientation "v"
:halign "center"
:class "module text"
:space-evenly false
:spacing 0
(box :orientation "h"
:halign "center"
:space-evenly false
:spacing 15
(label :class {volume--data.output.mute ? "offline" : "special"}
:text "${volume--data.output.volume}%")
(label :class {volume--data.input.mute ? "offline" : "special"}
:text "${volume--data.input.volume}%"))
"audio system"))
(defwidget volume-small-gauge []
(box :orientation "v"
:halign "center"
:width 35
:space-evenly false
:spacing 10
:class ""
(label :text "VOL"
:class "special")
(overlay :width 30
:height 30
(circular-progress :value {75 / 2.05}
:class "gauge-gutter"
:start-at 37.5
:thickness 2)
(circular-progress :value {75 / 2.05}
:class "gauge-gutter"
:start-at 12.5
:clockwise false
:thickness 2)
(circular-progress :value {volume--data.output.mute ? 0 : min(volume--data.output.volume * 0.75 / 2.05, 75 / 2.05)}
:class 'gauge ${volume--data.output.mute ? "green" : volume--data.output.volume > 100 ? "highlight" : ""}'
:start-at 37.5
:thickness 2)
(circular-progress :value {volume--data.input.mute ? 0 : min(volume--data.input.volume * 0.75 / 2.05, 75 / 2.05)}
:class 'gauge ${volume--data.input.mute ? "green" : volume--data.input.volume > 100 ? "highlight" : ""}'
:start-at 12.5
:clockwise false
:thickness 2))))
(defwidget volume--gauge [io]
(box :orientation "v"
:halign {io == "in" ? "start" : "end"}
:width 95
:space-evenly false
:spacing 10
:class "nebula"
(label :text {io})
(box :halign "center"
(overlay
(system--gauge :value {volume--data["${io}put"].volume}
:threshold {volume--data["${io}put"].mute ? 0 : 100})
(transform :translate-y "-2px"
(box
(box :halign "center"
:valign "center"
:orientation "h"
:space-evenly false
:visible {!volume--data["${io}put"].mute}
(label :text "%"
:class "invisible")
(label :text {volume--data["${io}put"].volume}
:class "special")
(label :text "%"
:class "offline"))
(box :halign "center"
:valign "center"
:orientation "h"
:space-evenly false
:visible {volume--data["${io}put"].mute}
(label :text "mute"
:class "offline"))
))))))
(defwidget volume-gauges []
(box :orientation "v"
:space-evenly false
:spacing 10
:width 200
:halign "start"
:class "nebula"
(label :class "medium special"
:text "Audio")
(box :orientation "h"
:space-evenly false
:width 200
:halign "start"
:spacing 10
(volume--gauge :io "out")
(volume--gauge :io "in"))))