From a5c2b28ae9bcd8688099dd5b7eb07ffab758cef0 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Wed, 23 Jan 2019 02:16:57 +0900 Subject: [PATCH] fix readme and GUI notifications --- README.md | 1 + nohang_notify_helper | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4ac2c2a..7c916e7 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ For basic usage: - `Python` 3.3+ (not tested with previous) To show GUI notifications: +- [notification server](https://wiki.archlinux.org/index.php/Desktop_notifications#Notification_servers) (most of desktop environments use their own implementations) - `libnotify` (Fedora, Arch Linux) or `libnotify-bin` (Debian GNU/Linux, Ubuntu) - `sudo` if nohang started with UID=0 diff --git a/nohang_notify_helper b/nohang_notify_helper index 4b329f3..f2aade0 100755 --- a/nohang_notify_helper +++ b/nohang_notify_helper @@ -11,7 +11,7 @@ if len(argv) < 2 or argv[1] == "-h" or argv[1] == "--help": print('Usage: ./nohang_notify_helper "title" "body"') exit(1) -wait_time = 12 +wait_time = 10 display_env = 'DISPLAY=' dbus_env = 'DBUS_SESSION_BUS_ADDRESS=' @@ -99,13 +99,17 @@ list_with_envs = root_notify_env() if len(list_with_envs) > 0: # iterating over logged-in users for i in list_with_envs: - username, dbus_env = i[0], i[2] + username, display_env, dbus_env = i[0], i[1], i[2] + display_tuple = display_env.partition('=') dbus_tuple = dbus_env.partition('=') - dbus_key, dbus_value = dbus_tuple[0], dbus_tuple[2] + display_value = display_tuple[2] + dbus_value = dbus_tuple[2] with Popen([ 'sudo', '-u', username, - 'env', 'DBUS_SESSION_BUS_ADDRESS=' + dbus_value, + 'env', + 'DISPLAY=' + display_value, + 'DBUS_SESSION_BUS_ADDRESS=' + dbus_value, 'notify-send', '--icon=dialog-warning', argv[1], argv[2] ]) as proc: try: