]> git.rmz.io Git - dotfiles.git/commitdiff
awesome: autostart applications from awesome
authorSamir Benmendil <me@rmz.io>
Sun, 24 Jan 2021 03:53:19 +0000 (03:53 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 24 Jan 2021 21:35:32 +0000 (21:35 +0000)
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.

awesome/rc.lua
awesome/rules.lua
awesome/utils.lua
xinit/xprofile.d/99-applications.sh

index 22ff0a4504de1ed4bdc8296ba556c816a27c82e5..6ce193595f7cb280d0c77da1f83ff7dc1099dce3 100644 (file)
@@ -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 })
index e69406562341d4a03b255c1fe13bace7bbdf06dc..2af4d432f049afe1e7e5195a16ace3355fab002f 100644 (file)
@@ -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] } },
 }
index 40422416fa798df90f2ee3d4f3b5dd28265fa49e..993d95d13f739e16438395aa25fa0207685423db 100644 (file)
@@ -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)
index 91e909c33942647ae41b81c0b1df38e1849e2273..15a5a204b68fa6b633f501a629fa81bfda91715a 100755 (executable)
@@ -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 &