2018-01-04 19:38:54 +01:00
|
|
|
-- {{{ Helper functions
|
2017-04-10 01:14:46 +02:00
|
|
|
function file_exists(name)
|
|
|
|
|
local f = io.open(name, "r")
|
|
|
|
|
if f~=nil then io.close(f) return true else return false end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function run_once(cmd)
|
|
|
|
|
findme = cmd
|
|
|
|
|
firstspace = cmd:find(" ")
|
|
|
|
|
if firstspace then
|
|
|
|
|
findme = cmd:sub(0, firstspace-1)
|
|
|
|
|
end
|
|
|
|
|
awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function tablelength(T)
|
|
|
|
|
local count = 0
|
|
|
|
|
for _ in pairs(T) do count = count + 1 end
|
|
|
|
|
return count
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-12 23:50:31 +02:00
|
|
|
function suspend()
|
|
|
|
|
awful.util.spawn("/usr/bin/slock")
|
|
|
|
|
awful.util.spawn("loginctl suspend")
|
|
|
|
|
end
|
|
|
|
|
|