Advertisements

Devilspie2: Lua Scripts

Prompted by that suggestion, here’s the current collection of Devilspie2 scripts (in ~/.config/devilspie2/) that make my dual-monitor setup (left: 2560×1440 landscape, right: 1050×1680 portrait) usable with a single X session in Xubuntu 12.10. The window manager understands about the monitor layout, so maximizing a window will fill whatever monitor it’s currently occupying.

acroread.lua — maximized on portrait

if (get_window_name()=="Adobe Reader") then
      unmaximize();
      set_window_geometry(0,0,1000,100);
      set_window_geometry(2561,0,1000,100);
      maximize();
end

chromium.lua — right half of landscape

if (get_application_name()=="Chromium" and get_window_name() ~= "Print") then
   set_window_geometry(1400,0,1150,1200);
   maximize_vertically();
end

debugging.lua — handy with –debug option

debug_print("Window Name: " .. get_window_name());
debug_print("Application name: " .. get_application_name());

digikam.lua — right half of landscape, force large Search dialog, dammit

if (get_application_name() == "Digikam") then
	debug_print("DigiKam conditional - top");
	if (get_window_name() == "Advanced Search") then
		debug_print("Digikam - Adv Search");
		set_window_geometry(750,100,1000,1300);
	else
		debug_print("Main DigiKam window");
		set_window_geometry(0,0,1400,1000);
		maximize_vertically();
	end
end

firefox.lua — left half of landscape, enlarge dialogs

if (get_application_name()=="Firefox") then
	debug_print("FF conditional - top");
	if (get_window_name() == "Print") then
		set_window_position(700,350);
	elseif (0 == string.find(get_window_name(),"Password")) then
		set_window_position(0,0);
		maximize_vertically();
	end
end

gimp.lua — force Gutenprint dialog to the top, dammit

if (get_application_name() == "GNU Image Manipulation Program") then
	debug_print("GIMP conditional - top");
	if (string.find(get_window_name(),"Print")) then
		debug_print("GIMP - GutenPrint")
		set_window_position(700,350);
		make_always_on_top();
	else
		debug_print("GIMP - Main window");
	end
end

passwords.lua — put password dialogs in mid-screen

if (get_window_name()=="Password Required") then
	debug_print("Password");
	set_window_position(700,350);
end

pronterface.lua — force to middle-ish of Desktop 2

if (get_window_name()=="Printer Interface") then
   set_window_workspace(2);
   set_window_position(1200,750);
end

slic3r.lua — force to right side of Desktop 2

if (get_window_name()=="Slic3r") then
   set_window_workspace(2);
   set_window_geometry(1600,0,700,700);
end

terminal.lua — maximized on portrait

if (get_window_name()=="Terminal") then
   set_window_position(2561,0);
   maximize();
end

thunderbird.lua — left half of landscape, force big dialogs

if (get_application_name() == "Thunderbird") then
	debug_print("TBird conditional - top");
	if (1 == string.find(get_window_name(),"Print")) then
		debug_print("TBird - print...");
		set_window_position(700,350);
	elseif (string.find(get_window_name(),"Sending") or
			string.find(get_window_name(),"Confirm") or
			string.find(get_window_name(),"Processing")) then
		debug_print("TBird - generic dialog");
		set_window_position(200,600);
	elseif (string.find(get_window_name(),"Write:")) then
		debug_print("TBird - writing");
		set_window_geometry(1300,0,900,600);
		maximize_vertically();
	elseif (0 == string.find(get_window_name(),"Password")) then
		debug_print("Main TBird window?");
		debug_print(" name: ",get_window_name());
		set_window_geometry(0,0,1300,1200);
		maximize_vertically();
	end
end
Advertisements

  1. #1 by Frans on 2013-09-15 - 11:07

    Is there a rationale behind the double set_geometry in acroread.lua or is it just a leftover from authoring?

    • #2 by Ed on 2013-09-15 - 12:35

      Adobe Reader starts maximized on the landscape monitor, even though it closed on the portrait monitor; it seems to want to start at (0,0) and then fill the space available. However, it’s impossible to move a window that occupies the entire landscape monitor to the portrait monitor in one step; it must fit the destination monitor before moving. So the script un-maximizes the window, shrinks it down, moves it to the portrait monitor, and then blows it up.

      Took a while to figure that out… [grin]

      • #3 by Frans on 2013-09-15 - 13:56

        Ah, that actually explains a single-occurrence issue I had with my clone window script. For some reason the clone window never moved to the right monitor, but the video must’ve been too large. Not that I recall ever downloading any videos larger than 1920×1080 (the monitor in question is 1920×1200), but that must’ve been the issue.

        • #4 by Ed on 2013-09-15 - 15:28

          any videos larger than 1920×1080 (the monitor in question is 1920×1200)

          Plus the borders and decorations and foo-foos: that wouldn’t quite fit. Then you get into scaling and things get complexicated…

        • #5 by Frans on 2013-09-29 - 15:17

          Ah yes, good old window decorations. But oddly enough, even though I’ve been downloading the occasional 1080p video from YouTube, they didn’t give me any trouble. Btw, you might want to consider checking out TableTop.

    • #6 by Frans on 2013-09-15 - 13:59

      On another note, good call on always opening with a large search box. I’m not currently using any applications where it matters, but I recall using something in the past where I was always dragging the window larger.

      • #7 by Ed on 2013-09-15 - 15:26

        In fact, Digikam pushed me over the edge: it opens the Advanced Search dialog at a size that cuts off just enough of the right side to hide the ending date search box pulldown, which defaults to whatever the last date was. I always want to search through “today” and that’s never the default.

        On a huge monitor there’s no reason to trim off the rightmost half inch of the dialog, so I’m not sure what their reasoning might have been. It’d be really cool if they saved and reused the size / location of the dialog…