Dual Monitors: devilspie2 FTW!

Because it seems there’s no good support for separate X sessions with dual monitors these days, the landscape and portrait monitors on my desk represent viewports into a larger pixel array within a single X session. As a consequence, it’s entirely possible to slide windows across the gutter between the two displays (generally producing an essentially unusable result), but one cannot flip through workspaces on only one monitor.

Worse, some programs seem to have trouble remembering that they were last seen on the portrait monitor, so I must rearrange the windows at the start of every session. First world problem, yeah, but still annoying.

I’d previously used devilspie to force windows to their proper places across monitors, sessions, and workspaces, but its s-expression syntax was impenetrable and I eventually gave up using it.

A fork (or continuation or something) called devilspie2 uses lua scripts that I can both read and write. It’s an Ubuntu package and easy to set up.

A typical script in ~/.config/devilspie2 looks like this:

if (get_application_name()=="Firefox") then
   set_window_geometry(0,0,1300,1200);
   maximize_vertically();
end

Putting Adobe Reader on the portrait monitor looks about the same:

if (get_application_name()=="acroread") then
   unmaximize();
   set_window_geometry(2561,0,1000,100);
   maximize();
end

Set /usr/bin/devilspie2 as an auto-started program and it Just Works…

About these ads

  1. #1 by Frans on 2013-04-27 - 11:12

    I switched to devilspie2 myself last year. Lua is significantly easier to work with. Btw, I currently maintain the Dutch translation of devilspie2.

    • #2 by Ed on 2013-04-27 - 15:48

      I currently maintain the Dutch translation of devilspie2

      It’s a small world, isn’t it? Wow…

      • #3 by Frans on 2013-04-27 - 17:59

        The developer implemented a feature I requested within about 2 days. I felt it was only fair to contribute something back. :)

  2. #4 by Billy on 2013-09-02 - 16:48

    If you want to be able to switch workspaces on each monitor independently, look into openbox-multihead. Openbox has a built-in method of specifying where to spawn new windows, though I use devilspie2 instead (Lua makes it super easy to do fancy stuff). BurntSushi, who maintains openbox-multihead, also has a WM called wingo that looks promising, though I haven’t gotten around to trying it myself.

    • #5 by Ed on 2013-09-02 - 17:04

      use devilspie2 instead

      Devilspie2 works wonderfully well: now all the windows open in the right spot and at the right size!

      I’m down to two workspaces, one for the regular stuff and the other for CAD. The new landscape monitor has 2560×1440 dots, so I can run most programs at half-screen-width and it’s good enough; the CAD stuff runs full screen, with reference material on the portrait monitor. Alt-Tab is my copilot!

      I should dump my set of Devilspie2 Lua scripts here, because I’m doomed if they ever Go Away.

  1. Devilspie2: Lua Scripts | The Smell of Molten Projects in the Morning