-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwi.lua
executable file
·173 lines (163 loc) · 4.64 KB
/
wi.lua
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
local awful = require("awful")
local wibox = require("wibox")
local beautiful = require("beautiful")
local vicious = require("vicious")
local naughty = require("naughty")
-- Spacers
volspace = wibox.widget.textbox()
volspace:set_text(" ")
-- {{{ BATTERY
-- Battery attributes
local bat_state = ""
local bat_charge = 0
local bat_time = 0
local blink = true
-- Icon
baticon = wibox.widget.imagebox()
baticon:set_image(beautiful.widget_batfull)
-- Charge %
batpct = wibox.widget.textbox()
vicious.register(batpct, vicious.widgets.bat, function(widget, args)
bat_state = args[1]
bat_charge = args[2]
bat_time = args[3]
if args[1] == "-" then
if bat_charge > 70 then
baticon:set_image(beautiful.widget_batfull)
elseif bat_charge > 30 then
baticon:set_image(beautiful.widget_batmed)
elseif bat_charge > 10 then
baticon:set_image(beautiful.widget_batlow)
else
baticon:set_image(beautiful.widget_batempty)
end
else
baticon:set_image(beautiful.widget_ac)
if args[1] == "+" then
blink = not blink
if blink then
baticon:set_image(beautiful.widget_acblink)
end
end
end
return args[2] .. "%"
end, nil, "BAT1")
-- Buttons
function popup_bat()
local state = ""
if bat_state == "↯" then
state = "Full"
elseif bat_state == "↯" then
state = "Charged"
elseif bat_state == "+" then
state = "Charging"
elseif bat_state == "-" then
state = "Discharging"
elseif bat_state == "⌁" then
state = "Not charging"
else
state = "Unknown"
end
naughty.notify { text = "Charge : " .. bat_charge .. "%\nState : " .. state ..
" (" .. bat_time .. ")", timeout = 5, hover_timeout = 0.5 }
end
batpct:buttons(awful.util.table.join(awful.button({ }, 1, popup_bat)))
baticon:buttons(batpct:buttons())
-- End Battery}}}
--
-- {{{ PACMAN
-- Icon
pacicon = wibox.widget.imagebox()
pacicon:set_image(beautiful.widget_pac)
--
-- Upgrades
pacwidget = wibox.widget.textbox()
vicious.register(pacwidget, vicious.widgets.pkg, function(widget, args)
if args[1] > 0 then
pacicon:set_image(beautiful.widget_pacnew)
else
pacicon:set_image(beautiful.widget_pac)
end
return args[1]
end, 1801, "Arch S") -- Arch S for ignorepkg
--
-- Buttons
function popup_pac()
local pac_updates = ""
local f = io.popen("pacman -Sup --dbpath /tmp/pacsync")
if f then
pac_updates = f:read("*a"):match(".*/(.*)-.*\n$")
end
f:close()
if not pac_updates then
pac_updates = "System is up to date"
end
naughty.notify { text = pac_updates }
end
pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac)))
pacicon:buttons(pacwidget:buttons())
-- End Pacman }}}
--
-- {{{ VOLUME
-- Cache
vicious.cache(vicious.widgets.volume)
--
-- Icon
volicon = wibox.widget.imagebox()
volicon:set_image(beautiful.widget_vol)
--
-- Volume %
volpct = wibox.widget.textbox()
vicious.register(volpct, vicious.widgets.volume, "$1%", nil, "Master")
--
-- Buttons
volicon:buttons(awful.util.table.join(
awful.button({ }, 1,
function() awful.util.spawn_with_shell("amixer -q set Master toggle") end),
awful.button({ }, 4,
function() awful.util.spawn_with_shell("amixer -q set Master 3+% unmute") end),
awful.button({ }, 5,
function() awful.util.spawn_with_shell("amixer -q set Master 3-% unmute") end)
))
volpct:buttons(volicon:buttons())
volspace:buttons(volicon:buttons())
-- End Volume }}}
--
-- {{{ Start CPU
cpuicon = wibox.widget.imagebox()
cpuicon:set_image(beautiful.widget_cpu)
--
cpu = wibox.widget.textbox()
vicious.register(cpu, vicious.widgets.cpu, "All: $1% 1: $2% 2: $3% 3: $4% 4: $5%", 2)
-- End CPU }}}
--
-- {{{ Start Mem
memicon = wibox.widget.imagebox()
memicon:set_image(beautiful.widget_ram)
--
mem = wibox.widget.textbox()
vicious.register(mem, vicious.widgets.mem, "Mem: $1% Use: $2MB Total: $3MB Free: $4MB Swap: $5%", 2)
-- End Mem }}}
--
-- {{{ Start Gmail
mailicon = wibox.widget.imagebox(beautiful.widget_mail)
mailwidget = wibox.widget.textbox()
gmail_t = awful.tooltip({ objects = { mailwidget },})
vicious.register(mailwidget, vicious.widgets.gmail,
function (widget, args)
gmail_t:set_text(args["{subject}"])
gmail_t:add_to_object(mailicon)
return args["{count}"]
end, 120)
mailicon:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.util.spawn("urxvt -e mutt", false) end)
))
-- End Gmail }}}
--
-- {{{ Start Wifi
wifiicon = wibox.widget.imagebox()
wifiicon:set_image(beautiful.widget_wifi)
--
wifi = wibox.widget.textbox()
vicious.register(wifi, vicious.widgets.wifi, "${ssid} Rate: ${rate}MB/s Link: ${link}%", 3, "wlp3s0")
-- End Wifi }}}