|
|
I've been trying to do this/sort of doing it for a couple years now. For most of that time I have been using Spirited Away, which has the annoying inability to auto-hide the active window. Because of this, to hide all windows you need to make sure there is no active window, most easily accomplished by clicking on the desktop. Still, this requires specific action, which is easy to forget, and requires "training" anyone who might come along and use the computer.
I noticed ericjay's answer when it was posted, and thought I might finally have a solution. Unfortunately, it wasn't a straightforward process, so I thought I'd share my eventual solution here.
First of all, you need spaces enabled. (Exposé leaves an annoying dark border around the desktop, and the Mac OS provides no convenient way of hiding the active window and all inactive windows at the same time).
On Mac OS 10.6, go to to the "Exposé and Spaces" pane in System preferences, and check the "enable spaces" box. Once spaces is enabled (of if it already was), ensure that you have an unused space you can dedicate to remaining empty. From here on out, I'll assume this is space number 2.
Also, make sure that, at the bottom of the pane, you have something bound to "To switch directly to a space". From here on out, I'll assume this is control (^ Number keys).
On Mac OS 10.7, spaces are part of Mission Control. Activate Mission Control, move the mouse to the top right of the screen, and click the "+" button which appears. This will open a new desktop space (which I am similarly going to assume is number 2, going forward), which should be kept empty of windows.
Also, once you've created a desktop space you can dedicate to remaining empty, go to the "Keyboard" pane of System Preferences, go to the "Keyboard Shortcuts" tab, select Mission Control from the list, and then expand the "Mission Control" sub-list item. Make sure that something is bound to "Switch to desktop 2", where "2" is the number of the desktop space you created. Going forward, I'll assume this is control.
Next, you'll need to install sleepwatcher. Basically, you need to create the directory /usr/local/sbin (sudo mkdir -p /usr/local/sbin), and move the sleepwatcher binary executable (sleepwatcher_2.2/sleepwatcher) into this directory. If you want the manpage, the Readme details its installation. Don't worry about installing any of the plist files.
Four short scripts will be needed, with execute permissions. You can put these in your home folder or somewhere like /etc, but I'll use the home folder:
touch ~/.{loginhook,logouthook,idle,idleresume}
chmod +x ~/.{loginhook,logouthook,idle,idleresume}
Now, because sleepwatcher idle commands don't seem to work using launchctl (why we didn't install the launchctl plists), we need to create a loginhook to run a sleepwatcher whenever a user logs in, and a logouthook to kill it when the user logs out (change "your_username" accordingly):
sudo defaults write com.apple.loginwindow LoginHook /Users/your_username/.loginhook
sudo defaults write com.apple.loginwindow LogoutHook /Users/your_username/.logouthook
Put the following lines in the ~/.loginhook script:
#!/bin/sh
/usr/local/sbin/sleepwatcher -d -t 150 -i /Users/your_username/.idle -R /Users/your_username/.idleresume
Change 150 to whatever delay you want, in tenths of a second (so 150 = 15 seconds).
And put the following lines in the ~/.logouthook script:
#!/bin/sh
kill -9 `ps ax | grep sleepwatcher | cut -d ' ' -f 3`
Write short command-line AppleScripts to change to the dedicated empty space upon idle, and back when the user resumes input. Assuming that the space is number 2, and that you used control as the key to go directly to a space,
In the ~/.idle script, add the following lines:
#!/bin/sh
osascript -e 'tell application "System Events" to keystroke "2" using control down'
Similarly, in the ~/.idleresume script, add the following lines
#!/bin/sh
osascript -e 'tell application "System Events" to keystroke "1" using control down'
Finally, logout, and log back in. Done!
|