diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2024-03-10 12:38:04 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2024-03-10 12:38:04 +0100 |
| commit | 9e9808917137fecd34d5683409f78a976a155510 (patch) | |
| tree | 976a92432ed0ede3173bd0677659eb0e453713da /guides/setups | |
| parent | 5e452997c5d46520ab7c5bb54dd5ffeecfe39005 (diff) | |
| download | memory-leaks-9e9808917137fecd34d5683409f78a976a155510.tar.xz | |
Look into environment tweaks for systemd units and desktop files
Diffstat (limited to 'guides/setups')
| -rw-r--r-- | guides/setups/operating-systems/apps.org | 76 |
1 files changed, 58 insertions, 18 deletions
diff --git a/guides/setups/operating-systems/apps.org b/guides/setups/operating-systems/apps.org index 6bba368..efede03 100644 --- a/guides/setups/operating-systems/apps.org +++ b/guides/setups/operating-systems/apps.org @@ -113,34 +113,74 @@ infopath-no-defaults=On EOF #+end_src -* TODO ~bash~ completions +* TODO systemd services +=systemd.unit(5)= § "User Unit Search Path" mentions a couple of +variables that we could append: -* TODO Desktop entry files -Prepend =${HOME}/apps/${program}/share= to =XDG_DATA_DIRS=? +- =$XDG_CONFIG_DIRS/systemd/user/*= +- =$XDG_DATA_DIRS/systemd/user/*= -* TODO systemd services -See systemd.unit(5) +And: -* Putting it all together -Presenting =~/apps/activate=, to be sourced from =~/.profile=: +#+begin_quote +When the variable =$SYSTEMD_UNIT_PATH= is set, the contents of this +variable overrides the unit load path. If =$SYSTEMD_UNIT_PATH= ends +with an empty component (=:=), the usual unit load path will be +appended to the contents of the variable. +#+end_quote -#+begin_src bash -# Hey Emacs; this is a -*- shell-script -*-. -# Hopefully invoked by bash 🤞 +So we could either: + +1. find the directory 𝒟 where an app tucks =systemd/user= in its + installation tree, and append 𝒟 to one of the XDG variables, +2. find the directory where an app tucks its =.service= files, and + append that directory to =SYSTEMD_UNIT_PATH=, keeping a final + colon. + +(1) could feed multiple birds with one scone: in particular, +=XDG_DATA_DIRS= is used for other purposes (see § Desktop entry +files). Serendipitously, [[https://github.com/systemd/systemd/blob/1d87a00a951dca801c8ccd79c1460fa91efa7dce/src/basic/path-lookup.c#L147][the systemd sources]] suggest =DATA= over +=CONFIG= for our purposes: + +#+begin_src c + /* Implement the mechanisms defined in + * + * https://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html + * + * We look in both the config and the data dirs because we + * want to encourage that distributors ship their unit files + * as data, and allow overriding as configuration. + */ +#+end_src -_apps_dir=$(dirname ${BASH_SOURCE}) +* TODO Desktop entry files +The Freedesktop [[https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html][Desktop Menu]] and [[https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html][Desktop Entry]] specs spell out how +=XDG_DATA_DIRS= will be searched for =applications/*.desktop= files. -_apps_PATH=$( - shopt -s nullglob - bins=( "${_apps_dir}"/*/bin ) - IFS=: eval 'echo "${bins[*]}"' -) +* TODO ~bash~ completions -export PATH=${_apps_PATH}:${PATH} -#+end_src +* Putting it all together +Presenting [[./apps-demo/activate][=~/apps/activate=]], to be sourced from =~/.profile=: + +#+INCLUDE: "apps-demo/activate" src sh * Resources ** [[https://nullprogram.com/blog/2017/06/19/][nullprogram.com]] — Building and Installing Software in $HOME Explains how to set things up so that one can use =~/.local= as a first-class citizen for applications, libraries and development resources (headers, pkg-config, manpages). + +** [[https://specifications.freedesktop.org][specifications.freedesktop.org]] — Freedesktop.org Specifications +Hosts the specifications for the behavior and environment variables +most GNU/Linux distros (that I have experience with) adhere to, e.g. + +- the [[https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html][Base Directory spec]] :: defines the various + =XDG_*_@(HOME|DIR|DIRS)= variables referenced here; +- the [[https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html][Desktop Entry spec]] :: explains the significance of a desktop + file's filename with respect to its position within =XDG_DATA_DIRS=; +- the [[https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html][Desktop Menu spec]] :: defines the expected file locations for + desktop files (and more) with respect to XDG base directories. + +** [[https://wiki.archlinux.org/title/Environment_variables#Per_user][wiki.archlinux.org]] — Environment variables § Per user - ArchWiki +A thorough overview of the myriad of ways users can amend environment +variables, as examined in § PATH. |
