session-cleanup-script=/usr/share/lightdm_kill_sleep.sh &
It seems like need to have that if the user is still active e.g. like when switch but log back in. Is that the same as lock screen in your situation?
The modifications are as below (I am a newbie thus some lines could be simplified further):
#!/bin/sh
# lightdm_sleep.sh
file="/tmp/unique_identifier"
(while true; do sleep 60; systemctl suspend; done) &
echo $! > $file
#!/bin/sh
# lightdm_kill_sleep.sh
file="/tmp/unique_identifier"
if [ -f "$file" ]
then
kill `cat $file`
rm $file
fi
# in lightdm.conf
greeter-setup-script =/usr/share/lightdm_sleep.sh &
session-setup-script =/usr/share/lightdm_kill_sleep.sh &
session-cleanup-script=/usr/share/lightdm_kill_sleep.sh &
So far the system behave as I expected.
]]>Ideally that darn thing would not inhibit anything, but it seems that "light-locker-command -q" queries the locking state, so you could have a watchdog (cron job, ever running script, ...) that queries the lock state and kills the suspend script.
Ever looked into an alternative locker like i3lock?
]]>The script would certainly have to be modified somehow. Currently it won't let the greeter start. I have no idea how to make a wrapper script though.
]]>I have no idea how to solve this without being forced to manually kill the script everytime I unlock the screen.
]]>#!/bin/sh
(while true; do sleep 60; systemctl suspend; done) &
echo $! > /tmp/unique_identifier
#!/bin/sh
kill -- -`cat /tmp/unique_identifier`
notice the weird dash row!
Remaining task will be to find a unique and assigned filename, but if you've only one lightdm process running, you can just name it "lightdm_suspend_pid" or so.
]]>I have a problem with killing the script after logging in.
At first I tried to put the killall command in session-setup-script, but the command kept failing forcing the lightdm to restart spawning new loops of the suspend script.
session-setup-script='killall lightdm_sleep.sh'
Secondly, I tried to make a script out of it. Now I can login again, but suspend script is not killed. I have no idea why.
#!/bin/bash
killall lightdm_sleep.sh
EDIT: When I try to kill the lightdm_sleep.sh from terminal, I need root privileges as the script was run as root by lightdm. But lightdm should run the second script as root too, so that shouldn't be a problem.
]]>did you check whether lightdm inhibits systemd?
Yes and it doesn't. Or at least it shouldn't.
But I checked it while logged in too and there is xfpm listed to inhibite closing of the lid. But I know it doesn't so who knows how the inhibiting works. It seems buggy.
Try to fork inside the script:
#!/bin/sh (while true; do sleep 60; systemctl suspend; done) &
Thanks, that worked.
Well I guess the issue is solved.
Thank you for your help, seth.
#!/bin/sh
(while true; do sleep 60; systemctl suspend; done) &
For the trailing "&" in the config to work, lightdm would have to intepret it (like any shell interpreter), eg. by calling the *script* (not "command") through a wrapping shell.
ooc, did you check whether lightdm inhibits systemd?
]]>You might be able to mitigate this behavior using the "greeter-setup-script" and "session-setup-script " keys in the lightdm config where the first would start a script to sleep 10 minutes and the suspend where the latter would kill that script again.
Yes I thought about this too actually, but haven't figured out how to make it run as I need to.
At first, I used this script:
sleep 60 && systemctl suspend
That worked, but it only suspended the system once, before putting the password in and locking it back again.
So if I would woke it by accident more than once, it wouldn't help.
Then I tried to make a loop
while :
do
sleep 60
systemctl suspend
done
But now the greeter wouldn't even start as it always waited for the loop to finish (which would never happen). So I was only waking the system up periodically to a black screen.
Then I tried to "run the script in the background".
greeter-setup-script='/opt/lightdm_sleep.sh &'
Which got me a flickering black screen.
I'm not very skilled in bash scripting. Is there a way to make this work?
]]>If lightdm uses the systemd infrastructure (and doesn't talk to xfpm directly) you should be able to confirm this with "systemd-inhibit --list"
You might be able to mitigate this behavior using the "greeter-setup-script" and "session-setup-script " keys in the lightdm config where the first would start a script to sleep 10 minutes and the suspend where the latter would kill that script again. (This however ignores interaction w/ lightm, but it will take only few seconds to enter credentials)
Notice that I do not know whether that works when using lightm to "lock" the session as well.
]]>However, when the screen is locked by lightdm or when nobody is logged in, the system won't suspend.
I need the system to suspend after 10 min idle when the screen is locked by 'dm-tool lock' (lightdm) or when no user is logged in, but lightdm is running.
The 'no user logged in' part is not that important as I'm logged in most of the time.
But it does happen that I accidentally wake up the system from sleep, but then I do not enter any password. The system is idle on lightdm password prompt for locked screen and will never suspend again.
Or did I get your post wrong and you want the DM to suspend the system on idleness? (I thought you need to invoke it and wanted to get rid of it)
https://joeyh.name/code/sleepd/ used to provide this, but is now unmaintained (will likely still work, though)
My /etc/systemd/logind.conf
IdleAction=suspend
IdleActionSec=1min
default for IdleActionSec was 30min, so I suppose I can use values in minutes.
phalkon ~ $ sudo systemctl status systemd-logind.service
[sudo] password for phalkon:
● systemd-logind.service - Login Service
Loaded: loaded (/usr/lib/systemd/system/systemd-logind.service; static; vendor preset: disabled)
Active: active (running) since Wed 2017-02-15 11:50:45 CET; 14min ago
Docs: man:systemd-logind.service(8)
man:logind.conf(5)
http://www.freedesktop.org/wiki/Software/systemd/logind
http://www.freedesktop.org/wiki/Software/systemd/multiseat
Main PID: 460 (systemd-logind)
Status: "Processing requests..."
Tasks: 1 (limit: 4915)
CGroup: /system.slice/systemd-logind.service
└─460 /usr/lib/systemd/systemd-logind
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event4 (Power But
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event5 (Video Bus
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event6 (Video Bus
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event1 (Power But
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event2 (Lid Switc
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event3 (Sleep But
Feb 15 11:50:45 HAL9000 systemd-logind[460]: Watching system buttons on /dev/input/event12 (Acer WMI
Feb 15 11:50:52 HAL9000 systemd-logind[460]: New session c1 of user lightdm.
Feb 15 11:53:32 HAL9000 systemd-logind[460]: Removed session c1.
Feb 15 11:53:32 HAL9000 systemd-logind[460]: New session c2 of user phalkon.
As you can see in this log I waited almost 3 minutes before logging in, which should be enough for the system to suspend.
It won't suspend the system when nobody is logged in nor when the screen is locked.
Also, as I understand it, it should suspend the system even when I'm logged in and the screen isn't locked, but that also doesn't work.
I use modified lightson script for setting xfpm into presentation mode to prevent system from suspend while watching youtube videos.
I assume logind would ignore xfce presentation mode if it worked properly, wouldn't it?
EDIT: Forgot to mention that I have no other config files mentioned in logind.conf man page that could override the settings.
]]>Currently, if I startup the system but won't login, the system stays on and won't suspend after a period of no input.
Also, when the system is accidentally woken up from suspend, but no password is given to unlock it, it won't suspend again.
I use xfce as a DE. Xfpm to setup when to suspend the system. Modified xflock4 script locks the screen with 'dm-tool lock' before suspending.
]]>