MacOS – create two different Docks that I can switch back and forth between

dockmacos

I have two different accounts right now – one for work, one for play. It helps me stay focused, and it's quite useful.

However, sometimes I don't really love switching back and forth between user accounts sometimes. Thus, I've thought up an idea: What if I had 2 different Docks that I could switch between with a keyboard shortcut?

Thus, my question: Can I create 2 different Docks with 2 different sets of apps on each of them that I can switch between with a keyboard shortcut?

Example: Dock 1 has Finder, Mail, Safari, iTunes, Chrome, Trash on it; Dock 2 has Finder, Firefox, Trash, Opera, and Dictionary on it. I press Command-Option-0 and it switches to Dock 2. I press it again and it switches to Dock 1.

Best Answer

You could use an Automator service or one of the global-keybaord-trigger apps to run a script that switches between two different Dock preference plist files and then relaunches the Dock.

#!/bin/sh
#you'd have a dock-work.plist and dock-home.plist file 

cd ~/Library/Preferences/

if [ -e dock-is-work.state ] ; then 
    rm dock-is-work.state
    touch dock-is-home.state

    #save changes to existing Dock setup
    cp com.apple.dock.plist com.apple.dock-work.plist

    #copy home setup to main preference location
    cp com.apple.dock-home.plist com.apple.dock.plist
else
    rm dock-is-home.state
    touch dock-is-work.state

    #save changes to existing Dock setup
    cp com.apple.dock.plist com.apple.dock-home.plist

    #copy work setup to main preference location
    cp com.apple.dock-work.plist com.apple.dock.plist
fi

osascript -e "tell application \"Dock\" to quit"

(I haven't done bash if-then-else in awhile, so this might not execute as is.)