summaryrefslogtreecommitdiff
path: root/guides/sysadmin/apps-demo/activate
diff options
context:
space:
mode:
Diffstat (limited to 'guides/sysadmin/apps-demo/activate')
-rw-r--r--guides/sysadmin/apps-demo/activate34
1 files changed, 34 insertions, 0 deletions
diff --git a/guides/sysadmin/apps-demo/activate b/guides/sysadmin/apps-demo/activate
new file mode 100644
index 0000000..b8c9138
--- /dev/null
+++ b/guides/sysadmin/apps-demo/activate
@@ -0,0 +1,34 @@
+# Hey Emacs; this is a -*- shell-script -*-.
+# Hopefully invoked by bash 🤞
+
+_apps_dir=$(realpath --no-symlinks $(dirname ${BASH_SOURCE}))
+
+_apps_PATH=$(
+ shopt -s nullglob
+ bins=( "${_apps_dir}"/*/bin )
+ IFS=: eval 'echo "${bins[*]}"'
+)
+export PATH=${_apps_PATH}:${PATH}
+
+_apps_XDG_DATA_DIRS=$(
+ shopt -s nullglob
+ # We could set globstar and let Bash loose, searching the depths
+ # of _apps_dir for
+ # **/{applications/*.desktop,systemd/user/*.service}
+ # but it seems like asking for trouble. Make some assumptions
+ # about where applications typically dump their XDG-related files.
+ datadirs=($(
+ {
+ for dkentry in "${_apps_dir}"/*/share/applications/*.desktop
+ do
+ echo ${dkentry%/applications/*.desktop}
+ done
+ for unit in "${_apps_dir}"/*/lib*/systemd/user/*.service
+ do
+ echo ${unit%/systemd/user/*.service}
+ done
+ } | sort -u
+ ))
+ IFS=: eval 'echo "${datadirs[*]}"'
+)
+export XDG_DATA_DIRS="${_apps_XDG_DATA_DIRS}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"