Tips, Tricks & Hacks for OS X

So if you read my earlier posts about using 1Password in Windows using 1PasswordAnywhere and SSB’s, you’ll probably be psyched to learn there is now a way to get browser integration of those passwords in Google Chrome on Windows as well!

I recently read on the 1Password blog how to use a little feature initially meant for the iPhone to get your 1Password integration into Google Chrome on the mac.  This is great for people who use Chrome on the mac, I usually just use Safari, so I figured it didn’t really apply to me.

But I do use Chrome on Windows pretty regulary, and then it occurred to me I could use this trick to get my passwords into Chrome on Windows as well!

Here’s the basic idea: 1Password can create a bookmarklet, which basically contains a whole database of all your logins in javascript, encrypted by a password of your choosing.  This is how they allow you to login using Mobile Safari on the iPhone, since they can’t write a plugin for the iPhone’s browser.

Turns out though, this little bookmarklet is also compatible with Chrome!  So you can just drag it over to your Chrome toolbar, and voila!  So how do you get into Chrome on Windows then?

# Xmarks the spot

Time for another fantastic little syncing utility to add to your toolbox. Xmarks is great little bookmark syncing utility, compatible with IE, Firefox, Safari, and yes, even Chrome for windows.  (You’ll need the latest beta of Chrome with extensions enabled to use it.)  I use it to sync bookmarks across several computers and browsers.

# Install Xmarks

Install Xmarks for Safari on the mac where you have 1Password installed.  Also install the Xmarks Chrome extension on the Windows machine.

# Create the bookmarklet

Follow the instructions here to create your bookmarklet.  Now, instead of just dragging it to the Chrome toolbar, also drag it to Safari’s toolbar.

# Sync Xmarks

Sync Xmarks on the mac, and then on Chrome.  You should now see your bookmarklet on your Windows version of Chrome.  Go to a site with a saved login and give it a go!

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!