Automatically Change Your Dock Design 2

Terminal

Share
Automatically Change Your Dock Design

Hey

This tip was submitted by Sam. If you have any tips you want to share please contact me and I would be happy to talk to you. This tip is designed to automatically change your dock design every so often, automatically. I have posted before about changing your dock design. This post is designed so your dock will change automatically.

First download a couple of dock designs from your favourite dock design site. I like Leopard Docks. Open up /System/Library/CoreServices/Dock.app/Contents/Resources/ in Finder and copy in your dock designs naming them dock1.png dock2.png etc. At this time backup scurve-m.png. This script will replace the scurve-m.png file with your dock design. Its a good idea to have this file backed up.

Open up Terminal and type the following.

cd /System/Library/CoreServices/Dock.app/Contents/Resources/

That will but you inside the dock application. We are going to create a small bash script to automatically change the dock. For easy of use and size we are going to place it in this folder. In Terminal type.

sudo nano dockchanger

You will have to enter you admin password since we are playing with a system protected directory. In nano copy and paste or type the following.

#!/bin/sh
while [ "forever" ]
do
sudo  cp -r dock1.png scurve-m.png
killall Dock
sleep 15
sudo  cp -r dock2.png scurve-m.png
killall Dock
sleep 15
sudo  cp -r dock3.png scurve-m.png
killall Dock
sleep 15
sudo cp -r dock4.png scurve-m.png
killall Dock
sleep 15
sudo cp -r dock5.png scurve-m.png
killall Dock
sleep 15
done

This will replace the scurve-m.png file with your dock design file every 15 seconds (I think). You can change the time to suit. This will then kill the dock so you can see the new design. Save the file by pressing Control + C and giving it a name.

In Terminal again type:

sh dockchange

You have to make sure that you are in you dock folder from earlier. If everything worked your dock should then start to get replaced. To end the script press Control + C in Terminal.

There are some cavets with this script. You have to be in the dock folder to run it and you have to have Terminal open and type the long command for it to run. In a future post I am going to take this a bit further and combine it with cron.

If you want to get your old dock dock. Use your scurve-m.png file and copy it back into place.

If you want to take your skills with Terminal a bit further I recommend you check out the Terminal Category on this site. If you fancy reading a book there is a couple on Amazon that I regularly see mentioned and recommend, O’reilly Unix Geeks and Unix Under the Hood both are designed for Mac OS X and take Terminal further.


If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips