Hi…
I found a nice little script to reload the stack drawer icon on my dock. it basically move the icon form folder A to Folder B than back to A, keeping the icon always on top so i can sort by date added. it works but im try to make it work a little better. also it take a while run take about 7 second to work. sometimes my Folder Action Dispatcher process start run at 99%. little help please im a newbie…
here’s what i got
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 “.icns” 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
Here’s a couple ideas for you. First, we can find out if you have an icns file starting with a dash easier using a “whose” filter. Second, in order to refresh to dock icon I just quit the dock rather than moving files around. The dock gets automatically relaunched and all the icons will refresh.
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set icnsFiles to files of this_folder whose name extension is "icns" and name starts with "-"
end tell
if icnsFiles is not {} then tell application "Dock" to quit
end adding folder items to
i do have a .incs file for the dock drawer icon (-Downloads-.icns). With that script, when i add a item the stack it just relaunches the dock. the dock drawer icon doesn’t stay in the front.
I’m not sure what you’re saying. The icon should be the file with the alphabetically highest name. Quitting of the dock just gets the folder to refresh… just like your code of moving the icon to a different folder and then back again. If you don’t like the dock quitting then use your code. In either case you should use the code I gave to find the dock icon. It will be faster than your code and it will be item 1 of icnsFiles. Your script would be…
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set icnsFiles to files of this_folder whose name extension is "icns" and name starts with "-"
end tell
if icnsFiles is not {} then
tell application "Finder" to set icon_name to name of (item 1 of icnsFiles)
do shell script "mv -f " & quoted form of POSIX path of ((this_folder as text) & icon_name) & " /tmp"
do shell script "mv -f " & quoted form of POSIX path of ("/tmp/" & icon_name) & " " & quoted form of POSIX path of this_folder
end if
end adding folder items to
that works also…thanks. I was wondering if i was to specify the “icns” file in the script would it work faster. It still take around 10 secs to finish. Im sorting my download folder by Date Added. so when i add a file to the download folder i need the stack drawer icon “-downloads-.icns” to stay on top of the stack to stay visible.
here a pic
http://cl.ly/0N3M1p2A3W2z2k3a242T
UPDATE…
I applied the script to my application folder stack and it make my system hangs with the spinning color wheel for 2-3 minutes and then the stack icon refreshes.