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
Valid values are True and False.
gui_notifications = True
gui_notifications = False
Enable GUI notifications about the low level of available memory.
Valid values are True and False.
@ -358,7 +358,7 @@ print_mem_check_results = False
0 - печатать все проверки памяти.
Неотрицательное число.
min_mem_report_interval = 10
min_mem_report_interval = 60
Print sleep periods between memory checks.
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
Slice=nohang.slice
Restart=always
MemoryMax=20M
TasksMax=10
MemoryMax=50M
TasksMax=20
OOMScoreAdjust=-5
Nice=-20
IOSchedulingClass=1

View File

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