From: Samir Benmendil Date: Sun, 24 Jan 2021 03:53:19 +0000 (+0000) Subject: awesome: autostart applications from awesome X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/bcf13301fce23ff122f3d5b6bbb3688bf60c944b?ds=inline awesome: autostart applications from awesome Ideally I had hoped that I could have a more logical tree structure where awesome, the window manager starts before the clients. It seems to have been backwards when xinit was responsible for spawning autostarts. However, doing it this way seems to have resulted in awesome dropping the spawns which are caught by PID1 (as seen in htop/pstree). I don't think this is a big deal, but it's also not great. --- diff --git a/awesome/rc.lua b/awesome/rc.lua index 22ff0a4..6ce1935 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -55,5 +55,20 @@ require("rules") -- require("conky") require("signals") --- Set keys +-- Set keys {{{1 root.keys(globalkeys) + +-- Autostart {{{1 +local utils = require("utils") +-- This seems to not keep awesome as parent of these processes +utils.spawn_terminal_once("ncmpcpp", { instance = "ncmpcpp" + , tag = mediatag + }) +utils.spawn_terminal_once("neomutt", + { instance = "mutt" , tag = wwwtag }) +utils.spawn_terminal_once("weechat", { instance = "weechat" + , tag = imtag + , function (c) awful.client.setmaster(c) end + }) +-- can't get this to work propery, restarting awesowe will respawn a new qutebrowser +awful.spawn.single_instance("qutebrowser", { instance = "qutebrowser", tag = wwwtag }) diff --git a/awesome/rules.lua b/awesome/rules.lua index e694065..2af4d43 100644 --- a/awesome/rules.lua +++ b/awesome/rules.lua @@ -47,15 +47,6 @@ awful.rules.rules = { properties = { floating = true } }, { rule = { class = terminal_class }, properties = { opacity = 0.8 } }, - { rule = { class = terminal_class, instance = "mutt" }, - properties = { tag = wwwtag, - function (c) awful.client.setslave(c) end } }, - { rule = { class = terminal_class, instance = "ncmpcpp" }, - properties = { tag = mediatag, - function (c) awful.client.setmaster(c) end } }, - { rule = { class = terminal_class, instance = "weechat" }, - properties = { tag = imtag, - function (c) awful.client.setmaster(c) end } }, { rule_any = { class = { "Steam", "steam" } }, properties = { tag = tags[1][9] } }, } diff --git a/awesome/utils.lua b/awesome/utils.lua index 4042241..993d95d 100644 --- a/awesome/utils.lua +++ b/awesome/utils.lua @@ -13,15 +13,28 @@ function utils.is_dir(path) return os.execute(('[ -d "%s" ]'):format(path)) end -function utils.spawn_terminal(prg, cprop, cb) +local function terminal_cmd(prg, name) local join = require("gears.table").join local term_cmd = {terminal} - if cprop and cprop.instance then + if name then if terminal:match("rxvt") then - term_cmd = join(term_cmd, {"-name", cprop.instance}) + term_cmd = join(term_cmd, {"-name", name}) end end - awful.spawn(join(term_cmd, {"-e", prg}), cprop, cb) + 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) diff --git a/xinit/xprofile.d/99-applications.sh b/xinit/xprofile.d/99-applications.sh index 91e909c..15a5a20 100755 --- a/xinit/xprofile.d/99-applications.sh +++ b/xinit/xprofile.d/99-applications.sh @@ -5,12 +5,6 @@ URXVT_PERL_LIB=$URXVT_PERL_LIB:$HOME/src/dotfiles/urxvt/perls/deprecated export URXVT_PERL_LIB urxvtd -q -o -f -hash ncmpcpp && urxvtc -name ncmpcpp -icon ~/src/dotfiles/icons/bmp.png -e ncmpcpp -hash weechat && urxvtc -name weechat -icon ~/src/dotfiles/icons/im-irc.png -e weechat -hash neomutt && urxvtc -name mutt -icon ~/src/dotfiles/icons/internet-mail.png -e neomutt - compton --config ~/.config/compton.conf & unclutter --timeout 1 & xcape -e "Control_L=Escape;Control_R=Escape" - -qutebrowser &