summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-13 17:46:36 +0200
committerSimon Rettberg2015-09-13 17:46:36 +0200
commit634c928b6d82136e63d0fce052e1b0cd359fdf1e (patch)
treec3a4ac9d9c525cca61caac34cbbadfe5c06a6fc6 /remote
parentbrainfart (diff)
downloadtm-scripts-634c928b6d82136e63d0fce052e1b0cd359fdf1e.tar.gz
tm-scripts-634c928b6d82136e63d0fce052e1b0cd359fdf1e.tar.xz
tm-scripts-634c928b6d82136e63d0fce052e1b0cd359fdf1e.zip
[idleaction] Fix automatic shutdown when logout timeout AND shutdown timeout are both set
Diffstat (limited to 'remote')
-rwxr-xr-xremote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script24
1 files changed, 15 insertions, 9 deletions
diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
index 17633caa..9a9bdf1c 100755
--- a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
+++ b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
@@ -28,13 +28,19 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then
# X11
if [ -n "$DISPLAY" ]; then
# Seems to be x11
- USRHOME=$(/usr/bin/getent passwd "$NAME" | awk -F ':' '{print $6}')
- export XAUTHORITY="$USRHOME/.Xauthority"
+ IDLE=
+ export XAUTHORITY=$(ps a | grep -v grep | grep -o -- '-auth.*$' | awk '{print $2}')
+ [ -n "$XAUTHORITY" ] && [ -f "$XAUTHORITY" ] && IDLE=$(xprintidle)
# Now that we have DISPLAY and XAUTHORITY set, xprintidle should work
- IDLE=$(xprintidle)
+ if [ -z "$IDLE" ]; then
+ # Try user's xauth
+ USRHOME=$(/usr/bin/getent passwd "$NAME" | awk -F ':' '{print $6}')
+ export XAUTHORITY="$USRHOME/.Xauthority"
+ [ -f "$XAUTHORITY" ] && IDLE=$(xprintidle)
+ fi
if [ -n "$IDLE" ]; then
IDLE=$(( $IDLE / 1000 ))
- if [ "$IDLE" -lt "$SLX_LOGOUT_TIMEOUT" ]; then
+ if [ -z "$IDLE" ] || [ "$IDLE" -lt "$SLX_LOGOUT_TIMEOUT" ]; then
IS_IDLE=no
else
loginctl terminate-session "$ses"
@@ -63,11 +69,11 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ] && [ "${SLX_LOGOUT_TIMEOUT}" -gt 0 ]; then
# end other sessions
done
rm -f -- "$TMP"
- if [ "$IS_IDLE" = "yes" ]; then
- [ ! -e "$IDLEHINT" ] && echo "$NOW" > "$IDLEHINT"
- else
- rm -f -- "$IDLEHINT"
- fi
+ fi
+ if [ "$IS_IDLE" = "yes" ]; then
+ [ ! -e "$IDLEHINT" ] && echo "$NOW" > "$IDLEHINT"
+ else
+ rm -f -- "$IDLEHINT"
fi
else
# No logout timeout is set, take shortcut for shutdown timeout (if set)