#!/bin/bash # This script should contain the command(s) necessary to switch off 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 green="\e[1;32m" red="\e[1;31m" blue="\e[1;34m" null="\e[m" columns=80 offset1="\e[${columns}C" let "columns2 = columns - 2" offset2="\e[${columns2}C" echo -en " ${blue}*${null} Withdrawing driver..." rmmod nvidia sleep 0.3 lsmod | grep -q nvidia if [ $? -eq 0 ] ; then echo -e "${offset2}[${red}FAIL${null}]" echo "Error: could not unload nvidia module, leaving card turned on" 1>&2 exit else echo -e "${offset2}[ ${green}OK${null} ]" fi 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 "Disabling nVidia card failed (${result})." ;; *) echo "Disabling nVidia card succeeded." ;; esac } echo -en " ${blue}*${null} Doing ACPI calls..." #INSERTPOWEROFF # echo _OFF $(acpi_call "\_SB.PCI0.PEG0.PEGP._OFF") log=$(acpi_call "\_SB.PCI0.PEG0.PEGP._PS3") if [ $? -eq 0 ] ; then echo -e "${offset1}[ ${green}OK${null} ]" else echo -e "${offset1}[${red}FAIL${null}]" echo $log 1>&2 fi unset red green blue null columns columns2 offset1 offset2 log