Created
December 26, 2012 14:44
-
-
Save nilya/4380689 to your computer and use it in GitHub Desktop.
"vgaswitch" script to turn on/off discrete videocard under Linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Place this file under /usr/local/bin/vgaswitch | |
# load module (without this module "vgaswitcheroo" isn't available on my system) | |
modprobe radeon | |
# switch | |
SWITCH=/sys/kernel/debug/vgaswitcheroo/switch | |
if [ $# -eq 1 ]; then | |
if [ "$1" == "low" ]; then | |
echo "Turning on low-power card." | |
echo DIGD > $SWITCH | |
elif [ "$1" == "high" ]; then | |
echo "Turning on high-power card." | |
echo DDIS > $SWITCH | |
elif [ "$1" == "on" ]; then | |
echo "Turning on unused card." | |
echo ON > $SWITCH | |
elif [ "$1" == "off" ]; then | |
echo "Turning off unused card." | |
echo OFF > $SWITCH | |
elif [ "$1" == "st" ]; then | |
cat $SWITCH | |
fi | |
else | |
echo "Commands: [low, high, on, off]" | |
echo | |
echo "Status:" | |
cat $SWITCH | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: vgaswitch | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Power on second videocard to fix errors on shutdown. | |
# Description: Place this file under /etc/init.d/vgaswitch and run "update-rc.d vgaswitch defaults". | |
### END INIT INFO | |
# Do NOT "set -e" | |
# PATH should only include /usr/* if it runs after the mountnfs.sh script | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
case "$1" in | |
start) | |
;; | |
stop) | |
/usr/local/bin/vgaswitch on | |
;; | |
esac | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://01.org/linuxgraphics/gfx-docs/drm/gpu/vga-switcheroo.html