X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/0186777142eb733e600b34210854a77b2d390a77..f5c53ca295288779b25abc8a5f57b1336a8f7e87:/awesome/utils.lua?ds=sidebyside diff --git a/awesome/utils.lua b/awesome/utils.lua index 0c56131..b8dd97f 100644 --- a/awesome/utils.lua +++ b/awesome/utils.lua @@ -9,6 +9,10 @@ utils.globalkeys = { } local host = io.popen("hostname") utils.host = host:read("*l") +function utils.is_dir(path) + return os.execute(('[ -d "%s" ]'):format(path)) +end + function utils.run_or_kill(prg, cprop, screen) if not prg then do return nil end @@ -43,7 +47,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 @@ -57,9 +61,9 @@ 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 @@ -75,11 +79,15 @@ 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() + return utils.is_dir("/sys/class/power_supply/BAT0") end return utils