Skip to content

Commit 511864a

Browse files
committed
update Process Management in Main Loop
1 parent 22c061d commit 511864a

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

shelldio.sh

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -736,35 +736,32 @@ while true; do
736736
start_mpv
737737

738738
while true; do
739-
trap '{ clear; echo "Έξοδος..."; tput cnorm; exit 1; }' SIGINT
739+
trap '{ clear; echo "Έξοδος..."; tput cnorm; kill $mpv_pid 2>/dev/null; exit 1; }' SIGINT
740740
clear
741-
info
742-
sleep 0
743-
read -r -n1 -t1 input_play # Για μικρότερη αναμονή της read
744-
if [[ $input_play = "q" ]] || [[ $input_play = "Q" ]]; then
745-
clear
746-
echo "Έξοδος..."
747-
tput cnorm # Εμφάνιση cursor
748-
exit 0
749-
elif [[ $input_play = "r" ]] || [[ $input_play = "R" ]]; then
750-
for pid in $(pgrep '^mpv$'); do
751-
url="$(ps -o command= -p "$pid" | awk '{print $2}')"
752-
if [[ "$url" == "$stathmos_url" ]]; then
753-
echo "Έξοδος..."
754-
tput cnorm # Εμφάνιση cursor
755-
kill "$pid"
756-
else
757-
printf "Απέτυχε ο αυτόματος τερματισμός. \nΠάτα τον συνδυασμό Ctrl+C ή κλείσε το τερματικό \nή τερμάτισε το Shelldio απο τις διεργασίες του συστήματος"
758-
fi
759-
done
741+
742+
if info; then
743+
# info() returned 0, go back to menu
744+
if [[ -n "$mpv_pid" ]]; then
745+
fade_out
746+
kill "$mpv_pid" 2>/dev/null
747+
wait "$mpv_pid" 2>/dev/null
748+
fi
760749
clear
761750
echo "Επιστροφή στη λίστα σταθμών"
762751
tput cnorm # Εμφάνιση cursor
763752
sleep 1
764753
clear
765754
break
755+
else
756+
# info() returned 1, quit application
757+
clear
758+
echo "Έξοδος..."
759+
tput cnorm # Εμφάνιση cursor
760+
if [[ -n "$mpv_pid" ]]; then
761+
kill "$mpv_pid" 2>/dev/null
762+
fi
763+
exit 0
766764
fi
767-
768765
done
769766

770767
done

0 commit comments

Comments
 (0)