[Awesome, Bin.org] Change the way my programs autostart

Autostarting my programs are now done through a shell script, which
Awesome calls.
This commit is contained in:
Lucien Cartier-Tilet 2020-09-02 13:28:14 +02:00
parent 84aba5216f
commit c290305a26
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 53 additions and 46 deletions

View File

@ -1483,55 +1483,13 @@
:CUSTOM_ID: Autostart-f2cf42fe
:END:
By simply adding a line requesting to spawn a command, it is possible to
create some autolaunch. All of my autolaunched apps are launch through the
shell.
#+NAME: autostart-table
| Command | What it is for |
|-------------------------------------------------+----------------------------------------|
| pumopm | Power manager |
| /usr/lib/xfce-polkit/xfce-polkit | Launch or relaunch Polkit |
| sleep 1 && set-screens | Auto-organize screens |
| picom --experimental-backends | Launch or relaunch Picom |
| nitrogen --restore | Restore background |
| xss-lock -- lock | Enable lockscreen after a blank screen |
| nm-applet | Launch NetworkManager applet |
| numlockx on | Enable numlock |
| mpc stop | Stop music |
| mpd_discord_richpresence --no-idle --fork | Launch MPD rich presence for Discord |
| sleep 3 && emacsclient -c -e \"(delete-frame)\" | Launch blank EmacsClient |
#+NAME: autostart
#+BEGIN_SRC emacs-lisp :tangle no :exports none :cache yes :var apps=autostart-table
(mapconcat (lambda (x)
(format "awful.spawn.with_shell(\"%s\")"
(car x)))
apps
"\n")
#+END_SRC
#+RESULTS[e65349733980220944a79123e3ee0f4d638e5068]: autostart
#+begin_example
awful.spawn.with_shell("pumopm")
awful.spawn.with_shell("pkill xfce-polkit; /usr/lib/xfce-polkit/xfce-polkit")
awful.spawn.with_shell("sleep 1 && set-screens")
awful.spawn.with_shell("picom --experimental-backends")
awful.spawn.with_shell("nitrogen --restore")
awful.spawn.with_shell("xss-lock -- lock")
awful.spawn.with_shell("nm-applet")
awful.spawn.with_shell("numlockx on")
awful.spawn.with_shell("mpc stop")
awful.spawn.with_shell("mpd_discord_richpresence --no-idle --fork")
awful.spawn.with_shell("sleep 3 && emacsclient -c -e \"(delete-frame)\"")
#+end_example
Each of the command gets called with the call of ~awful.spawn.with_shell()~,
as you can see below.
create some autolaunch. All of my autolaunched apps are launch through a
custom script which you can [[file:~/org/config/bin.org::#Autostart-a99e99e7][find here]]. The command gets called with
~awful.spawn.with_shell()~, as you can see below.
#+BEGIN_SRC lua
<<autostart()>>
awful.spawn.with_shell("autostart")
#+END_SRC
PumoPM is a custom power manager Ive written, because other power managers
didnt fit my needs, so I wrote my own. You can find it [[https://labs.phundrak.com/phundrak/pumopm][here]].
* What to do now :noexport:
:PROPERTIES:

View File

@ -5,6 +5,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's i3 config" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the i3 config file of Phundrak" />
#+PROPERTY: header-args :exports code
#+PROPERTY: header-args:emacs-lisp :exports none :tangle no
* Presentation
:PROPERTIES:
@ -80,6 +81,54 @@
end
#+END_SRC
* Autostart
:PROPERTIES:
:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :tangle ~/.local/bin/autostart
:CUSTOM_ID: Autostart-a99e99e7
:END:
Because I sometimes switch from window manager to window manager, creating a
script that handles by itself autostarting things for me is way easier than
rewriting every time the autostart part of my configuration. As you can every
instance will be launched asynchronously, and only if there is no other
instance of said command running.
For the record, PumoPM is my custom power manager, you can find its source
code [[https://labs.phundrak.com/phundrak/pumopm][here]]. ~set-screens~ is a custom script declared [[*set-screens][below]].
#+NAME: autostart-table
| Command | Arguments | Run once? |
|----------------------------+-----------------------------------------------------------------+-----------|
| ~pumopm~ | | yes |
| ~xfce-polkit~ | | yes |
| ~picom~ | ~--experimental-backends~ | yes |
| ~xidlehook~ | ~--not-when-audio --not-when-fullscreen --timer 3600 i3lock ''~ | yes |
| ~nm-applet~ | | yes |
| ~numlockx~ | ~on~ | yes |
| ~mpd_discord_richpresence~ | ~--no-idle --fork~ | yes |
| ~nitrogen~ | ~--restore~ | no |
| ~mpc~ | ~stop~ | no |
| ~emacsclient~ | ~-c -e \"(delete-frame)\"~ | no |
#+NAME: autostart-gen
#+BEGIN_SRC emacs-lisp :var table=autostart-table :cache yes
(mapconcat (lambda ($start-command)
(let* (($command (s-replace "~" "" (nth 0 $start-command)))
($arguments (s-replace "~" "" (nth 1 $start-command)))
($once? (string= "yes" (nth 2 $start-command))))
(if $once?
(concat (format "if ! test (pgrep %s 2&> /dev/null)\n\t" $command)
(s-collapse-whitespace (format "%s %s &" $command $arguments))
"\nend\n")
(format "%s %s &\n" $command $arguments))))
table
"\n")
#+END_SRC
#+BEGIN_SRC fish :noweb yes
set -l PATH $PATH /usr/lib/xfce-polkit
<<autostart-gen()>>
#+END_SRC
* awiki
:PROPERTIES:
:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :tangle ~/.local/bin/awiki