From 9cea076f5dbb2865868b29693237a4e4d84210d2 Mon Sep 17 00:00:00 2001
From: Htylol <dixperm909@yandex.ru>
Date: Tue, 8 Apr 2025 00:41:12 +0500
Subject: [PATCH] Fixes pw_exit_tray

---
 data_from_portwine/scripts/functions_helper | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper
index 9a48b342..6539d2f6 100755
--- a/data_from_portwine/scripts/functions_helper
+++ b/data_from_portwine/scripts/functions_helper
@@ -1931,15 +1931,10 @@ pw_kill_autostart () {
 export -f pw_kill_autostart
 
 pw_exit_tray () {
-    if [[ "$XDG_SESSION_TYPE" == "tty" || "$(readlink -f /bin/sh)" == *"/dash" ]] ; then
-        if [[ -n "$(pgrep -a yad_gui_pp | grep "\--notification" | awk '{print $1}')" ]] ; then
-            kill -s SIGUSR1 "$(pgrep -a yad_gui_pp | grep "\--notification" | awk '{print $1}')"
-        fi
-    else
-        if [[ -n "$(pgrep -a tray_gui_pp)" ]] ; then
-            kill -s SIGUSR1 $(pgrep -a tray_gui_pp) 2>/dev/null
-        fi
-    fi
+    read -r -a PGREP_TRAY_GUI_PP < <(pgrep -a tray_gui_pp)
+    [[ -n ${PGREP_TRAY_GUI_PP[0]} ]] && kill -s SIGUSR1 "${PGREP_TRAY_GUI_PP[0]}" 2>/dev/null
+    read -r -a PGREP_YAD_GUI_PP < <(pgrep -a yad_gui_pp)
+    [[ -n ${PGREP_YAD_GUI_PP[0]} ]] && kill -s SIGUSR1 "${PGREP_YAD_GUI_PP[0]}" 2>/dev/null
 }
 export -f pw_exit_tray