Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit 15f92e0

Browse files
committed
add lenovo ideapad support
1 parent 679c143 commit 15f92e0

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

gr.ictpro.jsalatas.plasma.pstate/contents/code/set_prefs.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ LG_FAN_MODE=$LG_LAPTOP_DRIVER/fan_mode
1818
LG_BATTERY_CHARGE_LIMIT=$LG_LAPTOP_DRIVER/battery_care_limit
1919
LG_USB_CHARGE=$LG_LAPTOP_DRIVER/usb_charge
2020

21+
IDEAPAD_LAPTOP_DRIVER=/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/
22+
IDEAPAD_BATTERY_CONSERVATION=$IDEAPAD_LAPTOP_DRIVER/conservation_mode
23+
IDEAPAD_FN_LOCK=$IDEAPAD_LAPTOP_DRIVER/fn_lock
24+
2125
check_lg_drivers() {
2226
if [ -d $LG_LAPTOP_DRIVER ]; then
2327
return 0
@@ -26,6 +30,14 @@ check_lg_drivers() {
2630
fi
2731
}
2832

33+
check_ideapad_drivers() {
34+
if [ -d $IDEAPAD_LAPTOP_DRIVER ]; then
35+
return 0
36+
else
37+
return 1
38+
fi
39+
}
40+
2941
check_dell_thermal () {
3042
smbios-thermal-ctl -g > /dev/null 2>&1
3143
OUT=$?
@@ -161,6 +173,28 @@ set_lg_usb_charge() {
161173
fi
162174
}
163175

176+
set_ideapad_battery_conservation(){
177+
enabled=$1
178+
if [ -n "$enabled" ]; then
179+
if [ "$enabled" == "true" ]; then
180+
printf '1\n' > $IDEAPAD_BATTERY_CONSERVATION; 2> /dev/null
181+
else
182+
printf '0\n' > $IDEAPAD_BATTERY_CONSERVATION; 2> /dev/null
183+
fi
184+
fi
185+
}
186+
187+
set_ideapad_fn_lock(){
188+
enabled=$1
189+
if [ -n "$enabled" ]; then
190+
if [ "$enabled" == "true" ]; then
191+
printf '0\n' > $IDEAPAD_FN_LOCK; 2> /dev/null
192+
else
193+
printf '1\n' > $IDEAPAD_FN_LOCK; 2> /dev/null
194+
fi
195+
fi
196+
}
197+
164198
read_all () {
165199
cpu_min_perf=`cat $CPU_MIN_PERF`
166200
cpu_max_perf=`cat $CPU_MAX_PERF`
@@ -213,6 +247,21 @@ if check_lg_drivers; then
213247
fi
214248
fi
215249

250+
if check_ideapad_drivers; then
251+
ideapad_battery_conservation=`cat $IDEAPAD_BATTERY_CONSERVATION`
252+
if [ "$ideapad_battery_conservation" == "1" ]; then
253+
ideapad_battery_conservation="true"
254+
else
255+
ideapad_battery_conservation="false"
256+
fi
257+
ideapad_fn_lock=`cat $IDEAPAD_FN_LOCK`
258+
if [ "$ideapad_fn_lock" == "0" ]; then
259+
ideapad_fn_lock="true"
260+
else
261+
ideapad_fn_lock="false"
262+
fi
263+
fi
264+
216265
if check_nvidia; then
217266
powermizer=`nvidia-settings -q GpuPowerMizerMode | grep "Attribute 'GPUPowerMizerMode'" | awk -F "): " '{print $2}' | awk -F "." '{print $1}' `
218267
fi
@@ -237,6 +286,10 @@ if check_lg_drivers; then
237286
json="${json},\"lg_usb_charge\":\"${lg_usb_charge}\""
238287
json="${json},\"lg_fan_mode\":\"${lg_fan_mode}\""
239288
fi
289+
if check_ideapad_drivers; then
290+
json="${json},\"ideapad_battery_conservation\":\"${ideapad_battery_conservation}\""
291+
json="${json},\"ideapad_fn_lock\":\"${ideapad_fn_lock}\""
292+
fi
240293
if check_nvidia; then
241294
json="${json},\"powermizer\":\"${powermizer}\""
242295
fi
@@ -293,6 +346,14 @@ case $1 in
293346
set_lg_usb_charge $2
294347
;;
295348

349+
"-ideapad-battery-conservation")
350+
set_ideapad_battery_conservation $2
351+
;;
352+
353+
"-ideapad-fn-lock")
354+
set_ideapad_fn_lock $2
355+
;;
356+
296357
"-powermizer")
297358
set_powermizer $2
298359
;;
@@ -315,6 +376,8 @@ case $1 in
315376
echo " -lg-battery-charge-limit |"
316377
echo " -lg-fan-mode |"
317378
echo " -lg-usb-charge |"
379+
echo " -ideapad-battery-conservation |"
380+
echo " -ideapad-fn-lock |"
318381
echo " -powermizer ] value"
319382
echo "2: set_prefs.sh -read-all"
320383
exit 3

gr.ictpro.jsalatas.plasma.pstate/contents/code/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@ var sensors = {
7979
'lg_battery_charge_limit': {'value': undefined, 'unit':'', 'print': to_bool},
8080
'lg_usb_charge': {'value': undefined, 'unit':'', 'print': to_bool},
8181
'lg_fan_mode': {'value': undefined, 'unit':'', 'print': to_bool},
82+
'ideapad_battery_conservation': {'value': undefined, 'unit':'', 'print': to_bool},
83+
'ideapad_fn_lock': {'value': undefined, 'unit':'', 'print': to_bool},
8284
'powermizer': {'value': undefined, 'unit':'', 'print': to_string},
8385

8486
}
8587

8688
var vendors = {
8789
'dell': {'provides': ['thermal_mode']},
8890
'lg-laptop': {'provides': ['lg_battery_charge_limit', 'lg_usb_charge', 'lg_fan_mode']},
91+
'ideapad-laptop': {'provides': ['ideapad_battery_conservation', 'ideapad_fn_lock']},
8992
'nvidia': {'provides': ['powermizer']}
9093
}
9194

@@ -146,6 +149,13 @@ var model = [
146149
{'type': 'switch', 'text': 'Silent Mode', 'sensor': 'lg_fan_mode'}
147150
]
148151
},
152+
{'type': 'header', 'text': 'Ideapad Laptop', 'icon': 'm',
153+
'vendors': ['ideapad-laptop'],
154+
'items': [
155+
{'type': 'switch', 'text': 'Battery Conservation', 'sensor': 'ideapad_battery_conservation'},
156+
{'type': 'switch', 'text': 'Hotkey Mode', 'sensor': 'ideapad_fn_lock'}
157+
]
158+
},
149159
{'type': 'header', 'text': 'Nvidia Settings', 'icon': 'o',
150160
'vendors': ['nvidia'],
151161
'items': [

0 commit comments

Comments
 (0)