Wednesday, April 20, 2011

Disper indicator for switching Nvidia display modes on Ubuntu 11.04 Natty

This is a small Pyhton script which displays an indicator for Disper in Ubuntu 11.04 Natty (Unity desktop).

Disper can be found at

As far as I know this is the only command line utility which can handle the TwinView settings for Nvidia cards.

import gobject
import gtk
import appindicator
import commands

def single(w):
    commands.getstatusoutput('disper -s')

def extend(w):
    commands.getstatusoutput('disper -e')

def clone(w):
    commands.getstatusoutput('disper -c')

def add_menu_item(name, action):
  menu_item = gtk.MenuItem(name)
  menu_item.connect("activate", action)
if __name__ == "__main__":
  ind = appindicator.Indicator ("disper-indicator",
  ind.set_status (appindicator.STATUS_ACTIVE)

  menu = gtk.Menu()
  add_menu_item('Single', single)
  add_menu_item('Extend', extend)
  add_menu_item('Clone', clone)