Skip to content

Commit 46a7cdb

Browse files
committed
new loginc claude
1 parent 95401e9 commit 46a7cdb

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

shelldio.sh

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -257,76 +257,75 @@ joker() {
257257
local stations="$all_stations"
258258
local station_number
259259
local input_play=""
260+
261+
# Count total lines in stations file
260262
while IFS='' read -r line || [[ -n "$line" ]]; do
261263
lines=$((lines + 1))
262264
done <"$stations"
265+
263266
station_number=$(( (RANDOM % lines) + 1 )) #Διάλεξε τυχαίο σταθμό (ξεκινάει από 1)
264267
validate_station_lists
265268

266-
while true; do
267-
terms=0
268-
trap ' [ $terms = 1 ] || { terms=1; kill -TERM -$$; }; exit' EXIT INT HUP TERM QUIT
269+
# Setup signal handling
270+
terms=0
271+
trap ' [ $terms = 1 ] || { terms=1; kill -TERM -$$; }; exit' EXIT INT HUP TERM QUIT
269272

270-
if [ -d "$HOME/.shelldio/" ]; then
271-
if [ ! -f "$all_stations" ]; then
272-
echo "Δεν ήταν δυνατή η εύρεση του αρχείου σταθμών. Γίνεται η λήψη του..."
273-
sleep 2
274-
curl -sL https://raw.githubusercontent.com/CerebruxCode/shelldio/stable/.shelldio/all_stations.txt --output "$HOME/.shelldio/all_stations.txt"
275-
fi
276-
else
277-
echo "Δημιουργείται ο κρυφός φάκελος .shelldio ο οποίος θα περιέχει τα αρχεία των σταθμών."
278-
sleep 2
279-
mkdir -p "$HOME/.shelldio"
280-
echo "Γίνεται η λήψη του αρχείου με όλους τους σταθμούς."
273+
# Ensure stations file exists
274+
if [ -d "$HOME/.shelldio/" ]; then
275+
if [ ! -f "$all_stations" ]; then
276+
echo "Δεν ήταν δυνατή η εύρεση του αρχείου σταθμών. Γίνεται η λήψη του..."
281277
sleep 2
282278
curl -sL https://raw.githubusercontent.com/CerebruxCode/shelldio/stable/.shelldio/all_stations.txt --output "$HOME/.shelldio/all_stations.txt"
283279
fi
280+
else
281+
echo "Δημιουργείται ο κρυφός φάκελος .shelldio ο οποίος θα περιέχει τα αρχεία των σταθμών."
282+
sleep 2
283+
mkdir -p "$HOME/.shelldio"
284+
echo "Γίνεται η λήψη του αρχείου με όλους τους σταθμούς."
285+
sleep 2
286+
curl -sL https://raw.githubusercontent.com/CerebruxCode/shelldio/stable/.shelldio/all_stations.txt --output "$HOME/.shelldio/all_stations.txt"
287+
fi
284288

285-
while true; do
286-
if [[ $input_play = "q" ]] || [[ $input_play = "Q" ]]; then
287-
echo "Έξοδος..."
288-
tput cnorm # Εμφάνιση cursor
289-
exit 0
290-
else
291-
station=$(sed "${station_number}q;d" "$stations")
292-
selected_play=$station_number # για να εμφανίζει το αριθμό που επέλεξε ο χρήστης στον Player UI
293-
stathmos_name=$(echo "$station" | cut -d "," -f1)
294-
stathmos_url=$(echo "$station" | cut -d "," -f2)
295-
break
296-
fi
297-
done
289+
while true; do
290+
# Get station info
291+
station=$(sed "${station_number}q;d" "$stations")
292+
selected_play=$station_number # για να εμφανίζει το αριθμό που επέλεξε ο χρήστης στον Player UI
293+
stathmos_name=$(echo "$station" | cut -d "," -f1)
294+
stathmos_url=$(echo "$station" | cut -d "," -f2)
298295

296+
# Start playing the station
299297
mpv "$stathmos_url" &>/dev/null &
298+
mpv_pid=$!
300299

300+
# User interaction loop
301301
while true; do
302302
trap '{ clear; echo "Έξοδος..."; tput cnorm; exit 1; }' SIGINT
303303
clear
304304
joker_info
305305
sleep 0
306306
read -r -n1 -t1 input_play # Για μικρότερη αναμονή της read
307+
307308
if [[ $input_play = "q" ]] || [[ $input_play = "Q" ]]; then
308309
clear
309310
echo "Έξοδος..."
310311
tput cnorm # Εμφάνιση cursor
312+
# Kill the current mpv process
313+
kill $mpv_pid 2>/dev/null
311314
exit 0
312315
elif [[ $input_play = "r" ]] || [[ $input_play = "R" ]]; then
313-
for pid in $(pgrep '^mpv$'); do
314-
url="$(ps -o command= -p "$pid" | awk '{print $2}')"
315-
if [[ "$url" == "$stathmos_url" ]]; then
316-
echo "Έξοδος..."
317-
tput cnorm # Εμφάνιση cursor
318-
kill "$pid"
319-
else
320-
printf "Απέτυχε ο αυτόματος τερματισμός. \nΠάτα τον συνδυασμό Ctrl+C ή κλείσε το τερματικό \nή τερμάτισε το Shelldio απο τις διεργασίες του συστήματος"
321-
fi
322-
done
316+
# Kill current mpv process
317+
kill $mpv_pid 2>/dev/null
318+
wait $mpv_pid 2>/dev/null
319+
320+
# Select new random station
323321
station_number=$(( (RANDOM % lines) + 1 ))
324-
break
322+
echo "Επιλογή νέου τυχαίου σταθμού..."
323+
sleep 1
324+
break # Break out of inner loop to start new station
325325
fi
326326
done
327327
done
328328
}
329-
330329
reset_favorites() {
331330
if [ ! -f "$my_stations" ]; then
332331
echo "Μη έγκυρη επιλογή. Το αρχείο αγαπημένων δεν υπάρχει."

0 commit comments

Comments
 (0)