diff options
Diffstat (limited to '.config/luastatus-scripts-dwm/alsa-gauge.lua')
-rw-r--r-- | .config/luastatus-scripts-dwm/alsa-gauge.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/.config/luastatus-scripts-dwm/alsa-gauge.lua b/.config/luastatus-scripts-dwm/alsa-gauge.lua new file mode 100644 index 0000000..966e625 --- /dev/null +++ b/.config/luastatus-scripts-dwm/alsa-gauge.lua @@ -0,0 +1,18 @@ +local GAUGE_NCHARS = 10 + +local function mk_gauge(level, full, empty) + local nfull = math.floor(level * GAUGE_NCHARS + 0.5) + return full:rep(nfull) .. empty:rep(GAUGE_NCHARS - nfull) +end + +widget = { + plugin = 'alsa', + cb = function(t) + local level = (t.vol.cur - t.vol.min) / (t.vol.max - t.vol.min) + if t.mute then + return mk_gauge(level, '×', '—') + else + return mk_gauge(level, '●', '○') + end + end, +} |