From e3b2307a15d337676be058cc8dff01c9c4494271 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 21 Jun 2019 16:10:53 +0000 Subject: [PATCH] [awesome] add vpn widget --- home/.config/awesome/icons/vpn.png | Bin 0 -> 128 bytes home/.config/awesome/rc.lua | 2 ++ home/.config/awesome/widgets.lua | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 home/.config/awesome/icons/vpn.png diff --git a/home/.config/awesome/icons/vpn.png b/home/.config/awesome/icons/vpn.png new file mode 100644 index 0000000000000000000000000000000000000000..ee285ff985c495ed30f2bb867ddcd475d43056ed GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh@3?y?HWJG`zTYyi9E09*}zNE=p_!P)uED7=p zW^j0RBMrn!@^*J&=wOxg0CJ=~T^vI=t|uorFrSf^keI=uFylYJ&^E`Xiy0aIJFqWR T>N)lpsEonW)z4*}Q$iB}5;h)4 literal 0 HcmV?d00001 diff --git a/home/.config/awesome/rc.lua b/home/.config/awesome/rc.lua index c2f2510..9b1f4eb 100644 --- a/home/.config/awesome/rc.lua +++ b/home/.config/awesome/rc.lua @@ -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, diff --git a/home/.config/awesome/widgets.lua b/home/.config/awesome/widgets.lua index 766c64c..35545b3 100644 --- a/home/.config/awesome/widgets.lua +++ b/home/.config/awesome/widgets.lua @@ -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)