How To Set Default Workspace, Size and Window Effects in Gnome

By | 2007/07/25

Among the many cool things that I’ve learned this week at Ubuntu Live there is one that I’m definitely going to keep using!  Quickly, before I get started, I need to link back to the Ubuntu Forums post that started this whole thing. There is also a lot more examples and extensions on the wiki, seen here.  Unfortunately, outside of these, there is very limited documentation on the web for this tool, so you wont find much more than what you see here.  If you do please post a comment with a link.

There are a few steps to this full tutorial so get comfortable and follow along.

Installation

To get the features of this tutorial we will need to install a quick package. It’s pretty small and should just take a minute or two to download and install. Use the following command, or install the package using your favorite package manager:

sudo aptitude install devilspie

What exactly does this package actually do? From the package description:

This tool will find windows as they are created and perform actions on them, such as resizing, moving to another workspace, or pinning them to all workspaces.

In english? You can basically set rules for your favorite applications and make sure they load on the appropriate virtual desktop, at the certain sizes, etc. This has been something that I wish I had for a while and never really looked into. A have a nice organization of applications between my desktops, but all done manually. This automates the whole thing instead.

Configuring

Now that we’ve got the package installed we need to set the configuration of what we’d like it to do.

Create a new directory to store your new devilspie-related configuration file (yes, once you start using this you’ll create more and more–you want them organized). Use the following:

mkdir ~/.devilspie

After this is created we’ll create our custom configuration for the regular applications we launch.  For example:

vim ~/.devilspie/firefox.ds

Paste in the following config to your new file:

(if
(is (application_name) "Firefox")
(begin
(set_workspace 2)
(maximize)
)
)

Basically what this is doing is watching for anything launched using the application_name “Firefox”, and give it the following features and options. It’ll load it on virtual desktop number 2 and set the window to maximize.  Pretty basic, but so far this has been impossible in gnome.  Of course if you’d like it to always load on virtual desktop 1,3,4, etc simply change the number to your preference.

Some more examples for common applications that I use listed below:

vim ~/.devilspie/thunderbird.ds

Paste in the following config to your new file:

(if
(is (application_name) "Thunderbird")
(begin
(set_workspace 3)
(maximize)
)
)

..or for beep-media-player to be on all desktops:

vim ~/.devilspie/bmp.ds

(if (is (application_name) "Beep Media Player") (pin))

…you get the idea.  If you’d like to create your own custom rules create a new file in the .devilspie directory and create a debug.ds file.  Within that file put:

(debug)

The next time you run devilspie it will read any of the files within .devilspie, which will now include this debugging option.  You will see from the debug output the detected application_name of each currently running application.  If you don’t know the proper name to use for creating your own rules you may want to use this debug option to help you along.

Persistence

Lastly I’m sure you’ll want these features to run all the time, so you’ll need to set the devilspie application to autostart.  You may want to add devilspie to your “Applications > Preferences > Sessions”, which will make it start each time you log in, and read your created window customization options.

Troubleshooting

If you notice your rules don’t seem to be working try the following:

  1. Make sure devilspie is running (ps ef | grep devilspie, etc)
  2. Double check your application_name (or similar) via debug
  3. Double check your *.ds config file syntax

Enjoy.  Please leave comments with customizations that you’ve made below.  Considering the lack of documentation for this project a good list of examples would be great!

32 thoughts on “How To Set Default Workspace, Size and Window Effects in Gnome

  1. Maxo

    I really like this tool as well. I think it’s abilities should be built in at the OS level. Maybe an option in the right-click menu to set options for the program.

  2. Josh

    I agree with Maxo. This is something that should already be in Gnome. I wish the Gnome developers would stop confusing “simple” with “crippled.” O

    [douchebaggery]
    On another note, “devilspie” is a stupid name and asking new Linux users to edit files in vim is probably not wise. Wouldn’t it make sense to have a GUI to do these tasks? I never cease to be amazed at how low a priority user interfaces are given in the Linux world. UI should be one of the first considerations in applications development for Linux, just like it is for those other operating systems.
    [/douchebaggery]

  3. Pingback: University Update - Firefox - How To Set Default Workspace, Size and Window Effects in Gnome

    1. qajaq

      In KDE (at least in the version 4.1 that I have running on my open SuSE Linux OS), you can right-click on the bar at the top of any open window, then click, in succession, Advanced > Special windows settings… > Geometry (tab); then click on the check-box next to "Desktop", In the drop-down menu next to the word "Desktop," then, select the "Force" option. Then, from the adjacent drop-down menu, select the workspace ("desktop" in the KDE lexicon) on which you want it to appear. That takes care of putting it where you want it. And in my experience, if I close the program (Firefox, Konsole, jEdit, etc.) from a maximized configuration, it re-opens to maximized when I invoke it next time.

  4. Stephen Weeks

    I’d just like to mention here that this functionality is built in to e17, has been for quite a while, and is easily accessible in a clicky gui config in the window menu.

    Just set your window up how you want it to be, click ‘remember’ in the window menu, and choose the attributes that you want remembered. Very nice.

  5. Niels

    Is there anyway to set it up such that firefox 2 loads on the 2nd virtual desktop when you log in, but should you just happen to open firefox it will open on the desktop you’re on?

    1. Anthony Thyssen

      I do this in a .xsession file with a different program "xwit", however a 'personal clients' scritp can also be launched from gnome session as well to do the same thing.

      The script runs firefox on startup, then watches for the window to appear (using a looped xwininfo in another script) geting its Xid at the same time. when you have the xid, I can then use "xwit" to position, iconize, or set its desktop, just as I like.

  6. Jim Priest

    Sweet! I had seen something similar that would do this in Windows – this is great -I agree – why isn’t this baked into Gnome by default? Can’t wait to get home and give it a go…

  7. anonymous coward

    Stephen Weeks: When will e17 be released? I’d love to be able to install it from my distro’s repositories.

  8. Joe A

    Can I use this to make new IM (with pidgin 2.0.2) windows not take focus? Because that would just take me another step above AIM client users 😛

  9. anonymous

    Heheh. KDE’s had this built-in for a while. Click the window icon/menu thingy on the upper left corner of any window in KDE, then choose advanced -> special window settings, and a neat little dialog pops up. you can configure window size, which desktop to place the window, keep above/below, and just about every other option. I use this to force my pidgin buddy list to stay docked on the right and maximized vertically with the window borders hidden

  10. tombraun

    Yes, KDE has hat it forever. When I changed from KDE (Novell Desktop Linux) to Gnome (Ubuntu) this was one of the features I really missed. It took me another two years, or so, before I finally discovered devilspie.

    I fully agree with previous posters: This should definitely be part of the standard Gnome capabilities. Even the Gnome developers on their ‘simplicity’ trip should admit that a simple ‘remember’ option is not going to confuse anyone.

    Or the ability to modify screensaver settings, for that matter and while we are at it…

  11. High Camp

    I can’t get it to work. I’m not sure if it matters that I’m running the newest Xubuntu (and I’m a n00b). I’ve set Deilspie to autostart in the applications. I’ve created a directory .devilspie in my home directory. In that home directory I put the Firefox file first to test, then Gvim, then Debug and none of them have worked.

    Anyone have any ideas?

  12. Some Guy

    The Compiz composite window manager with related window rules plug-ins also handles window matching, amongst a slew of other goodies.

  13. victor

    sorry to be think, but i havent got a clue how i am suppost to entry that data. could you clarify a bit..
    many thanks

  14. Pingback: TuxJournal.net 2.0 » Archivio » Desktop: mettete le regole alle vostre finestre (3/4)

  15. Torsten

    Is it possible to restrict icons to certain workspaces as well?

  16. Luciano

    Hello,

    Thanks for all the great info! I’ve installed virualbox and devilspie. Only problem is with devlspie cause I keep getting this error and it does not move the windows to other workspaces:

    ** (devilspie:10241): WARNING **: Workspace number 2 does not exist

    (devilspie:10241): Wnck-CRITICAL **: wnck_window_move_to_workspace: assertion `WNCK_IS_WORKSPACE (space)’ failed

    I did not findany solution yet on the many posts i’ve googled..

    Any ideas please??

  17. Luciano

    hello,

    found the answer in ubuntuforums:
    “because of compiz you have to use set_viewport
    instead of set_workspace”

  18. sainath

    I too got the problem with set workspace and i
    uninstalled compiz and tried .It says no error but it won’t work.
    can any one tell me how to do?

  19. Martin

    It worked, when I set System > Preferences > Apprearance > Visual Effects to None. This apparently uses the metacity window manager, who knows about different workspaces. Compiz only knows viewports. You can also try something like $metacity –replace to switch to metacity manually. Unfortunately, I couldn’t figure out how to get real transparency with metacity, so I have to stick to compwiz.

  20. Lars from Mars

    What a pain in the butt to do what should be an automatic feature of Gnome or metacity — by default put the windows where they were left the last time and sized likewise. Mac OS has done this since it was "NeXTSTEP" in 1990.

  21. Mike SZ

    As usual, this information is outdated and wrong. This makes no sense. Preferences has been moved to be under System. And there is no "Sessions" in Preferences.

    You may want to add devilspie to your “Applications > Preferences > Sessions”,

  22. Rjava

    This seems to work in metacity but not with compiz running. Any workarounds for this I would love to use it but not if I can't get it going in compiz.

  23. Rjava

    I got it working, I missed the "set_viewport" diff stated above. Thanks anyway

  24. Pingback: Answer My Searches » Blog Archive » Mini Searches with Answers

  25. Ade

    I was wondering if I could make an application on my 2nd monitor, not on the 2nd workspace. Is this possible?

    Thanks for the tutorial

  26. Eric Sebasta

    This was possible natively in KDE since 3 (I do not even know anymore, kde4 got to ugly for me), and Corel Linux/Xandros (which Microsoft bought to tank) also had the ability to adjust the priority of an application by right clicking the title bar. Fricken rocked.

Comments are closed.