* Remove | in type * Repare battery read problem * Compatible with many arguments
This commit is contained in:
parent
1e44c8031c
commit
a7df94d832
|
@ -33,10 +33,6 @@ def ideapad_acpi_print_thresholds():
|
||||||
print(f"battery count = {len(batteries)}")
|
print(f"battery count = {len(batteries)}")
|
||||||
for bat in batteries:
|
for bat in batteries:
|
||||||
try:
|
try:
|
||||||
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_start_threshold', 'r') as f:
|
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_start_threshold")}')
|
||||||
print(f'{bat} start threshold = {f.read()}', end="")
|
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_stop_threshold")}')
|
||||||
|
except Exception as e: print(f"ERROR: failed to read battery {bat} thresholds: ", repr(e))
|
||||||
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_stop_threshold', 'r') as f:
|
|
||||||
print(f'{bat} stop threshold = {f.read()}', end="")
|
|
||||||
|
|
||||||
except Exception: print(f"ERROR: failed to read battery {bat} thresholds")
|
|
||||||
|
|
|
@ -64,10 +64,6 @@ def ideapad_laptop_print_thresholds():
|
||||||
print(f"battery count = {len(batteries)}")
|
print(f"battery count = {len(batteries)}")
|
||||||
for bat in batteries:
|
for bat in batteries:
|
||||||
try:
|
try:
|
||||||
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_start_threshold', 'r') as f:
|
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_start_threshold")}')
|
||||||
print(f'{bat} start threshold = {f.read()}', end="")
|
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_stop_threshold")}')
|
||||||
|
except Exception as e: print(f"ERROR: failed to read battery {bat} thresholds: ", repr(e))
|
||||||
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_stop_threshold', 'r') as f:
|
|
||||||
print(f'{bat} stop threshold = {f.read()}', end="")
|
|
||||||
|
|
||||||
except Exception as e: print(f"ERROR: failed to read {bat} thresholds: {e}")
|
|
||||||
|
|
|
@ -34,10 +34,6 @@ def thinkpad_print_thresholds():
|
||||||
print(f"battery count = {len(batteries)}")
|
print(f"battery count = {len(batteries)}")
|
||||||
for bat in batteries:
|
for bat in batteries:
|
||||||
try:
|
try:
|
||||||
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_start_threshold', 'r') as f:
|
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_start_threshold")}')
|
||||||
print(f'{bat} start threshold = {f.read()}', end="")
|
print(f'{bat} start threshold = {subprocess.getoutput(f"cat {POWER_SUPPLY_DIR}{bat}/charge_stop_threshold")}')
|
||||||
|
except Exception as e: print(f"ERROR: failed to read battery {bat} thresholds: ", repr(e))
|
||||||
with open(f'{POWER_SUPPLY_DIR}{bat}/charge_stop_threshold', 'r') as f:
|
|
||||||
print(f'{bat} stop threshold = {f.read()}', end="")
|
|
||||||
|
|
||||||
except Exception: print(f"ERROR: failed to read battery {bat} thresholds")
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from subprocess import run, PIPE
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def find_config_file(args_config_file: str | None) -> str:
|
def find_config_file(args_config_file) -> str:
|
||||||
"""
|
"""
|
||||||
Find the config file to use.
|
Find the config file to use.
|
||||||
|
|
||||||
|
|
|
@ -3,32 +3,15 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# get script name
|
|
||||||
PROGNAME=$(basename "${0}")
|
|
||||||
|
|
||||||
# bailout function
|
# bailout function
|
||||||
err_exit()
|
err_exit() {
|
||||||
{
|
echo "$(basename $0): ${1:-wrong invocation. try --help for help.}" 1>&2
|
||||||
echo "${PROGNAME}: ${1:-wrong invocation. try --help for help.}" 1>&2
|
exit 1
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# invocation handling
|
|
||||||
#
|
|
||||||
|
|
||||||
# load python virtual environment
|
# load python virtual environment
|
||||||
venv_dir=/opt/auto-cpufreq/venv
|
opt_path=/opt/auto-cpufreq
|
||||||
. "$venv_dir/bin/activate"
|
venv_bin_dir=$opt_path/venv/bin
|
||||||
|
. "$venv_bin_dir/activate"
|
||||||
|
|
||||||
# run python code with venv loaded
|
PYTHONPATH=$opt_path $venv_bin_dir/python $venv_bin_dir/auto-cpufreq "$@"
|
||||||
if [[ "$#" -ne 1 ]]; then
|
|
||||||
PYTHONPATH=/opt/auto-cpufreq \
|
|
||||||
/opt/auto-cpufreq/venv/bin/python \
|
|
||||||
/opt/auto-cpufreq/venv/bin/auto-cpufreq
|
|
||||||
else
|
|
||||||
param="$1"
|
|
||||||
PYTHONPATH=/opt/auto-cpufreq \
|
|
||||||
/opt/auto-cpufreq/venv/bin/python \
|
|
||||||
/opt/auto-cpufreq/venv/bin/auto-cpufreq \
|
|
||||||
"${param}"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in New Issue