[Bin] Remove Elisp dependencies in code generation

Remove dependency on dash.el and s.el in code generation
This commit is contained in:
Lucien Cartier-Tilet 2021-10-23 18:24:45 +02:00
parent f94adbfc35
commit 6a73bdb74e
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 30 additions and 25 deletions

View File

@ -44,30 +44,33 @@ of said command running.
#+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?
(let ((command (replace-regexp-in-string (regexp-quote "~") "" (nth 0 start-command)))
(arguments (replace-regexp-in-string (regexp-quote "~") "" (nth 1 start-command)))
(oncep (string= "yes" (nth 2 start-command))))
(if oncep
(format "pgrep -x %s 2&>/dev/null || echo (%s) 2&>/dev/null"
command
(s-collapse-whitespace (format "%s %s & && disown"
command
arguments)))
(replace-regexp-in-string " +" " " (format "%s %s & && disown"
command
arguments)))
(format "%s %s &" command arguments))))
table
"\n")
#+END_SRC
#+RESULTS[6bdde37274cbbcce2fcd7e86690ce9ce7f32c62f]: autostart-gen
: xrdb -merge $HOME/.Xresources &
: mpc stop &
: set-screens &
: pgrep -x picom 2&>/dev/null || echo (picom & && disown) 2&>/dev/null
: pgrep -x pumopm 2&>/dev/null || echo (pumopm & && disown) 2&>/dev/null
: pgrep -x xfce-polkit 2&>/dev/null || echo (xfce-polkit & && disown) 2&>/dev/null
: pgrep -x nm-applet 2&>/dev/null || echo (nm-applet & && disown) 2&>/dev/null
: pgrep -x numlockx 2&>/dev/null || echo (numlockx on & && disown) 2&>/dev/null
: xwallpaper --zoom (cat $HOME/.cache/wallpaper) &
#+RESULTS[085e16ae9fd402b050b526763cc792af26aaaf41]: autostart-gen
#+begin_example
mpc stop &
pgrep -x picom 2&>/dev/null || echo (picom & && disown) 2&>/dev/null
set-screens &
pgrep -x numlockx 2&>/dev/null || echo (numlockx on & && disown) 2&>/dev/null
pgrep -x pumopm 2&>/dev/null || echo (pumopm & && disown) 2&>/dev/null
pgrep -x xfce-polkit 2&>/dev/null || echo (xfce-polkit & && disown) 2&>/dev/null
pgrep -x nm-applet 2&>/dev/null || echo (nm-applet & && disown) 2&>/dev/null
xwallpaper --zoom (cat $HOME/.cache/wallpaper) &
pgrep -x xss-lock 2&>/dev/null || echo (xss-lock plock & && disown) 2&>/dev/null
xrdb -merge $HOME/.Xresources &
#+end_example
I also have an external sound card, a Scarlet 2i2 G3, that I would like to use
as my default audio output. However, it might not be always connected, hence the
@ -782,12 +785,12 @@ end
#+NAME: ytdl-arg-set-default-value-gen
#+BEGIN_SRC emacs-lisp :var args=ytdl-table-arguments
(let* ((args (-filter (lambda (arg)
(let* ((var (unless (string= "None" (nth 3 arg)) (nth 3 arg)))
(default (format "%s" (nth 4 arg)))
(default (unless (string= "None" default) default)))
(and var default)))
args)))
(let* ((args (seq-filter (lambda (arg)
(let* ((var (unless (string= "None" (nth 3 arg)) (nth 3 arg)))
(default (format "%s" (nth 4 arg)))
(default (unless (string= "None" default) default)))
(and var default)))
args)))
(mapconcat (lambda (arg)
(let* ((var (nth 3 arg))
(default (format "%s" (nth 4 arg))))

View File

@ -1,4 +1,3 @@
# -*- after-save-hook: (org-babel-tangle t); -*-
#+title: MPD Configuration
#+setupfile: ~/org/config/headers
#+options: auto-id:t
@ -39,7 +38,10 @@ MPD requires a few compulsory parameters that we will see below.
#+name: mpd-gen-values
#+begin_src emacs-lisp :var table=mpd-required-parameters :exports results
(mapconcat (lambda (parameter)
(let* ((trim-name (lambda (parameter) (string-replace "=" "" parameter)))
(let* ((trim-name (lambda (parameter)
(replace-regexp-in-string (regexp-quote "=")
""
parameter)))
(name (apply trim-name `(,(car parameter))))
(value (apply trim-name `(,(cadr parameter)))))
(format "%s \"%s\"" name value)))