Tips, Tricks & Hacks for OS X

Earlier, I discussed how to control your torrents from a remote machine using Transmission, but for simply adding new torrents to Transmission, it turns out there’s an even simpler solution, using, yet again, Dropbox.  (I swear, they aren’t paying me!  I just really love this app!)

# 1.  Create a “watch folder” for new Torrents in Dropbox.

First create a folder where you’ll download new torrents you want added to your home server running Transmission.  I called mine, um, Torrents.

# 2. Setup Transmission to monitor your folder.

Open up Transmission and go to Preferences and select Transfers.  First, you want to make sure torrents are automatically added by checking “Start transfers when added” and either un-checking the “Display ‘adding transfer’ options window” or “Only when there are multiple files”, depending on if you still want this window to open up when you add files normally.

Now check the “Auto add” button and select the folder you created above.

As a side note, you should also ensure that the folder you are downloading these files *to* is outside of your Dropbox if you plan on downloading large files too big for your account.

# 3. Download a torrent to folder.

Download your (totally legitimage and wholly legal) torrent file to the Torrents folder of your Dropbox on another computer.

Voila!  Your torrent should now be downloading and ready for your enjoyment once you get home.  If you’re interested in checking on it’s progress while you’re away, check out my earlier post detailing that.

# 4. What if I already have Transmission monitoring a different folder?

So, I actually already have Transmission watching my Downloads folder so that things downloaded in a web browser automatically open as well.  Unfortunately Transmission only allows you to watch one folder at a time.  To get around this, I used the same trick I did in my iTunes/Dropbox watched folder tip.  I set up a launch daemon to watch my Torrents folder inside Dropbox and move any torrent files to the Downloads folder, where they’ll be picked up by Transmission.  You can download the script I made here.

Yep, that’s right, anywhere. Even Windows and Linux.

So you guys already know I’m a big fan of Dropbox right? If you didn’t, read up on my earlier post Dropbox + iTunes 9 = Automatically add songs to a remote copy of iTunes.

# You guys, 1Password is really rad

This tip is another neat little use for Dropbox using my favorite password manager: 1Password. So 1Password is an awesome app for OS X for keeping track of and generating your passwords. Note, it’s not free. But a little googling will find you a discount. Personally, I find this app (and the companion iPhone app) to be well worth the price. I use it to keep track everything, from logins to WiFi passwords to bank account numbers to software licenses. It’s a fine piece of software, plugs into your mac browsers, and is pretty darn secure.

So anyway, this tip assumes you’re already using 1Password. Now suppose you’ve got multiple computers, like me, and some of them (gasp!) aren’t even macs (I know!). But you’d still like to be able to access your passwords (securely!) from anywhere. As it turns out this, is extremely easy to do across macs using Dropbox. In fact, the fine folks at 1Password even wrote a very detailed explanation of how to do it. Another thing you should note, the 1Password app has what I consider a “reasonable” licence…you pay per user, not computer. So yes, go ahead and register that second mac with the same 1Password license. They’re cool with that. :)

OK, but then you’re at work or something, where maybe they force you to use Windows or something (ewww, Windows) or maybe Linux, who knows. And now you can’t remember your password to that one site you’d really like to login into right now. Whatever will you do?

Well, since you’ve probably already got Dropbox installed (since you can stick that pretty much anywhere), you’re in luck, thanks to a nifty little feature of 1Password called 1PasswordAnywhere. Navigate to the folder inside of Dropbox where you saved your 1Password agile keychain. The keychain will appear as a folder in Windows or Linux. Open up that folder and inside you’ll notice a file called 1Password.html.

Ohhh, what does that do?

Yup, a fully functional web app version of your 1Password database, fully password protected, usable from any computer that has a web browser. (You know, all of them.)

BIG CAVEAT: This database is read-only, so you can’t add or generate passwords via the web app.

# Prism: Turn that Web App into an actual App

Time for another little utility I’m a big fan of! This time it’s Prism, from Mozilla. Basically, Prism lets you turn web apps into pseudo-applications. And that’s what I decided to do with 1Password on my Windows laptop, since I couldn’t install 1Password itself.

Download and install Prism. Now we’re going to create an application for 1Password. Start up Prism and enter the URL for your new app, which will in this case be something like

file:///C:/Users/<yourusername>/My Dropbox/1Password.agilekeychain/1Password.html

You can just copy and paste the URL from the browser when you clicked that .html file earlier. Name it 1Password and choose where you want the shortcut located. I put it on my Desktop. You can even choose an icon for your App, I used this .png file I found upon the internets (© Agile Web Solutions, naturally).

Now you should have a shortcut to your 1Password app.

Open it up:

Ta-da!

# And when I say anywhere, I really do mean anywhere.

I previously mentioned the iPhone app for 1Password, which would let you keep your 1Password database synced to your phone.

But suppose, heaven forbid, you don’t have an iPhone? And say you’re using a computer that’s not yours and doesn’t have Dropbox installed, now what?

Don’t worry, Dropbox has a handy web interface, and since all your data is stored in the cloud, it’s available from any computer with an internet connection. Just head on over to the Dropbox website and navigate to the folder where you saved the keychain and find the html file, just as you did on your computer earlier. Click the link, and there’s your 1Password database, still protected with your master password.

Taking it even a step further, there are some add-ons for dropbox (sadly, Windows-only at this point) which will let you sync your Dropbox to a portable USB drive, DropboxPortable and DropboxU3 (for U3 drives). With your Dropbox sync’ed to your keychain, you can even access your 1Password db without an internet connection, by simply navigating to the 1Password.html file in your keychain and clicking on it.

Have any other ideas for accessing 1Password anywhere? Post a comment!

Update (12/13/09): Check out my new post on integrating 1Password into Chrome on Windows using Xmarks.

So, a little context.

At home, I’ve got a Mac mini running as a media server. I keep all my music on there instead of my Macbook or Thinkpad (eww, Windows, I know, but it’s for work) because it’s got a ginormous hard drive specifically for that purpose. (I use Simplify Media to stream said library to any computer I happen to be on).

Just as a side note though, this will work for anyone using two computers, one on which the iTunes library is maintained and one where the media files are downloaded. The machine with the iTunes library does not necessarily need to be up and running on all the time. Also, this solution is specifically for a scenario in which an OS X machine is the target with the iTunes Library on it. If you’ve got your Library one a Windows machine (eww, Windows), sorry, you’re on your own. :)

During the week, the computer I happen to be on, sadly, my work computer. This is also the time when I might read a random music blog and download an mp3, or a friend might send me some songs via email or IM or what-have-you. So if I’m at work, where do these end up? Right, on my work computer. Far, far away from my iTunes library at home.

# This is where Dropbox comes in

Dropbox, for the uninitiated, is a fantastic little app that allows you to sync a folder between all your computers, as well as their server, “in the cloud”. God, who else is starting to hate that phrase, amirite? Anyway. You get 2GB free, you can buy some more if you want. So I have Dropbox installed on the laptops and the mini, and when I download a song on one of them, I just stick it right in the Dropbox folder, and when I get home, there it is sitting, on that computer, waiting to be imported into iTunes. Lovely!

Except I am lazy and forgetful and never remember to do that part. And the songs sit in the Dropbox, unlistened to, collecting dust, taking up space in my Dropbox.

# This where iTunes 9 comes in

With iTunes 9 we finally, finally, got a feature that users have wanted, like, FOR-EV-ER. A watched folder. Sort of. Well, it works, but it ain’t very flexible. Under your iTunes Music (or iTunes Media) folder, there’s a folder called “Automatically Add to iTunes”. Does just what it says on the tin. Put an mp3, or folder full of ‘em, into this folder, and blammo, there they are in your iTunes library. Nice.

So, now I’m thinking, how can I make this work with Dropbox, and get around that laziness/forgetfullness problem?

# What didn’t work - Symlinks

So the first thing I tried was symlinking* the iTunes special watch folder to a folder inside of Dropbox. So I moved the “Automatically Add to iTunes” folder inside of Dropbox, and inside of the iTunes Media folder, placed a symlink with the same name linking to the folder.

That didn’t work.

iTunes didn’t recognize anything placed in the folder. Seems it will only recognize things dropped into the appropriately named folder inside the iTunes Media folder. No ifs, ands, or buts. D’oh.

So I recreated the folder and tried placing a symlink to the folder I’d made inside Dropbox inside of it.

That didn’t work either.

iTunes actually tried to add the symlink itself, and not recognizing it as a proper format for iTunes, placed in a folder called “Not Added”.

:(

So the next thing I tried was to leave the iTunes special folder alone, and symlink to it from Dropbox. This got me soooo close. See Dropbox, unlike iTunes, actually does play nicely with symlinks. Most of the time.

I created a symlink to the special watched folder from within iTunes. Dropbox then proceeded to create similarly named folders on my other computers. When I added a file to this folder on a local machine, it synced to Dropbox, and back down to the folder via the symlink. Success! Almost! See, after iTunes adds the file to its library, it cleans up after itself and removes it from the folder. Only, Dropbox doesn’t see that it’s been deleted because the actual symlink file inside the Dropbox folder hasn’t been modified, just the folder it points to**. So Dropbox doesn’t delete the file from the server or the other machines. So close!

*If you don’t feel like opening up Terminal every time you need to make a symlink, there’s this contextual menu extension: SymbolicLinker.

**Dropbox does recognize that it’s been deleted upon restart, but that’s annoying.

# OK, screw the symlinks, let’s just try moving the files

The it occurred to me, I could use launchctl to create a deamon that would monitor a folder for files added to it, exactly what I wanted. So I ditched the symlink inside of Dropbox, and simply created a folder there. I then wrote a simple little bash script to move the contents of that directory into the proper one in the iTunes folder.

#!/bin/bash
/usr/local/bin/growlnotify -n "Auto Add to iTunes" -a iTunes -m "Moving to iTunes Folder"
cd "/Users/[USERNAME]/Dropbox/Automatically Add to iTunes/"
mv * "/Users/[USERNAME]/Music/iTunes/iTunes Media/Automatically Add to iTunes"
/usr/local/bin/growlnotify -n "Auto Add to iTunes" -a iTunes -m "Moved to iTunes Folder"

So, obviously, you’ll want to replace [USERNAME] with your own, and “iTunes Media” with “iTunes Music” if that’s how yours is named. And if you don’t have Growl + growlnotify installed (or you prefer not to have growl notifications for this) go ahead and remove the lines referring to growlnotify.

Download the shell script here and place it wherever you like to keep your scripts (I like ~/Library/Scripts). Open up TextEdit, or your preferred editor, and open the file and edit it as I mentioned above and save it. Now open up Terminal and navigate to where you saved the file.

cd Library/Scripts

Now make the file executable:

chmod a+x autoitunes.sh

If you’d like to test out that it works, place a file in the Dropbox auto-add folder you created, and run the script manually:

./ autoitunes.sh

Any file you placed in there should be moved to the iTunes special folder and removed from Dropbox.

Now, we have to get this little script run whenever a file is added to our folder. For this we’ll use something launchd. Don’t worry, we won’t have to mess with launchctl for this, there’s a neat little GUI for it called Lingon. Download and install that app and open it up. We’ll use this to create the daemon that will watch our folder and run the script.

Start up Lingon and click New. Select which type of daemon you’d like to create, I chose My Agents since Dropbox is only running when I am logged in anyway.

Now we create the agent. Step 1 is to give it a name. This can be pretty much anything you want, as long as it’s unique. I called mine “com.jessbrandi.AutomaticallyAddToiTunes”.

Next tell the agent what to run. Click Choose and browse to the shell script you saved and select it.

Finally, tell it when to run. We want it to run files are added to the folder we created within Dropbox, so in the last box click Path and navigate to it. I also selected at system start up, for good measure, in case of some sort of crash (what? OS X crash?) or something.

Click save, exit and reboot.

That’s it! You’re done! Now if you add an mp3 or video to the folder in Dropbox on any machine, it should automatically be added to iTunes!

Try it out. Find an mp3 (on the machine without the library):

Save it to the Dropbox:

As soon as Dropbox downloads it, it’s moved:

And iTunes takes care of the rest. The mp3 should now be in your iTunes Library.

One last thought on notifications, I added the Growl notifications, but they’re totally optionally. And as the script is being run on the target machine, that’s where it will show up, not on the machine you downloaded the original media file on. You should, however, get a notification from Dropbox on that machine that the file has been removed.

Please let me know if you have any comments or questions, or a better way to do this!