Saturday, December 1, 2007

Corrections to Automator Post

A week or two ago, I posted a suggestion on how to change the Dock background. I then commented on that blog about how it doesn't work right. Well, I have finally figured out a few things on how to make it work properly. First, the attached link takes you to a page with many new Dock designs to download for free. There is even an app to help change the Dock, but I had problems with it and so I still had to write my own. What I discovered is that even though you can use shell scripts, you can't use sudo. And if you don't have permission to make the change and are never prompted for a password, the shell script simply exits without making all the changes. So, I had to rethink my method of changing the dock. Plus, I didn't want to have to write a script for every single new Dock background I wanted. So, I developed a slightly longer version that asks you where the files are. This also allowed me to incorporate some other features such as changing just the separator or just the indicators. Thus, I now have 4 scripts to change the Dock as follows:

ModifyDockIndicators
ModifyDockSeparator

ModifyDockTheme
RestoreOriginalDock

I think these are all fairly self explanatory. The idea is that ModifyDockTheme will copy all .png files from a folder and replace them in Dock.app. So you could have a veritable theme with total customization of the Dock. I did not include a ModifyDockBackground script because I figure I'd use the theme more and if I wanted to I could simply use the other scripts to change the indicators or separator to what I want.

Here is a screenshot for Restoring the Dock. This is one is particularly important because I run it in all the other scripts so as to always start from the original.
I minimized all the scripts because the titles are most important. The first step gets the resources folder in Dock.app. It creates an alias to it on the desktop. This is extremely important because for some reason the finder scripts in Automator don't allow access to protected folders. By doing this the alias doesn't seem to be protected. Also notice that some of these scripts don't have arrows connecting them. If you aren't familiar with Automator, you can right-click on the title and tell it to ignore input. This is also important and handy to keep Automator from getting confused. Next I tell it to get specified finder items, this is the folder that contains my backup of the original Dock. The next line gets the contents of that folder, then I filter it by .png, and finally copy them to the alias on the desktop. Be sure to tell the copy command to overwrite existing files. The shell script only does one thing, killall Dock. Lastly, I get the alias and move it to the trash to clean up my desktop.

Now, I'm not entirely sure why this works where the last one fails. It never asks me for a password to make the change. But it has been flawless ever since I wrote it. Now, save this script as an app. Keep it in a location where you keep all your apps and never move it or your other scripts will be broken.

Next is a screenshot for modifying the Dock theme. You don't have to have a theme really, but this script filters all .png files in the folder of your choice, so if you only have the 4 scurve files, those will get copied. But if you have a full-blown them, all .png files will get copied. Here's how it goes.

The first step uses the restore script to bring the Dock back to factory specs. For the theme script, I chose to do this all the time so we don't get a mixture of themes. I follow all the same steps as before, only this time you'll notice that I ask for finder items. This will prompt you to pick a folder containing .png files for the Dock. It will filter all .png files, copy them into the alias, restart the Dock and delete the alias, just as before. Pretty simple huh.

Lastly, you may want to change only the separator or only the indicators. It is the same script as above except I've included an applescript to prompt whether or not you want to restore the Dock first. The pause is important because sometimes it doesn't perform the operation fast enough and you end up with two aliases on the desktop, then it only deletes the one. So be sure to include the pause for proper cleanup. Also, there is one other key thing. When you filter you have to put in indicator for the indicator script, or separator for the separator script. Since the only files in a Dock theme that contain those names are .png, it is safe not to look specifically for an image file.

I've placed all of these in a folder where I keep all my custom designed workflows and apps. I created an alias to that folder and placed it in my scripts folder so it'll show up in my scripts menu. I did this because I was tired of trying to keep track of all the copies of scripts I have and where they are stored. So now I create aliases to the original location and place the aliases in scripts or finder plugins. This keeps all my scripts in my Documents folder under Scripts where I can keep a very organized hierarchy as well as keep them in a consistent place and never move them, ensuring that they always work.

As a last comment to all of this, you can see how running three scripts could create a custom them. You can run the ModifyDockTheme script to change the overall appearance, then run the Indicator and Separator scripts to alter those to your liking. And guess what, it doesn't take much effort to see that all you have to do to save your custom theme is write another automator script to filter the .png files from the resources folder and copy them to a new folder of your choice of name. You can have an endless supply of personal themes.

I hope you've enjoyed this Automator and Dock changing tutorial, and I apologize for the misinformation from before.

Apple Feedback

No comments:

Post a Comment