Disabling xscreensaver when using xfce + vnc
Have you ever run into the problem that your xfce starts xscreensaver automatically whenever you start up your favorite vnc server? I have. My previous solutions were to kill it manually each time or to remove it from my system all together. But that is hardly a solution but more of a work around.
Yesterday I started to look around where I could adjust the xfce global startup file (/etc/xdg/xfce4/xinitrc) and I noticed that the part responsible for the xscreensaver has a check for a VNCSESSION variable.
# Launch xscreensaver (if available), but only as non-root user
if test $UID -gt 0 -a -z "$VNCSESSION"; then
if test x"`which xscreensaver 2>/dev/null`" != x""; then
xscreensaver -no-splash &
elif test x"`which gnome-screensaver 2>/dev/null`" != x""; then
gnome-screensaver &
fi
fi
So the solution would be to make sure this variable is exported before starting xfce4 and we can do this in the xstartup script located in the ~/.vnc/ folder. I simply added export VNCSESSION=”tightvnc”. You can put whatever you want in VNCSESSION afaik. It wasn’t set by default so my best guess is it doesn’t matter. I’ll make sure to remember updating this when I run into a problem because of this solution.
My xstartup script now looks like this:
#!/bin/sh export VNCSESSION="tightvnc" xrdb $HOME/.Xresources source $HOME/.xinitrc
As you can see, I made it so that my regular .xinitrc file gets run too. This is where I order xfce4 to launch too.
Hope you find this quick fix helpful and don’t have to kill or remove xscreensaver anymore from now on.