You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-monitor/SOURCES/session-monitor.sh

19 lines
395 B

#!/bin/bash
check_session_state() {
active_session=$(loginctl | grep "online" | awk '{print $1}')
for session in $active_session; do
current_state=$(loginctl show-session $session -p Active --value)
if [[ $current_state == "no" ]]; then
/usr/bin/loginctl lock-session $session
fi
done
}
while true; do
check_session_state
sleep 1
done