[+] update pr34

1. fetch sensitive configs,
    mark telegram to prevent sway idle, when fullscreen;
  2. update oom_firefox tool,
    to support custom worker_regex, main_regex;
  3. update .whl for pr34;
This commit is contained in:
Siarhei Siniak 2025-12-13 20:18:55 +03:00
parent 0c581d6f5c
commit d782ec7731
8 changed files with 80 additions and 25 deletions

@ -23,7 +23,7 @@ elif sys.argv[1] == 'after-suspend':
subprocess.check_call(['modprobe', 'ideapad_laptop',]) subprocess.check_call(['modprobe', 'ideapad_laptop',])
#subprocess.check_call(['modprobe', 'atkbd',]) #subprocess.check_call(['modprobe', 'atkbd',])
subprocess.check_call(['nmcli', 'radio', 'wifi', 'on']) subprocess.check_call(['nmcli', 'radio', 'wifi', 'on'])
subprocess.check_call(['rfkill', 'unblock', '109']) #subprocess.check_call(['rfkill', 'unblock', '109'])
#subprocess.check_call(r''' #subprocess.check_call(r'''
# # systemctl restart wg-quick@siarhei-hp.service # # systemctl restart wg-quick@siarhei-hp.service
#''', shell=True,) #''', shell=True,)

@ -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.54', version: '0.1.5.59',
# default_options: [ # default_options: [
# 'cpp_std=c++23', # 'cpp_std=c++23',
# # 'prefer_static=true', # # 'prefer_static=true',

@ -190,11 +190,32 @@ def kill_prioritized(
procs: list['get_firefox_procs_ps_t.res_t.entry_t'], procs: list['get_firefox_procs_ps_t.res_t.entry_t'],
to_free_mb, to_free_mb,
low_priority_pids, low_priority_pids,
main_regex: Optional[str],
worker_regex: Optional[str],
): ):
candidates = [] candidates = []
for p in procs: for p in procs:
if is_main_firefox(p): if worker_regex is None and main_regex is None:
pass
elif (
not worker_regex is None
and not re.compile(worker_regex).match(p['cmd']) is None
):
pass
elif (
not main_regex is None
and not re.compile(main_regex).match(p['cmd']) is None
):
continue continue
elif not main_regex is None and not worker_regex is None:
continue
elif main_regex is None and not worker_regex is None:
continue
elif not main_regex is None and worker_regex is None:
pass
else:
raise NotImplementedError
try: try:
# rss_mb = p.memory_info().rss / (1024 * 1024) # rss_mb = p.memory_info().rss / (1024 * 1024)
rss_mb = p['rss'] / (1024 * 1024) rss_mb = p['rss'] / (1024 * 1024)
@ -260,27 +281,6 @@ def launch_firefox_with_limits(
def main(): def main():
os.makedirs(
pathlib.Path('~/.cache/oom_firefox/').expanduser(), exist_ok=True
)
logging.basicConfig(
level=logging.INFO,
format=(
'%(asctime)s '
'%(levelname)-8s '
'%(filename)s:%(lineno)d '
'%(funcName)s %(message)s'
),
handlers=[
logging.handlers.RotatingFileHandler(
pathlib.Path('~/.cache/oom_firefox/log').expanduser(),
maxBytes=128 * 1024,
backupCount=3,
)
],
)
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Firefox memory manager with slice + graceful shutdown' description='Firefox memory manager with slice + graceful shutdown'
) )
@ -314,6 +314,19 @@ def main():
default='firefox-limited', default='firefox-limited',
help='Name for systemd transient unit', help='Name for systemd transient unit',
) )
parser.add_argument(
'--main-regex',
type=str,
default=None,
help='regex for main processes, that are not to kill',
)
parser.add_argument(
'--worker-regex',
type=str,
# default=r'^.*contentproc.*$',
default=None,
help='regex for worker processes, that can be killed, like .*contentproc.* for firefox',
)
parser.add_argument( parser.add_argument(
'--firefox-extra', '--firefox-extra',
action='append', action='append',
@ -328,6 +341,29 @@ def main():
args = parser.parse_args() args = parser.parse_args()
os.makedirs(
pathlib.Path('~/.cache/oom_firefox/').expanduser(), exist_ok=True
)
logging.basicConfig(
level=logging.INFO,
format=(
'%(asctime)s '
'%(levelname)-8s '
'%(filename)s:%(lineno)d '
'%(funcName)s %(message)s'
),
handlers=[
logging.handlers.RotatingFileHandler(
pathlib.Path(
'~/.cache/oom_firefox/log-%s' % args.unit_name
).expanduser(),
maxBytes=128 * 1024,
backupCount=3,
)
],
)
low_priority_pids = set() low_priority_pids = set()
body = TextArea(focusable=False, scrollbar=True) body = TextArea(focusable=False, scrollbar=True)
@ -378,7 +414,11 @@ def main():
if total > limit: if total > limit:
to_free = total - kill_to to_free = total - kill_to
killed, freed = kill_prioritized( killed, freed = kill_prioritized(
procs, to_free, low_priority_pids procs,
to_free,
low_priority_pids,
main_regex=args.main_regex,
worker_regex=args.worker_regex,
) )
lines.append(f'Killed: {killed}') lines.append(f'Killed: {killed}')
lines.append(f'Freed ≈ {freed:.1f} MB') lines.append(f'Freed ≈ {freed:.1f} MB')

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.