2024-02-07 06:27:56 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import subprocess
|
|
|
|
|
2024-03-11 07:09:26 +01:00
|
|
|
from auto_cpufreq.battery_scripts.thinkpad import thinkpad_setup, thinkpad_print_thresholds
|
|
|
|
from auto_cpufreq.battery_scripts.ideapad_acpi import ideapad_acpi_setup, ideapad_acpi_print_thresholds
|
|
|
|
from auto_cpufreq.battery_scripts.ideapad_laptop import ideapad_laptop_setup, ideapad_laptop_print_thresholds
|
2024-02-07 06:27:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
def lsmod(module):
|
2024-02-13 19:34:11 +01:00
|
|
|
output = subprocess.run(
|
2024-03-19 00:37:47 +01:00
|
|
|
['lsmod'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True)
|
2024-02-07 06:27:56 +01:00
|
|
|
if module in output.stdout:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2024-03-11 07:09:26 +01:00
|
|
|
def battery_setup():
|
2024-02-07 06:27:56 +01:00
|
|
|
|
2024-03-11 07:09:26 +01:00
|
|
|
if lsmod("thinkpad_acpi"):
|
|
|
|
thinkpad_setup()
|
2024-02-07 06:27:56 +01:00
|
|
|
|
2024-03-11 07:09:26 +01:00
|
|
|
elif lsmod("ideapad_acpi"):
|
|
|
|
ideapad_acpi_setup()
|
2024-02-07 06:27:56 +01:00
|
|
|
|
2024-03-11 07:09:26 +01:00
|
|
|
elif lsmod("ideapad_laptop"):
|
|
|
|
ideapad_laptop_setup()
|
2024-02-07 06:27:56 +01:00
|
|
|
|
|
|
|
else:
|
2024-03-11 07:09:26 +01:00
|
|
|
return
|
2024-02-07 06:27:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
def battery_get_thresholds():
|
2024-04-30 08:35:53 +02:00
|
|
|
|
2024-03-11 07:09:26 +01:00
|
|
|
if lsmod("thinkpad_acpi"):
|
|
|
|
thinkpad_print_thresholds()
|
|
|
|
|
|
|
|
elif lsmod("ideapad_acpi"):
|
|
|
|
ideapad_acpi_print_thresholds()
|
|
|
|
|
|
|
|
elif lsmod("ideapad_laptop"):
|
|
|
|
ideapad_laptop_print_thresholds()
|
|
|
|
|
2024-02-07 06:27:56 +01:00
|
|
|
else:
|
|
|
|
return
|