Finished up script.

This commit is contained in:
Josh Sherman 2015-01-15 21:47:40 -05:00
parent 9ed06b876e
commit 5c1c96c4ff

View file

@ -11,18 +11,16 @@ case $# in
killall Dock killall Dock
fi fi
else else
# Checks that a profile name was specified
case $1 in case $1 in
save|load) save|load)
if [ -z $2 ]; then if [ -z $2 ]; then
echo 'Error: You must specify a profile name' echo 'Error: You must specify a profile name'
exit 1 exit 1
else else
PROFILE=~/Library/Preferences/$2.com.apple.dock.json LOADED=~/Library/Preferences/com.apple.dock.plist
PROFILE=~/Library/Preferences/$2.com.apple.dock.plist
if [ $1 == save ]; then if [ $1 == save ]; then
# Checks if profile exists, if so, prompt to overwrite
if [ -e $PROFILE ]; then if [ -e $PROFILE ]; then
read -p "Would you like to overwrite the profile '$2' (y/n)? " -n 1 -r read -p "Would you like to overwrite the profile '$2' (y/n)? " -n 1 -r
@ -33,17 +31,19 @@ case $# in
fi fi
fi fi
defaults read com.apple.dock > $PROFILE defaults export $LOADED $PROFILE
else else
# Checks if profile exists, if not, error if [ ! -e $PROFILE ]; then
echo 'Error: Profile does not exist'
defaults delete com.apple.dock exit 1
defaults write com.apple.dock '`cat $PROFILE`' else
echo "defaults write com.apple.dock '`cat $PROFILE`'" defaults delete $LOADED
defaults import $LOADED $PROFILE
killall Dock killall Dock
fi fi
fi fi
fi
;; ;;
*) *)
echo 'Error: Invalid command, expecting reset, save or load' echo 'Error: Invalid command, expecting reset, save or load'