Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Navigable 'Volumes' pop-up in dock System
In systems prior to 10.1, you could use some trickery with the /Volumes folder to keep a navigable list of internal and external drives as a pop-up folder in your dock. With 10.1, something changed in the manner in which links and aliases are resolved, and this no longer works. It's still trivial to have your internal drives in such a folder, but CD-ROMs and other removables will no longer show as navigable via drop-down menus.

David Nelson, author of two recently published scripts here, has written another AppleScript which handles this process in 10.1 and later. Due to the size of the script, it's not reproduced here, but is available on my idisk; click the link to download Drive Alias Tender. The archive expands into a folder containing the script and a ReadMe file. It's simple to use - find a place to store the folder, double-click the script, and you're running.

David hasn't tested this script extensively, but I've been running it (with a much slower update interval) for a few days with no problems at all.

The only downside to the script that I see is that it creates a dock icon, since it must always be running in order to update the drive folder's contents. I haven't played around with it, but it seems you could probably change the script from always-run to run-once, and then set a cron job to run the AppleScript at certain intervals ... but that's pure conjecture on my part. If there's anyone with some time on their hands who wishes to experiment with it, it would be interesting to find a way to make it work "in the background".

Read the rest of the article if you'd like to see the steps David took to develop the script; it's sort of interesting to see what he had to do to make this thing work (reposted with his permission)...

Here's how David went about solving the problem of updating the folder for newly added volumes:
I realized that this type of thing would require a stay open script, which is not ideal since it clutters up the Dock, so I looked for other solutions before I started writing a script.

My first thought was to put /Volumes in the dock. Interestingly, when I did this the aliases showed up in the pop-up menu for /Volumes in the dock, but they were not navigable; no triangle, no pop-up menu. :( I suspect the "Aliases" that are created in /Volumes are not normal Aliases.

That seemed to be a deadend, so I went ahead and wrote a script. I don't know how many people will want to use it considering that it needs to be running all the time to work, but it was an interesting exercise, and it could be useful to people as example code. Or heck maybe people will want to use it, I'm really not good at predicting these things. :) It is a cool idea, and will be one of my first projects as a get Pearl figured out, then it could run as a cron job completely in the background.

Here's a brief description of how it works. Note: The word alias is used to describe a type of file reference in AppleScript, as well as to refer to shortcut files in the Finder. This can get a little confusing, so I will trying to say alias reference when I am talking about a file reference, and alias file when I am talking about a shortcut file in the Finder. BTW An alias reference is a reference to an item that will not break if the item is moved or renamed.

The script maintains its collection of alias files to your drives in a folder named "Drives" which is in the same folder as the script. This is of course the folder you want to stick in the dock.

The script uses a run handler, which contains statements that are run once when the script is first launched, and an idle handler, which contains statements that are run at a specified interval, in this case every ten seconds. Between calls to the idle handler the script is truly idle, using 0% of the CPU, according to top.

The statements in the run handler move any alias files that exist in the Drives folder to the system's temporary items folder, so it starts fresh whenever it is launched. Items in the temp folder are deleted by the system when you reboot, or maybe when you log out, not sure. Anyhow, I send things there instead of the trash, so the user is not bothered by aliases mysteriously showing up in the trash. If you want to see exactly where they go run (path to temporary items) in Script Editor.

The statements in the idle handler do everything else, and then they do it again ten seconds later. :-)

The first job is to set a bunch of variables we will need. These include a list of alias references to all disks known to the Finder, a list containing the names of each of these disks, a list of all alias references to the alias files in the Drives folder, and a list containing the names of each of these alias files.

Next we check the list containing the names of the alias files in the Drives folder, against the list of disk names, and remove any alias files that don't have a corresponding disk. You guessed it, we send them to the temporary items folder.

Finally we check the list of disk names against the list containing the names of the alias files in the Drives folder, and create alias files for any disks that don't have one.

That's it.

I have been letting this script run on my system for an hour, and it does not seem to be doing anything strange, but that is all the testing I have done. If you wish to post it you are welcome to.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[2,814 views]  

Navigable 'Volumes' pop-up in dock | 1 comments | Create New Account
Click here to return to the 'Navigable 'Volumes' pop-up in dock' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use crontab
Authored by: james_sorenson on Dec 13, '01 07:29:11PM

Nicely done script! I altered it to be a "run-once" script, and then I added a line in my crontab file so that the script is called every minute. If you save the script as a compiled document (instead of an application), you'll never see the applescript icon appear in the dock.

The crontab command is as follows:
/usr/bin/osascript $HOME/Scripts/DriveFolder.scpt;

where DriveFolder.scpt is my modified script. Just do a quick search for "crontab" if you need help setting it up.

Currently, I still use my DragThing trick, but this script just might come in handy.



[ Reply to This | # ]