From 5c2276a0b05574bbc29fcb0eb98d545ea524b6bf Mon Sep 17 00:00:00 2001 From: yangfl Date: Fri, 7 Mar 2025 22:25:40 +0800 Subject: [PATCH 6/6] Make the use of notify-send / sudo conditional --- src/nohang | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/nohang b/src/nohang index 671d082..52d4d84 100755 --- a/src/nohang +++ b/src/nohang @@ -3,6 +3,7 @@ import os from ctypes import CDLL +from shutil import which from time import sleep, monotonic from operator import itemgetter from sys import stdout, stderr, argv, exit @@ -392,11 +393,21 @@ def pop(cmd): def send_notification(title, body): """ """ + if which('notify-send') is None: + if debug_gui_notifications: + log('send_notification: notify-send is not installed') + return None + if self_uid != 0: cmd = ['notify-send', '--icon=dialog-warning', title, body] pop(cmd) return None + if which('sudo') is None: + if debug_gui_notifications: + log('send_notification: sudo is not installed') + return None + t1 = monotonic() if envd['t'] is None: -- 2.47.2