Search code examples
pythonlinuxbashscreenmultiple-monitors

Get screen layout of multiple screens on linux/Gnome


I am trying to create an application for multiple screens however I so far cannot find a way to locate the secondary screens position (relative to the primary screen by x and y coordinates).

I prefer to use python or bash (via libraries/frameworks are fine). I also checked with xorg.conf and it doesn't reflect my current screen setup.

I am using Ubuntu 11.10 (default Gnome 2 I believe), using compiz as the window manager. So to repeat, my question is how to get the screen layout (coordinates relative to primary screen) of all the monitors preferably by python or bash.


Solution

  • Nevermind, I used Pyqt instead. Here is some code...

    from PyQt4.QtGui import QApplication, QPixmap
    desktop = QApplication.desktop()
    screenRect = desktop.screenGeometry(1)   #2nd monitor
    print screenRect.x(), screenRect.y()   #returns the x and y of that screen