X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/172cfbb4b15794f9dd12a4531e6ba6b8f0edbb2a..4e2652f76eb8951e95ed97c24f90d43494611ee4:/awesome/utils.lua diff --git a/awesome/utils.lua b/awesome/utils.lua index 070cb3e..7f1d4b3 100644 --- a/awesome/utils.lua +++ b/awesome/utils.lua @@ -13,6 +13,30 @@ 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 name then + if terminal:match("rxvt") then + term_cmd = join(term_cmd, {"-name", name}) + end + end + return join(term_cmd, {"-e", 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 @@ -68,7 +92,7 @@ function utils.run_once(prg,arg_string,pname,screen) 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 +103,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()