aboutsummaryrefslogtreecommitdiff
path: root/sh/user-init.sh.in
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/user-init.sh.in
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/user-init.sh.in')
-rw-r--r--sh/user-init.sh.in28
1 files changed, 28 insertions, 0 deletions
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"