summary refs log tree commit diff
path: root/os/etc/s6-rc/src/desktop-session-running/up
blob: de48622cf9b4ed8489ef97131395850fb1d63e99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 }