]> git.rmz.io Git - dotfiles.git/blob - awesome/utils.lua
0ec93aa355f14c5abd5dfd22df7486bf29b01576
[dotfiles.git] / awesome / utils.lua
1 local utils = { }
2 utils.rules = { }
3 utils.globalkeys = { }
4
5 local host = io.popen("hostname")
6 utils.host = host:read("*l")
7
8 function utils.run_or_kill(command)
9 -- Check throught the clients if the class match the command
10 local lower_command=string.lower(command)
11 for k, c in pairs(client.get()) do
12 -- apparently some steam games don't have a client class
13 if c.class ~= nil then
14 local class=string.lower(c.class)
15 if string.match(class, lower_command) then
16 for i, v in ipairs(c:tags()) do
17 c:kill()
18 return
19 end
20 end
21 end
22 end
23 awful.util.spawn(command)
24 end
25
26 function utils.joinTables(t1, t2)
27 for k,v in ipairs(t2) do table.insert(t1, v) end return t1
28 end
29
30 function utils.rules.append(rules)
31 awful.rules.rules = awful.util.table.join(awful.rules.rules, rules)
32 end
33
34 function utils.globalkeys.append(keys)
35 globalkeys = awful.util.table.join(globalkeys, keys)
36 end
37
38 return utils