How can I turn off Xfce session saving system-wide?

Solution 1:

(Tested with Xubuntu 12.04, but with the ppas for Xfce 4.10 and 4.12 installed, but the option I discuss was available for Xfce 4.8)

There is a way to globally disable the option of saving the session, and the best way to achieve it is to use Xfce kiosk mode. One of the available kiosk mode options, buried in the source code for xfce4-session, is SaveSession. If we look at /home/mike/xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c, we can see the undocumented setting:

/* check kiosk */
  shutdown->kiosk_can_save_session = xfce_kiosk_query (kiosk, "SaveSession");

Firstly, create the kiosk directory with

sudo mkdir /etc/xdg/xfce4/kiosk

and then create and edit the kioskrc with your text editor:

sudo nano /etc/xdg/xfce4/kiosk/kioskrc

Place the following in your kioskrc:

[xfce4-session]
SaveSession=NONE

Now, save the changes and logout and login again as your user to test it. The checkbox option to save the session should have disappeared.

Before the setting is applied, the box is still available:

enter image description here

Afterwards, with kiosk mode active, the option is no longer available:

enter image description here

If you wish to use kiosk mode to globally disable other settings, such as the ability to shutdown or suspend, etc, see my answer here:

  • How to change the hibernate and suspend settings at a system-wide level in Xfce?

Solution 2:

the hack from misterich didn't do the trick for me either, somehow it still can write to sessions folder

my solution:

  1. rm -rf "$HOME/.cache/sessions"

  2. touch "$HOME/.cache/sessions"

now there is a file named sessions instead of sessions folder therefore it can't write file to it anymore.