Is there a setting to auto logout the user from XSession or LXDE desktop after a period of inactivity?
Here is an easy looking method, but I haven’t tested it: Auto Logout Inactive Users After A Period Of Time In Linux - OSTechNix
So looks like the
TMOUT variable is used by X desktops in general to log out after it’s value in seconds inactivity.
but this is for command line access, isn’t it? At least I tested method 2 and got logout from CLI/SSH but was staying active on a desktop.
Oh, then I was interpreting it wrongly. Still an interesting feature I didn’t know before.
Probably this works for desktops? Debian -- Details of package autolog in bullseye
sudo apt install autolog sudo nano /etc/autolog.conf
Most desktops have a feature to lock the screen on inactivity, but your really want to have a logout, right?
This has been my experience when I tried it. It works great to logout an SSH session but not a remote desktop or remote vnc session.
Exactly. I want to logout the user that way, if a desktop session is left open for too long, all apps will be closed and the user logged out.
My use case:
I am running Diet Pi on a Nano Pi device with 512MB RAM and the only browser that I can get to run decent on LXDE is Palemoon (I tried Midori, Falcon Firefox and all those eat up more ram than the device has) . However when I leave Palemoon running, it is always hitting 450MB and sometimes higher. I want to a logout the user and close the apps to make sure the memory doesn’t go into swap if the session is idle.
I have tried the autolog and so far it works when I am running a remote SSH session but it’s still not logging out / closing my desktop connection after the idle time. This is my configuration file. I am not sure what to add to logout from and RDP session
group=root idle=2 grace=10
name=root idle=2 grace=10 nomail
group=users idle=2 grace=10 hard ban=2 clear
name=guest idle=2 grace=10 hard ban=2 clear
name=root idle=2 grace=10 hard ban=2 clear
Okay so now we have a way for individual users to control their auto logout and one for the admin to control user’s auto logout, but both for console only . We need to search further for desktop logouts. This will be btw the same on all distros, but probably individual for specific desktop environments.
some ask a similar question on the RPi forum. But no real solution Auto logout - Raspberry Pi Forums
This has promise. But killing the user is not the best option. If the user is logged in as root, this will also kill all processes. But killing the desktop works. I am just not sure if this is good in the long run since it’s not a clean exit.
this command worked for my desktop
xautolock -time 1 -locker “sudo pkill lxsession” &
The question is how do I make this run in the background on session start. I tried adding a desktop entry to the autostart folder, but didn’t work. Suggestions?
It’s shell syntax so it should work to put the command into a script and call that script with an autostart desktop entry.
I tried that but can’t get it to launch on login and xsession start.
I added the file to ~/.config/autostart and /home/dietpi/.config/autostart
Here is my desktop file
Exec=xautolock -time 1 -locker “sudo pkill lxsession” &
anything else I should try.
I mean to put
xautolock -time 1 -locker “sudo pkill lxsession” & into a dedicated shell script file and call that dedicated file from the desktop entry.
I had tried all that and at the end, I created it as a service. The one important parameter is to pass the DISPLAY environment variable in the service. Without that the script didn’t work.
Thanks for all the help.
This is my working service file
Description=kill lxsession service
ExecStart=xautolock -time 1 -locker “pkill lxsession”
Thankyou for the help!