X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/ab367a8e65009a9aea65a2f3ccca9be636e75083..0d89e0b38f04e0dc6fd0e2b51efa044bd3ccfc5a:/awesome/utils.lua?ds=sidebyside diff --git a/awesome/utils.lua b/awesome/utils.lua index 7519473..0c56131 100644 --- a/awesome/utils.lua +++ b/awesome/utils.lua @@ -9,22 +9,41 @@ utils.globalkeys = { } local host = io.popen("hostname") utils.host = host:read("*l") -function utils.run_or_kill(command) - -- Check throught the clients if the class match the command - local lower_command=string.lower(command) +function utils.run_or_kill(prg, cprop, screen) + if not prg then + do return nil end + end + + if not cprop then + cprop = { } + end + + if not cprop.class then + cprop.class = prg + end + + if not cprop.instance then + cprop.instance = "" + end + + cprop.class = string.lower(cprop.class) + cprop.instance = string.lower(cprop.instance) + for k, c in pairs(client.get()) do -- apparently some steam games don't have a client class - if c.class ~= nil then - local class=string.lower(c.class) - if string.match(class, lower_command) then - for i, v in ipairs(c:tags()) do - c:kill() - return - end + if c.class == nil then + return + end + local class=string.lower(c.class) + local instance=string.lower(c.instance) + if string.match(class, cprop.class) and string.match(instance, cprop.instance) then + for i, v in ipairs(c:tags()) do + c:kill() + return end end end - awful.util.spawn(command) + awful.util.spawn_with_shell(prg, screen) end -- http://awesome.naquadah.org/wiki/Autostart#Simple_way @@ -37,7 +56,7 @@ function utils.run_once(prg,arg_string,pname,screen) pname = prg end - if not arg_string then + 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)