jump to navigation

Now, that is justice… April 12, 2009

Posted by bigmaconcampus in Rhinoism.
Tags: , ,
add a comment

Rhinoism of the day:

“Can you kill someone, if they killed you first?”

Mirror, mirror on my Mac April 2, 2009

Posted by bigmaconcampus in Mac Tech.
2 comments

While working on a lockdown mechanism recently, I needed to activate mirroring on displays when necessary via command-line. The method uses Applescript and GUI scripting, not my preferred method but does what it needs.

In the applescript, I pass it a variable from the parent script, either on or off and expect to possibly get a returned variable of true, if applicable, so I can run the command again later if I need to turn mirror mode back off.

*Note* Scripts tend to cut off visually on screen. You can copy/paste the script to grab it.


on run argv
set TOGGLE to item 1 of argv
if TOGGLE is "on" then
set TOGGLE to "1" as integer
else
set TOGGLE to "0" as integer
end if
try
tell application "System Preferences"
activate
reveal anchor "displaysArrangementTab" of pane id "com.apple.preference.displays"
tell application "System Events"
tell application process "System Preferences"
tell window 1
tell group 1 of tab group 1
if value of checkbox "Mirror Displays" is not TOGGLE then
set TurnOffMirror to "true"
click checkbox "Mirror Displays"
tell application "System Preferences" to quit
return TurnOffMirror
end if
end tell
end tell
end tell
end tell
end tell
on error
tell application "System Events"
tell application process "System Preferences"
keystroke return
end tell
end tell
end try
tell application "System Preferences" to quit
end run

An alternative I found works well, but didn’t totally fit my needs. It toggles mirror mode on and off. I need it to toggle only under certain circumstances. Still, might be useful to someone else, and best of all it’s open source.

http://www.fabiancanas.com/Fabian_Canas/Projects/Entries/2009/2/4_Mirror_Displays.html