aboutsummaryrefslogtreecommitdiffstats
path: root/.config/luastatus-scripts-dwm/alsa-gauge.lua
blob: 966e62588e4d617af0bcef6a08df6114669218d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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,
}