Joan7770
Posts: 3
Joined: Thu Mar 01, 2018 10:35 pm

Auto logout

Thu Mar 01, 2018 10:38 pm

How do I set the raspberry pi to auto-logout from the desktop environment?

klricks
Posts: 6503
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Auto logout

Fri Mar 02, 2018 2:22 am

Joan7770 wrote:
Thu Mar 01, 2018 10:38 pm
How do I set the raspberry pi to auto-logout from the desktop environment?
Do you really mean loggout? or is screen lock sufficient?

For screen lock you can use xscreensaver and set lock screen after x min.

Code: Select all

sudo apt install xscreensaver
There are also several other screenlock packages in the repository.

For a real logout, one way is to install xautolock which will run any command or program after a set idle time or when the mouse is placed on a certain position on the screen.

Code: Select all

sudo apt install xautolock
You can run pkill -u pi to force logout user pi.

Code: Select all

sudo pkill -u pi
Put together:

Code: Select all

xautolock -time 5 -locker "sudo pkill -u pi" &
This will logout user pi after 5 min idle.
The above command could be put in autostart so that it runs each time the user logs in or reboots.

Code: Select all

home/pi/.config/lxsession/LXDE-pi/autostart
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Joan7770
Posts: 3
Joined: Thu Mar 01, 2018 10:35 pm

Re: Auto logout

Fri Mar 02, 2018 6:36 am

I looked at the manual for pkill and the way you use it would just kill all processes, I was thinking more like being taken to the login screen while all processes would still be running in the background.

Would xscreensaver achieve this or will it just be a graphical screensaver that disappears after a key press or mouse movement?

klricks
Posts: 6503
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Auto logout

Fri Mar 02, 2018 8:21 am

Joan7770 wrote:
Fri Mar 02, 2018 6:36 am
I looked at the manual for pkill and the way you use it would just kill all processes, I was thinking more like being taken to the login screen while all processes would still be running in the background.

Would xscreensaver achieve this or will it just be a graphical screensaver that disappears after a key press or mouse movement?
pkill -u pi will kill all user processes then logout and wait at the login screen..... Same as logging out by using the menu. No user processes will be running either way. This is what is meant when you asked about "logout from the desktop environment"...........

xscreensaver has an option to lock the screen after a period of inactivity so that the users password is required to unlock the screen. All processes will remain intact.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Joan7770
Posts: 3
Joined: Thu Mar 01, 2018 10:35 pm

Re: Auto logout

Fri Mar 02, 2018 9:27 pm

Ok yes thank you

FerociousRPi
Posts: 7
Joined: Tue Jun 30, 2015 10:14 pm

Re: Auto logout

Fri Apr 20, 2018 3:07 pm

"xscreensaver" doesn't seem to be available anymore.... Any other solution?

Thanks!

$ sudo apt install xscreensaver
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package xscreensaver is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'xscreensaver' has no installation candidate
Last edited by FerociousRPi on Fri Apr 20, 2018 3:27 pm, edited 2 times in total.

fruitoftheloom
Posts: 20169
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Auto logout

Fri Apr 20, 2018 3:16 pm

FerociousRPi wrote:
Fri Apr 20, 2018 3:07 pm
"xscreensaver" doesn't seem to be available anymore....

$ sudo apt install xscreensaver
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package xscreensaver is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'xscreensaver' has no installation candidate

Did you update first ??

Code: Select all

sudo apt-get update
sudo apt-get install xscreensaver
adieu

Asus CS10 Chromebit / HP Envy 4500 Wireless Printer / Raspberry Pi Model 2B v1.1 / RealVNC Software...

Return to “Raspbian”