diff --git a/.config/.gitkeep b/.config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.config/bspwm/.gitkeep b/.config/bspwm/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.config/bspwm/scripts/.gitkeep b/.config/bspwm/scripts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.config/bspwm/scripts/webradio.sh b/.config/bspwm/scripts/webradio.sh new file mode 100755 index 0000000..4179239 --- /dev/null +++ b/.config/bspwm/scripts/webradio.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# __ __ _____ +# / \ / \ / __ \ +# / /\ \ / /\ \ | |__| | Manuel Prinz (MP) +# / / \ \/ / \ \ | ___/ +# / / \__/ \ \| | +# /_/ \_\_| +# +# description: Script webradio for Polybar +# last change: 29.07.2023 + +## variables ## +msgID="11111" +mpvsocket="/tmp/mpv" +path_logo="/home/$USER/Nextcloud/webradio" +file_title="/tmp/webradio_title" + +## function displaytime: displays the time in human readable format +displaytime() { + local T=$1 + #local D=$((T/60/60/24)) + local H=$((T/60/60%24)) + local M=$((T/60%60)) + local S=$((T%60)) + #(( $D > 0 )) && printf '%d:' $D + (( $H > 0 )) && printf '%02d:' $H + (( $M > 0 )) && printf '%02d:' $M + #(( $D > 0 || $H > 0 || $M > 0 )) + printf '%02d\n' $S +} + +# is mpv running? +if test -e "$mpvsocket"; then + # read actual title + act_title=`echo '{ "command": ["get_property", "media-title"] }' | socat - /tmp/mpv | awk -F\" '{print $4}'` + + # read playtime and convert to human readable format + playtime=`echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpv | awk -F: '{print $2}' | awk -F, '{print $1}' | awk -F. '{print $1}'` + playtime_act=$(displaytime $playtime) + + # read station name and logo + radiostation=`cat /tmp/radiostation | awk '{print $1}'` + radiostation_logo=`cat /tmp/radiostation | awk '{print $2}'` + + # title file exist? + if test -e "$file_title"; then + title_check=`cat /tmp/webradio_title` + # actual title equals NOT the name in the title file? + if [[ "$title_check" != "$act_title" ]]; then + echo $act_title > $file_title + dunstify -t 5000 -a "Webradio: $radiostation" -r $msgID -I "$path_logo/$radiostation_logo" "$act_title" + fi + else + # if title file not exists + echo $act_title > $file_title + dunstify -t 5000 -a "Webradio: $radiostation" -r $msgID -I "$path_logo/$radiostation_logo" "$act_title" + fi + + # echo play symbol and playtime to polybar + echo " $playtime_act" +else + # Webradio is not running + echo "" +fi diff --git a/.config/rofi/.gitkeep b/.config/rofi/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.config/rofi/arc_dark_transparent_colors.rasi b/.config/rofi/arc_dark_transparent_colors.rasi new file mode 100644 index 0000000..e416820 --- /dev/null +++ b/.config/rofi/arc_dark_transparent_colors.rasi @@ -0,0 +1,34 @@ +/******************************************************* + * ROFI Arch Dark Transparent colors for EndeavourOS + * Maintainer: joekamprad + *******************************************************/ +* { + selected-normal-foreground: rgba ( 255, 147, 5, 100 % ); + foreground: rgba ( 196, 203, 212, 100 % ); + normal-foreground: @foreground; + alternate-normal-background: rgba ( 45, 48, 59, 1 % ); + red: rgba ( 220, 50, 47, 100 % ); + selected-urgent-foreground: rgba ( 249, 249, 249, 100 % ); + blue: rgba ( 38, 139, 210, 100 % ); + urgent-foreground: rgba ( 204, 102, 102, 100 % ); + alternate-urgent-background: rgba ( 75, 81, 96, 90 % ); + active-foreground: rgba ( 101, 172, 255, 100 % ); + lightbg: rgba ( 238, 232, 213, 100 % ); + selected-active-foreground: rgba ( 249, 249, 249, 100 % ); + alternate-active-background: rgba ( 45, 48, 59, 88 % ); + background: rgba ( 45, 48, 59, 88 % ); + alternate-normal-foreground: @foreground; + normal-background: rgba ( 45, 48, 59, 1 % ); + lightfg: rgba ( 88, 104, 117, 100 % ); + selected-normal-background: rgba ( 24, 26, 32, 100 % ); + border-color: rgba ( 255, 147, 5, 100 % ); + spacing: 2; + separatorcolor: rgba ( 45, 48, 59, 1 % ); + urgent-background: rgba ( 45, 48, 59, 15 % ); + selected-urgent-background: rgba ( 165, 66, 66, 100 % ); + alternate-urgent-foreground: @urgent-foreground; + background-color: rgba ( 0, 0, 0, 0 % ); + alternate-active-foreground: @active-foreground; + active-background: rgba ( 29, 31, 33, 17 % ); + selected-active-background: rgba ( 26, 28, 35, 100 % ); +} diff --git a/.config/rofi/webradio.rasi b/.config/rofi/webradio.rasi new file mode 100644 index 0000000..e8d1ba8 --- /dev/null +++ b/.config/rofi/webradio.rasi @@ -0,0 +1,120 @@ +/******************************************************* + * ROFI configs i3 powermenu for EndeavourOS + * Maintainer: joekamprad + *******************************************************/ + +configuration { + show-icons: false; + icon-theme: "Arc-X-D"; + scroll-method: 0; + disable-history: false; + sidebar-mode: false; +} + +@import "~/.config/rofi/arc_dark_transparent_colors.rasi" + +window { + background-color: @background; + border: 2; + border-radius: 8px; + padding: 10; + transparency: "real"; + width: 200px; + location: center; + y-offset: 30; +} +listview { + lines: 7; + columns: 1; + scrollbar: false; +} +element { + border: 0; + padding: 1px ; +} +element-text { + background-color: inherit; + text-color: inherit; +} +element.normal.normal { + background-color: @normal-background; + text-color: @normal-foreground; +} +element.normal.urgent { + background-color: @urgent-background; + text-color: @urgent-foreground; +} +element.normal.active { + background-color: @active-background; + text-color: @active-foreground; +} +element.selected.normal { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +element.selected.urgent { + background-color: @selected-urgent-background; + text-color: @selected-urgent-foreground; +} +element.selected.active { + background-color: @selected-active-background; + text-color: @selected-active-foreground; +} +element.alternate.normal { + background-color: @alternate-normal-background; + text-color: @alternate-normal-foreground; +} +element.alternate.urgent { + background-color: @alternate-urgent-background; + text-color: @alternate-urgent-foreground; +} +element.alternate.active { + background-color: @alternate-active-background; + text-color: @alternate-active-foreground; +} +scrollbar { + width: 2px ; + border: 0; + handle-color: @scrollbar-foreground; + handle-width: 4px ; + padding: 0; +} +mode-switcher { + border: 2px 0px 0px ; + border-color: @separatorcolor; +} +button { + spacing: 0; + text-color: @normal-foreground; +} +button.selected { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +inputbar { + spacing: 0; + text-color: @normal-foreground; + padding: 1px ; +} +case-indicator { + spacing: 0; + text-color: @normal-foreground; +} +entry { + spacing: 0; + text-color: @input-foreground; + placeholder: ""; +} +prompt { + spacing: 0; + text-color: @prompt-foreground; +} +inputbar { + children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; +} +textbox-prompt-colon { + expand: false; + str: ":"; + margin: 0px 0.3em 0em 0em ; + text-color: @prompt-foreground; +} diff --git a/.config/rofi/webradio.sh b/.config/rofi/webradio.sh new file mode 100755 index 0000000..a6f6674 --- /dev/null +++ b/.config/rofi/webradio.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# __ __ _____ +# / \ / \ / __ \ +# / /\ \ / /\ \ | |__| | Manuel Prinz (MP) +# / / \ \/ / \ \ | ___/ +# / / \__/ \ \| | +# /_/ \_\_| +# +# description: Webradio with rofi and mpv +# last change: 29.07.2023 + +# 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 diff --git a/README.org b/README.org new file mode 100644 index 0000000..2442506 --- /dev/null +++ b/README.org @@ -0,0 +1,342 @@ +#+title: Config Webradio +#+AUTHOR: Manuel Prinz +#+DATE: 29.08.2023 +#+STARTUP: showeverything + +* Einleitung +Rofi Skript zur Wiedergabe von Webradio-Streams. Start mit ~Strg + Alt + w~ oder via Klick auf das Symbol in Polybar. Rechtsklick auf das Symbol zeigt den aktuellen Titel nochmals an, indem die aktuelle Titel-Datei gelöscht wird. + +/Abhängigkeiten:/ ++ mpv ++ socat ++ dunst ++ ttf-font-awesome ++ ttf-ubuntu-font-family ++ rofi + +* Senderliste +Sender, die aktuell implementiert sind. + ++ DASDING ++ 1LIVE ++ 1LIVEdiggi ++ SUNSHINE_LIVE ++ SWR3 ++ WDR2 + +* Eintrag in sxhkdrc +Hier der Eintrag, der in ~/home/$USER/.config/sxhkd/sxhkdrc~ gemacht werden muss. + +#+begin_src shell +# webradio +ctrl + alt + w + ~/.config/rofi/webradio.sh +#+end_src + +* Modul in Polybar +Hier die Definition des Moduls in der Polybar Konfiguration in ~/home/$USER/.config/polybar/config.ini~. + +#+begin_src conf +[module/webradio] +type = custom/script +interval = 3 +exec = ~/.config/bspwm/scripts/webradio.sh +click-left = ~/.config/rofi/webradio.sh +click-right = rm -f /tmp/webradio_title +format-foreground = ${colors.foreground-white} +format-background = ${colors.background-blue} +format-prefix = "" +label = " %output% " +#+end_src + +* Startskript und Config für Rofi + +** Skript +Skript, welches das Rofi-Menü startet. + +#+begin_src shell :tangle ~/Nextcloud/repos/webradio/.config/rofi/webradio.sh :tangle-mode (identity #o755) +#!/usr/bin/env bash +# __ __ _____ +# / \ / \ / __ \ +# / /\ \ / /\ \ | |__| | Manuel Prinz (MP) +# / / \ \/ / \ \ | ___/ +# / / \__/ \ \| | +# /_/ \_\_| +# +# description: Webradio with rofi and mpv +# last change: 29.07.2023 + +# 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 +#+end_src + +** Config +Hier wird das Aussehen vom Rofi-Menü definiert. + +#+begin_src css :tangle ~/Nextcloud/repos/webradio/.config/rofi/webradio.rasi +/******************************************************* + ,* ROFI configs i3 powermenu for EndeavourOS + ,* Maintainer: joekamprad + ,*******************************************************/ + +configuration { + show-icons: false; + icon-theme: "Arc-X-D"; + scroll-method: 0; + disable-history: false; + sidebar-mode: false; +} + +@import "~/.config/rofi/arc_dark_transparent_colors.rasi" + +window { + background-color: @background; + border: 2; + border-radius: 8px; + padding: 10; + transparency: "real"; + width: 200px; + location: center; + y-offset: 30; +} +listview { + lines: 7; + columns: 1; + scrollbar: false; +} +element { + border: 0; + padding: 1px ; +} +element-text { + background-color: inherit; + text-color: inherit; +} +element.normal.normal { + background-color: @normal-background; + text-color: @normal-foreground; +} +element.normal.urgent { + background-color: @urgent-background; + text-color: @urgent-foreground; +} +element.normal.active { + background-color: @active-background; + text-color: @active-foreground; +} +element.selected.normal { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +element.selected.urgent { + background-color: @selected-urgent-background; + text-color: @selected-urgent-foreground; +} +element.selected.active { + background-color: @selected-active-background; + text-color: @selected-active-foreground; +} +element.alternate.normal { + background-color: @alternate-normal-background; + text-color: @alternate-normal-foreground; +} +element.alternate.urgent { + background-color: @alternate-urgent-background; + text-color: @alternate-urgent-foreground; +} +element.alternate.active { + background-color: @alternate-active-background; + text-color: @alternate-active-foreground; +} +scrollbar { + width: 2px ; + border: 0; + handle-color: @scrollbar-foreground; + handle-width: 4px ; + padding: 0; +} +mode-switcher { + border: 2px 0px 0px ; + border-color: @separatorcolor; +} +button { + spacing: 0; + text-color: @normal-foreground; +} +button.selected { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +inputbar { + spacing: 0; + text-color: @normal-foreground; + padding: 1px ; +} +case-indicator { + spacing: 0; + text-color: @normal-foreground; +} +entry { + spacing: 0; + text-color: @input-foreground; + placeholder: ""; +} +prompt { + spacing: 0; + text-color: @prompt-foreground; +} +inputbar { + children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; +} +textbox-prompt-colon { + expand: false; + str: ":"; + margin: 0px 0.3em 0em 0em ; + text-color: @prompt-foreground; +} +#+end_src + +* Polybar Skript +Dieses Skript wird als Modul vom Typ ~custom/script~ in Polybar eingefügt. + +#+NAME: webradio +#+begin_src shell :tangle ~/Nextcloud/repos/webradio/.config/bspwm/scripts/webradio.sh :tangle-mode (identity #o755) +#!/usr/bin/env bash +# __ __ _____ +# / \ / \ / __ \ +# / /\ \ / /\ \ | |__| | Manuel Prinz (MP) +# / / \ \/ / \ \ | ___/ +# / / \__/ \ \| | +# /_/ \_\_| +# +# description: Script webradio for Polybar +# last change: 29.07.2023 + +## variables ## +msgID="11111" +mpvsocket="/tmp/mpv" +path_logo="/home/$USER/Nextcloud/webradio" +file_title="/tmp/webradio_title" + +## function displaytime: displays the time in human readable format +displaytime() { + local T=$1 + #local D=$((T/60/60/24)) + local H=$((T/60/60%24)) + local M=$((T/60%60)) + local S=$((T%60)) + #(( $D > 0 )) && printf '%d:' $D + (( $H > 0 )) && printf '%02d:' $H + (( $M > 0 )) && printf '%02d:' $M + #(( $D > 0 || $H > 0 || $M > 0 )) + printf '%02d\n' $S +} + +# is mpv running? +if test -e "$mpvsocket"; then + # read actual title + act_title=`echo '{ "command": ["get_property", "media-title"] }' | socat - /tmp/mpv | awk -F\" '{print $4}'` + + # read playtime and convert to human readable format + playtime=`echo '{ "command": ["get_property", "playback-time"] }' | socat - /tmp/mpv | awk -F: '{print $2}' | awk -F, '{print $1}' | awk -F. '{print $1}'` + playtime_act=$(displaytime $playtime) + + # read station name and logo + radiostation=`cat /tmp/radiostation | awk '{print $1}'` + radiostation_logo=`cat /tmp/radiostation | awk '{print $2}'` + + # title file exist? + if test -e "$file_title"; then + title_check=`cat /tmp/webradio_title` + # actual title equals NOT the name in the title file? + if [[ "$title_check" != "$act_title" ]]; then + echo $act_title > $file_title + dunstify -t 5000 -a "Webradio: $radiostation" -r $msgID -I "$path_logo/$radiostation_logo" "$act_title" + fi + else + # if title file not exists + echo $act_title > $file_title + dunstify -t 5000 -a "Webradio: $radiostation" -r $msgID -I "$path_logo/$radiostation_logo" "$act_title" + fi + + # echo play symbol and playtime to polybar + echo " $playtime_act" +else + # Webradio is not running + echo "" +fi + +#+end_src diff --git a/webradio/dasding_logo.png b/webradio/dasding_logo.png new file mode 100644 index 0000000..7b6c9b3 Binary files /dev/null and b/webradio/dasding_logo.png differ diff --git a/webradio/einslive_logo.jpg b/webradio/einslive_logo.jpg new file mode 100644 index 0000000..d406f87 Binary files /dev/null and b/webradio/einslive_logo.jpg differ diff --git a/webradio/einslivediggi_logo.png b/webradio/einslivediggi_logo.png new file mode 100644 index 0000000..b8c6fc6 Binary files /dev/null and b/webradio/einslivediggi_logo.png differ diff --git a/webradio/sunshinelive_logo.png b/webradio/sunshinelive_logo.png new file mode 100644 index 0000000..49b444e Binary files /dev/null and b/webradio/sunshinelive_logo.png differ diff --git a/webradio/swr3_logo.jpg b/webradio/swr3_logo.jpg new file mode 100644 index 0000000..8ee55f9 Binary files /dev/null and b/webradio/swr3_logo.jpg differ diff --git a/webradio/wdr2_logo.png b/webradio/wdr2_logo.png new file mode 100644 index 0000000..19c309e Binary files /dev/null and b/webradio/wdr2_logo.png differ