#!/bin/bash # This script should contain the command(s) necessary to switch on the # nVidia card. # This is a template script. # # Please note that the acpi_call module is need for these operations: # http://linux-hybrid-graphics.blogspot.com/2010/07/using-acpicall-module-to-switch-onoff.html modprobe acpi_call if ! lsmod | grep -q acpi_call; then echo "Error: acpi_call module not loaded" 1>&2 exit fi acpi_call () { echo "$*" > /proc/acpi/call result=$(cat /proc/acpi/call) case "$result" in Error*) echo "Enabling nVidia card failed (${result})." ;; *) echo "Enabling nVidia card succeeded." ;; esac } green="\e[1;32m" red="\e[1;31m" blue="\e[1;34m" null="\e[m" columns=80 offset="\e[${columns}C" echo -en " ${blue}*${null} Doing ACPI calls..." #INSERTPOWERON #echo _ON $(acpi_call "\_SB.PCI0.PEG0.PEGP._ON") log=$(acpi_call "\_SB.PCI0.PEG0.PEGP._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}" && acpi_call "\_SB.PCI0.PEG0.PEGP._PS0") if [ $? -eq 0 ] ; then echo -e "${offset}[ ${green}OK${null} ]" echo -en " ${blue}*${null} Inserting driver..." modprobe nvidia-current else echo -e "${offset}[${red}FAIL${null}]" echo $log 1>&2 echo -n "Insert driver nevertheless? (y/n) " read answer [ "x${answer}" = "xy" ] && modprobe nvidia-current fi [ $? -eq 0 ] && echo -e "${offset}[ ${green}OK${null} ]" unset green red blue null columns offset log # modprobe nvidia-current