summaryrefslogtreecommitdiffstats
path: root/core/modules/idleaction
diff options
context:
space:
mode:
authorSimon Rettberg2018-10-12 15:08:07 +0200
committerSimon Rettberg2018-10-12 15:08:07 +0200
commitae4ea3674d19d20fa30b946cc9a8674393f62b1d (patch)
tree348c7aa3684655aa01b73e17f09c9f1e85492461 /core/modules/idleaction
parent[idleaction] Account for 5 minute delay when calculating shutdown (diff)
downloadmltk-ae4ea3674d19d20fa30b946cc9a8674393f62b1d.tar.gz
mltk-ae4ea3674d19d20fa30b946cc9a8674393f62b1d.tar.xz
mltk-ae4ea3674d19d20fa30b946cc9a8674393f62b1d.zip
[idleaction] Remember lock time and reset idletime if changed
If a user unlocks the session and locks it again within two minutes, the idle timeout will not be reset. Even worse, this also happens when you manage to logout and in (as a different user) within two mins.
Diffstat (limited to 'core/modules/idleaction')
-rwxr-xr-xcore/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script28
1 files changed, 18 insertions, 10 deletions
diff --git a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
index 33a64cdb..df1e8f0d 100755
--- a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
+++ b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
@@ -87,20 +87,26 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then
# the idle time of when the screen was locked - look it up and if not found, write current value
RUNFILE="/run/idleaction-$DISPLAY"
[ -f "$RUNFILE" ] || gen_runfile > "$RUNFILE"
- if [ -z "$LOCK" ]; then
- # Not locked anymore, nuke old value
- sed -i '/^lockIdleTime=/d' "$RUNFILE"
- else
+ OLDLOCKTIME=$(awk -F= '{if ($1 == "lockTime") { print $2; exit } }' "$RUNFILE")
+ [ -z "$OLDLOCKTIME" ] && OLDLOCKTIME=0
+ if [ -z "$LOCK" ] || [ "$(( OLDLOCKTIME - LOCK ))" -gt 120 ] || [ "$(( LOCK - OLDLOCKTIME ))" -gt 120 ]; then
+ # Not locked anymore, or lock time has changed (= unlock and relock), nuke old value
+ sed -i '/^lockIdleTime=/d;/^lockTime=/d' "$RUNFILE"
+ fi
+ if [ -n "$LOCK" ]; then
# Screen is locked, ignore further idle time updates
RET=$(awk -F= '{if ($1 == "lockIdleTime") { print $2; exit } }' "$RUNFILE")
if [ -z "$RET" ]; then
if [ -z "$IDLE" ]; then
IDLE="$LOCK"
fi
- echo "lockIdleTime=$IDLE" >> "$RUNFILE"
+ {
+ echo "lockIdleTime=$IDLE"
+ echo "lockTime=$LOCK"
+ } >> "$RUNFILE"
else
# Use previous value
- IDLE="$RET" # XXX
+ IDLE="$RET"
fi
fi
if [ -z "$IDLE" ] && [ -n "$LOCK" ]; then
@@ -210,10 +216,12 @@ write_crontab ()
}
if [ -n "$SLX_SHUTDOWN_SCHEDULE" -o -n "$SLX_REBOOT_SCHEDULE" ] && [ ! -e "$CRONFILE" ]; then
- echo "# OpenSLX: Trigger poweroff/reboot at certain time of day" > "$CRONFILE"
- echo "SHELL=/bin/ash" >> "$CRONFILE"
- echo "PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin" >> "$CRONFILE"
- echo "" >> "$CRONFILE"
+ {
+ echo "# OpenSLX: Trigger poweroff/reboot at certain time of day"
+ echo "SHELL=/bin/ash"
+ echo "PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"
+ echo ""
+ } > "$CRONFILE"
write_crontab "poweroff" "$SLX_SHUTDOWN_SCHEDULE"
write_crontab "reboot" "$SLX_REBOOT_SCHEDULE"
# Might want to re-set rtcwake timestamp periodically