diff options
| author | Robert Günzler <r@gnzler.io> | 2023-09-25 11:56:34 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2023-09-25 11:56:34 +0200 |
| commit | f5c219983c0f60a07f1bd52b6f6071e86f35455e (patch) | |
| tree | b7520a02b9822481f29aea4ccb404744a73414b1 /os/etc/s6-rc/src/desktop-session-running | |
| parent | 91ba318df1ff9b04d08af373ae904f61a91bf489 (diff) | |
add os config
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'os/etc/s6-rc/src/desktop-session-running')
5 files changed, 43 insertions, 0 deletions
diff --git a/os/etc/s6-rc/src/desktop-session-running/dependencies.d/tinydm b/os/etc/s6-rc/src/desktop-session-running/dependencies.d/tinydm new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/os/etc/s6-rc/src/desktop-session-running/dependencies.d/tinydm diff --git a/os/etc/s6-rc/src/desktop-session-running/down b/os/etc/s6-rc/src/desktop-session-running/down new file mode 100644 index 0000000..aa46989 --- /dev/null +++ b/os/etc/s6-rc/src/desktop-session-running/down @@ -0,0 +1,6 @@ +#!/bin/execlineb -P + +importas -D "/run" XDG_RUNTIME_DIR XDG_RUNTIME_DIR +define dir ${XDG_RUNTIME_DIR}/session-env + +foreground { rm -rf ${dir} } diff --git a/os/etc/s6-rc/src/desktop-session-running/find-marker-proc b/os/etc/s6-rc/src/desktop-session-running/find-marker-proc new file mode 100755 index 0000000..4f39eec --- /dev/null +++ b/os/etc/s6-rc/src/desktop-session-running/find-marker-proc @@ -0,0 +1,15 @@ +#!/bin/sh +# find first process with marker=true envvar set +set -eu +uid="${1:?}" +done= +while true; do + for pid in $(pgrep -u ${uid}); do + if grep -q 'marker=true' /proc/${pid}/environ 2>/dev/null; then + printf "%s" "$pid" + done=1 + break + fi + done + [ -n "$done" ] && break +done diff --git a/os/etc/s6-rc/src/desktop-session-running/type b/os/etc/s6-rc/src/desktop-session-running/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/os/etc/s6-rc/src/desktop-session-running/type @@ -0,0 +1 @@ +oneshot diff --git a/os/etc/s6-rc/src/desktop-session-running/up b/os/etc/s6-rc/src/desktop-session-running/up new file mode 100644 index 0000000..de48622 --- /dev/null +++ b/os/etc/s6-rc/src/desktop-session-running/up @@ -0,0 +1,21 @@ +#!/bin/execlineb -P + +# get username from config +envfile /etc/s6-rc/config/user.conf +importas -iu USER USER +s6-envuidgid -i ${USER} +importas -iu UID UID + +# find first process with marker=true envvar set +backtick -E pid { sh /etc/s6-rc/src/desktop-session-running/find-marker-proc ${UID} } + +# create session-env directory +importas -D "/run" XDG_RUNTIME_DIR XDG_RUNTIME_DIR +define dir ${XDG_RUNTIME_DIR}/session-env +foreground { mkdir -p ${dir} } +cd ${dir} +pipeline { grep -zE "^(SWAY|I3|.*DISPLAY|DBUS|XDG|BEMENU|PATH|HOME|LANG)" /proc/${pid}/environ } +foreground { awk --assign=RS=\\0 -- "{idx=index($0,\"=\"); print substr($0,idx+1) > substr($0,0,idx-1)}" } + +# hack +foreground { sleep 0.5 } |