[+] update config

1. update pr34 cpufreq action
  1.1. add support for amd_pstate cpus;
  1.2. add pr34 .whl release;
  2. fetch configs for new platform;
  3. fetch sensitive configs and store gpg encrypted data;
This commit is contained in:
Siarhei Siniak 2025-11-30 21:51:48 +03:00
parent 1377fdd9ff
commit b50468154f
12 changed files with 253 additions and 2 deletions

1
.gitattributes vendored

@ -2,3 +2,4 @@ releases/tar/** filter=lfs diff=lfs merge=lfs -text
releases/whl/** filter=lfs diff=lfs merge=lfs -text releases/whl/** filter=lfs diff=lfs merge=lfs -text
python/deps/whl/** filter=lfs diff=lfs merge=lfs -text python/deps/whl/** filter=lfs diff=lfs merge=lfs -text
docker/*/deps/whl/** filter=lfs diff=lfs merge=lfs -text docker/*/deps/whl/** filter=lfs diff=lfs merge=lfs -text
**/*.gpg filter=lfs diff=lfs merge=lfs -text

@ -117,6 +117,25 @@ dotfiles_put_platform:
sudo udevadm control --reload sudo udevadm control --reload
sudo systemctl daemon-reload sudo systemctl daemon-reload
GPG_RECIPIENTS_ARGS ?= -r 891382BEBFEFFC6729837400DA0B6C15FBB70FC9
dotfiles_fetch_platform:
mkdir -p platform_dotfiles/$(PLATFORM)
mkdir -p platform_dotfiles_gpg/$(PLATFORM)
tar -cvf - \
/etc/udev/rules.d/ \
/usr/local/bin \
| tar -xvf - -C platform_dotfiles/$(PLATFORM)
tar -h -cvf - \
~/.sway/config.d \
~/.config/commands-status.json \
/etc/fstab \
| gpg -e $(GPG_RECIPIENTS_ARGS) \
> platform_dotfiles_gpg/$(PLATFORM)/sensitive-configs-$$(date -Iseconds).gpg
dotfiles_fetch_platform_ideapad_slim_3_15arp10:
make dotfiles_fetch_platform \
PLATFORM=ideapad_slim_3_15arp10
dotfiles_sway_put: dotfiles_sway_put:
mkdir -p ~/.sway mkdir -p ~/.sway
cp dotfiles/.sway/config ~/.sway/config cp dotfiles/.sway/config ~/.sway/config

@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="net", KERNEL=="tun0", TAG+="systemd"

@ -0,0 +1,11 @@
ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/pci0000:00/0000:00:1b.0/hdaudioC0D0/leds/hda::mute", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness"
ACTION=="add|change", SUBSYSTEM=="leds", DEVPATH=="/devices/platform/applesmc.768/leds/smc::kbd_backlight", RUN{program}+="/usr/bin/chmod 666 /sys$devpath/brightness"
# udevadm info --attribute-walk --path=/sys/devices/platform/applesmc.768/
# udevadm trigger --action=add --verbose --parent-match /devices/platform/applesmc.768/
#ACTION=="add|change", KERNEL=="applesmc.768", SUBSYSTEM=="platform", DRIVER=="applesmc", RUN{program}+="ls -allh /sys$devpath/", OPTIONS="log_level=debug"
#ACTION=="add|change", KERNEL=="applesmc.768", SUBSYSTEM=="platform", DRIVER=="applesmc", RUN{program}+="/usr/bin/ls -allh /sys$devpath/", OPTIONS="log_level=debug"
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", KERNEL=="cpu1", 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"

@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="max_performance", OPTIONS="log_level=debug"

@ -0,0 +1,116 @@
#!/usr/bin/python3
# vi: filetype=python
import re
import sys
import os
import time
import subprocess
import argparse
import logging
from typing import (Any,)
logger = logging.getLogger(__name__)
def run() -> None:
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser()
parser.add_argument(
'--device',
)
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
''',
),
amd_pstate=dict(
devpath=r'/?sys/devices/system/cpu/cpu1',
node='/sys/devices/system/cpu/amd_pstate/status',
cmd=r'''
chown root:fan /sys/devices/system/cpu/cpu*/cpufreq/boost
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/boost
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()

@ -0,0 +1,73 @@
#!/usr/bin/python3
#vi syntax=python
import subprocess
import sys
import logging
from typing import (Optional,)
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
if sys.argv[1] == 'before-suspend':
logger.info('before-suspend started')
subprocess.check_call(['nmcli', 'radio', 'wifi', 'off'])
#subprocess.check_call(['modprobe', '-r', 'atkbd',])
subprocess.check_call(['modprobe', '-r', 'ideapad_laptop',])
subprocess.check_call(['modprobe', '-r', 'i8042',])
logger.info('before-suspend done')
elif sys.argv[1] == 'after-suspend':
logger.info('after-suspend started')
subprocess.check_call(['modprobe', 'i8042',])
subprocess.check_call(['modprobe', 'ideapad_laptop',])
#subprocess.check_call(['modprobe', 'atkbd',])
subprocess.check_call(['nmcli', 'radio', 'wifi', 'on'])
subprocess.check_call(['rfkill', 'unblock', '109'])
#subprocess.check_call(r'''
# # systemctl restart wg-quick@siarhei-hp.service
#''', shell=True,)
logger.info('after-suspend done')
elif sys.argv[1] == 'lid-switch':
import evdev
import time
import io
lid = evdev.UInput({5 : [0]}, name="virtual-lid-switch")
last_state : Optional[bool] = None
try:
while True:
try:
with io.open('/proc/acpi/button/lid/LID0/state', 'r') as f:
value = f.read()
except:
logger.exception('')
value = None
time.sleep(1)
continue
if not value is None:
if 'open' in value:
is_opened = True
else:
is_opened = False
if last_state != is_opened:
if is_opened:
logger.info(dict(msg='lid opened'))
lid.write(5, 0, 0)
lid.write(0, 0, 0)
else:
logger.info(dict(msg='lid closed'))
lid.write(5, 0, 1)
lid.write(0, 0, 0)
last_state = is_opened
time.sleep(0.1)
finally:
lid.close()
else:
raise NotImplementedError

@ -5,7 +5,7 @@ project(
).stdout().strip('\n'), ).stdout().strip('\n'),
# 'online.fxreader.uv', # 'online.fxreader.uv',
# ['c', 'cpp'], # ['c', 'cpp'],
version: '0.1.5.40', version: '0.1.5.41',
# default_options: [ # default_options: [
# 'cpp_std=c++23', # 'cpp_std=c++23',
# # 'prefer_static=true', # # 'prefer_static=true',

@ -2605,8 +2605,10 @@ def desktop_services(argv):
]: ]:
if os.path.exists('/sys/bus/platform/devices/applesmc.768'): if os.path.exists('/sys/bus/platform/devices/applesmc.768'):
return 'applesmc.768' return 'applesmc.768'
if os.path.exists('/sys/devices/system/cpu/intel_pstate/no_turbo'): elif os.path.exists('/sys/devices/system/cpu/intel_pstate/no_turbo'):
return 'intel_pstate' return 'intel_pstate'
elif os.path.exists('/sys/devices/system/cpu/amd_pstate'):
return 'amd_pstate'
else: else:
raise NotImplementedError raise NotImplementedError
@ -2637,6 +2639,15 @@ echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo 40 > /sys/devices/system/cpu/intel_pstate/max_perf_pct; echo 40 > /sys/devices/system/cpu/intel_pstate/max_perf_pct;
echo 900000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; echo 900000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
""",
shell=True,
)
elif cls.profile() == 'amd_pstate':
subprocess.check_call(
r"""
echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo 800000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
echo 0 | tee /sys/devices/system/cpu/cpu*/cpufreq/boost
""", """,
shell=True, shell=True,
) )
@ -2668,6 +2679,15 @@ echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
echo 60 > /sys/devices/system/cpu/intel_pstate/max_perf_pct; echo 60 > /sys/devices/system/cpu/intel_pstate/max_perf_pct;
echo 1200000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; echo 1200000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; echo schedutil | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
""",
shell=True,
)
elif cls.profile() == 'amd_pstate':
subprocess.check_call(
r"""
echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
cat /sys/devices/system/cpu/cpu0/cpufreq/amd_pstate_max_freq | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq;
echo 1 | tee /sys/devices/system/cpu/cpu*/cpufreq/boost
""", """,
shell=True, shell=True,
) )

BIN
releases/whl/online_fxreader_pr34-0.1.5.41-py3-none-any.whl (Stored with Git LFS) Normal file

Binary file not shown.