From 7fa2a8a83cbd65ea3a47119a7c652b6a5694d10e Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Fri, 4 Apr 2025 12:40:09 +0300 Subject: [PATCH] [+] update platform 1. update udev for air 2012; 2. update commands for air 2012; --- deps/com.github.aiortc.aiortc | 2 +- .../etc/udev/{ => rules.d}/40-leds.rules | 4 +- .../usr/local/bin/online-fxreader-pr34-udev | 110 ++++++++++++++---- .../usr/local/bin/online-fxreader-pr34-udev | 24 ++-- python/online/fxreader/pr34/commands.py | 18 ++- python/pyproject.toml | 2 +- ...ine_fxreader_pr34-0.1.5.9-py3-none-any.whl | 3 + 7 files changed, 125 insertions(+), 38 deletions(-) rename platform_dotfiles/macbook_air_2012/etc/udev/{ => rules.d}/40-leds.rules (79%) create mode 100644 releases/whl/online_fxreader_pr34-0.1.5.9-py3-none-any.whl diff --git a/deps/com.github.aiortc.aiortc b/deps/com.github.aiortc.aiortc index 56af6d1..e52e1c2 160000 --- a/deps/com.github.aiortc.aiortc +++ b/deps/com.github.aiortc.aiortc @@ -1 +1 @@ -Subproject commit 56af6d17019cef5bd52bd47a64697de7245b7a2d +Subproject commit e52e1c22071d49ff23768dfefd1b33b94552ff6d diff --git a/platform_dotfiles/macbook_air_2012/etc/udev/40-leds.rules b/platform_dotfiles/macbook_air_2012/etc/udev/rules.d/40-leds.rules similarity index 79% rename from platform_dotfiles/macbook_air_2012/etc/udev/40-leds.rules rename to platform_dotfiles/macbook_air_2012/etc/udev/rules.d/40-leds.rules index b52ab0d..b075758 100644 --- a/platform_dotfiles/macbook_air_2012/etc/udev/40-leds.rules +++ b/platform_dotfiles/macbook_air_2012/etc/udev/rules.d/40-leds.rules @@ -7,5 +7,5 @@ ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/platform/applesmc.76 ACTION=="add|change", KERNEL=="applesmc.768", SUBSYSTEM=="platform", DRIVER=="applesmc", TAG+="systemd", ENV{SYSTEMD_WANTS}="online.fxreader.pr34.udev@$devnode.service", OPTIONS="log_level=debug" #KERNEL=="applesmc.768", SUBSYSTEM=="platform", DRIVER=="applesmc", MODE="0660", TAG+="uaccess", OPTIONS="log_level=debug", OPTIONS+="watch" ACTION=="add|change", DEVPATH=="/class/backlight/intel_backlight", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness" -ACTION=="add|change", DEVPATH=="/devices/system/cpu/", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/cpufreq/scaling_governor" -ACTION=="add|change", KERNEL=="cpu[0-9]", SUBSYSTEM=="cpu", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/cpufreq/scaling_governor" +ACTION=="add|change", KERNEL=="cpu0", SUBSYSTEM=="cpu", TAG+="systemd", ENV{SYSTEMD_WANTS}="online.fxreader.pr34.udev@$devnode.service", OPTIONS="log_level=debug" +ACTION=="add|change", KERNEL=="cpu[0-9]", SUBSYSTEM=="cpu", TAG+="systemd", ENV{SYSTEMD_WANTS}="online.fxreader.pr34.udev@$devnode.service", OPTIONS="log_level=debug" diff --git a/platform_dotfiles/macbook_air_2012/usr/local/bin/online-fxreader-pr34-udev b/platform_dotfiles/macbook_air_2012/usr/local/bin/online-fxreader-pr34-udev index 728a002..3a1499d 100755 --- a/platform_dotfiles/macbook_air_2012/usr/local/bin/online-fxreader-pr34-udev +++ b/platform_dotfiles/macbook_air_2012/usr/local/bin/online-fxreader-pr34-udev @@ -2,36 +2,102 @@ # vi: filetype=python +import re import sys import os import subprocess import argparse +import logging from typing import (Any,) +logger = logging.getLogger(__name__) -parser = argparse.ArgumentParser() -parser.add_argument( - '--device', -) -options = parser.parse_args() +def run() -> None: + logging.basicConfig(level=logging.INFO) -DEVICES : dict[str, Any] = dict( - applesmc=dict( - devpath='sys/devices/platform/applesmc.768', - fan_node='/sys/devices/platform/applesmc.768/fan1_manual', - cmd=r''' - chown root:fan /sys/devices/platform/applesmc.768/fan1_* - chmod g+w /sys/devices/platform/applesmc.768/fan1_* - ''', - ), -) + parser = argparse.ArgumentParser() + parser.add_argument( + '--device', + ) -if options.device == DEVICES['applesmc']['devpath']: - while True: - if os.path.exists(DEVICES['applesmc']['fan_node']): - subprocess.check_call(DEVICES['applesmc']['cmd'], shell=True) - break -else: - raise NotImplementedError + options = parser.parse_args() + + DEVICES : dict[str, Any] = dict( + applesmc=dict( + devpath='sys/devices/platform/applesmc.768', + node='/sys/devices/platform/applesmc.768/fan1_manual', + cmd=r''' + chown root:fan /sys/devices/platform/applesmc.768/fan1_* + chmod g+w /sys/devices/platform/applesmc.768/fan1_* + ''', + ), + intel_pstate=dict( + devpath=r'/?sys/devices/system/cpu/cpu0', + node='/sys/devices/system/cpu/intel_pstate/no_turbo', + cmd=r''' + chown root:fan /sys/devices/system/cpu/intel_pstate/no_turbo + chown root:fan /sys/devices/system/cpu/intel_pstate/max_perf_pct + #chown root:fan /sys/devices/system/cpu/intel_pstate/status + chmod g+w /sys/devices/system/cpu/intel_pstate/no_turbo + chmod g+w /sys/devices/system/cpu/intel_pstate/max_perf_pct + #chmod g+w /sys/devices/system/cpu/intel_pstate/status + echo passive > /sys/devices/system/cpu/intel_pstate/status + chown root:fan /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor + chown root:fan /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq + chmod g+w /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor + chmod g+w /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq + ''', + ), + #governor=dict( + # devpath=r'/?sys/devices/system/cpu/cpu(\d+)', + # node=r'/sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor', + # cmd=r''' + # chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor + # chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq + # chmod g+w /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor + # chmod g+w /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq + # ''', + #), + ) + + processed : int = 0 + + logger.info(dict(device=options.device)) + + for k, v in DEVICES.items(): + devpath = re.compile(v['devpath']) + + devpath_m = devpath.match(options.device) + + if devpath_m is None: + continue + + node_2 = v['node'].format(*devpath_m.groups()) + + # logger.info(dict(devpath_m=devpath_m, node=node_2)) + + while not os.path.exists(node_2): + #continue + time.sleep(1) + + cmd_2 = v['cmd'].format(*devpath_m.groups()) + + subprocess.check_call(cmd_2, shell=True) + + logger.info(dict( + devpath_m=devpath_m, + node_2=node_2, + cmd_2=cmd_2, + msg='processed', + label=k, + )) + + processed += 1 + + if processed == 0: + raise NotImplementedError + +if __name__ == '__main__': + run() diff --git a/platform_dotfiles/macbook_air_2018/usr/local/bin/online-fxreader-pr34-udev b/platform_dotfiles/macbook_air_2018/usr/local/bin/online-fxreader-pr34-udev index 40d15ec..3a1499d 100755 --- a/platform_dotfiles/macbook_air_2018/usr/local/bin/online-fxreader-pr34-udev +++ b/platform_dotfiles/macbook_air_2018/usr/local/bin/online-fxreader-pr34-udev @@ -44,18 +44,22 @@ def run() -> None: chmod g+w /sys/devices/system/cpu/intel_pstate/max_perf_pct #chmod g+w /sys/devices/system/cpu/intel_pstate/status echo passive > /sys/devices/system/cpu/intel_pstate/status + chown root:fan /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor + chown root:fan /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq + chmod g+w /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor + chmod g+w /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq ''', ), - governor=dict( - devpath=r'/?sys/devices/system/cpu/cpu(\d+)', - node=r'/sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor', - cmd=r''' - chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor - chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq - chmod g+w /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor - chmod g+w /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq - ''', - ), + #governor=dict( + # devpath=r'/?sys/devices/system/cpu/cpu(\d+)', + # node=r'/sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor', + # cmd=r''' + # chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor + # chown root:fan /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq + # chmod g+w /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_governor + # chmod g+w /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq + # ''', + #), ) processed : int = 0 diff --git a/python/online/fxreader/pr34/commands.py b/python/online/fxreader/pr34/commands.py index 5100c83..ac10bf0 100644 --- a/python/online/fxreader/pr34/commands.py +++ b/python/online/fxreader/pr34/commands.py @@ -2614,8 +2614,16 @@ def desktop_services(argv): def powersave(cls): if cls.profile() == 'applesmc.768': subprocess.check_call(r''' +#echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; +#echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; +#echo 1 > /sys/bus/platform/devices/applesmc.768/fan1_manual; +#echo 2000 > /sys/bus/platform/devices/applesmc.768/fan1_output; + echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; -echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; +echo 30 > /sys/devices/system/cpu/intel_pstate/max_perf_pct; +echo 900000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; +echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; + echo 1 > /sys/bus/platform/devices/applesmc.768/fan1_manual; echo 2000 > /sys/bus/platform/devices/applesmc.768/fan1_output; ''', shell=True) @@ -2633,8 +2641,14 @@ echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; def performance(cls): if cls.profile() == 'applesmc.768': subprocess.check_call(r''' +#echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; +#echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; + echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; -echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; +echo 60 > /sys/devices/system/cpu/intel_pstate/max_perf_pct; +echo 1200000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; +echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; + echo 1 > /sys/bus/platform/devices/applesmc.768/fan1_manual; echo 6500 > /sys/bus/platform/devices/applesmc.768/fan1_output; ''', shell=True) diff --git a/python/pyproject.toml b/python/pyproject.toml index 731073b..35976b5 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = 'online.fxreader.pr34' -version = '0.1.5.8' +version = '0.1.5.9' dependencies = [ #"-r requirements.txt", diff --git a/releases/whl/online_fxreader_pr34-0.1.5.9-py3-none-any.whl b/releases/whl/online_fxreader_pr34-0.1.5.9-py3-none-any.whl new file mode 100644 index 0000000..681c013 --- /dev/null +++ b/releases/whl/online_fxreader_pr34-0.1.5.9-py3-none-any.whl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cab4efe434a88d719b0b309c0e8f9a54361f33393cce54f91618742db5b4beb9 +size 69373