2 local io = { popen = io.popen }
3 local string = { match = string.match,
9 local host = io.popen("hostname")
10 utils.host = host:read("*l")
12 function utils.run_or_kill(command)
13 -- Check throught the clients if the class match the command
14 local lower_command=string.lower(command)
15 for k, c in pairs(client.get()) do
16 -- apparently some steam games don't have a client class
17 if c.class ~= nil then
18 local class=string.lower(c.class)
19 if string.match(class, lower_command) then
20 for i, v in ipairs(c:tags()) do
27 awful.util.spawn(command)
30 -- http://awesome.naquadah.org/wiki/Autostart#Simple_way
31 function utils.run_once(prg,arg_string,pname,screen)
40 if not arg_string then
41 awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
43 awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
47 function utils.get_default_sink()
48 local f = io.popen('ponymix defaults --short')
51 return string.match(line, "^sink%s*%d*%s*(.-)%s")
54 function utils.joinTables(t1, t2)
55 for k,v in ipairs(t2) do table.insert(t1, v) end return t1
58 function utils.rules.append(rules)
59 awful.rules.rules = awful.util.table.join(awful.rules.rules, rules)
62 function utils.globalkeys.append(keys)
63 globalkeys = awful.util.table.join(globalkeys, keys)