Skip to content

Instantly share code, notes, and snippets.

@s0r00t
Last active August 29, 2015 14:14
Show Gist options
  • Save s0r00t/1b39dd8844358ebcbd94 to your computer and use it in GitHub Desktop.
Save s0r00t/1b39dd8844358ebcbd94 to your computer and use it in GitHub Desktop.
My awesome widgets n stuff. 3.5.6
[[
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
]]
--Sound widget
sound = wibox.widget.textbox()
vicious.register(sound, vicious.widgets.volume, ' :: $2 $1%',2, "Master")
--Battery widget
battery = wibox.widget.textbox()
batstat = "↯"
vicious.register(battery, function(format, warg)
local args = vicious.widgets.bat(format, warg)
if args[2] < 25 then
args['{color}'] = '#BF1515'
elseif args[2] < 50 then
args['{color}'] = '#b58900'
else
args['{color}'] = '#219621'
end
if args[1] ~= batstat then
if args[1] == "-" then
naughty.notify({ preset = naughty.config.presets.critical,
title = "NOT CHARGING" })
elseif args[1] == "+" then
naughty.notify({ preset = naughty.config.presets.critical,
title = "CHARGING" })
end
batstat = args[1]
end
return args
end, '<span color="${color}"> $2%</span>$1 :: ', 10, 'BAT0')
--Network widget
function isOnline(inter, wid, wid2)
wid:set_text(" " .. inter .. " : Loading...")
if string.match(awful.util.pread("ifconfig ".. inter .. " | grep RUNNING | wc -l"), "1") == "1" then
vicious.register(wid, vicious.widgets.net,' ' .. inter .. ' : <span color="#BF1515">▼ ${' .. inter .. ' down_kb}</span> <span color="#219621">${' .. inter .. ' up_kb} ▲</span> ' .. awful.util.pread("dig +short myip.opendns.com @resolver1.opendns.com"), 3)
wid2:set_text(" | " .. awful.util.pread("ifconfig ".. inter .." | awk '/inet/ { gsub(\":\",\" \"); print $3; exit }'"))
else
wid:set_text(" " .. inter .. " : Not connected")
end
end
--wifi
wifi = wibox.widget.textbox()
wifiip = wibox.widget.textbox()
isOnline("wlan0", wifi, wifiip)
wifi:buttons(awful.util.table.join(awful.button({ }, 1, function () isOnline("wlan0", wifi, wifiip) end)))
wifiip:buttons(awful.util.table.join(awful.button({ }, 1, function () isOnline("wlan0", wifi, wifiip) end)))
--eth
eth = wibox.widget.textbox()
ethip = wibox.widget.textbox()
isOnline("eth0", eth, ethip)
eth:buttons(awful.util.table.join(awful.button({ }, 1, function () isOnline("eth0", eth, ethip) end)))
ethip:buttons(awful.util.table.join(awful.button({ }, 1, function () isOnline("eth0", eth, ethip) end)))
--globalkeys to use multimedia keys
awful.key({}, "#122", function() awful.util.spawn("amixer set Master 5%-", false) end),
awful.key({}, "#123", function() awful.util.spawn("amixer set Master 5%+", false) end),
awful.key({}, "#121", function() awful.util.spawn("amixer -D pulse set Master 1+ toggle", false) end),
--this is to run shutter
awful.key({}, "Print", function() awful.util.spawn("shutter -s", false) end),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment