1#!/bin/bash
2# Author: Zan Bassi
3# Email: zan@zeroonelabs.com
4#
5# Terms of service: Use at your own risk.
6#
7# Gets the username of the user currently logged in.
8# Will return "root" if no one is logged in through the Finder.
9currentuser="$(ls -l /dev/console | awk '{ print $3 }')"
10# Gets the full path of the user home folder.
11# Will return "/var/root" if no user is logged in through the Finder.
12curuserhome="$(dscl . read /Users/"${currentuser}" NFSHomeDirectory | awk -F": " '{print $NF}')"
13
14# If there is a user logged in (who is not root), set it for that person.
15if [[ ! ${currentuser} = "root" ]];then
16 echo "Setting bottom-left hot corner for ${currentuser}."
17 defaults write "${curuserhome}"/Library/Preferences/com.apple.dock.plist wvous-bl-corner -int 5
18 echo "Setting status bar Finder preference for ${currentuser}."
19 defaults write "${curuserhome}"/Library/Preferences/com.apple.finder ShowStatusBar -bool true
20fi
21defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
22
23_setPrefForAll () {
24 # Will return an array of full paths for any local user accounts on the machine.
25 # Each array index is separated by a newline character.
26 uhomearray=($(dscl . list /Users NFSHomeDirectory | grep -vE "/var|_www|^com" | awk '{print $NF}'))
27 # For each index in the array, do:
28 for UHOME in ${uhomearray[@]};do
29 # defaults write /Users/xxx/Library/...
30 echo "Setting bottom-left hot corner for the following user path: ${UHOME}."
31 defaults write "${UHOME}"/Library/Preferences/com.apple.dock.plist wvous-bl-corner -int 5
32 echo "Setting status bar Finder preference for the following user path: ${UHOME}."
33 defaults write "${UHOME}"/Library/Preferences/com.apple.finder ShowStatusBar -bool true
34 done
35}
36_setPrefForAll
37exit