Try using this for the command
xfce4-session-logout -s
man xfce4-session-logout
The xfce4-session-logout command allows you to programmatically
logout
from your Xfce session. It requests the session manager to display the
logout confirmation screen, or, if given one of the command-line
options below, causes the session manager to take the requested action
immediately.
--suspend
Suspend without displaying the logout dialog
(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](https://i.stack.imgur.com/xhtd2.jpg)
Afterwards, with kiosk mode active, the option is no longer available:
![enter image description here](https://i.stack.imgur.com/z0Yg8.jpg)
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:
Best Answer
Often for multi-user systems or for special purposes, Xfce kiosk mode is used so that you can disable all shutdown options for users such as hibernate and suspend. I am running Xubuntu 12.04, but with the ppas for Xfce 4.10 and 4.12. I think there were some issues with kiosk mode a while ago, but it seems to work again now, at least in my tests (see the before and after screenshots below).
Kiosk mode does not need any additional downloads or installations, but will only take effect if you have
/etc/xdg/xfce4/kiosk/kioskrc
, so first runThere can be several sections of the
kioskrc
file, but we will concentrate onxfce4-session
, as those are the settings you require. The official documentation is useful in explaining the options available forxfce4-session
, but below is an example of the possible content of thexfce4-session
part of/etc/xdg/xfce4/kiosk/kioskrc
. This would give you a really strict kiosk mode that would leave non-administrative users without any ability to shutdown the machine (or use suspend/hibernate) using the menus or via commands in terminal, although they could still logout. You may not want to use these settings, this is just an example (see below for further explanation):In place of
Shutdown=NONE
and other settings, you could very reasonably specify your own main user (e.g.Shutdown=mike
), so only you still have the ability to suspend/shutdown using the menu (without resorting to using sudo with command-line shutdown equivalents), but it depends on your purposes. If you want to specify groups use%groupname
, and for users just specifyusername
; the settingsALL
andNONE
are self explanatory.Open the
kioskrc
with your text editor:Then copy the above block of settings for
xfce4-session
, making sure that you alter the values to suit your purposes. Then save the file, logout and login again with your user or another user to test the settings.My example of 'before and after' with the strictest kiosk mode settings, which will apply to all users:
a) Before with normal Xfce settings, running as user mike:
b) After, with kiosk mode and strict settings enabled, running as user mike:
For more information, please see the Xfce documentation.