From 992a604a6bc80889373fe532d6a3e9ee58ea7426 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Wed, 20 Jun 2018 01:36:26 +0900 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=83?= =?UTF-8?q?=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nohang | 16 ++++++++++------ nohang.conf | 7 ++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/nohang b/nohang index f17223b..c508b19 100755 --- a/nohang +++ b/nohang @@ -15,8 +15,6 @@ from argparse import ArgumentParser # задание констант -display = ':0' - version = 'unknown' sig_dict = {9: 'SIGKILL', 15: 'SIGTERM'} @@ -161,10 +159,9 @@ def send_notify(signal, name, pid, oom_score, vm_rss, vm_swap): # отправляем уведомление всем залогиненным пользователям for uid in os.listdir('/run/user'): - root_notify_command = 'sudo -u {} DISPLAY={} DBUS_SESSION_BUS_AD' \ - 'DRESS=unix:path=/run/user/{}/bus notify-send {} "Preventin' \ - 'g OOM" '.format( - users_dict[uid], display, uid, notify_options) + root_notify_command = 'sudo -u {} DISPLAY={} notify-send {} "Pr' \ + 'eventing OOM" '.format( + users_dict[uid], display, notify_options) os.system(root_notify_command + info) @@ -658,6 +655,13 @@ else: print('notify_options not in config\nExit') exit() + +if 'display' in config_dict: + display = config_dict['display'].strip() +else: + print('display not in config\nExit') + exit() + ########################################################################## # получение уровней в кибибайтах diff --git a/nohang.conf b/nohang.conf index 71d4c67..4802c8d 100644 --- a/nohang.conf +++ b/nohang.conf @@ -149,7 +149,7 @@ oom_score_adj_max = 20 Эта возможность требует наличия notify-send в системе. В Debian/Ubuntu это обеспечивается установкой пакета libnotify-bin. В Fedora и Arch Linux - пакет libnotify. - Также требуется наличие notification-daemon. + Также требуется наличие сервера уведомлений. При запуске nohang от рута уведомления рассылаются всем залогиненным пользователям. See also wiki.archlinux.org/index.php/Desktop_notifications @@ -165,3 +165,8 @@ desktop_notifications = True notify_options = + Должен совпадать с выводом + $ echo $DISPLAY + +display = :0 +