From 1eb2ea409737bc720a6690b00d7f3a70765770d8 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 19 Feb 2026 22:27:28 +0300 Subject: [PATCH] music --- .gitignore | 2 + home/user/.local/bin/radio | 26 ++++++--- home/user/.local/bin/tunes | 117 +++++++++++++++++++++++++++++++++++-- home/user/.tmux/landing | 15 +++++ home/user/.tmux/music | 16 +++++ 5 files changed, 162 insertions(+), 14 deletions(-) create mode 100755 home/user/.tmux/landing create mode 100755 home/user/.tmux/music diff --git a/.gitignore b/.gitignore index ea28378..5dfd034 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ home/user/.tmux/* !home/user/.tmux/ssh !home/user/.tmux/example-background-job !home/user/.tmux/system-update +!home/user/.tmux/music +!home/user/.tmux/landing home/user/.config/git/local diff --git a/home/user/.local/bin/radio b/home/user/.local/bin/radio index 9fc6e3f..b445486 100755 --- a/home/user/.local/bin/radio +++ b/home/user/.local/bin/radio @@ -4,16 +4,26 @@ set -eu channel="${1:-}" if [ "${channel}" = lofi ]; then - url='https://live.hunter.fm/lofi_low' -elif [ "${channel}" = trance ]; then - url='http://ubuntu.hbr1.com:19800/trance.ogg' -elif [ "${channel}" = salsa ]; then - url='https://latinasalsa.ice.infomaniak.ch/latinasalsa.mp3' -elif [ "${channel}" = kfai ]; then - url='https://kfai.broadcasttool.stream/kfai-1' + url='https://radiorecord.hostingradio.ru/lofi96.aacp' +elif [ "${channel}" = fallout ]; then + url='http://fallout.fm:8000/falloutfm1.ogg' +elif [ "${channel}" = wasteland ]; then + url='http://wasteland.su:8080/radio' +elif [ "${channel}" = retrofm ]; then + url='http://hls-01-retro.emgsound.ru/12/128/playlist.m3u8' +elif [ "${channel}" = rusradio ]; then + url='https://rusradio.hostingradio.ru/rusradio128.mp3' +elif [ "${channel}" = rock ]; then + url='https://radiorecord.hostingradio.ru/rock96.aacp' +elif [ "${channel}" = phonk ]; then + url='https://radiorecord.hostingradio.ru/phonk96.aacp' +elif [ "${channel}" = dorognoe ]; then + url='https://dorognoe.hostingradio.ru:8000/dorognoe' else - echo "don't know \"${channel}\": lofi/trance/salsa/kfai" 1>&2 + echo "don't know \"${channel}\": lofi/fallout/wasteland/retrofm/rusradio/rock/phonk/dorognoe" 1>&2 exit 1 fi exec mpv --really-quiet "${url}" + +# https://gist.github.com/ergoz/e7837a54956116167db93b016dbd51a9 diff --git a/home/user/.local/bin/tunes b/home/user/.local/bin/tunes index d4455f1..146e1e6 100755 --- a/home/user/.local/bin/tunes +++ b/home/user/.local/bin/tunes @@ -1,11 +1,116 @@ #!/bin/sh set -eu -playlist="${1:-}" -shift || true +ACTION="${1:-}" +PROG="$(basename "${0}")" +SOCKET_PATH="/tmp/mpv-${USER}.sock" -if [ -z "${playlist}" ]; then - playlist="${HOME}/Music" -fi +send_cmd() { + echo "{ \"command\": ${1} }" | socat - "${SOCKET_PATH}" +} -exec mpv --shuffle --no-video --ytdl-format=worstaudio "${@}" -- "${playlist}" + +play_playlist() { + playlist="${1:-}" + + if [ -z "${playlist}" ]; then + playlist="${HOME}/Music" + fi + + exec mpv --input-ipc-server="${SOCKET_PATH}" --shuffle --no-video --ytdl-format=worstaudio "${@}" -- "${playlist}" +} + +tune_radio() { + channel="${1:-}" + + if [ "${channel}" = lofi ]; then + url='https://radiorecord.hostingradio.ru/lofi96.aacp' + elif [ "${channel}" = fallout ]; then + url='http://fallout.fm:8000/falloutfm1.ogg' + elif [ "${channel}" = wasteland ]; then + url='http://wasteland.su:8080/radio' + elif [ "${channel}" = retrofm ]; then + url='http://hls-01-retro.emgsound.ru/12/128/playlist.m3u8' + elif [ "${channel}" = rusradio ]; then + url='https://rusradio.hostingradio.ru/rusradio128.mp3' + elif [ "${channel}" = rock ]; then + url='https://radiorecord.hostingradio.ru/rock96.aacp' + elif [ "${channel}" = phonk ]; then + url='https://radiorecord.hostingradio.ru/phonk96.aacp' + elif [ "${channel}" = dorognoe ]; then + url='https://dorognoe.hostingradio.ru:8000/dorognoe' + else + echo "${PROG} radio: don't know \"${channel}\": lofi/fallout/wasteland/retrofm/rusradio/rock/phonk/dorognoe" 1>&2 + exit 1 + fi + + send_cmd "[\"loadfile\", \"${url}\", \"replace\"]" +} + +play_radio() { + channel="${1:-}" + + if [ "${channel}" = lofi ]; then + url='https://radiorecord.hostingradio.ru/lofi96.aacp' + elif [ "${channel}" = fallout ]; then + url='http://fallout.fm:8000/falloutfm1.ogg' + elif [ "${channel}" = wasteland ]; then + url='http://wasteland.su:8080/radio' + elif [ "${channel}" = retrofm ]; then + url='http://hls-01-retro.emgsound.ru/12/128/playlist.m3u8' + elif [ "${channel}" = rusradio ]; then + url='https://rusradio.hostingradio.ru/rusradio128.mp3' + elif [ "${channel}" = rock ]; then + url='https://radiorecord.hostingradio.ru/rock96.aacp' + elif [ "${channel}" = phonk ]; then + url='https://radiorecord.hostingradio.ru/phonk96.aacp' + elif [ "${channel}" = dorognoe ]; then + url='https://dorognoe.hostingradio.ru:8000/dorognoe' + else + echo "${PROG} radio: don't know \"${channel}\": lofi/fallout/wasteland/retrofm/rusradio/rock/phonk/dorognoe" 1>&2 + exit 1 + fi + + exec mpv --really-quiet "${url}" +} + +cmd_run() { + case "${1:-}" in + music) shift; + play_playlist "${@}" + ;; + radio) shift; + play_radio "${@}" + ;; + help|"") + echo "Usage: ${PROG} run {music PLAYLIST|radio CHANNEL}" + echo "Example: ${PROG} run music" + ;; + esac +} + + +case "${ACTION}" in + next|n) shift; + send_cmd '["playlist-next"]' + echo "➡️ Next" + ;; + prev|p) shift; + send_cmd '["playlist-prev"]' + echo "⬅️ Prev" + ;; + pause|space) shift; + send_cmd '["cycle", "pause"]' + echo "⏯️ Pause" + ;; + run) shift; + cmd_run "${@}" + ;; + radio) shift; + tune_radio "${@}" + ;; + help|"") + echo "Usage: ${PROG} {next|prev|pause|run|radio CHANNEL}" + echo "Example: ${PROG} next" + ;; +esac diff --git a/home/user/.tmux/landing b/home/user/.tmux/landing new file mode 100755 index 0000000..bc8df36 --- /dev/null +++ b/home/user/.tmux/landing @@ -0,0 +1,15 @@ +#!/bin/sh + +set -eux + +readonly SESSION=landing +readonly MAINW=landing + +readonly WORKING_PROJECT="${HOME}" + +if ! tmux has-session -t="${SESSION}"; then + tmux new-session -s "${SESSION}" -d -n "1" -c "${WORKING_PROJECT}" 'sh -c "tmux set-option remain-on-exit on; figlet -ct -f big Landing; trap : INT; while true; do sleep 3600; done"' + tmux rename-window -t="${SESSION}:1" "${MAINW}" +fi + +tmux switch-client -t "${SESSION}" diff --git a/home/user/.tmux/music b/home/user/.tmux/music new file mode 100755 index 0000000..4ab1ddc --- /dev/null +++ b/home/user/.tmux/music @@ -0,0 +1,16 @@ +#!/bin/sh + +set -eux + +readonly SESSION=music +readonly MAINW=music + +readonly WORKING_PROJECT="${HOME}" + +if ! tmux has-session -t="${SESSION}"; then + tmux new-session -s "${SESSION}" -d -n "${MAINW}" -c "${WORKING_PROJECT}" + tmux rename-window -t "${SESSION}:1" "${MAINW}" + tmux send-keys -t "${SESSION}:${MAINW}.1" "tunes run music" Enter +fi + +tmux switch-client -t "${SESSION}"