keeping my custom leopard stack overlays in front!
i've been using leopard for a couple of weeks now. and i don't know about you, but i have a hard time telling at a glance which stack is which... a handful of blogs have posted about the japanese blogger (note: blog is all in japanese) who hooked us up with really spiffy custom stack overlays. now the overlays are available in color, and there are a ton more of them.
the latest version of the overlay icons come pre-tweaked, so they'll work whether you sort by name, by "date modified", or by "date created". but my downloads stack is sorted by "date added", and the it turns out that "date added" is tough to spoof with timestamps.
a couple of blogs have posted applescript or automator solutions, but none of them were quite slick enough for me. so here's my shot at it:
- download the custom stack overlays, choose some you like, and add them to your stacks. if you have the old overlays already, make sure to grab the new ones for this to work.
- download and unzip my refresh stack overlays script.
- copy it to
/Library/Scripts/Folder Action Scripts - add the new folder action to any folder you want—i use it on "ToDo" and "Downloads". (instructions for adding folder actions here).
- whenever a file is added to your folder, the stack overlay will move to the front.
in case you're interested, here's the script
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set file_list to name of every file of this_folder
repeat with this_item in file_list
if this_item begins with " " and this_item ends with " .app" then
set icon_name to this_item
exit repeat
end if
end repeat
do shell script "mv -f " & quoted form of (POSIX path of this_folder & icon_name) & " /tmp"
do shell script "mv -f " & quoted form of ("/tmp/" & icon_name) & " " & quoted form of (POSIX path of this_folder)
end tell
end adding folder items to













Comments
That's pretty slick. How'd you find out all of that nifty AppleScript stuff???
That's pretty rad, mine actually work already without doing any script work. I don't know why but it I think it's because my folder is organized backwards or something so that the oldest thing shows up first. I'm not sure how it works.
The only other thing I wish I could do now on my dock is put all my active applications in a stack. I mostly don't do anything with the icons down there and when I'm running a lot of stuff it gets a little crowded down there.
I followed ur instructions and can't seem to get it to work.
Oops nevermind I configured Folder Actions instead of Added it. Works now. Thanks, it's awesome!
no problem :)
Hi Justin,
I've noticed that the folder actions are not enabled everytime I startup. (Hence I have to enable folder actions for my Download folder.)
Is there some way to automatically enable folder actions after startup?
Thanks in advance!
Kenny
that's strange. i've never run into that problem. you should only have to enable folder actions once. good luck figuring it out...
i learned it from *nix...
i think it's funny that the best way i could figure out to do the two main lines of the program was with shell commands instead of applescript :)
This is really cool. I use it now for my downloads and it works great. But I was wondering if you have a script for sorting it by "kind". I have my applications sorted by kind and I need a script to put the stack overlay before all the applications.
Thanx
unfortunately that's not as easy... (as if writing this script was all that easy). i've been looking but haven't found a good solution for sorting by kind yet. sorry.
Very slick, thanks! One thing I've noticed is that when I download a .DMG with Safari and it opens it automatically, the folder action doesn't always go through. I'm not sure if it's renaming xxx.download to xxx.dmg or something to that effect, but I sometimes find the stack icon not on top.
i've noticed that happening occasionally too... i'll see if i can figure this one out.
Hey, I don't know much about applescript, but i have an idea on how to solve the .dmg thing.
a) Write something that does an auto refresh every few seconds.
b) Detect change within the folder? As in, detect the renaming of a file done by Safari.
i thought of the same thing. unfortunately i haven't found a folder action that will deal with renaming (and most of the forums and discussions i've found have the same problem).
I think I have solved this problem. Why it works is way beyond me. But it seems to work on my set-up.
The other thing I've yet to figure out is how to prevent the foreground app from losing focus when the script runs. An tips on that?
Here is the improved code that deals with file renaming:
on removing folder items from this_folder after losing removed_items
ApplyStackOverlay(this_folder)
end removing folder items from
on adding folder items to this_folder after receiving added_items
ApplyStackOverlay(this_folder)
end adding folder items to
on ApplyStackOverlay(this_folder)
tell application "Finder"
set file_list to name of every file of this_folder
repeat with this_item in file_list
if this_item begins with " " and this_item ends with " .app" then
set icon_name to this_item
exit repeat
end if
end repeat
if not (exists ("/tmp/" & icon_name)) then
do shell script "mv -f " & quoted form of (POSIX path of this_folder & icon_name) & " /tmp &"
do shell script "mv -f " & quoted form of ("/tmp/" & icon_name) & " " & quoted form of (POSIX path of this_folder) & " &"
end if
end tell
end ApplyStackOverlay
yay! almost... I've been running into myriad issues trying to get this to work-- mainly that the stack overlays are empty apps, and leopard won't show the icons in the stack, only a "prohibited application" icon (default apps icon with a (\) symbol). Any ideas on how to work around that?
I also keep fiddling with .png files and gotten them to work but leopard is being waffly with whether it wants to put the white "frame" behind the transparent icon or not.
actually i ran into that exact problem. it seems that when that happens, dragging the overlay onto the desktop then back into the stack often fixes it. if that doesn't work, dragging it from the .dmg to the desktop to the stack usually works. i'm not sure why the drawer icons are like that, but they seem to do much better with a layover on the desktop than they do with a direct flight.
the best way to fix this problem is to restart the Dock... type this in the terminal:
killall DockI just reformatted my Mac and doing the usual custom set-up stuff -- which now includes applying your overlay script to my two "downloads" folders. I just wanted to stop by and formally thank you for this kick-ass work! The other scripts are kludgy (and my own attempt wasn't much better) but yours works really, really well. Thanks again!