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

View File

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