diff options
Diffstat (limited to '')
-rw-r--r-- | .config/awesome/functions/run_once.lua | 35 | ||||
-rw-r--r-- | .config/awesome/rc.lua | 27 |
2 files changed, 20 insertions, 42 deletions
diff --git a/.config/awesome/functions/run_once.lua b/.config/awesome/functions/run_once.lua deleted file mode 100644 index 7c57482..0000000 --- a/.config/awesome/functions/run_once.lua +++ /dev/null @@ -1,35 +0,0 @@ -local awful = require("awful") -local lfs = require("lfs") - -local function processwalker() - local function yieldprocess() - for dir in lfs.dir("/proc") do - if tonumber(dir) ~= nil then - local f, err = io.open("/proc/"..dir.."/cmdline") - if f then - local cmdline = f:read("*all") - f:close() - if cmdline ~= "" then - coroutine.yield(cmdline) - end - end - end - end - end - return coroutine.wrap(yieldprocess) -end - -function run_once(process, cmd) - assert(type(process) == "string") - local regex_killer = { - ["+"] = "%+", ["-"] = "%-", - ["*"] = "%*", ["?"] = "%?" } - - for p in processwalker() do - if p:find(process:gsub("[-+?*]", regex_killer)) then - return - end - end - return awful.spawn(cmd or process) -end --- run once END diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 21f79e8..a7cd86c 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -22,9 +22,6 @@ vicious.contrib = require("vicious.contrib") lain = require("lain") lain.helpers = require("lain.helpers") --- Load run_once function -require("functions.run_once") - -- {{{ Error handling -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) @@ -111,6 +108,22 @@ local function client_menu_toggle_fn() end end end + +local function run_once(cmd_name,cmd_args,process_name) + if not cmd_name then + do return nil end + end + + if not process_name then + process_name = cmd_name + end + + if not cmd_args then + awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. process_name .. "' || (" .. cmd_name .. ")") + else + awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. process_name .. "' || (" .. cmd_name .. " " .. cmd_args .. ")") + end +end -- }}} -- {{{ Menu @@ -867,8 +880,8 @@ client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_n -- {{{ Startup Apps run_once("redshift") run_once("xbindkeys") --- run_once("parcellite", "parcellite --no-icon") -run_once("nitrogen", "nitrogen --restore") -run_once("xautolock", "xautolock -time 20 -locker 'i3lock -denc 000000' -killtime 60 -killer 'systemctl suspend' -detectsleep") -run_once("pulseaudio", "pulseaudio --daemonize") +-- run_once("parcellite", "--no-icon") +run_once("nitrogen","--restore") +run_once("xautolock", "-time 20 -locker 'i3lock -denc 000000' -killtime 60 -killer 'systemctl suspend' -detectsleep") +run_once("pulseaudio", "--daemonize") -- }}} |