Posted on 07-31-2012 02:16 PM
We have our Macs set to auto-logout after 5 minutes of inactivity. Is there a way to script a dialog box to come up before the logout? Something along the lines of: "You are about to be logged out due to inactivity. Press continue if you wish to continue using this computer." Then, if they don't click continue, they are forced out.
Solved! Go to Solution.
Posted on 07-31-2012 02:43 PM
CocoaDialog is nice. I've been playing with it since it was suggested here, but its not going to help you figure out the logic of how to get that message to pop up before the Mac is about to log out. It only facilitates the mechanism to display a message to the user and get input it can act on.
To make something come up after, say, 4 minutes of idle time on the Mac, you might want to take a look at SleepWatcher- http://www.bernhard-baehr.de
It takes a little work to figure out how to use it, and you would need to package it and deploy to your Macs (but that's true for CocoaDialog as well) But it allows you to trigger a script on an idle time (that you can specify) or sleep/wake. I've used it in the past and its handy. Only thing is, it installs a System StartupItem to do its work, so you'll have to decide if you really want to use something like that.
Another way to do it to get idle time with ioreg. See this older hints article. The command still works as of 10.7.4
http://hints.macworld.com/article.php?story=20040330161158532
You could use the above to trigger a script at the 4 minute idle time mark to alert them it will log out in one minute, for example.
Posted on 07-31-2012 02:20 PM
http://mstratman.github.com/cocoadialog/
its the best tool i have found for augmenting messaging to the users in packages and scripts.
Posted on 07-31-2012 02:43 PM
CocoaDialog is nice. I've been playing with it since it was suggested here, but its not going to help you figure out the logic of how to get that message to pop up before the Mac is about to log out. It only facilitates the mechanism to display a message to the user and get input it can act on.
To make something come up after, say, 4 minutes of idle time on the Mac, you might want to take a look at SleepWatcher- http://www.bernhard-baehr.de
It takes a little work to figure out how to use it, and you would need to package it and deploy to your Macs (but that's true for CocoaDialog as well) But it allows you to trigger a script on an idle time (that you can specify) or sleep/wake. I've used it in the past and its handy. Only thing is, it installs a System StartupItem to do its work, so you'll have to decide if you really want to use something like that.
Another way to do it to get idle time with ioreg. See this older hints article. The command still works as of 10.7.4
http://hints.macworld.com/article.php?story=20040330161158532
You could use the above to trigger a script at the 4 minute idle time mark to alert them it will log out in one minute, for example.
Posted on 01-06-2014 09:01 AM
It's been a while, so I thought I would revisit my original question. I looked at CocoaDialog, SleepWatcher, and ioreg, but I'm having a hard time bringing it all together smoothly. Granted, I am a bit of a scripting novice...
Here's what I'd like to do:
When the computer reaches a specified idle time, prompt a dialog box warning of an auto logout, give the user a minute or so to over-ride, if not, auto logout.
Any help from those with a better grasp of scripting (probably all of you) would be MUCH appreciated - many free drinks at the next JNUC.
Posted on 01-06-2014 10:56 AM
@tep,
Because you're using the system's auto logout functionality to trigger at 5 minutes, you may want to consider creating either a LaunchAgent or LaunchDaemon to run every 10-15 seconds to check the idle time and pop up the message after say, 4 minutes, to give the warning before auto logout. If you used the jamf check in, even if you have it set for every 5 minutes, there would likely be cases where the check in would happen after the 5 minutes of idle time, which wouldn't be very helpful.
I haven't used SleepWatcher in a long while despite my recommendation above, so I don't know how much I could help you with that. But for a script using ioreg, it wouldn't be hard to get something whipped up.
This actually leads me to a question though. Since I don't have that option set on our Macs I'm not sure, but doesn't the OS already pop up a logout warning about 1 minute before it auto logs out? If so, is that not sufficient as is?