Skip to content

Instantly share code, notes, and snippets.

@ShadOoW
Last active November 2, 2015 15:07
Show Gist options
  • Save ShadOoW/5753d77bebb0f01a02ef to your computer and use it in GitHub Desktop.
Save ShadOoW/5753d77bebb0f01a02ef to your computer and use it in GitHub Desktop.
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
@ShadOoW
Copy link
Author

ShadOoW commented Nov 2, 2015

mywifimenu = awful.menu(wifi_menu())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment