mirror of
https://github.com/don-philipe/knorke.git
synced 2025-11-08 14:57:02 +01:00
Simple widget to show presence of VPN tun device
This commit is contained in:
40
vpn.lua
Normal file
40
vpn.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
local icon_vpn_noconn
|
||||
local icon_vpn_conn
|
||||
|
||||
|
||||
-- Create layout with widgets
|
||||
local widget = wibox.widget {
|
||||
{
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = true
|
||||
},
|
||||
layout = wibox.layout.align.horizontal
|
||||
}
|
||||
|
||||
gears.timer {
|
||||
timeout = 10,
|
||||
autostart = true,
|
||||
callback = function ()
|
||||
awful.spawn.easy_async_with_shell("ifconfig | grep \"tun.*:\"",
|
||||
function (stdout, _, _, _)
|
||||
if (stdout == "") then
|
||||
widget.icon:set_image(icon_vpn_noconn)
|
||||
else
|
||||
widget.icon:set_image(icon_vpn_conn)
|
||||
end
|
||||
end)
|
||||
end
|
||||
}
|
||||
|
||||
-- Widget function that is available from the outside.
|
||||
function widget.set_icons(vpn_noconn, vpn_conn)
|
||||
icon_vpn_noconn = vpn_noconn
|
||||
icon_vpn_conn = vpn_conn
|
||||
end
|
||||
|
||||
return widget
|
||||
Reference in New Issue
Block a user