]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/utils.lua
lazyvim: absorb treesitter plugins
[dotfiles.git] / awesome / utils.lua
index 0f12be1aab2c6ba50fd5ae8d5efb339c7449c9b0..13856335ad3c7acbc919e44b8ab88023260ebf45 100644 (file)
@@ -13,6 +13,37 @@ function utils.is_dir(path)
     return os.execute(('[ -d "%s" ]'):format(path))
 end
 
+local function terminal_cmd(prg, name)
+    local join = require("gears.table").join
+    local term_cmd = {terminal}
+    if terminal:match("rxvt") then
+        if name then
+            term_cmd = join(term_cmd, {"-name", name})
+        end
+    elseif terminal:match("wezterm") then
+        term_cmd = join(term_cmd, {"start"})
+        if name then
+            term_cmd = join(term_cmd, {"--class", name})
+        end
+    else
+        term_cmd = join(term_cmd, {"-e"})
+    end
+    return join(term_cmd, {prg})
+end
+
+function utils.spawn_terminal(prg, cprop, cb)
+    if not cprop then
+        cprop = {}
+    end
+    local name = cprop.instance
+    awful.spawn(terminal_cmd(prg, name), cprop, cb)
+end
+
+function utils.spawn_terminal_once(prg, rules, matcher, unique_id, cb)
+    local name = rules.instance
+    awful.spawn.once(terminal_cmd(prg, name), rules, matcher, unique_id, cb)
+end
+
 function utils.run_or_kill(prg, cprop, screen)
     if not prg then
         do return nil end
@@ -47,7 +78,7 @@ function utils.run_or_kill(prg, cprop, screen)
             end
         end
     end
-    awful.util.spawn_with_shell(prg, screen)
+    awful.spawn.with_shell(prg, screen)
 end
 
 -- http://awesome.naquadah.org/wiki/Autostart#Simple_way
@@ -61,14 +92,14 @@ function utils.run_once(prg,arg_string,pname,screen)
     end
 
     if not arg_string then
-        awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
+        awful.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)
+        awful.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')
+    local f = io.popen('pactl get-default-sink')
     line = f:read('*l')
     f:close()
     return string.match(line, "^sink%s*%d*%s*(.-)%s")
@@ -79,11 +110,11 @@ function utils.joinTables(t1, t2)
 end
 
 function utils.rules.append(rules)
-    awful.rules.rules = awful.util.table.join(awful.rules.rules, rules)
+    awful.rules.rules = gears.table.join(awful.rules.rules, rules)
 end
 
 function utils.globalkeys.append(keys)
-    globalkeys = awful.util.table.join(globalkeys, keys)
+    globalkeys = gears.table.join(globalkeys, keys)
 end
 
 function utils.has_battery()