fix readme and GUI notifications
This commit is contained in:
parent
9976094164
commit
a5c2b28ae9
@ -51,6 +51,7 @@ For basic usage:
|
|||||||
- `Python` 3.3+ (not tested with previous)
|
- `Python` 3.3+ (not tested with previous)
|
||||||
|
|
||||||
To show GUI notifications:
|
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)
|
- `libnotify` (Fedora, Arch Linux) or `libnotify-bin` (Debian GNU/Linux, Ubuntu)
|
||||||
- `sudo` if nohang started with UID=0
|
- `sudo` if nohang started with UID=0
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ if len(argv) < 2 or argv[1] == "-h" or argv[1] == "--help":
|
|||||||
print('Usage: ./nohang_notify_helper "title" "body"')
|
print('Usage: ./nohang_notify_helper "title" "body"')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
wait_time = 12
|
wait_time = 10
|
||||||
|
|
||||||
display_env = 'DISPLAY='
|
display_env = 'DISPLAY='
|
||||||
dbus_env = 'DBUS_SESSION_BUS_ADDRESS='
|
dbus_env = 'DBUS_SESSION_BUS_ADDRESS='
|
||||||
@ -99,13 +99,17 @@ list_with_envs = root_notify_env()
|
|||||||
if len(list_with_envs) > 0:
|
if len(list_with_envs) > 0:
|
||||||
# iterating over logged-in users
|
# iterating over logged-in users
|
||||||
for i in list_with_envs:
|
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_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([
|
with Popen([
|
||||||
'sudo', '-u', username,
|
'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]
|
'notify-send', '--icon=dialog-warning', argv[1], argv[2]
|
||||||
]) as proc:
|
]) as proc:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user