[+] update oom_firefox

1. allow to change kill percent
    via p hotkey;
This commit is contained in:
Siarhei Siniak 2025-12-24 16:10:49 +03:00
parent ff045106fc
commit 2e4f407974
4 changed files with 53 additions and 2 deletions

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

@ -237,6 +237,10 @@ def kill_prioritized(
p=p,
action='kill',
msg='started',
to_free_mb=to_free_mb,
killed=killed,
freed=freed,
low_priority_pids=low_priority_pids,
)
)
@ -472,6 +476,11 @@ def main():
root_floats.append(f)
app.layout.focus(ta)
def change_kill_percent(kill_percent: float) -> None:
assert kill_percent >= 10 and kill_percent <= 90
args.kill_percent = kill_percent
def change_max_mb(max_mb: int) -> None:
for cmd in (
[
@ -502,7 +511,6 @@ def main():
txt = ta.text
m = re.compile(r'^\s*(\d+)\s*$').match(txt)
a: str = 234234
if m:
change_max_mb(int(m[1]))
@ -529,6 +537,39 @@ def main():
root_floats.append(f)
app.layout.focus(ta)
def open_percentage_dialog():
ta = TextArea(text='', multiline=True, scrollbar=True)
def on_ok():
txt = ta.text
m = re.compile(r'^\s*(\d+|\d+\.\d+)\s*$').match(txt)
if m:
change_kill_percent(float(m[1]))
close_dialog()
refresh_body()
else:
logger.error('invalid input %s' % txt)
def on_cancel():
close_dialog()
dialog = Dialog(
title='Enter kill percent from 10% to 90%, without % sign',
body=ta,
buttons=[
Button(text='OK', handler=on_ok),
Button(text='Cancel', handler=on_cancel),
],
width=60,
modal=True,
)
f = Float(content=dialog, left=2, top=2)
dialog_float[0] = f
root_floats.append(f)
app.layout.focus(ta)
def open_message(title, message):
def on_close():
close_dialog()
@ -571,6 +612,10 @@ def main():
def _(event):
open_limit_dialog()
@kb.add('p')
def _(event):
open_percentage_dialog()
HELP_TEXT = 'm=add PIDs, l=change limit, s=settings, a=about, q=quit'
@kb.add('h')

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

Binary file not shown.

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

Binary file not shown.