]> git.rmz.io Git - dotfiles.git/commitdiff
create utils module, with function to run or kill
authorSamir Benmendil <samir.benmendil@gmail.com>
Wed, 12 Jun 2013 02:12:16 +0000 (04:12 +0200)
committerSamir Benmendil <samir.benmendil@gmail.com>
Wed, 12 Jun 2013 02:32:25 +0000 (04:32 +0200)
awesome/utils.lua [new file with mode: 0644]

diff --git a/awesome/utils.lua b/awesome/utils.lua
new file mode 100644 (file)
index 0000000..c7a5492
--- /dev/null
@@ -0,0 +1,18 @@
+local utils = { }
+
+function utils.run_or_kill(command)
+    -- Check throught the clients if the class match the command
+    local lower_command=string.lower(command)
+    for k, c in pairs(client.get()) do
+        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
+        end
+    end
+    awful.util.spawn(command)
+end
+
+return utils