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:
- Make sure devilspie is running (ps ef | grep devilspie, etc)
- Double check your application_name (or similar) via debug
- 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!
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.
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]
Pingback: University Update - Firefox - How To Set Default Workspace, Size and Window Effects in Gnome
Anyway to do this in KDE?
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.
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.
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?
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.
I wrote down some examples [1] too a while ago. Not all of them work perfectly (like the one for gimp). Anyway, I can`t live without devilspie anymore ;-).
[1] http://www.chimeric.de/snippets/linux/devilspie#examples
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…
Stephen Weeks: When will e17 be released? I’d love to be able to install it from my distro’s repositories.
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 😛
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
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…
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?
The Compiz composite window manager with related window rules plug-ins also handles window matching, amongst a slew of other goodies.
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
Pingback: TuxJournal.net 2.0 » Archivio » Desktop: mettete le regole alle vostre finestre (3/4)
Is it possible to restrict icons to certain workspaces as well?
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??
hello,
found the answer in ubuntuforums:
“because of compiz you have to use set_viewport
instead of set_workspace”
Only for the record 🙂 http://foosel.org/linux/devilspie
This might be interesting for easier use as well:
http://code.google.com/p/gdevilspie/wiki/gDevilspie
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?
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.
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.
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”,
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.
I got it working, I missed the "set_viewport" diff stated above. Thanks anyway
Pingback: Answer My Searches » Blog Archive » Mini Searches with Answers
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
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.