-
Notifications
You must be signed in to change notification settings - Fork 14
/
battery-conservation
executable file
·52 lines (46 loc) · 1.03 KB
/
battery-conservation
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
#!/bin/bash
function print_help() {
printf "\
Usage: battery-conservation [OPTION]\n\
\n\
Options:\n\
-h Print help information.\n\
-n Turn battery conservation on.\n\
-f Turn battery conservation off.\n\
-s See battery conservation status.\n"
}
file_path="/sys/bus/platform/drivers/ideapad_acpi/VPC2004*/conservation_mode"
while getopts 'hsnf' OPTION
do
case "$OPTION" in
h)
print_help
exit 0
;;
s)
status=$(bash -c "cat $file_path")
if [ "$status" = "0" ]; then
echo "Off"
elif [ "$status" = "1" ]; then
echo "On"
else
echo "Unknown"
fi
exit 0
;;
n)
sudo bash -c "echo 1 > $file_path"
exit 0
;;
f)
sudo bash -c "echo 0 > $file_path"
exit 0
;;
?)
print_help
exit 1
;;
esac
done
print_help
exit 1