Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save macmule/2490c91405fa3b7446a19fa13c36ca6d to your computer and use it in GitHub Desktop.

Select an option

Save macmule/2490c91405fa3b7446a19fa13c36ca6d to your computer and use it in GitHub Desktop.
#!/bin/bash
####################################################################################################
#
# License: https://macmule.com/license/
#
###################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
###
# Get the Username of the logged in user
###
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
###
# Prompt the user for the location of the folder that they wish screen shots to be created in
###
folderPath=$(osascript -e 'try
tell application "SystemUIServer"
choose folder with prompt "Which folder would like screenshots to go to? (the default location is your Desktop)"
set folderPath to POSIX path of result
end
end')
# Echo chosen location
echo "User has chosen $folderPath..."
# Update User plist
defaults write /Users/"$loggedInUser"/Library/Preferences/com.apple.screencapture location "$folderPath"
# As we're root, amend ownership back to set for plist
chown "$loggedInUser" /Users/"$loggedInUser"/Library/Preferences/com.apple.screencapture.plist
# Correct the file mode
chmod 755 /Users/"$loggedInUser"/Library/Preferences/com.apple.screencapture.plist
# Restart SystemUIServer for changes to take affect
killall SystemUIServer
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment