From 209408b6b83979e89bb711df59c81f7ec9ccc8b8 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Wed, 20 Jun 2018 00:12:08 +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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nohang b/nohang index ce6400e..f17223b 100755 --- a/nohang +++ b/nohang @@ -15,6 +15,8 @@ from argparse import ArgumentParser # задание констант +display = ':0' + version = 'unknown' sig_dict = {9: 'SIGKILL', 15: 'SIGTERM'} @@ -159,7 +161,10 @@ def send_notify(signal, name, pid, oom_score, vm_rss, vm_swap): # отправляем уведомление всем залогиненным пользователям for uid in os.listdir('/run/user'): - root_notify_command = 'DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/{}/bus XAUTHORITY=/home/{}/.Xauthority sudo -u {} notify-send {} "Preventing OOM" '.format(uid, users_dict[uid], users_dict[uid], notify_options) + 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) os.system(root_notify_command + info)