-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlaptop_mode.sh
58 lines (52 loc) · 1.35 KB
/
laptop_mode.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
#!/bin/bash
function EchoRed()
{
Msg=$1
Msg="[${FUNCNAME[1]}:${LINENO}]$Msg"
echo -e "\033[31m$Msg\033[0m"
}
function EchoGreen()
{
Msg=$1
Msg="[${FUNCNAME[1]}:${LINENO}]$Msg"
echo -e "\033[32m$Msg\033[0m"
}
function LapTopModeRun
{
sudo laptop_mode start
if [[ $? -ne 0 ]];then
sudo apt-get install laptop-mode-tools
sudo laptop_mode start
fi
cat /proc/sys/vm/laptop_mode
}
function LapTopModeCfgItem
{
KeyWord=$1
CfgFile=$2
grep -Hn "$KeyWord=" $CfgFile
if [[ $? -eq 0 ]];then
echo "sed -e 's#"$KeyWord"=.*#"$KeyWord"=1#g' -i $CfgFile"
sed -e 's#'"$KeyWord"'=.*#'"$KeyWord"'=1#g' -i $CfgFile
else
EchoRed "$KeyWord does not exist in $CfgFile."
fi
}
function LapTopModeCfg
{
CfgFile=$1
EchoGreen CfgFile:$CfgFile
LapTopModeCfgItem "ENABLE_LAPTOP_MODE" "$CfgFile"
LapTopModeCfgItem "ENABLE_LAPTOP_MODE_TOOLS" "$CfgFile"
LapTopModeCfgItem "ENABLE_LAPTOP_MODE_ON_BATTERY" "$CfgFile"
LapTopModeCfgItem "ENABLE_LAPTOP_MODE_ON_AC" "$CfgFile"
LapTopModeCfgItem "ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED" "$CfgFile"
grep -Hn "ENABLE_LAPTOP_MODE" $CfgFile
}
LapTopModeRun
CfgFile="/etc/default/acpi-support"
#LapTopModeCfg "$CfgFile"
CfgFile="/etc/laptop-mode/laptop-mode.conf"
#LapTopModeCfg "$CfgFile"
CfgFile="cfg_file.conf"
LapTopModeCfg "$CfgFile"