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 http://launchpad.net/disper.

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.append(menu_item)
  menu_item.connect("activate", action)
  menu_item.show()
    
if __name__ == "__main__":
  ind = appindicator.Indicator ("disper-indicator",
                              "gsd-xrandr",
                              appindicator.CATEGORY_HARDWARE)
  ind.set_status (appindicator.STATUS_ACTIVE)

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

  ind.set_menu(menu)

  gtk.main()

Monday, January 10, 2011

Android AppEngine Login Error 500

Android caches authentication tokens. Therefore when getting a 500 error while authenticating against AppEngine the reason might be a timed out authentication token. In this case the token has to be invalidated and a new login request has to be send.

if (response.getStatusLine().getStatusCode() != 302) {
  Log.d(TAG, "Login failed. Trying again with new token.");
  AccountManager accountManager = AccountManager.get(context);
  accountManager.invalidateAuthToken("com.google",getAuthenticationToken(context));
}