Author Topic: auto logout (SOLVED)  (Read 2490 times)

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
auto logout (SOLVED)
« on: April 13, 2016, 12:41:43 am »
Hi guys

Is there a way to auto logout after say 10 minutes of inactivity or some other preset time interval in PM6




Graeme
« Last Edit: April 15, 2016, 07:09:50 am by emegra »
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline Slim.Fatz

  • Global Moderator
  • Veteran
  • *****
  • Posts: 2316
  • Karma: 614
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: auto logout
« Reply #1 on: April 13, 2016, 03:44:30 am »
Hi emegra,

I am not currently at home and must reply using a Windoze computer  >:( but you can check this article about using the when-command app. According to the article, one of the triggers can be an "idle session" and I am pretty sure that you can set up your action to be shutting the computer down (although I'm not sure, since -- as stated -- I am not at home, where I have when-command installed on my machines).

In the online tutorial I found that one of the conditions is "Idle Session", and then you set the time idle to be 10 minutes. You might need to write a script that would then get called and it then actually does the shutdown, but maybe there is an included action for shutdowns.

Regards,

-- Slim
Respect science, respect nature, respect each other.

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline Slim.Fatz

  • Global Moderator
  • Veteran
  • *****
  • Posts: 2316
  • Karma: 614
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: auto logout
« Reply #2 on: April 13, 2016, 08:50:26 am »
Hi emegra,

At home now and my Peppermint Six with the when-command installation is up and running. As I suggested, it looks as if you could set this up to perform a shut-down (this would be a what is referred to as your "task" that you will need to write as a little shell script containing the shutdown command) after the computer as been idle for x minutes (this is what is referred to as the "condition" that, when met, results in when-command calling your shell script which actually performs the shutdown).

The steps are described my last post in the article that I linked into for you: first you must, of course, install the when-command. Rather than building it, I added Francesco Garosi's PPA containing the when-command by using the Y PPA Manager and installed a deb package that is for when-command (his current version is 0.9.10~beta.4).

Then start it and call up "Edit Tasks..." in the menu that pops up when clicking on the when-command icon. Give your task a Name (no spaces allowed) and for Command enter the path to your shell script (or, if it is in your system PATH I guess the path to the script is not required).

After creating the Task you create (or assign) the Condition by clicking again on the when-command icon and selecting "Edit Conditions...", give the Condition a Name (again, no spaces allowed) and in the drop-down list Type select Idle Session. You will now notice that the line named Command has suddenly disappeared and has been replaced by Idle Minutes where you would now enter 10. Now since you already have created your named Task, go down to the text box below and Add your named Task -- it should appear in the drop down list below the text box and to the left of the Add button (click on that button on the left to open this drop-down list of your named Tasks).

That basically is it.

Regards,

-- Slim
Respect science, respect nature, respect each other.

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: auto logout
« Reply #3 on: April 13, 2016, 09:41:41 am »
Are we talking logout or shutdown (after inactivity) ?
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Slim.Fatz

  • Global Moderator
  • Veteran
  • *****
  • Posts: 2316
  • Karma: 614
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: auto logout
« Reply #4 on: April 13, 2016, 10:59:06 am »
Hi,

Oh, sorry  :-X I guess he was wanting to log out not shutdown. Still the same ideas apply when you use when-command -- you just need to have your script start a logout rather than a shut down after the 10 minutes of inactivity.

Regards,

-- Slim
Respect science, respect nature, respect each other.

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
Re: auto logout
« Reply #5 on: April 13, 2016, 12:24:08 pm »
Hi Slim.Fatz

Thanks for your help with this and sorry for taking a while to respond, I've been crazy busy at work and doing a lot of work at home which is where this issue has arose, I'm moving my study into another room because I now have 2 Grandchildren who need the bigger room.

my oldest Grand-Daughter has her own PC but due to space restrictions I'm removing her PC and giving her an account on my wifes PC so I want to make it that anytime she goes to use her computer she has to log in to her own account otherwise if the PC is sitting logged into my wifes account she'll be tempted to just use that.

I didn't think this would be quite so complicated but it sounds quite straightforward nonetheless and just to clarify I don't want to shutdown I only want to logout but it seems the same rules apply more or less so I'll give your suggestion a go and post back with the results as soon as possible

Once again thanks for your help it's much appreciated


Graeme
« Last Edit: April 13, 2016, 12:26:05 pm by emegra »
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline Slim.Fatz

  • Global Moderator
  • Veteran
  • *****
  • Posts: 2316
  • Karma: 614
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: auto logout
« Reply #6 on: April 13, 2016, 12:42:12 pm »
Hi emegra,

Glad to be of assistance and I hope this is what you are seeking to solve your problem/question.  :)

Hope to hear soon that you have got it working.  8)

Regards,

-- Slim
Respect science, respect nature, respect each other.

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: auto logout
« Reply #7 on: April 14, 2016, 07:24:12 am »
I can give you a 'dirty' method to do this .. but it will NOT save any data from open applications

If you're happy that:
Code: [Select]
lxsession logoutlogs you out in a suitable fashion....



Create an executable script that runs that command:
Code: [Select]
sudo gedit /usr/bin/my-custom-autologoutmake it read
Code: [Select]
#!/bin/sh
lxsession logout
SAVE the file and exit gedit.

now make it executable with:
Code: [Select]
sudo chmod +x /usr/bin/my-custom-autologoutNext install xautolock:
Code: [Select]
sudo apt-get install xautolockthat's the utility that's going to keep an eye on keyboard/mouse/touchpad activity and run the above script after a predefined period of inactivity.

Now create an autostart file to that tells xautolock to run the my-dirty-autologout script after 15 mins of inactivity (you'll have to create one of these in every account that you want to autologout .. so basically at least in your wifes account):
Code: [Select]
gedit ~/.config/autostart/my-custom-autologout.desktopmake it read
Code: [Select]
[Desktop Entry]
Type=Application
Name=My Dirty AutoLogout
Exec=bash -c "xautolock -time 15 -locker my-custom-autologout"
Icon=lxde-logout
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
SAVE the file and exit gedit.

this command isn't *necessary*, but If you want the .desktop file to display the icon, make it executable
Code: [Select]
chmod +x ~/.config/autostart/my-custom-autologout.desktopNow log off/on to activate.



You can change the "-time 15" to whatever you want .. it counts in minutes, so that's 15 mins of inactivity

if at any time you want to stop the xautolock utility from counting, just kill it with:
Code: [Select]
sudo killall xautolock
« Last Edit: April 14, 2016, 01:29:46 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
Re: auto logout
« Reply #8 on: April 14, 2016, 08:08:58 am »
I tried for a short while this morning using Slim Fatz suggestion with When-Command but I was getting an error installing it so I give up intending having another shot when I have a bit more time, I did however get it installed on my work computer but didn't have time setting it up  but it does look like a very useful tool nonetheless.

@Mark
Looking at your pkill x suggestion I'm a bit concerned about not saving any work, wouldn't
Code: [Select]
lxsession logout be a little less dirty ?




Graeme




« Last Edit: April 14, 2016, 08:22:52 am by emegra »
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: auto logout
« Reply #9 on: April 14, 2016, 01:25:14 pm »
lxsession logout won't save any work either, but you're probably right it may be cleaner (though I have a feeling it doesn't do much other than kill the x session anyway) so I'll modify the above instructions to use lxsession logout instead ;)
« Last Edit: April 14, 2016, 01:27:32 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
Re: auto logout
« Reply #10 on: April 15, 2016, 12:38:17 am »
Quote
lxsession logout won't save any work either, but you're probably right it may be cleaner (though I have a feeling it doesn't do much other than kill the x session anyway)

running pkill x & lxsession logout appears to do exactly the same thing however i suppose i could change the command to
Code: [Select]
lxsession users-switch which appears to save the session before logging out.

anyway in the meantime I followed you instructions and it works perfect so thanks for that

I'm still trying to figure out When-Command because I really like to look of that application and once I figure out how to set it up properly it could be very useful for setting up other automated tasks so thanks to Slim Fatz for bringing it to my attention


Graeme

If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26452
  • Karma: 65531
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: auto logout
« Reply #11 on: April 15, 2016, 03:47:49 am »
Thanks for that I was looking for the user-switch command :)

BUT

What makes you think that saves the session first ? .. it certainly doesn't save any open docs/apps before closing (at least not on my system) ?
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline Slim.Fatz

  • Global Moderator
  • Veteran
  • *****
  • Posts: 2316
  • Karma: 614
  • Where's the mouse?
    • View Profile
  • Peppermint version(s): Peppermint 7, 8.5 & 10 - 64bit
Re: auto logout
« Reply #12 on: April 15, 2016, 05:29:05 am »
I'm still trying to figure out When-Command because I really like to look of that application and once I figure out how to set it up properly it could be very useful for setting up other automated tasks so thanks to Slim Fatz for bringing it to my attention

Graeme
Hi Graeme,

First of all, you are welcome. Secondly, what problems are you having with the when-command program?

Regards,

-- Slim
 
Respect science, respect nature, respect each other.

Tread lightly: Fluxbox, JWM, i3, Openbox, awesome

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
Re: auto logout
« Reply #13 on: April 15, 2016, 05:56:18 am »

Quote
What makes you think that saves the session first ? .. it certainly doesn't save any open docs/apps before closing (at least not on my system) ?

There does seem to be a difference in as much as user-switch takes much longer to execute which I thought meant it was saving the session but you're right it doesn't save any running applications but try it with a web page open with user-switch when you log back in and reopen Firefox it will take you straight back to the web page you were on but with lxsession-logout you'll be taken to the restore page titled "Well this is embarassing" (you know the one I mean) at least that's how it's working on my system



Graeme
If you can keep your head while all around are losing theirs then you're not quite grasping the situation

Offline emegra

  • Administrator
  • Veteran
  • *****
  • Posts: 1946
  • Karma: 450
  • New Forum User
    • View Profile
  • Peppermint version(s): Peppermint 10 64bit
Re: auto logout
« Reply #14 on: April 15, 2016, 06:07:04 am »

Quote
First of all, you are welcome. Secondly, what problems are you having with the when-command program?

I only had a short spell with it, I'm notorious for not reading tutorials and just messing about with things until I get them to work but in a nutshell I'm not sure where I place the working directory and what I should be putting in it, I did try putting an executable script in the working folder and locating it in /home/Documents but that didn't seem to work, then I ran out of time, but I think with a bit more time I can work it out or study the tutorials a bit more




Graeme
If you can keep your head while all around are losing theirs then you're not quite grasping the situation