Skip to content

Commit

Permalink
kill old gui from the gui subprocess side
Browse files Browse the repository at this point in the history
  • Loading branch information
Botspot committed Jul 7, 2023
1 parent 37fe8aa commit 1b5d410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
14 changes: 5 additions & 9 deletions gui
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ if [[ $(id -u) == 0 ]]; then
fi

# set GUI format versioning
export GUI_FORMAT_VERSION=3
export GUI_FORMAT_VERSION=2

#display first 4 arguments this script receives (for debugging)
if false;then
echo "1 $1" 1>&2
echo "2 $2" 1>&2
echo "3 $3" 1>&2
echo "4 $4" 1>&2
#Transition from the GUI that calls itself to the self-contained GUI: when called by the old GUI, kill that yad window and treat this subprocess as the new main thread
if [ -z "$1$2" ] && [ ! -z "$3" ] && [ ! -z "$4" ] ;then
kill $(ps -fC yad | grep "yad --class Pi-Apps --name Pi Apps --center --title=Pi-Apps --image" | awk '{print $2}')
fi

DIRECTORY="$(readlink -f "$(dirname "$0")")"
Expand Down Expand Up @@ -480,7 +477,7 @@ if [[ "$guimode" == yad* ]];then
fi
}

kill_details() { #close the details window in 1 second. Uses the $detailspid variable. To close it immediately add an argument of 0
kill_details() { #close the details window in 1 second for better UX. Uses the $detailspid variable. To close it immediately add an argument of 0
(
if [ "$1" != 0 ];then
sleep 1.5
Expand Down Expand Up @@ -665,4 +662,3 @@ elif [[ "$guimode" == xlunch* ]];then

fi


17 changes: 3 additions & 14 deletions updater
Original file line number Diff line number Diff line change
Expand Up @@ -759,25 +759,14 @@ elif [ "$runmode" == 'set-status' ];then #check for updates and write updatable
if [ "$updatable_files" != "$(cat "${DIRECTORY}/data/update-status/updatable-files")" ];then
echo "$updatable_files" | grep . > "${DIRECTORY}/data/update-status/updatable-files"
fi

# this is the only part of any script that is called after running an update using the new files
# since the new gui merge requires the gui script to be restarted, use this opportunity to kill the old GUI and start a new one
# only done once with a runonce if current gui format version is less than 2
# only done once with a runonce if current gui format version is not 2
runonce <<"EOF"
if [[ "$GUI_FORMAT_VERSION" -lt 2 ]]; then
if [[ "$GUI_FORMAT_VERSION" != 2 ]]; then
pkill gui && ( "${DIRECTORY}/gui" & )
echo "stopped the GUI"
elif [[ "$GUI_FORMAT_VERSION" == 2 ]]; then
pkill gui && kill $(ps -fC yad | grep "yad --class Pi-Apps --name Pi Apps --center --title=Pi-Apps --image" | awk '{print $2}') && echo "Pi-Apps is always working to improve.
As part of that we need you to restart the Pi-Apps GUI.
We went ahead and closed it for you.
Open it again to get back to installing, uninstalling, and updating software!
Sorry for the inconvenience :)" | yad --class Pi-Apps --name "Pi Apps" --text-info --width=500 --height=400 --title='Please Restart Pi-Apps' \
--image="${DIRECTORY}/icons/error.png" --image-on-top \
--wrap --fontname=16 --center \
--button=OK!"${DIRECTORY}/icons/check.png":0 &
echo "stopped the GUI"
else
echo "skipped stopping the gui"
fi
Expand Down

0 comments on commit 1b5d410

Please sign in to comment.