Idle Logouts in Mac Labs

Idle Logouts in Mac Labs

janvier 18, 2013 Add Comment

I've been playing with Real Studio recently and have been enjoying my learning experience. Justin Elliott has been giving me some extra help when I get stuck and we ended working on an app together for our labs.

Problem:
Users sometimes forget to log out, this can be a security risk. Using AppleScripts or safe commands to log users out doesn't always work as expected, think open Microsoft Word doc with changes. In order to force users to log out, we needed to develop an application to do so.

Solution:
The PSU Idle Logout.app was written in Real Studio to force machines to reboot when users hit a specified idle time. The time is specified in a plist and compared to the amount of time the USB HID devices (mouse and keyboard) have been idle. Here is the line of code used to get that time:
echo $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))
If time reaches what has been specified as the idle limit, the computer will reboot by running a script. This solution requires that the /etc/sudoers file is modified so that standard users can reboot the machine with the script. See the GitHub repository for more information!

The Real Studio code and application are available on GitHub for modification and use. Please let me know if it helps you!

Update:
The repository has been moved into the CLC Mac Team organization in GitHub. Please use this link:
https://github.com/CLCMacTeam/IdleLogout