aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-12 00:51:12 +0200
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-19 20:40:28 +0200
commitfd961d2ea0eea2cc60f4af1aca6b6e7711d43995 (patch)
treefc53ad7bf4d46a3b72e151b79e8433ff4d565514 /sh
parentc34fcd63f05044f9034b26c52f19c91e04668da7 (diff)
openrc-user: init script for users
adds a new multiplexed script for starting user sessions. it also sets up XDG_RUNTIME_DIR. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'sh')
-rw-r--r--sh/meson.build1
-rw-r--r--sh/user-init.sh.in28
2 files changed, 29 insertions, 0 deletions
diff --git a/sh/meson.build b/sh/meson.build
index e8849d40..bbc95c25 100644
--- a/sh/meson.build
+++ b/sh/meson.build
@@ -28,6 +28,7 @@ sh_config = [
scripts_config = [
'gendepends.sh.in',
'openrc-run.sh.in',
+ 'user-init.sh.in',
]
if os == 'Linux'
diff --git a/sh/user-init.sh.in b/sh/user-init.sh.in
new file mode 100644
index 00000000..eaedc631
--- /dev/null
+++ b/sh/user-init.sh.in
@@ -0,0 +1,28 @@
+#!@SHELL@
+
+sourcex()
+{
+ if [ "$1" = "-e" ]; then
+ shift
+ [ -e "$1" ] || return 1
+ fi
+ if ! . "$1"; then
+ eerror "$RC_SVCNAME: error loading $1"
+ exit 1
+ fi
+}
+
+_sysconf="${XDG_CONFIG_HOME:-${HOME}/.config}/openrc"
+
+sourcex -e "@SYSCONFDIR@/rc.conf"
+sourcex -e "$_sysconf/rc.conf"
+
+case $1 in
+ start) _runlevel="${rc_user_runlevel:-default}";;
+ stop) _runlevel="${rc_user_shutdown_runlevel:-none}";;
+ *) exit 1
+esac
+
+mkdir -p "$_sysconf/runlevels/$_runlevel"
+
+openrc --user "$_runlevel"