[awesome] add vpn widget
This commit is contained in:
parent
3695a3a327
commit
e3b2307a15
BIN
home/.config/awesome/icons/vpn.png
Normal file
BIN
home/.config/awesome/icons/vpn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 128 B |
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in a new issue