-
Notifications
You must be signed in to change notification settings - Fork 1
/
caribe
executable file
·106 lines (99 loc) · 2.86 KB
/
caribe
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
#!/bin/sh
# echo 'on' if 1st argument is equal to 2nd, otherwise 'off'
on_off() {
if [ $# -lt 2 ]; then
echo 'off'
elif [ "$1" -eq "$2" ]; then
echo 'on'
else
echo 'off'
fi
}
battery_care() {
file='/sys/devices/platform/sony-laptop/battery_care_limiter'
current_value=$(cat $file)
choice=$(
dialog --radiolist \
'Set the fan contolls' \
0 60 0 \
'50' 'Battery care (50%)' "$(on_off 50 "$current_value")"\
'80' 'Battery care (80%)' "$(on_off 80 "$current_value")"\
'0' 'Disable battery care' "$(on_off 0 "$current_value")"\
2>&1 >/dev/tty
)
if [ $? -eq 0 ]; then
echo "$choice" >$file || exit 1
fi
}
fan_controll() {
file='/sys/devices/platform/sony-laptop/thermal_control'
current_value=$(cat $file)
choice=$(
dialog --radiolist \
'Set the fan contolls' \
0 60 0 \
'balanced' 'Balanced performance mode' "$(on_off balanced "$current_value")" \
'silent' 'Silent fan mode' "$(on_off silent "$current_value")" \
'performance' 'High performance mode' "$(on_off performance "$current_value")" \
2>&1 >/dev/tty
)
if [ $? -eq 0 ]; then
echo "$choice" >$file || exit 1
fi
}
kbd_backlight() {
file='/sys/devices/platform/sony-laptop/kbd_backlight'
current_value=$(cat<$file)
choice=$(
dialog --radiolist \
'Enable/disable the keyboard backlight' \
0 60 0 \
'0' 'Disable' "$(on_off 0 "$current_value")" \
'1' 'Enable' "$(on_off 1 "$current_value")" \
2>&1 >/dev/tty
)
if [ $? -eq 0 ]; then
echo "$choice" >$file || exit 1
fi
}
lid_resume() {
file='/sys/devices/platform/sony-laptop/lid_resume_S5'
current_value=$(cat $file)
choice=$(
dialog --radiolist \
'Enable/disable resume on lid open' \
0 60 0 \
'0' 'Disable' "$(on_off 0 "$current_value")"\
'1' 'Enable' "$(on_off 1 "$current_value")"\
2>&1 >/dev/tty
)
if [ $? -eq 0 ]; then
echo "$choice" >$file || exit 1
fi
}
mainmenu() {
battery_care='Battery Care'
fan_controll='Fan Controll'
kbd_backlight='Keyboard Backlight'
lid_resume='Resume on lid open'
while true; do
choice=$(
dialog --title 'VAIO Care' \
--menu 'Select an item to configure' 0 60 0 \
"$battery_care" 'Set the maximum of the battery charge' \
"$fan_controll" 'Set the fan controlls' \
"$kbd_backlight" 'Enable/disable the keyboard backlight' \
"$lid_resume" 'Enable/disable resume on lid open' \
2>&1 >/dev/tty
)
[ $? -ne 0 ] && return
case $choice in
"$battery_care") battery_care;;
"$fan_controll") fan_controll;;
"$kbd_backlight") kbd_backlight;;
"$lid_resume") lid_resume;;
esac
done
}
mainmenu
clear