--- tmp 2006-10-30 00:22:04.000000000 -0700 +++ nvidia-config-display 2006-10-29 23:30:22.000000000 -0700 @@ -1,4 +1,6 @@ -s program is free software; you can redistribute it and/or modify +#!/usr/bin/python +# +# 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. @@ -95,6 +97,21 @@ i += 1 # +# Check if only glx is loading + +def fixOneModule(): + i = 0 + glx = 0 + for m in modules.load: + if (m.name.lower() == "glx"): + glx += 1 + i += 1 + if glx == i: + return 1 + else: + return 0 + +# # Set driver to newDriver where # if driver is oldDriver # @@ -103,6 +120,25 @@ if (dev.driver.lower() == oldDriver.lower()): dev.driver = newDriver +# Add and remove device options + +def addDeviceOption(device, newOption, optionInfo): + for dev in device: + for o in dev.options: + i = 0 + if (o.name.lower() == newOption.lower()): + dev.options.remove(i) + i += 1 + dev.options.insert(xf86config.XF86Option(newOption, optionInfo)) + +def removeDeviceOption(device, oldOption): + for dev in device: + for o in dev.options: + i = 0 + if (o.name.lower() == oldOption.lower()): + dev.options.remove(i) + i += 1 + def printError(err): print "Error: ", err @@ -157,24 +193,27 @@ xconfig.files.module = TOP_MOD_DIR # Create an empty modules section - if xconfig.modules == None: - xconfig.modules = xf86config.XF86ConfModule() + #if xconfig.modules == None: + # xconfig.modules = xf86config.XF86ConfModule() if (arg == "enable"): # Enable nvidia driver: # Add nvidia module path, disable dri and GLcore modules # make sure glx is enabled and change driver to 'nvidia' addModulePath(xconfig.files, "/extensions/nvidia") - removeModule(xconfig.modules, "dri") - removeModule(xconfig.modules, "GLcore") - addModule(xconfig.modules, "glx") + if xconfig.modules: + if fixOneModule: + removeModule(xconfig.modules, "glx") + else: + addModule(xconfig.modules, "glx") toggleDriver(xconfig.device, "nv", "nvidia") + addDeviceOption(xconfig.device, "AddARGBGLXVisuals", "True") elif (arg == "disable"): # Disable nvidia driver: # Remove nvidia module path, enable dri module # and change driver to 'nv' removeModulePath(xconfig.files, "/extensions/nvidia") - addModule(xconfig.modules, "dri") + removeDeviceOption(xconfig.device, "AddARGBGLXVisuals") toggleDriver(xconfig.device, "nvidia", "nv") else: # This shouldn't happen, but we handle it anyway