Sunday, August 31, 2008

Gnome/Firefox tip: Pandora as a Separate Application

The problem: Pandora is more like a desktop application than a website. It should stay open when you close your browser. If you do web development, or your browser tends to crash a lot, or you just like to close Firefox sometimes, you probably don't want to lose your tunes. Figure out a way to keep Pandora open when the rest of your web browsing session is gone.

This is a walkthrough for Gnome/Compiz users for isolating Pandora from the rest of Firefox cleanly. Much of this will be applicable to you if you don't use Compiz, and even if you don't use Gnome.

This assumes Firefox 3.0.1/Linux, I can't vouch for command line options on any other version.

When I refer to your Default Firefox Icon, I am talking about whatever means you usually use to launch Firefox, whether it's a toolbar icon, a menu icon, Alt+F2 "firefox", etc.

Create a Clean Pandora Profile

Start by shutting down all instances of firefox completely. Then bring up a Terminal window and type:
firefox -no-remote -ProfileManager
You'll get the small Profile Manager window. Create a new profile, named 'pandora'. You may, if you wish, clean it up. I did all of the following:
  • moved all the controls to the menu bar line at the very top (right-click a blank space and "customize...").
  • hid all the toolbars.
  • edit > preferences and changed the homepage to http://pandora.com/
Now quit from that firefox window. Once again, run:
firefox -no-remote -ProfileManager
Firefox makes your latest profile the default in all situations. To fix that (you don't want Pandora as your default browser): Select 'default' (or your original profile) from the window that just appeared, and let firefox open. Now your Default Firefox Icon won't open Pandora.

Make a Launcher

Right click on your Gnome menu panel, and "Add to Panel..." Select Custom Application Launcher. Enter the following:
  • Type: Application
  • Name: Pandora
  • Command: firefox -no-remote -P pandora
  • Comment: Opens in a separate Firefox process
(Only the Type and Command must match what I show above.)

Leave that window open for now. Re-launch Firefox using your Default Firefox Icon.

Let's get a pretty icon for the launcher you're about to make. In Firefox, visit:
http://pandora.com/favicon.ico and save the file as ~/.mozilla/firefox/*.pandora/pandora.ico

Now, go back to your New Launcher window (you didn't close it, right? :) and click on the springy-looking icon to change the icon. Choose the icon file you just saved as your icon. Now finish/OK until you are out of the New Launcher window and you have a new launcher.

Bonus Compiz Step: Place Windows Support

The Compiz "Place Windows" plugin lets you put windows on a particular workspace automatically. I want Pandora windows to automatically be placed on desktop 8, and other Firefox windows to automatically be placed on desktop 3. This was the trickiest part of the entire process.

This isn't an explanation of how to use Place Windows (find that elsewhere). This is an explanation of why using Place Windows for the tricked-out Pandora profile is difficult, and how you can fix it.

Problem: Compiz requires you to identify the windows you want to place by window Class, Name, Title, Type, or a few other things. For all firefox windows, Class, Name, Type and so on are the same; so if you want some firefox windows to go one place and some to go another, well, you can't do that with Place Windows unless you can differentiate them by title. But firefox always starts with the same title: "Mozilla Firefox". Compiz only looks at the initial title when it tries to place a window.

Solution: A plugin called MozFox. This is a version of FireSomething, that plugin that lets you randomly name your browser "Fireslug", etc. Bring up your Pandora profile using your new launcher icon, and visit the link above. You will have to create an account and log in there because this is currently an "experimental" plugin.

Install the plugin, and let the Pandora profile restart. When it comes back up, Tools > Addons > MozFox > Preferences. You will have to manually delete everything in the three lists. (You can select multiple to delete at once, then right-click and "delete". This is a pain in the butt.)

Add to each list: "Pandora", "Fire", "fox".

Now in the Place Windows plugin, set it up to match "title=Pandora.*". (You must have Regex Matching on.) Close out of that window, and restart Pandora. When it comes back up, Compiz will automatically position it where you told it to go!


3 comments:

drewp said...

This is supposed to be what http://labs.mozilla.com/projects/prism/ does, although I haven't seen it work yet.

Cory said...

Yeah. . . I'm looking forward to Prism, but (from their website):
"""
We have an early prototype for this working today on Windows, with work continuing on Mac and Linux (for which we should have builds available soon).
"""

Maybe then I can finally change the WM/taskbar icon as well.

Brent said...

Thanks for the tip. Lovely.

Mozfox is not current; Firesomething is current now, so one should use Firesomething.