Skip to content

Instantly share code, notes, and snippets.

@jachwe
Last active September 14, 2015 13:19
Show Gist options
  • Save jachwe/cbe0b209aa4c2334bd85 to your computer and use it in GitHub Desktop.
Save jachwe/cbe0b209aa4c2334bd85 to your computer and use it in GitHub Desktop.
Little snippet to capture the current screen in OSX and set it as Background Picture. Works for multiple Desktops by just ignoring errors. :-) Useful if you got a fullscreen App that might crash and have a fallback with a still image while restarting. I use this quite often in a tradefair context... have fun!
# usage: ./snapdesk.sh user@localhost
TARGET=$1
echo $TARGET;
ssh $TARGET << 'ENDSSH'
mkdir -p ~/snapdesk;
screencapture ~/snapdesk/1.png ~/snapdesk/2.png ~/snapdesk/3.png ~/snapdesk/4.png ~/snapdesk/5.png;
osascript -e 'tell application "System Events" to set picture of desktop 1 to "~/snapdesk/1.png"'
osascript -e 'tell application "System Events" to set picture of desktop 2 to "~/snapdesk/2.png"'
osascript -e 'tell application "System Events" to set picture of desktop 3 to "~/snapdesk/3.png"'
osascript -e 'tell application "System Events" to set picture of desktop 4 to "~/snapdesk/4.png"'
osascript -e 'tell application "System Events" to set picture of desktop 5 to "~/snapdesk/5.png"'
ENDSSH
scp -r $TARGET:./snapdesk/ "./snapdesk_$TARGET"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment