]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/utils.lua
dwb: update github css
[dotfiles.git] / awesome / utils.lua
index e97aa22f96da93a41e3ec4802353e9dd3f5bf5ab..7519473cb5d513321c4df379b72fcb7b5c02bb9e 100644 (file)
@@ -1,4 +1,10 @@
-local utils = { }
+local utils  = { }
+local io     = { popen = io.popen }
+local string = { match = string.match,
+                 lower = string.lower}
+
+utils.rules = { }
+utils.globalkeys = { }
 
 local host = io.popen("hostname")
 utils.host = host:read("*l")
 
 local host = io.popen("hostname")
 utils.host = host:read("*l")
@@ -21,4 +27,40 @@ function utils.run_or_kill(command)
     awful.util.spawn(command)
 end
 
     awful.util.spawn(command)
 end
 
+-- http://awesome.naquadah.org/wiki/Autostart#Simple_way
+function utils.run_once(prg,arg_string,pname,screen)
+    if not prg then
+        do return nil end
+    end
+
+    if not pname then
+       pname = prg
+    end
+
+    if not arg_string then 
+        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
+    else
+        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
+    end
+end
+
+function utils.get_default_sink()
+    local f = io.popen('ponymix defaults --short')
+    line = f:read('*l')
+    f:close()
+    return string.match(line, "^sink%s*%d*%s*(.-)%s")
+end
+
+function utils.joinTables(t1, t2)
+    for k,v in ipairs(t2) do table.insert(t1, v) end return t1
+end
+
+function utils.rules.append(rules)
+    awful.rules.rules = awful.util.table.join(awful.rules.rules, rules)
+end
+
+function utils.globalkeys.append(keys)
+    globalkeys = awful.util.table.join(globalkeys, keys)
+end
+
 return utils
 return utils