More logical pwr_{on,off}.
This commit is contained in:
parent
7ba3e230ae
commit
e97786e979
|
@ -1,14 +1,30 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
model=`dmidecode $@ -s system-product-name`
|
TRIES=8
|
||||||
|
|
||||||
let retry=8
|
lsmod | grep '^nouveau ' >/dev/null && modprobe -rf nouveau &>/dev/null
|
||||||
while [ 0 -lt $retry ]; do
|
|
||||||
if [ -f /sys/kernel/debug/vgaswitcheroo/switch ]; then
|
# Trying vgaswitcheroo method
|
||||||
|
if [ -f /sys/kernel/debug/vgaswitcheroo/switch ]; then
|
||||||
|
let tries=$TRIES
|
||||||
|
while [ 0 -lt $tries ]; do
|
||||||
modprobe -r nvidia \
|
modprobe -r nvidia \
|
||||||
&& echo 'OFF DIS' > /sys/kernel/debug/vgaswitcheroo/switch \
|
&& echo 'OFF DIS' > /sys/kernel/debug/vgaswitcheroo/switch \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
else
|
|
||||||
|
sleep 0.01
|
||||||
|
let tries--
|
||||||
|
echo "tries left: $tries"
|
||||||
|
done
|
||||||
|
echo "Cann't power off nVidia chip ;-("
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Trying acpi_call method
|
||||||
|
if [ -f /proc/acpi/call ]; then
|
||||||
|
model=`dmidecode $@ -s system-product-name`
|
||||||
|
tries=$TRIES
|
||||||
|
while [ 0 -lt $tries ]; do
|
||||||
case "$model" in
|
case "$model" in
|
||||||
M11XR2)
|
M11XR2)
|
||||||
modprobe -r nvidia \
|
modprobe -r nvidia \
|
||||||
|
@ -89,12 +105,12 @@ while [ 0 -lt $retry ]; do
|
||||||
*) echo "Snail: unknown Notebook model: $model"; exit -1
|
*) echo "Snail: unknown Notebook model: $model"; exit -1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 0.2
|
sleep 0.01
|
||||||
let retry--
|
let tries--
|
||||||
echo "retry countdown: $retry"
|
echo "tries left: $tries"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cann't power off nVidia chip"
|
||||||
exit -1
|
exit -1
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,30 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
model=`dmidecode $@ -s system-product-name`
|
TRIES=8
|
||||||
|
|
||||||
let retry=8
|
lsmod | grep '^nouveau ' >/dev/null && modprobe -rf nouveau &>/dev/null
|
||||||
while [ 0 -lt $retry ]; do
|
|
||||||
if [ -f /sys/kernel/debug/vgaswitcheroo/switch ]; then
|
# Trying vgaswitcheroo method
|
||||||
|
if [ -f /sys/kernel/debug/vgaswitcheroo/switch ]; then
|
||||||
|
let tries=$TRIES
|
||||||
|
while [ 0 -lt $tries ]; do
|
||||||
echo 'ON DIS' > /sys/kernel/debug/vgaswitcheroo/switch \
|
echo 'ON DIS' > /sys/kernel/debug/vgaswitcheroo/switch \
|
||||||
&& modprobe nvidia \
|
&& modprobe nvidia \
|
||||||
&& exit 0
|
&& exit 0
|
||||||
else
|
|
||||||
|
sleep 0.01
|
||||||
|
let tries--
|
||||||
|
echo "tries left: $tries"
|
||||||
|
done
|
||||||
|
echo "Cann't power on nVidia chip ;-("
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Trying acpi_call method
|
||||||
|
if [ -f /proc/acpi/call ]; then
|
||||||
|
model=`dmidecode $@ -s system-product-name`
|
||||||
|
tries=$TRIES
|
||||||
|
while [ 0 -lt $tries ]; do
|
||||||
case "$model" in
|
case "$model" in
|
||||||
M11XR2)
|
M11XR2)
|
||||||
echo '\_SB.PCI0.P0P2.PEGP._PS0' > /proc/acpi/call \
|
echo '\_SB.PCI0.P0P2.PEGP._PS0' > /proc/acpi/call \
|
||||||
|
@ -89,12 +105,12 @@ while [ 0 -lt $retry ]; do
|
||||||
*) echo "Snail: unknown Notebook model: $model"; exit -1
|
*) echo "Snail: unknown Notebook model: $model"; exit -1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 0.01
|
sleep 0.01
|
||||||
let retry--
|
let tries--
|
||||||
echo "retry countdown $retry"
|
echo "tries left: $tries"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cann't power on nVidia chip"
|
||||||
exit -1
|
exit -1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue