We're using Ubuntu 12.04.1 with Xfce 4.8. We have a script which sets environment variables needed by our software. In the past, I figured out how to run this script in the Xfce start up so that these environment variables are set up and available to gui based programs launched via icons. Recently an OS upgrade wiped out this setting and I can't remember or find how to do this. I've tried sourcing the script from ~/.profile, ~/.xinitrc, and ~/.config/xfce4/xinitrc, but no luck.
How to set environment variables for Xfce windowing environment
environment-variablesxfce
Related Solutions
It's actually pretty difficult. You can use the setx
command to set persistent environment variables for other users, but this won't work for NetworkService, because the service accounts have no passwords (so your credentials will always be rejected).
The only way that I know of to do this is using the task scheduler:
- Set up a task to run as the user "network service".
- Leave the triggers empty.
- For the action, have it run
cmd.exe
with the parameters/c setx temp [target]
. - Run the task manually.
- Delete the task.
This will work to set a persistent environment variable for the NetworkService user. As to whether this will successfully work to relocate the temporary files for that user, or whether it will cause any unpredictable side-effects, I can't say for certain. You may need to reboot to verify if it's putting the temp files where you want them.
You can verify that the environment variable has been changed for the correct user by using the environment
command within WMIC.
It's possible to do this - here's a screencast, using the Grml ZSH configuration.
Further information:
- Mikas Blog Post
- The
chpwd_profiles()
function in the Grml ZSH configuration.
Edit: This is actually pretty easy to do. Here's the relevant portion of your ~/.zshrc
:
function chpwd_profiles() {
local profile context
local -i reexecute
context=":chpwd:profiles:$PWD"
zstyle -s "$context" profile profile || profile='default'
zstyle -T "$context" re-execute && reexecute=1 || reexecute=0
if (( ${+parameters[CHPWD_PROFILE]} == 0 )); then
typeset -g CHPWD_PROFILE
local CHPWD_PROFILES_INIT=1
(( ${+functions[chpwd_profiles_init]} )) && chpwd_profiles_init
elif [[ $profile != $CHPWD_PROFILE ]]; then
(( ${+functions[chpwd_leave_profile_$CHPWD_PROFILE]} )) \
&& chpwd_leave_profile_${CHPWD_PROFILE}
fi
if (( reexecute )) || [[ $profile != $CHPWD_PROFILE ]]; then
(( ${+functions[chpwd_profile_$profile]} )) && chpwd_profile_${profile}
fi
CHPWD_PROFILE="${profile}"
return 0
}
# Add the chpwd_profiles() function to the list called by chpwd()!
chpwd_functions=( ${chpwd_functions} chpwd_profiles )
Activate the profile for each directory you want:
zstyle ':chpwd:profiles:/path/to/directory(|/|/*)' profile NAME
And don't forget to actually make a profile:
chpwd_profile_NAME() {
[[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
print "chpwd(): Switching to profile: $profile"
export VAR=value
}
Edit #2: This would actually be rather neat to couple with named directories [Stackoverflow.net].
Best Answer
per this https://wiki.archlinux.org/index.php/Xfce#Session you should "Copy the file /etc/xdg/xfce4/xinitrc to ~/.config/xfce4/". I edited etc/xdg/xfce4/xinitrc directly and the var was in the user session.