I work in a studio where several people often need to briefly share information with the entire room”like to review drawings or graphics before printing or rendering.
Rather than gathering around everyone’s individual monitors, I wanted a way to send video to another, communal screen.
Our studio includes a mac mini that spends the rest of the day as a server and jukebox; the mini has a big screen attached, perfectly positioned for viewing by the entire room.
I wrote this pair of scripts to make a “reverse screen sharing grabber.” Now when someone says “put it on the big screen,” a script on my computer activates screen sharing on the mini, which in turn sends a call to grab my screen.
For this setup, we we will call the computers Sender1 (bonjour name sender1.local) and Catcher (bonjour name catcher.local)
To keep my Sender1’s password available, but hidden, I put it in a Keychain Item on Catcher, using the bonjour name of the computer. (/Applications/Utilities/Keychain Access.app, File > New Password Item…)
on Catcher, i saved this Applescript as “ScreenSharingSwitch.app”
tell application "Keychain Scripting"
tell keychain 1
unlock
set theKey to first key whose name is "Sender1.local"
set theUsername to (account of theKey) as string
set thePassword to (password of theKey) as string
end tell
end tell
if application "Screen Sharing" is running then
do shell script "ps ax | grep " & (quoted form of "Screen Sharing") & " | grep -v grep | awk '{print $1}' | xargs kill -9"
else
tell application "Screen Sharing" to open location "vnc://" & theUsername & ":" & thePassword & "Sender1.local"
end if
when triggered, the script scans processes on Catcher”if Screen Sharing is already running, it terminates the process; if Screen Sharing is not running, it grabs Sender1’s screen. Thus, one call to start, or one call to stop.
I put ScreenSharingSwitch.app in /Library/Scripts so it could be available to all users.
on Sender1, I saved this Applescript as “ScreenSharingSender.app”
do shell script "ssh catcher.local \"open /Library/Scripts/ScreenSharingSwitch.app\""
this sends the call to Catcher to run ScreenSharingSwitch.app.
Finally, I want ScreenSharingSender.app to run without asking for a password in terminal, so I created an RSA Authentication Key between Sender1 and Catcher.
on Sender1, I mounted Catcher as a network volume.
Then in Terminal:
then:
finally, I copied the RSA key to Catcher:
Now the command runs without asking for a password.
This set-up is effective, but the scripts only work between one pair of computers.
It would be better if ScreenSharingSender.app could run from any computer, like Sender2, Sender3, etc., which could simply identify itself when making the call, something like…
set theHostname to do shell script “hostname”
do shell script “ssh catcher.local "open /Library/Scripts/ScreenSharingSwitch.app"” [+ pipe theHostname to Catcher]
then pass that to ScreenSharingSwitch.app as part of the open location.
tell application “Screen Sharing” to open location “vnc://” & theUsername & “:” & thePassword & theHostname
but I have reached the limits of my ability for today, and I would love any input from the community.
Thanks for reading!!