Posted on 09-16-2014 09:49 AM
Currently we use the Guest User login on the library computers which works great but occasionally students forget to logout on their own. Normally we use the auto-logout if computers has been idle for more than 30min, but since Guest User has a dialog box warning before the logout I cannot get the Guest User to automatically logout. We do not use FV2.
I am having difficultly figuring out a script to do any of the following: forcing a logout after idle time of 30 minutes, modifying the auto-logout to ignore the dialog box, or disabling the dialog box (I would prefer the dialog box stay for normal logout).
Thanks,
Edmund
Solved! Go to Solution.
Posted on 09-16-2014 10:59 AM
#!/bin/sh
IdleTimeSecs=$(expr $(ioreg -c IOHIDSystem | awk '/HIDIdleTime/{print $NF; exit}') / 1000000000)
echo "$IdleTimeSecs"
The first line will pull system idle time in seconds. You can test it by adding a sleep 20 or whatever command before the IdleTimeSecs line.
All you'd need to do is incorporate that into a script called by say, a LaunchAgent that runs every 10 seconds (10 seconds is the shortest time interval they can use) that checks the idle time and sees if its equal to or more than 1800 (30 minutes x 60 seconds = 1800 seconds) and if so, runs the logout functions like above.
I wouldn't even try using your usual every x trigger for Casper for something like this, since the likelihood of it running exactly at or even near 30 minutes idle time is nearly impossible. Use a local LaunchAgent or LaunchDaemon, though an Agent would be better since trying to get some of the logout commands to run from a Daemon/root can be a little tricky due to sandboxing in the OS.
Posted on 09-16-2014 09:56 AM
have you thought about using applescript to grab the window of the dialog box and click the "Ok" button, which I'm guessing it says ok. So that when it runs and forces the logout, the box will pop up and then it could grab that window and click ok. Just a thought, I've done something like this before.
Posted on 09-16-2014 10:01 AM
# Force logout
killall -3 WindowServer
Posted on 09-16-2014 10:09 AM
#!/bin/bash
## TO LOGOUT THE USER ##
### ENVIRONMENT VARIABLES ###
# Get the currently logged in user
user=`ls -l /dev/console | cut -d " " -f4`
###### DO NOT MODIFY BELOW THIS LINE #######
command='/usr/bin/osascript <<END
try
tell application "System Events"
log out
end tell
END'
# Set the LoginItem
su - "${user}" -c "${command}"
exit 0
-- INSERT
Posted on 09-16-2014 10:28 AM
Sorry I should clarify, I'm having trouble incorporating the trigger of Idle time of 30min into that forced logoff.
Posted on 09-16-2014 10:59 AM
#!/bin/sh
IdleTimeSecs=$(expr $(ioreg -c IOHIDSystem | awk '/HIDIdleTime/{print $NF; exit}') / 1000000000)
echo "$IdleTimeSecs"
The first line will pull system idle time in seconds. You can test it by adding a sleep 20 or whatever command before the IdleTimeSecs line.
All you'd need to do is incorporate that into a script called by say, a LaunchAgent that runs every 10 seconds (10 seconds is the shortest time interval they can use) that checks the idle time and sees if its equal to or more than 1800 (30 minutes x 60 seconds = 1800 seconds) and if so, runs the logout functions like above.
I wouldn't even try using your usual every x trigger for Casper for something like this, since the likelihood of it running exactly at or even near 30 minutes idle time is nearly impossible. Use a local LaunchAgent or LaunchDaemon, though an Agent would be better since trying to get some of the logout commands to run from a Daemon/root can be a little tricky due to sandboxing in the OS.
Posted on 09-17-2014 11:16 AM
Thank you very much mm2270 and tkimpton.
Posted on 01-25-2019 07:28 AM
@osbalde Do you have a completed script you can share? I'd like to also force logout the Guest User after say 10 idle minutes or so...