diff options
author | Simon Rettberg | 2018-10-17 11:10:49 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-10-17 11:10:49 +0200 |
commit | 7a3e38c6a3f6e333b7346099c08dd201c81f5a19 (patch) | |
tree | 44dc197c9f6327f693328450362a10e7fe04c4d0 /core/modules/idleaction | |
parent | [vmware12] Fix broken keymap when leaving vm (terminal etc.) (diff) | |
download | mltk-7a3e38c6a3f6e333b7346099c08dd201c81f5a19.tar.gz mltk-7a3e38c6a3f6e333b7346099c08dd201c81f5a19.tar.xz mltk-7a3e38c6a3f6e333b7346099c08dd201c81f5a19.zip |
[xscreensaver/vmware12] Support ungrab hooks, work around idletime reset
vmware ungrab code has to fake mouse cursor movement, resetting PC idle
time :-( - Now we can't record the PC idle time the moment the screen
saver turned on anymore, since it will be reset at that point.
Diffstat (limited to 'core/modules/idleaction')
-rw-r--r-- | core/modules/idleaction/data/etc/cron.d/openslx-idleaction | 2 | ||||
-rwxr-xr-x | core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script | 20 |
2 files changed, 19 insertions, 3 deletions
diff --git a/core/modules/idleaction/data/etc/cron.d/openslx-idleaction b/core/modules/idleaction/data/etc/cron.d/openslx-idleaction index 9669add9..a7f342a0 100644 --- a/core/modules/idleaction/data/etc/cron.d/openslx-idleaction +++ b/core/modules/idleaction/data/etc/cron.d/openslx-idleaction @@ -3,5 +3,5 @@ SHELL=/bin/ash PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin -*/2 * * * * root /opt/openslx/scripts/idleaction-cron_script +* * * * * root /opt/openslx/scripts/idleaction-cron_script 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 f40ffa34..78e0212b 100755 --- a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script +++ b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script @@ -92,6 +92,10 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then 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" + if [ -n "$LOCK" ]; then + TIMEOUT=$(( LOCK + SLX_LOGOUT_TIMEOUT )) + sed -i "s/^lockDeadline=.*\$/lockDeadline=$TIMEOUT/" "$RUNFILE" + fi fi if [ -n "$LOCK" ]; then # Screen is locked, ignore further idle time updates @@ -113,7 +117,20 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then IDLE="$LOCK" fi if [ -n "$IDLE" ] && [ "$IDLE" -gt 0 ]; then - TIMEOUT=$(( IDLE + SLX_LOGOUT_TIMEOUT )) + if [ -z "$LOCK" ] || grep -Fxq 'lockDeadline=0' "$RUNFILE"; then + # Only update if screen is unlocked, or no deadline was recorded yet + TIMEOUT=$(( IDLE + SLX_LOGOUT_TIMEOUT )) + sed -i "s/^lockDeadline=.*\$/lockDeadline=$TIMEOUT/" "$RUNFILE" + else + # Use stored value + RET=$(awk -F= '{if ($1 == "lockDeadline") { print $2; exit } }' "$RUNFILE") + if [ -n "$RET" ]; then + TIMEOUT="$RET" + else + TIMEOUT=$(( IDLE + SLX_LOGOUT_TIMEOUT )) + echo "lockDeadline=$TIMEOUT" >> "$RUNFILE" + fi + fi if [ "$TIMEOUT" -lt "$NOW" ]; then rm -f -- "$RUNFILE" @@ -121,7 +138,6 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then loginctl terminate-session "$ses" else IS_IDLE=no - sed -i "s/^lockDeadline=.*$/lockDeadline=$TIMEOUT/" "$RUNFILE" fi else # xprint* did not work? |