Skip to main content

Thread: Automatic video driver switching for laptops with switchable graphics


i developed method automatically switching video driver on laptop depending on graphics chip choose @ boot time. have mentioned in other threads , have been asked on occasion, thought i'd share in central place in case helps other people. may useful high-end laptop multiple graphics chips (switchable graphics) runs in dock , out of dock.

little background:

higher-end laptops have multiple graphics chips. seems combination of integrated video provided intel chipset along discrete ati or nvidia graphics chip. lenovo has implemented on w-series laptops, think there other manufacturers higher end products. on lenovo laptops typically have option in bios config @ boot-up choosing either "integrated" graphics or "discrete" graphics, integrated=intel , discrete=ati or nvidia. on lenovo w500 discrete chip ati hd3650 , on newer w520 nvidia quadro 1000m, , used method on both machines.

note "switchable graphics" options such nvidia's "optimus" not helped script. believe there efforts support linux (the "bumblebee" project perhaps?) setup intended make easier switch between integrated graphics using included open-source intel driver , discrete graphics using proprietary fglrx or nvidia driver after choosing graphics chip @ boot time. useful if have multi-monitor setup using dock can run using discrete chip when docked integrated chip when undocked. typically integrated graphics burns less power, it's useful when running on battery, doesn't typically support dvi outputs and/or multiple external monitors.

so, here recipe. if has better way this, please chime in. i'm using newer w520 example machine, , crafted ubuntu 11.04 upstart boot scripts.

-----

couple of things understand first. when running open-source intel graphics driver not need /etc/x11/xorg.conf configuration file xorg handles configuration automatically, need xorg.conf when running proprietary drivers ati (fglrx) or nvidia graphics. believe if use open-source ati or nvidia (nouveau) drivers should not need method. matter of personal choice, , many people may happy open-source drivers , won't need method switch graphics drivers. i'm assuming have made choice use proprietary driver discrete graphics chip , have enabled , installed driver properly, there plenty of other threads how (and it's trivial in newer ubuntu versions).

first step nvidia graphics configured way want , make xorg.conf file represents configuration. took experimentation me, wasn't difficult.

nvidia dual monitor configuration

xorg.conf that's correct nvidia, did boot in discrete graphics mode (selected in bios config) , ran "nvidia x server settings" application, me in system menus. believe same /usr/bin/nvidia-xconfig program, , may need root run it. dual monitors believe want use "twinview" setting, , arrange screens how them in configuration program. when have both monitors turned on , configured way want them, should have configuration application write out xorg.conf file. didn't work me reason in application gave error couldn't write directly /etc/x11 (despite having permissions) changed path , wrote xorg.conf file home area.

@ point should test configuration working rebooting again in nvidia mode new xorg.conf file in place @ /etc/x11. if works way want, you're in shape, otherwise repeat configuration process until dual monitors set way want them.

automatic configuration switching between intel , nvidia

whole idea here add step boot process either switches in xorg.conf file (for nvidia) or deletes xorg.conf file (for intel) before graphics driver loaded during boot-up. needs done in boot process.

this, need (1) place following script in /etc/init.d, (2) place newly created xorg.conf file nvidia mode in /etc/x11 under different name xorg.conf.nvidia, , (3) add line in /etc/init/kdm.conf kde users or /etc/init/gdm.conf gnome users invokes script. here example /etc/init/kdm.conf:

.
.
.
/etc/init.d/xorg-config # (this line add)
/etc/init.d/xorg-config
if [ -n "$upstart_events" ]
then
.
.
. etc...

here script:

code:
#xorg.conf switcher shell script  #  #1. place script (or link script) in /etc/init.d/  #2. create xorg.conf.nvidia file in /etc/x11 (copy  #     configured xorg.conf when fglrx driver used)  #3. add line in /etc/init/kdm.conf execute script first step  #     in script section:  #  # example /etc/init/kdm.conf:  # .  # .  # .  # script  #     /etc/init.d/xorg-config  #     if [ -n "$upstart_events" ]  #      # .  # .  # . etc...    /usr/bin/lspci > /tmp/lspci.txt  video=`/usr/bin/lspci |grep -i vga|grep -c nvidia`    if [ "$video" = 1 ];  cp -f /etc/x11/xorg.conf.nvidia /etc/x11/xorg.conf  else  rm -f /etc/x11/xorg.conf  fi
make sure script has execute privileges (only root necessary, think). if have machine discrete ati graphics chip, need change grep portion of script string "ati" instead of "nvidia", , change xorg.conf.nvidia filename appropriate.

if reboot undocked integrated (intel) graphics selected in bios config, when script runs @ boot time should automatically delete /etc/x11/xorg.conf , x should bring intel graphics driver properly, , if reboot docked dual monitors , select discrete (nvidia) graphics in bios config script should automatically copy /etc/x11/xorg.conf.nvidia script /etc/x11 , dual monitors should come properly.

nice if ubuntu included more built-in method doing (hint ubuntu developers might read this), laptops switchable graphics seem gaining in popularity @ high-end.



Forum The Ubuntu Forum Community Ubuntu Official Flavours Support Hardware [all variants] Automatic video driver switching for laptops with switchable graphics


Ubuntu

Comments

Popular posts from this blog

Warning, the Safe Path is not accessible vm3 - Joomla! Forum - community, help and support

uppercase letters in url - Joomla! Forum - community, help and support

Joomla! Update is not offering Joomla 3 - Joomla! Forum - community, help and support