Skip to content

Commit bc82112

Browse files
cerebruxchamdim
andauthored
Development (#145)
* Προσθήκη fade_in & fade_out κατά την εναλλαγή των streams * socket readiness check before calling fade_in() * unused loop variable should be _ --------- Co-authored-by: chamdim <[email protected]>
1 parent 3ccae05 commit bc82112

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

shelldio.sh

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626

2727
### Variable List
2828

29-
version="v25.08.12"
29+
version="v25.08.13"
3030

3131
all_stations="$HOME/.shelldio/all_stations.txt"
3232
my_stations="$HOME/.shelldio/my_stations.txt"
@@ -60,13 +60,46 @@ validate_station_lists() {
6060
# mpv --no-video --input-ipc-server=/tmp/mpv_socket "$stathmos_url" &>/dev/null &
6161
# mpv_pid=$!
6262
#}
63+
# start_mpv() {
64+
# if [[ -n "$mpv_pid" ]]; then
65+
# kill $mpv_pid 2>/dev/null
66+
# wait $mpv_pid 2>/dev/null
67+
# fi
68+
# mpv --no-video --input-ipc-server=/tmp/mpv_socket "$stathmos_url" &>/dev/null &
69+
# mpv_pid=$!
70+
# }
71+
fade_out() {
72+
for vol in {100..0..-5}; do
73+
echo '{ "command": ["set_property", "volume", '"$vol"'] }' | socat - /tmp/mpv_socket &>/dev/null
74+
sleep 0.03
75+
done
76+
}
77+
78+
fade_in() {
79+
for vol in {0..100..5}; do
80+
echo '{ "command": ["set_property", "volume", '"$vol"'] }' | socat - /tmp/mpv_socket &>/dev/null
81+
sleep 0.03
82+
done
83+
}
84+
6385
start_mpv() {
64-
if [[ -n "$mpv_pid" ]]; then
65-
kill $mpv_pid 2>/dev/null
66-
wait $mpv_pid 2>/dev/null
67-
fi
68-
mpv --no-video --input-ipc-server=/tmp/mpv_socket "$stathmos_url" &>/dev/null &
69-
mpv_pid=$!
86+
if [[ -n "$mpv_pid" ]] && kill -0 "$mpv_pid" 2>/dev/null; then
87+
fade_out
88+
kill "$mpv_pid" 2>/dev/null
89+
rm -f /tmp/mpv_socket
90+
fi
91+
92+
mpv --no-video --input-ipc-server=/tmp/mpv_socket --volume=0 "$stathmos_url" &>/dev/null &
93+
mpv_pid=$!
94+
95+
# Wait for the IPC socket to be ready (max 2 seconds)
96+
for _ in {1..40}; do
97+
if [ -S /tmp/mpv_socket ]; then
98+
break
99+
fi
100+
sleep 0.05
101+
done
102+
fade_in
70103
}
71104

72105
get_current_title() {
@@ -692,4 +725,4 @@ while true; do
692725

693726
done
694727

695-
done
728+
done

0 commit comments

Comments
 (0)