aboutsummaryrefslogtreecommitdiffstats
path: root/.config/luastatus-scripts-dwm/pulse-gauge.lua
blob: dbc5c67d15cba7d4cc9d996eab7966b271cf4c8d (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 = 'pulse',
    cb = function(t)
        local level = t.cur / t.norm
        if t.mute then
            return mk_gauge(level, '×', '—')
        else
            return mk_gauge(level, '●', '○')
        end
    end,
}