Skip to content
Snippets Groups Projects
setenv-@MOD@ 1.42 KiB
Newer Older
Eric Vidal's avatar
Eric Vidal committed
[main]
@type = oneshot
@name = setenv-@MOD@
@description = "Set well-know variable for @MOD@ user"
@user = (root)

[start]
@build = auto
@runas = @MOD@
@execute = 
(
	execl-subuidgid
	backtick -n HOME { homeof @MOD@ }
	importas -u HOME HOME
	foreground
	{
		if -nt { test -d ${HOME}/.66/conf/boot-user }
		mkdir -p ${HOME}/.66/conf/boot-user
	}
	redirfd -w 1 ${HOME}/.66/conf/boot-user/boot-user-@MOD@.conf
Eric Vidal's avatar
Eric Vidal committed

	## GENERAL VARIABLES

	if { 66-echo HOME=${HOME} }
	if { 66-echo LOGNAME=@MOD@ }
	if { 66-echo USER=@MOD@ }

	foreground { 
		importas PATH PATH 
		66-echo -- PATH=${PATH} 
Eric Vidal's avatar
Eric Vidal committed
	}
	foreground {
		backtick -D /usr/bin/sh -n shell {
			pipeline { getent passwd ${UID} }
			cut -d: -f7 
		}
		importas -u shell shell
		66-echo -- SHELL=${shell}
	}
	foreground 
	{
		backtick -n x 
		{
			sh -c "d=0 ; while true ; do \
			if [ ! -e "/tmp/.X$d-lock" -o -S "/tmp/.X11-unix/X$d" ]; then \
				66-echo -- $d ; \
				break ; \
			fi ; \
			d=$(($d + 1)) ; \
			done ;"
		}
		importas -u x x
		66-echo -- DISPLAY=:${x}  
Eric Vidal's avatar
Eric Vidal committed
	}
	## DBUS

	if { 66-echo -- DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${UID}/dbus }
Eric Vidal's avatar
Eric Vidal committed

	## XDG variables
				
	if { 66-echo -- XDG_RUNTIME_DIR=/run/user/${UID} }
	if { 66-echo -- XDG_CACHE_HOME=${HOME}/.cache }
	if { 66-echo -- XDG_CONFIG_HOME=${HOME}/.config }
	if { 66-echo -- XDG_DATA_HOME=${HOME}/.local/share }
	if { 66-echo -- XDG_DATA_DIRS=${HOME}/.local/share:/usr/local/share:/usr/share }
	66-echo -- XDG_SESSION_CLASS=user
Eric Vidal's avatar
Eric Vidal committed

)