#!/usr/bin/python # # # # Fixes an xorg.conf when using hybrid graphics # # Copyright 2008 Dell Inc. # Mario Limonciello # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. import string import subprocess import fileinput xorg_conf='/etc/X11/xorg.conf' count=0 cards=[] output=string.split(subprocess.Popen(['lspci'],stdout=subprocess.PIPE).communicate()[0],'\n') for line in output: if line and 'VGA' in line and 'nVidia' in line: count=count+1 cards.append(line) if count > 1: for card in cards: if "9200" not in card: for line in fileinput.input(xorg_conf,inplace=1): print line[:-1] if '\tOption\t\t"IgnoreDisplayDevices"\t"TV"' in line: print '\tBusID\t\t"PCI:' + string.replace(string.split(card)[0],'.',':') + '"' fileinput.close()