From 36bfd52368cab6aa82a2009f2e3b7608668f5745 Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Thu, 18 Feb 2021 12:30:26 +0100 Subject: [PATCH] Create setup to listen internet radio with mpd --- .config/mpd/mpd.conf | 5 + .config/openfm_channels.json | 181 ++++++++++++++++++++++++++ .config/sxhkd/sxhkdrc | 7 +- .local/bin/scripts/play-radio | 29 +++++ .local/bin/scripts/statusbar/sb-music | 23 ++-- 5 files changed, 235 insertions(+), 10 deletions(-) create mode 100644 .config/openfm_channels.json create mode 100755 .local/bin/scripts/play-radio diff --git a/.config/mpd/mpd.conf b/.config/mpd/mpd.conf index 8d0b943..a6404af 100644 --- a/.config/mpd/mpd.conf +++ b/.config/mpd/mpd.conf @@ -31,4 +31,9 @@ audio_output { name "Alsa for audio sound card" } +decoder { + plugin "faad" + enabled "no" +} + port "6600" diff --git a/.config/openfm_channels.json b/.config/openfm_channels.json new file mode 100644 index 0000000..7220625 --- /dev/null +++ b/.config/openfm_channels.json @@ -0,0 +1,181 @@ +{ + "Top 20 Pop": "96", + "Top 20 PL": "97", + "Top 20 Impreza": "95", + "Top 20 Disco Polo": "53", + "Top 20 Hip-Hop": "98", + "Top 20 Rock": "99", + "Top 20 Alt": "83", + "Top 2020 Hits": "131", + "Radio 357": "357", + "Radio Nowy Świat": "368", + "WP Radio: muzyka i informacje": "367", + "Radiospacja": "375", + "Radio TOK FM": "200", + "Radio Złote Przeboje": "201", + "Rock Radio": "202", + "Radio Pogoda": "203", + "Radio Kolor": "331", + "newonce.radio": "374", + "Halo.Radio": "372", + "Radio Kampus": "337", + "Radio Rockserwis FM": "379", + "Polish Radio London": "373", + "Radio Akadera": "332", + "Akademickie Radio LUZ": "334", + "Radio Fest": "335", + "Radio CCM": "336", + "Radio Centrum (Lublin)": "339", + "100% Hits": "64", + "4FUN Radio": "173", + "Freszzz: Zima 2021": "39", + "Hot Lista Open FM": "327", + "#popularne": "10", + "Po Polsku": "1", + "1001 Hits": "11", + "Największe Przeboje XX w.": "163", + "Ballady Wszech Czasów": "20", + "10s Hits": "352", + "00s Hits": "72", + "90s Hits": "14", + "80s Hits": "3", + "Classic Hits": "46", + "Top Wszech Czasów - Świat": "151", + "Top Wszech Czasów - Polska": "152", + "Tylko Polskie Przeboje": "111", + "Po Polsku 90": "369", + "Po Polsku 80": "79", + "Po Polsku 60/70": "17", + "Polskie Ballady": "165", + "Girl Power!": "364", + "K-pop": "147", + "Gwiazdy": "58", + "Latino Hits": "19", + "100% Ed Sheeran": "134", + "100% One Direction": "80", + "Dzień Dobry!": "69", + "Praca": "109", + "W Domu": "365", + "Szkoła": "347", + "Dobry Wieczór": "137", + "Dobranoc": "74", + "Muzyka do snu": "70", + "Weekend Hits": "127", + "Weekend Chill": "126", + "We Dwoje": "4", + "Happy": "120", + "Sad": "103", + "Relaks": "112", + "Joga": "362", + "Crema Café": "76", + "Nauka": "117", + "Koncentracja": "161", + "Chillout": "33", + "Ladies Café": "48", + "Love": "121", + "Sexy: Soul & R'n'B": "18", + "Spacer": "144", + "Hygge": "138", + "Retro Café": "25", + "Impreza": "2", + "500 Party Hits": "81", + "Dance": "31", + "House": "5", + "Trance": "7", + "Ladies Party": "102", + "Wesele": "110", + "Classic Party": "50", + "Klub 90": "8", + "Italo Disco": "27", + "Do Auta Club": "114", + "Disco Polo": "21", + "Impreza PL": "12", + "Disco Polo Freszzz": "57", + "Disco Polo Classic": "49", + "Polo & Dance": "128", + "SBM Radio": "384", + "Hip-Hop PL": "24", + "Hip-Hop Freszzz": "93", + "Miejska Stacja": "366", + "Top Wszech Czasów - Hip-Hop PL": "176", + "500 Hip-Hop Hits": "84", + "Trap USA": "354", + "Trap PL": "355", + "500 R'n'b Hits": "26", + "Hip-Hop USA": "23", + "Hip-Hop Klasyk": "107", + "Hip-Hop Ulica": "92", + "Taco i Quebo": "199", + "100% Chada": "198", + "100% O.S.T.R.": "47", + "500 Rock Hits": "82", + "Praca Rock": "104", + "Top Wszech Czasów - Rock": "153", + "Top Wszech Czasów - Rock PL": "186", + "Polska Rocks!": "177", + "Polski Rock": "29", + "Polski Rock Classic": "45", + "Radio Rak'n'Roll": "168", + "Rocks": "77", + "Giganci Rocka": "118", + "American Rock": "40", + "Grunge": "157", + "Rock Ballady": "61", + "Classic Rock": "32", + "500 Heavy Hits": "54", + "Classic Metal": "108", + "Ciężkie Brzmienia": "13", + "Do Auta Rock": "113", + "Punk Rock": "78", + "The Best of Happysad": "136", + "100% Dżem": "15", + "100% Kazik": "35", + "100% Grabaż": "73", + "100% Kora & Maanam": "158", + "100% Queen": "185", + "100% Guns N' Roses": "181", + "100% Metallica": "62", + "100% Iron Maiden": "182", + "100% Linkin Park": "42", + "500 Alternative Hits": "55", + "Alt PL": "36", + "Alt Freszzz": "6", + "Alt Café": "34", + "Alt Classic": "43", + "Alt Club": "9", + "The Best of Britpop": "159", + "100% Depeche Mode": "135", + "The Best of Coldplay": "145", + "500 Electronic Hits": "94", + "EDM Anthems": "361", + "Beats & Bass": "106", + "Dubstep": "68", + "Drum'n'Bass": "41", + "Trening": "101", + "Fitness": "65", + "Bieganie": "116", + "Cardio": "141", + "Muzyka Motywacyjna": "143", + "Kids - Muzyka & Ciekawostki": "16", + "Piosenki Dla Dzieci": "160", + "Piosenki Po Angielsku": "353", + "Kołysanki": "142", + "Pozytywki": "194", + "Szum": "193", + "500 Reggae Hits": "30", + "Polskie Reggae": "22", + "Jazz": "166", + "Smooth Jazz": "60", + "Muzyka Klasyczna": "67", + "Muzyka Filmowa": "38", + "Kraina Łagodności": "37", + "Szanty": "28", + "Biesiada": "59", + "Biesiada Śląska": "66", + "Odgłosy Natury": "52", + "100% Ukraina": "167", + "Ukraina Top 20": "191", + "Rock UA": "172", + "Dance UA": "187", + "Shanson": "169" +} \ No newline at end of file diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 8e91894..1eb670f 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -41,6 +41,9 @@ Pause # mute XF86AudioMute pamixer -t && pkill -RTMIN+1 dwmblocks +# select radio +XF86Tools + play-radio # volume control XF86Audio{Raise,Lower}Volume pamixer -{i,d}3 && pkill -RTMIN+1 dwmblocks @@ -49,10 +52,10 @@ XF86Audio{Next,Prev} playerctl {next,previous} && pkill -RTMIN+2 dwmblocks # pause/play {XF86AudioPlay,super + slash} - playerctl play-pause && pkill -RTMIN+2 dwmblocks + mpc status | grep -q "playing\|paused" && mpc toggle || playerctl play-pause && pkill -RTMIN+2 dwmblocks # stop XF86AudioStop - playerctl stop && pkill -RTMIN+2 dwmblocks + mpc stop && playerctl stop && pkill -RTMIN+2 dwmblocks ctrl + alt + {Left,Up,Down,period} rotscreen {left,normal,inverted,right} diff --git a/.local/bin/scripts/play-radio b/.local/bin/scripts/play-radio new file mode 100755 index 0000000..4d7f343 --- /dev/null +++ b/.local/bin/scripts/play-radio @@ -0,0 +1,29 @@ +#!/bin/sh + +# Select internet radio station and play it in mpd. + +OPEN_FM_CHANNELS_LIST="$HOME/.config/openfm_channels.json" + +STATIONS="$(sed 's/: .*//g; s/ /Open FM: /; s/"//g; s/}//g; s/{//g; /^$/d' "$OPEN_FM_CHANNELS_LIST") +newonce.radio +RMF FM +RMF Maxxx +Radio ZET" + +station=$(echo "$STATIONS" | rofi -dmenu -i -l 20 -p ' Radio Station') +[ ! "$station" ] && exit + +case "$station" in + "newonce.radio") radio="http://streamer.radio.co/s93b51ccc1/listen" ;; + "RMF FM") radio="http://195.150.20.4:8000/rmf_fm" ;; + "RMF Maxxx") radio="http://195.150.20.4:8000/rmf_maxxx" ;; + "Radio ZET") radio="https://zt02.cdn.eurozet.pl/zet-old.mp3" ;; + *) + id="$(grep "$(echo "$station" | sed 's/Open FM: //g')" "$OPEN_FM_CHANNELS_LIST" | sed 's/.*: //g; s/"//g; s/,//g')" + radio="http://stream.open.fm/$id" + ;; +esac + +mpc clear +mpc add "$radio" +mpc play diff --git a/.local/bin/scripts/statusbar/sb-music b/.local/bin/scripts/statusbar/sb-music index 31d4350..5f15056 100755 --- a/.local/bin/scripts/statusbar/sb-music +++ b/.local/bin/scripts/statusbar/sb-music @@ -1,15 +1,22 @@ #!/bin/sh -# if mpc status | grep -q "playing"; then -# mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[playing\\].*//g" -# elif mpc status | grep -q "paused"; then -# echo "" -# else -# echo "" -# fi +# asdf if playerctl --player=spotify status | grep -q "Playing"; then - playerctl metadata --format "{{ artist }} - {{ title }}" + printf "%s" "Spotify: " + playerctl metadata --player=spotify --format "{{ artist }} - {{ title }}" +elif [ "$(mpc status | awk 'NR==2 {print $1}')" = "[playing]" ]; then + if mpc status -f "%file%" | grep -q "open.fm"; then + channel_id="$(mpc status -f "%name%" | awk 'NR==1 {print $1}')" + name="$(grep \""$channel_id"\" /home/samedamci/.config/openfm_channels.json | sed 's/: .*//g; s/ //; s/"//g' | tr -d '\n')" + printf "%s" "Open FM: $name" + title="$(mpc status -f "%title%" | awk 'NR==1' | sed 's/ w .*//g; s/& .* -/-/g; s/feat. .* -/-/g; s/REKLAMA - open.fm - REKLAMA//g')" + [ ! "$title" = "" ] && printf "%s" ": $title" + elif mpc status -f "%file%" | grep -q "http://streamer.radio.co/s93b51ccc1/listen\|rmf_maxxx\|rmf_fm"; then + mpc status -f "%name%: %title%" | awk 'NR==1' | sed 's/ w .*//g; s/& .* -/-/g; s/feat. .* -/-/g; s/ft .* -/-/g; s/; .* -/ -/g; s/ (feat. .*//g; s/feat. .*//g; s/STOP_AD_BREAK//g' + elif mpc status -f "%file%" | grep -q "zet-old.mp3"; then + mpc status -f "%name%" | awk 'NR==1' + fi elif playerctl --player=spotify status | grep -q "Paused"; then echo "" else