Created
November 21, 2021 16:07
-
-
Save macmule/2490c91405fa3b7446a19fa13c36ca6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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