Skip to content

Instantly share code, notes, and snippets.

@katspaugh
Created June 15, 2011 21:08
Show Gist options
  • Save katspaugh/1028116 to your computer and use it in GitHub Desktop.
Save katspaugh/1028116 to your computer and use it in GitHub Desktop.
dwm statusbar
local function exec (cmd, ...)
local argstr = (table.maxn(arg) == 0 and '') or
string.format(' %q', table.concat(arg))
return os.execute(cmd .. argstr)
end
local function read (cmd)
local prog = io.popen(cmd)
local pout = prog:read('*a')
prog:close()
return pout
end
repeat
local wlan = read('ifconfig wlan0')
wlan = table.concat({
string.match(wlan, 'ssid (%a+)') or 'no ssid',
string.match(wlan, 'status: ([^%c]+)') or 'no carrier'
}, ': ')
local date = table.concat({
string.match(
os.date(),
'(%a+) (%a+ %d+) (%d+:%d+):%d+ (%d+)'
)
}, ' ')
exec(
'xsetroot -name',
table.concat({ wlan, date }, ' | ')
)
until 0 < exec('sleep', 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment