Last active
November 2, 2015 15:07
-
-
Save ShadOoW/5753d77bebb0f01a02ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wifi_menu () | |
local wifis = {} | |
local terms = {} | |
local connected = false | |
local connected_network = "" | |
local connected_network_index = -1 | |
local fh = io.popen("netctl list") | |
for l in fh:lines() do | |
wifis[#wifis+1] = l | |
end | |
fh:close() | |
for wifiCount = 1, #wifis do | |
local symb = string.sub(wifis[wifiCount],1,1) | |
if symb == "*" then | |
connected = true | |
connected_network = string.sub(wifis[wifiCount],2,-1) | |
connected_network_index = #wifis | |
end | |
end | |
for wifiCount = 1, #wifis do | |
local command = "" | |
if connected then | |
if wifiCount == connected_network_index then | |
command = "gksu netctl restart " .. connected_network | |
else | |
command = "gksu netctl stop " .. connected_network .. " ; gksu netctl start " .. wifis[wifiCount] | |
end | |
else | |
command = "gksu netctl start " .. wifis[wifiCount] | |
end | |
naughty.notify({text= command }) | |
terms[#terms+1] = {wifis[wifiCount], function() awful.util.spawn(command) end } | |
end | |
return terms | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mywifimenu = awful.menu(wifi_menu())