Open PDF previewer width specific size and position and “always on top” from command line

evincegnomemetacitypdfwindow

I'm using latexmk -pdf -pvc to keep compiling my LaTeX files to PDFs while they are displayed in evince. I'm doing that a lot with different files and I keep needing to zoom the PDF content, resize the window and enable "always on top". I like to be able to do this automatically using the command line.
Using -geometry doesn't work with evince ("Unknown option") and the command line help doesn't say anything about it as well. I tried the preview -w option which gives me a nice sized window, but the automatic update feature I need seems to be disabled in this mode.

I'm using Ubuntu 11.10 with the classic desktop and the default window manager.
Is there a possibility to set both the size and position as well as "always on top" from the command line for evince (or similar PDF viewer with auto-update)? I think there might be some window manager control tool which can resize and configure windows from the command line.

I'm aware of an evince feature request to add size and position arguments, which would be half the job already, but I don't think it will be implemented soon.

Best Answer

Since evince lacks options to explicitly control its own window management (as do most applications), the next approach is to control evince externally from the window manager itself. Assuming GNOME with metacity as the window manager, you'll have to use devilspie to get the window matching features.

  • Install devilspie from your official Ubuntu repositories.
  • Configure latexmk to use evince --name LaTeX_evince (instead of the default which is evince). This distinguishes your LaTeX evince windows from other evince windows.
  • Configure devilspie by adding the following to ~/.devilspie/latex_evince.ds

     (if (matches (window_class) "^LaTeX_evince")
         (begin
             (above)
             (geometry "<width>x<height>+<x>+<y>")))
    

    Replace the geometry string with one for the actual size and position you want.


    Caveat: syntax not tested by me.

  • Add devilspie to your autostarted application list under Applications > Preferences > Session.

Miscellany

  • A good devilspie reference.
  • Apparently in the next Ubuntu release, devilspie will be deprecated in favor of devilspie2. You'll have to update your configuration file syntax then.
Related Question