Friday, September 11, 2009

Setting Gnome to open Windows in different workspaces

Virtual workspaces are nice. That feature is implemented in almost every window manager currently and I'm used to work with them in Gnome: one workspace for code editor and other for browser, usually Firefox. On other two desktops I use to open other browsers and/or file managers.
It's very handy to use a shortcut to start both programs, so my one-liner script on desktop to start both applications is:

geany (or Aptana) | firefox

But how can I start the apps in different workspaces? The answer is simple: Devil's pie. Devilspie is a tool let's the user configure window application launchs.
Once installed, you can launch it via command line for testing. When you feel comfortable, simply add it to the window manager session startup (in Ubuntu: System -> Preferences -> Settings).
To customize an application launch, you have to create lisp-style s-expressions on custom files on ./devilspie folder. Only one expression is allowed per file. Custom S-Expression:


(if
(is (application_name) “firefox”)
(set_workspace 2))



Simple and powerful.


Last thing to remember: set_workspace do not work in metacity, use set_viewport. Metacity uses viewports instead of workspace, despite Gnome shows "workspace" label on context menus and docs.

No comments:

Post a Comment