Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions systemd/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ fi
/usr/bin/cp "$ROOT_DIR/system/codam-web-greeter-fetcher.sh" /usr/share/codam/codam-web-greeter-fetcher.sh
/usr/bin/cp "$ROOT_DIR/system/codam-web-greeter-idler.sh" /usr/share/codam/codam-web-greeter-idler.sh
/usr/bin/chmod 700 /usr/share/codam/codam-web-greeter-idler.sh
/usr/bin/cp "$ROOT_DIR/system/codam-web-greeter-idler-hook.sh" /usr/share/codam/codam-web-greeter-idler-hook.sh
/usr/bin/chmod 500 /usr/share/codam/codam-web-greeter-idler-hook.sh
/usr/bin/cp "$ROOT_DIR/user/codam-web-greeter-init.sh" /usr/share/codam/codam-web-greeter-init.sh
/usr/bin/cp "$ROOT_DIR/user/codam-web-greeter-cleanup.sh" /usr/share/codam/codam-web-greeter-cleanup.sh

Expand Down
15 changes: 15 additions & 0 deletions systemd/system/codam-web-greeter-idler-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# This script is executed after a user has been logged out due to inactivity by the codam-web-greeter-idler.sh script.
# It receives the following arguments:
# $1: username of the user that was logged out
# $2: idle time in milliseconds
# $3: time since screen was locked in milliseconds
# $4: max idle time in milliseconds
#
# You can use this script to perform custom actions, such as logging, notifications, coalition system integration, etc.
# It can be easily customized using the Ansible codam.webgreeter role.
#
# Example: Log the logout event to a file
# LOGFILE="/var/log/codam-web-greeter-idle-logout.log"
# echo "$(date): User '$1' was logged out due to inactivity (idletime: $2 ms, time_since_lock: $3 ms, max_idle_time: $4 ms)" >> "$LOGFILE"
11 changes: 9 additions & 2 deletions systemd/system/codam-web-greeter-idler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ while IFS= read -r line; do
MAX_IDLE_TIME_MINUTES=$((42))
MAX_IDLE_TIME=$((MAX_IDLE_TIME_MINUTES * 60 * 1000))
if [ "$IDLE_TIME" -gt "$MAX_IDLE_TIME" ] || [ "$TIME_SINCE_LOCK" -gt "$MAX_IDLE_TIME" ]; then
/usr/bin/echo "Session for user $USERNAME has been idle for over 42 minutes (idletime $IDLE_TIME ms, time_since_lock $TIME_SINCE_LOCK ms), forcing logout now by restarting lightdm"
/usr/bin/systemctl restart lightdm
/usr/bin/echo "Session for user $USERNAME has been idle for over 42 minutes (idletime $IDLE_TIME ms, time_since_lock $TIME_SINCE_LOCK ms), forcing logout now"
/usr/bin/loginctl terminate-user "$USERNAME" && /usr/bin/systemctl restart lightdm
# Run the hook script
if [ -f "/usr/share/codam/codam-web-greeter-idler-hook.sh" ]; then
/usr/bin/echo "Running custom codam-web-greeter post-idle logout hook script for user $USERNAME"
if ! /bin/bash /usr/share/codam/codam-web-greeter-idler-hook.sh "$USERNAME" "$IDLE_TIME" "$TIME_SINCE_LOCK" "$MAX_IDLE_TIME"; then
/usr/bin/echo "Warning: custom codam-web-greeter post-idle logout hook script failed for user $USERNAME" >&2
fi
fi
else
/usr/bin/echo "Session for $USERNAME has been idle for $((IDLE_TIME / 1000)) seconds, screen locked for $((TIME_SINCE_LOCK / 1000)) seconds"
fi
Expand Down