-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathippm.sh
executable file
·133 lines (120 loc) · 2.83 KB
/
ippm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
set -e
ACPI_CALL_PATH=/proc/acpi/call
CONSERVATION_MODE_PATH="/sys/bus/platform/drivers/ideapad_acpi/VPC*/conservation_mode"
check_conservation() {
cat $CONSERVATION_MODE_PATH
}
set_conservation() {
case $1 in
0)
echo "Turn OFF conservation mode"
echo 0 | tee $CONSERVATION_MODE_PATH > /dev/null
;;
1)
echo "Turn ON conservation mode"
echo 1 | tee $CONSERVATION_MODE_PATH > /dev/null
;;
*)
>&2 echo "0 or 1 expected"
exit 1
;;
esac
}
check_rapid_charge() {
# Check if rapid charge is on
echo '\_SB.PCI0.LPC0.EC0.FCGM' | tee $ACPI_CALL_PATH > /dev/null 2>&1
BYTE0=$(tr -d '\0' < $ACPI_CALL_PATH | grep -o "0x.")
if [[ $BYTE0 == "0x0" ]]
then
echo 0
else
echo 1
fi
}
set_rapid_charge() {
case $1 in
0)
echo "Turn OFF rapid charge"
echo '\_SB.PCI0.LPC0.EC0.VPC0.SBMC 0x08' | tee $ACPI_CALL_PATH > /dev/null 2>&1
;;
1)
echo "Turn ON rapid charge"
echo '\_SB.PCI0.LPC0.EC0.VPC0.SBMC 0x07' | tee $ACPI_CALL_PATH > /dev/null 2>&1
;;
*)
>&2 echo "0 or 1 expected"
exit 1
;;
esac
}
check_perf_mode() {
# Check status of BIOS POWER MODE
echo '\_SB.PCI0.LPC0.EC0.STMD' | tee $ACPI_CALL_PATH > /dev/null 2>&1
BYTE0=$(tr -d '\0' < $ACPI_CALL_PATH | grep -o "0x.")
echo '\_SB.PCI0.LPC0.EC0.QTMD' | tee $ACPI_CALL_PATH > /dev/null 2>&1
BYTE1=$(tr -d '\0' < $ACPI_CALL_PATH | grep -o "0x.")
case "$BYTE0 $BYTE1" in
"0x0 0x0" )
echo 0
;;
"0x0 0x1" )
echo 1
;;
"0x1 0x0" )
echo 2
;;
esac
}
set_perf_mode() {
case $1 in
0)
echo "Turning on Extreme Performance mode in BIOS"
echo '\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x0012B001' | tee $ACPI_CALL_PATH > /dev/null 2>&1
;;
1)
echo "Turning on Battery Saving mode in BIOS"
echo '\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x0013B001' | tee $ACPI_CALL_PATH > /dev/null 2>&1
;;
2)
echo "Turning on Intelligent Cooling mode in BIOS"
echo '\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x000FB001' | tee $ACPI_CALL_PATH > /dev/null 2>&1
;;
*)
>&2 echo "Choose one of [ 0=EXTREME_PERFORMANCE , 2=INTELLIGENT_COOLING , 1=BATTERY_SAVING ]"
exit 1
;;
esac
}
if [[ $1 == "get" ]]
then
if [[ $2 == "cm" ]]
then
check_conservation
exit 0
elif [[ $2 == "rc" ]]
then
check_rapid_charge
exit 0
elif [[ $2 == "perf" ]]
then
check_perf_mode
exit 0
fi
elif [[ $1 == "set" ]]
then
if [[ $2 == "cm" ]]
then
set_conservation $3
exit 0
elif [[ $2 == "rc" ]]
then
set_rapid_charge $3
exit 0
elif [[ $2 == "perf" ]]
then
set_perf_mode $3
exit 0
fi
fi
echo "Usage: ippm [set/get] [cm/rc/perf] [num]"