2017-12-01 00:21:33 -06:00
|
|
|
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)
|
2018-04-19 01:43:29 -05:00
|
|
|
bat_state = args[1]
|
|
|
|
bat_charge = args[2]
|
|
|
|
bat_time = args[3]
|
2017-12-01 00:21:33 -06:00
|
|
|
|
2018-04-19 01:43:29 -05:00
|
|
|
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
|
2017-12-01 00:21:33 -06:00
|
|
|
|
2018-04-19 01:43:29 -05:00
|
|
|
return args[2] .. "%"
|
|
|
|
end, nil, "BAT1")
|
2017-12-01 00:21:33 -06:00
|
|
|
|
|
|
|
-- Buttons
|
|
|
|
function popup_bat()
|
2018-04-19 01:43:29 -05:00
|
|
|
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
|
2017-12-01 00:21:33 -06:00
|
|
|
|
2018-04-19 01:43:29 -05:00
|
|
|
naughty.notify { text = "Charge : " .. bat_charge .. "%\nState : " .. state ..
|
|
|
|
" (" .. bat_time .. ")", timeout = 5, hover_timeout = 0.5 }
|
2017-12-01 00:21:33 -06:00
|
|
|
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)
|
2018-04-19 01:43:29 -05:00
|
|
|
if args[1] > 0 then
|
|
|
|
pacicon:set_image(beautiful.widget_pacnew)
|
|
|
|
else
|
|
|
|
pacicon:set_image(beautiful.widget_pac)
|
|
|
|
end
|
2017-12-01 00:21:33 -06:00
|
|
|
|
2018-04-19 01:43:29 -05:00
|
|
|
return args[1]
|
|
|
|
end, 1801, "Arch S") -- Arch S for ignorepkg
|
2017-12-01 00:21:33 -06:00
|
|
|
--
|
|
|
|
-- Buttons
|
2017-12-17 12:06:39 -06:00
|
|
|
function popup_pac()
|
2018-04-19 01:43:29 -05:00
|
|
|
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 }
|
2017-12-17 12:06:39 -06:00
|
|
|
end
|
|
|
|
pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac)))
|
|
|
|
pacicon:buttons(pacwidget:buttons())
|
2017-12-01 00:21:33 -06:00
|
|
|
-- 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(
|
2018-04-19 01:43:29 -05:00
|
|
|
awful.button({ }, 1,
|
|
|
|
function() awful.util.spawn_with_shell("pamixer -t") end),
|
|
|
|
awful.button({ }, 4,
|
|
|
|
function() awful.util.spawn_with_shell("pamixer -i 3") end),
|
|
|
|
awful.button({ }, 5,
|
|
|
|
function() awful.util.spawn_with_shell("pamixer -d 3") end)
|
2017-12-17 12:06:39 -06:00
|
|
|
))
|
|
|
|
volpct:buttons(volicon:buttons())
|
|
|
|
volspace:buttons(volicon:buttons())
|
|
|
|
-- End Volume }}}
|
|
|
|
--
|
2017-12-01 00:21:33 -06:00
|
|
|
-- {{{ 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 }}}
|
|
|
|
--
|
2017-12-17 12:06:39 -06:00
|
|
|
-- {{{ Start Gmail
|
2017-12-06 18:19:24 -06:00
|
|
|
--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}"]
|
2017-12-17 12:06:39 -06:00
|
|
|
-- end, 120)
|
2017-12-06 18:19:24 -06:00
|
|
|
--
|
|
|
|
-- mailicon:buttons(awful.util.table.join(
|
|
|
|
-- awful.button({ }, 1, function () awful.util.spawn("urxvt -e mutt", false) end)
|
|
|
|
-- ))
|
2017-12-01 00:21:33 -06:00
|
|
|
-- 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 }}}
|