This commit is contained in:
Alexey Avramov 2019-03-21 21:53:02 +09:00
parent 6ca23b4bfe
commit b08787de58
3 changed files with 22 additions and 22 deletions

View File

@ -309,7 +309,7 @@ $ETC apache2 /// systemctl restart apache2
See also wiki.archlinux.org/index.php/Desktop_notifications See also wiki.archlinux.org/index.php/Desktop_notifications
Valid values are True and False. Valid values are True and False.
gui_notifications = True gui_notifications = False
Enable GUI notifications about the low level of available memory. Enable GUI notifications about the low level of available memory.
Valid values are True and False. Valid values are True and False.
@ -358,7 +358,7 @@ print_mem_check_results = False
0 - печатать все проверки памяти. 0 - печатать все проверки памяти.
Неотрицательное число. Неотрицательное число.
min_mem_report_interval = 10 min_mem_report_interval = 60
Print sleep periods between memory checks. Print sleep periods between memory checks.
Valid values are True and False. Valid values are True and False.

View File

@ -7,8 +7,8 @@ Documentation=man:nohang(1) https://github.com/hakavlad/nohang
ExecStart=/usr/sbin/nohang --config /etc/nohang/nohang.conf ExecStart=/usr/sbin/nohang --config /etc/nohang/nohang.conf
Slice=nohang.slice Slice=nohang.slice
Restart=always Restart=always
MemoryMax=20M MemoryMax=50M
TasksMax=10 TasksMax=20
OOMScoreAdjust=-5 OOMScoreAdjust=-5
Nice=-20 Nice=-20
IOSchedulingClass=1 IOSchedulingClass=1

View File

@ -1,7 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#
# Usage:
# ./nohang_notify_helper "title" "body"
from os import listdir, path from os import listdir, path
from subprocess import Popen, TimeoutExpired from subprocess import Popen, TimeoutExpired
@ -122,21 +119,24 @@ if list_len > 0:
display_value = display_tuple[2] display_value = display_tuple[2]
dbus_value = dbus_tuple[2] dbus_value = dbus_tuple[2]
with Popen([ try:
'sudo', '-u', username, with Popen([
'env', 'sudo', '-u', username,
'DISPLAY=' + display_value, 'env',
'DBUS_SESSION_BUS_ADDRESS=' + dbus_value, 'DISPLAY=' + display_value,
'notify-send', 'DBUS_SESSION_BUS_ADDRESS=' + dbus_value,
'--icon=dialog-warning', 'notify-send',
a1, '--icon=dialog-warning',
a2 a1,
]) as proc: a2
try: ]) as proc:
proc.wait(timeout=wait_time) try:
except TimeoutExpired: proc.wait(timeout=wait_time)
proc.kill() except TimeoutExpired:
print('TimeoutExpired: notify user:' + username) proc.kill()
print('TimeoutExpired: notify user:' + username)
except BlockingIOError:
print('nohang_notify_helper: BlockingIOError')
else: else:
print( print(
'Not send GUI notification: [', 'Not send GUI notification: [',