Skip to content
Snippets Groups Projects

Remove systemd-autologout script.

Merged Tom Teichler requested to merge systemd-autologout into master
2 files
+ 0
29
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 0
27
#!/bin/sh
# Maximum idle time in seconds
MAXIDLE=604800
# Get current UNIX timestamp
now=$(date +%s)
# Get IDs of all current sessions known to logind
sessions=$(loginctl list-sessions | awk 'NR<2 { next }; { if (!NF) exit; print $1 }')
for session in $sessions; do
# Get time sicne when session is idle; truncating six least significant digits to get UNIX timestamp
idlesince=$(loginctl show-session -p IdleSinceHint "$session" | sed -e 's/IdleSinceHint=//' -e 's/......$//')
# Skip session if not idle
test x"$idlesince" = x"0" && continue
# Calculate whether session is older than $MAXIDLE; use bc for 64-bit arithmetic
left=$(echo "$MAXIDLE < ($now - $idlesince)" | bc)
# If idle for too long, terminate
if test x"$left" = x"1"; then
logger -t systemd-autologout "Terminating session $session"
loginctl terminate-session "$session"
fi
done
Loading