Files
webradio/.config/rofi/webradio.sh
2025-12-25 10:12:08 +01:00

87 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# __ __ _____
# / \ / \ / __ \
# / /\ \ / /\ \ | |__| | Manuel Prinz (MP)
# / / \ \/ / \ \ | ___/
# / / \__/ \ \| |
# /_/ \_\_|
#
# description: Webradio with rofi and mpv
# last change: 25.12.2025
# defining variables for radiostations
dasding="DASDING"
einslive="1LIVE"
einslivediggi="1LIVEdiggi"
sunshinelive="SUNSHINE_LIVE"
swr3="SWR3"
wdr2="WDR2"
stop="beenden"
# other variables
path_logo="/home/$USER/Nextcloud/webradio"
# Get answer from user via rofi
selected_option=$(echo "$dasding
$einslive
$einslivediggi
$sunshinelive
$swr3
$wdr2
$stop" | rofi -dmenu\
-i\
-p "Webradio"\
-config "~/.config/rofi/webradio.rasi"\
-line-margin 3\
-line-padding 10)
# Do something based on selected radiostation
if [ "$selected_option" == "$dasding" ]
then
killall mpv
mpv https://liveradio.swr.de/d9zadj3/dasding/ --input-ipc-server=/tmp/mpv &
echo DASDING dasding_logo.png > /tmp/radiostation
elif [ "$selected_option" == "$einslive" ]
then
killall mpv
mpv http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3 --input-ipc-server=/tmp/mpv &
echo 1LIVE einslive_logo.jpg > /tmp/radiostation
elif [ "$selected_option" == "$einslivediggi" ]
then
killall mpv
mpv http://wdr-1live-diggi.icecast.wdr.de/wdr/1live/diggi/mp3/128/stream.mp3 --input-ipc-server=/tmp/mpv &
echo 1LIVE_DIGGI einslivediggi_logo.png > /tmp/radiostation
elif [ "$selected_option" == "$swr3" ]
then
killall mpv
mpv https://liveradio.swr.de/sw282p3/swr3/play.mp3 --input-ipc-server=/tmp/mpv &
echo SWR3 swr3_logo.jpg > /tmp/radiostation
elif [ "$selected_option" == "$sunshinelive" ]
then
killall mpv
mpv https://stream.sunshine-live.de/2000er/mp3-192/stream.sunshine-live.de --input-ipc-server=/tmp/mpv &
echo SUNSHINE_LIVE sunshinelive_logo.png > /tmp/radiostation
elif [ "$selected_option" == "$wdr2" ]
then
killall mpv
mpv http://wdr-wdr2-rheinland.icecast.wdr.de/wdr/wdr2/rheinland/mp3/128/stream.mp3 --input-ipc-server=/tmp/mpv &
echo WDR2 wdr2_logo.png > /tmp/radiostation
elif [ "$selected_option" == "$stop" ]
then
if test -e "/tmp/mpv"; then
# read station name and logo
radiostation=`cat /tmp/radiostation | awk '{print $1}'`
radiostation_logo=`cat /tmp/radiostation | awk '{print $2}'`
dunstify -t 5000 -a "Webradio: $radiostation" -I "$path_logo/$radiostation_logo" "wird beendet"
killall mpv
rm -f /tmp/mpv
rm -f /tmp/radiostation
rm -f /tmp/webradio_title
else
dunstify -t 5000 -a "Webradio:" "läuft nicht"
fi
else
dunstify -t 5000 -a "Webradio:" "keine Auswahl getroffen"
fi