initial commit

This commit is contained in:
bacalhau 2025-07-02 23:31:56 +01:00
parent 1c0b24d925
commit 94c6af61f0

79
radio.sh Normal file
View file

@ -0,0 +1,79 @@
#!/bin/sh
TRACKS="/mnt/storage/radio/music/"
PLAYLISTS="/mnt/storage/radio/playlists/"
CURRENT="/mnt/storage/radio/playlists/current.m3u"
choose_playlist() {
chosen=$(find "$PLAYLISTS" -type f -name "*.m3u" | fzf)
if [ -n "$chosen" ]; then
ln -sf "$chosen" "$CURRENT"
echo "Now playing: $(basename "$chosen")"
else
echo "No playlist selected"
fi
}
edit_playlist() {
vim "$(readlink "$CURRENT")"
}
create_playlist() {
clear
read -p "name the playlist: " new
touch "$PLAYLISTS$new.m3u"
echo "#EXTM3U" > "$PLAYLISTS$new.m3u"
target=$("$PLAYLISTS$new.m3u")
selected=$(cd "$TRACKS" && find . -type f -iname "*.ogg" | sed 's|^\./||' | fzf -m)
if [ -n "$selected" ]; then
printf "%s\n" "$selected" | sed "s|^|$TRACKS|" >> "$target"
echo "Tracks added to the current playlist."
else
echo "Nothing was selected."
fi
}
add_to_playlist() {
target=$(readlink "$CURRENT")
if [ -z "$target" ] || [ ! -f "$target" ]; then
echo "No valid current playlist is set."
return 1
fi
selected=$(cd "$TRACKS" && find . -type f -iname "*.ogg" | sed 's|^\./||' | fzf -m)
if [ -n "$selected" ]; then
printf "%s\n" "$selected" | sed "s|^|$TRACKS|" >> "$target"
echo "Tracks added to the current playlist."
else
echo "Nothing was selected."
fi
}
reload_playlist() {
kill -HUP "$(pgrep -f ezstream)"
}
menu() {
echo "Now playing: $(basename "$(readlink "$CURRENT")")"
echo "1) Choose playlist"
echo "2) Create playlist"
echo "3) Add to playlist"
echo "4) Edit playlist"
echo "9) Reload playlist"
echo "0) Exit"
read -p "Select an option: " opt
case "$opt" in
1) choose_playlist ;;
2) create_playlist ;; # assuming you have this implemented elsewhere
3) add_to_playlist ;;
4) edit_playlist ;;
9) reload_playlist ;;
0) exit ;;
*) echo "Invalid option" ;;
esac
}
while true; do
clear
menu
done