aboutsummaryrefslogtreecommitdiff
path: root/.config/luastatus-scripts-dwm/battery.lua
blob: 6155fd47c1a9b0259a317ff6d0aa73f93bfd0acf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
widget = luastatus.require_plugin('battery-linux').widget{
    period = 2,
    cb = function(t)
        icon = ""
        if t.status == "Discharging" then
          if t.capacity < 10 then
            icon = "󰁺"
          elseif t.capacity < 20 then
            icon = "󰁻"
          elseif t.capacity < 30 then
            icon = "󰁼"
          elseif t.capacity < 40 then
            icon = "󰁽"
          elseif t.capacity < 50 then
            icon = "󰁾"
          elseif t.capacity < 60 then
            icon = "󰁿"
          elseif t.capacity < 70 then
            icon = "󰂀"
          elseif t.capacity < 80 then
            icon = "󰂁"
          elseif t.capacity < 90 then
            icon = "󰂂"
          else
            icon = "󰁹"
          end
        else
          if t.capacity < 10 then
            icon = "󰢜"
          elseif t.capacity < 20 then
            icon = "󰂆"
          elseif t.capacity < 30 then
            icon = "󰂇"
          elseif t.capacity < 40 then
            icon = "󰂈"
          elseif t.capacity < 50 then
            icon = "󰢝"
          elseif t.capacity < 60 then
            icon = "󰂉"
          elseif t.capacity < 70 then
            icon = "󰢞"
          elseif t.capacity < 80 then
            icon = "󰂊"
          elseif t.capacity < 90 then
            icon = "󰂋"
          else
            icon = "󰂅"
          end
        end

        return string.format('%s %3d%%', icon, t.capacity)
    end,
}