[shepherd] Fix init file

‘current-filename’ is the real file name of the file, not the symbolic link that
it's accessed through, so any relative references will be wrong.
This commit is contained in:
Tom Willemse 2022-03-06 15:11:45 -08:00
parent 13f4427ed9
commit 2313102c2b

View file

@ -3,11 +3,26 @@
#+begin_src scheme #+begin_src scheme
(use-modules (shepherd service) (use-modules (shepherd service)
((ice-9 ftw) #:select (scandir))) ((ice-9 ftw) #:select (scandir)))
#+end_src
I can't use ~(current-filename)~ here because this file will be symlinked into the =$XDG_CONFIG_DIR/shepherd/init.scm= and the =current-filename= function will return the actual path, not the path of the symbolic link.
#+begin_src scheme
(define init-directory
(string-append (getenv "XDG_CONFIG_HOME") "/shepherd/init.d"))
#+end_src
With that in place, we can loop over each =*.scm= file in the =init-directory= and load them.
#+begin_src scheme
(for-each (for-each
(λ (file) (load (string-append "init.d/" file))) (λ (file) (load (string-append "init.d/" file)))
(scandir (string-append (dirname (current-filename)) "/init.d") (scandir init-directory
(λ (file) (string-suffix? ".scm" file)))) (λ (file) (string-suffix? ".scm" file))))
#+end_src
Now turn shepherd into a daemon.
#+begin_src scheme
(action 'shepherd 'daemonize) (action 'shepherd 'daemonize)
#+end_src #+end_src