[awesome] add vpn widget

This commit is contained in:
Simon Bruder 2019-06-21 16:10:53 +00:00
parent 3695a3a327
commit e3b2307a15
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
3 changed files with 26 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

View file

@ -206,6 +206,8 @@ awful.screen.connect_for_each_screen(function(s)
widgets.tearstop,
widgets.redshift,
widgets.bluetooth,
widgets.vpn.icon,
widgets.vpn.widget,
widgets.netdown_icon,
widgets.netdown.widget,
widgets.netup_icon,

View file

@ -66,6 +66,30 @@ widgets.bat = lain.widget.bat({
end
})
widgets.vpn = {}
widgets.vpn.icon = wibox.widget.imagebox(iconsdir .. "vpn.png")
widgets.vpn.widget = wibox.widget.textbox()
widgets.vpn.update = function()
helpers.async({ "/bin/ip", "link" }, function(output)
connected = false
for line in output:gmatch("[^\r\n]+") do
vpn_server = string.match(line, "^%d+: mullvad%-(%a%a%d+):")
if vpn_server then
widgets.vpn.widget:set_markup(markup.fontfg(theme.font, theme.colors.blue, vpn_server .. " "))
connected = true
end
end
if connected then
widgets.vpn.icon.visible = true
else
widgets.vpn.widget:set_markup(markup.fontfg(theme.font, theme.colors.blue, ""))
widgets.vpn.icon.visible = false
end
end)
end
helpers.newtimer("vpn", 5, widgets.vpn.update)
widgets.bluetooth = wibox.widget.imagebox(iconsdir .. "bluetooth-on.png")
widgets.bluetooth.pass_state = function(callback)
helpers.async_with_shell("/sbin/rfkill -n -o SOFT list bluetooth|uniq", function(state)