Initial release of Python XRandR

Category: Ubuntu

 
Python-xrandr is a high level API for the RandR extension of the X.org server. RandR allows you to switch resolution, refresgh rate and output settings on the fly without having to hack the xorg.conf file or to restart your x server.

This is the intial release of python-xrandr. It supports some basic functions, e.g. setting your refresh rate, size and rotation (RandR 1.1) and enabling, disabling and postioning of outputs (RandR 1.2).

Python-xrandr comes with the command line tool pyxrandr. The tool is basically a rewrite of the original xrandr tool and a reference implementation of the bindings. See the man page or use the option --help for supported options. If you start pyxrandr without any options it will show you detailed information of your screens.

Here is a video that demonstrates the following two commands:

pyxrandr --output VGA --preferred --right-of LVDS

pyxrandr --output VGA --off

You can download a package for Ubuntu 'Gutsy' 7.10 here or add the following repository URL in System > Administration > Software Sources:

deb http://ppa.launchpad.net/displayconfig-gtk/ubuntu gutsy main

The source code is hosted in a bzr branch at Launchpad:

https://code.launchpad.net/~displayconfig-gtk/python-xrandr/main

Finally an example code which enables the DVI output:

from xrandr import xrandr

screen = xrandr.get_current_screen()

output = screen.get_output_by_name("DVI")

output.set_to_preferred_mode()

screen.apply_output_config()

Feel free to report bugs in our bug tracker or to send an email for comments and suggestions.

In the future python-xrandr will be used as an additional backend in displayconfig-gtk.


Update: I just release a small bug fix release 0.1.1 that solves a crash if no -dev packages have been installed and shrinks the screen after disabling an ouput

 
  1. Alberto Milone

    Tuesday, 27-11-07 12:14

    First of all, congratulations on this project :-)

    I had to modify xrandr.py in the following way so as to make it work on my laptop with an Intel card (on Gutsy):

    # load the libs
    try:
    xlib = cdll.LoadLibrary("libX11.so")
    except OSError:
    xlib = cdll.LoadLibrary("libX11.so.6")
    try:
    rr = cdll.LoadLibrary("libXrandr.so")
    except OSError:
    rr = cdll.LoadLibrary("libXrandr.so.2")


    The original version works well on my desktop with an NVIDIA card.


    This is what I get when I type these commands on my laptop:
    :~$ ls /usr/lib/libXrandr.so*
    /usr/lib/libXrandr.so.2 /usr/lib/libXrandr.so.2.1.0
    alberto@alberto-laptop:~$ ls -l /usr/lib/libXrandr.*
    lrwxrwxrwx 1 root root 18 2007-09-30 12:00 /usr/lib/libXrandr.so.2 -> libXrandr.so.2.1.0
    -rw-r--r-- 1 root root 22136 2007-05-16 20:04 /usr/lib/libXrandr.so.2.1.0

    :~$ ls -l /usr/lib/libX11.*
    lrwxrwxrwx 1 root root 15 2007-10-05 17:30 /usr/lib/libX11.so.6 -> libX11.so.6.2.0
    -rw-r--r-- 1 root root 986540 2007-10-05 00:20 /usr/lib/libX11.so.6.2.0

    In other words I have neither libX11.so nor libXrandr.so. I don't know if the lack of such symlinks can depend on the Intel driver.
 

CAPTCHA image for SPAM prevention