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:
Afterwards, with kiosk mode active, the option is no longer available:
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:
Solution 2
the hack from misterich didn't do the trick for me either, somehow it still can write to sessions folder
my solution:
rm -rf "$HOME/.cache/sessions"
touch "$HOME/.cache/sessions"
now there is a file named sessions instead of sessions folder therefore it can't write file to it anymore.
Related videos on Youtube
anniezm
Updated on September 18, 2022Comments
-
anniezm almost 2 years
I have a main Backbone view for my app and I'm having trouble rendering a template based on a button click.
If the user clicks the submit button, it should display template2, otherwise it should display template1. Right now, when I click the submit button, template2 only displays for a second and then disappears before template1 appears again.
Here's a simplified version of the code without the other app functionalities
app.viewExample = Backbone.View.extend({ el: "#in", template1: _.template( $('#one').html() ), template2: _.template( $('#two').html() ), events: { 'click .submit': 'result', }, initialize: function() { var bool = false; this.listenTo(app.col, 'all', this.render); }, render: function() { if (this.bool) { var rand = Math.floor(Math.random() * app.opts.length); var value = app.col.at(rand).get("title"); this.$el.html(this.template2( { result: value })); } else if (!this.bool) { var total = app.col.length; this.$el.html(this.template1( { total: total })); } }, result: function() { this.bool = true; this.render(); } });
*app.col is the collection for this app
Template:
<script type="text/template" id="template1"> <span id="count"> Currently <%= total %> <%= total === 1 ? 'option' : 'options' %> </span> <button id="clear-all">Clear all</button> </script> <script type="text/template" id="template2"> <div class="result"> Result: <%= result %> </div> <button class="restart">Restart</button> </script>
HTML:
<section id="in"> //stuff <button class="submit">Submit</button> </section>
-
code4coffee almost 10 yearsCould you show your template code as well as what app.col is?
-
anniezm almost 10 years@code4coffee updated my post!
-
-
Jasper about 11 yearsSorry for taking so long to accept, I didn't want to accept without having tried it out, and I wasn't doing maintenance on that server again until now.
-
Daniel Alder over 10 yearsIt seems that it doesn't work anymore with 4.10.1-1ubuntu1 under Xubuntu 13.10. Before the upgrade everything was ok :-(
-
Daidalus over 10 years@DanielAlder It still seems to work for me, as I am using the Xfce 4.10 ppa on 12.04; the update you mention is the Xubuntu 13.10 update I think. The kiosk option still seems to be enabled in the source and there are no patches disabling it, so it's very strange.
-
Daniel Alder over 10 years@Mik: the kioskrc still hides the 'save session' button, but funnily one out of 4 times after logging out and in the open windows which I had come back.
-
Daidalus over 10 years@DanielAlder Yes, this can still happen, even if saving sessions is disabled in settings > settings-manager > session and startup > session. You can get rid of any remnants from other sessions by clicking 'clear saved sessions' and then the windows won't come back. The session behaviour of xfce can be a bit odd sometimes, and I'm sure I remember a general bug being filed in the past about it.
-
anniezm almost 10 yearsAh thanks alot! Sorry about the view templating name mismatch, tried to simplify my code to post here and got mixed up.
-
mu is too short almost 10 yearsI figured at least some of the problems were related to the stripped down demo but I tried to cover them all just in case.
-
moosambi2020 almost 6 yearsThis technique still works in Mint 18.3 'Sylvia' Xfce edition :) Thank you. This is just what I needed.