Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- M = {}
- local awful = require("awful")
- xrdbGetProcPid = function(procKey)
- local xquery = io.popen("xrdb -query")
- for line in xquery:lines() do
- local procName, pid = string.match(line, "Awesome%.autorun%.(.+):%s(.+)")
- if procName == procKey then
- xquery:close()
- return pid
- end
- end
- xquery:close()
- return nil
- end
- xrdbSetProcPid = function(procName, pid)
- local xmerge = io.popen("xrdb -merge", "w")
- xmerge:write("Awesome.autorun."..procName..": "..pid)
- xmerge:close()
- end
- xrdbResetProcPid = function(procName)
- local xmerge = io.popen("xrdb -remove", "w")
- xmerge:write("Awesome.autorun."..procName)
- xmerge:close()
- end
- xrdbRunOnce = function(binary, parameters, procKey, delay)
- if not procKey then
- if string.find(binary, "/") then
- local comp
- for xcomp in string.gmatch(binary, "/([^/]+)") do
- comp = xcomp
- end
- procKey = comp
- else
- procKey = binary
- end
- end
- local pid = xrdbGetProcPid(procKey)
- if pid then
- return nil
- end
- if tonumber(delay) then
- local stimer = timer { timeout = delay }
- local run = function()
- stimer:stop()
- pid = awful.util.spawn(binary .. " " .. parameters, false)
- xrdbSetProcPid(procKey, pid)
- end
- stimer:connect_signal("timeout", run)
- stimer:start()
- else
- pid = awful.util.spawn(binary .. " " .. parameters, false)
- xrdbSetProcPid(procKey, pid)
- end
- end
- M.xrdbGetProcPid = xrdbGetProcPid
- M.xrdbSetProcPid = xrdbSetProcPid
- M.xrdbResetProcPid = xrdbResetProcPid
- M.xrdbRunOnce = xrdbRunOnce
- return M
Advertisement
Add Comment
Please, Sign In to add comment