Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 58 lines (42 sloc) 2.45 KB
#!/bin/sh
# add /Applications/TotalFinder.app in user's login items
osascript -e 'tell application "System Events"' -e 'make login item at end with properties { name:"TotalFinder", path:"/Applications/TotalFinder.app", kind:"application", hidden:false }' -e 'end tell'
# tweak finder settings to play nice with TotalFinder
/usr/bin/defaults write com.apple.finder DisableAllAnimations -bool true
/usr/bin/defaults write com.apple.finder _FXShowPosixPathInTitle -bool false
/usr/bin/defaults write com.apple.finder AnimateWindowZoom -bool false
/usr/bin/defaults write com.apple.finder FXDisableFancyWindowTransition -bool true
sleep 2
TMP=`sw_vers -productVersion|grep '10\.\(8\|9\|10\)'`
if [ $? -eq 0 ]; then
# the goal here is to relaunch Finder.app under the right user aka "Mach bootstrap namespace"
# note: we can have multiple users logged in concruently (for fast user switching), each has its own loginwindow process
# in $OUTPUT we will list all loginwindow processes and pick only the one belonging to the currently logged-in user
USERID=`id -u "$USER"`
OUTPUT=`ps -lax | grep '[l]oginwindow.app' | grep "^[ ]*$USERID "`
if [ -n "$OUTPUT" ]; then
set - $OUTPUT
PID=$2
echo "login window user name is \"$USER\" and PID is \"$PID\""
if [[ -n "$USER" && -n "$PID" ]]; then
/bin/launchctl bsexec "$PID" /usr/bin/env -i /usr/bin/su "$USER" -c "/usr/bin/open /Applications/TotalFinder.app"
fi
fi
else
# since 10.11
echo "detected El Capitan or higher"
# launchctl bsexec magic does not work anymore under 10.11 (El Capitan)
# we have to follow https://lists.macosforge.org/pipermail/launchd-dev/2015-July/001139.html
LAUCH_AGENTS_BOOT_PLIST_PATH="/Library/LaunchAgents/com.binaryage.totalfinder.agent.plist"
LAUNCHD_BOOT_PLIST_SOURCE="/Applications/TotalFinder.app/Contents/Resources/TotalFinder.bundle/Contents/Resources/com.binaryage.totalfinder.agent.plist"
echo "installing $LAUCH_AGENTS_BOOT_PLIST_PATH"
cp "$LAUNCHD_BOOT_PLIST_SOURCE" "$LAUCH_AGENTS_BOOT_PLIST_PATH"
USERID=`id -u "$USER"`
echo "loading boot launch agent via /bin/launchctl bootstrap gui/$USERID"
/bin/launchctl "bootout" "gui/$USERID" "$LAUCH_AGENTS_BOOT_PLIST_PATH" # just for case it is still loaded
/bin/launchctl "bootstrap" "gui/$USERID" "$LAUCH_AGENTS_BOOT_PLIST_PATH"
echo "grep of launch agents lists: `launchctl list | grep com.binaryage`"
sleep 2
echo "removing $LAUCH_AGENTS_BOOT_PLIST_PATH"
rm "$LAUCH_AGENTS_BOOT_PLIST_PATH"
fi
You can’t perform that action at this time.