diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2023-05-17 00:09:51 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2023-05-17 00:09:51 +0200 |
| commit | 5d3c0b24405381a41bd13a3135fa2969c2b47a48 (patch) | |
| tree | c59a2521159b90daac9e139e5ebaeaf24dd3fa0f /scripts/music | |
| parent | 436159f3542d4e11c81ff927ab6b22f5ad2619e0 (diff) | |
| parent | ca1fba1ef518b2f55bc168e9782b500dfec67c16 (diff) | |
Merge branch 'main' of https://github.com/Laitram31/config
Diffstat (limited to 'scripts/music')
| -rwxr-xr-x | scripts/music | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/music b/scripts/music new file mode 100755 index 0000000..42ceeeb --- /dev/null +++ b/scripts/music @@ -0,0 +1,30 @@ +#!/bin/sh +# simple music selector with dmenu that uses and interacts with mpv +# have a look at musiccmd, dwmblocks/sb_music and .local/etc/mpv/music +# shellcheck disable=SC2012 + +MUSICDIR="${XDG_MUSIC_DIR:-$HOME/music}" + +if [ "$1" = "--shuffle" ]; then + SHUFFLE=yes + shift +fi + +MUSIC="${1:-$MUSICDIR/$(ls "$MUSICDIR" | dmenu -i -p "Play ")}" +SCRIPT="$XDG_CONFIG_HOME/mpv/music/local.lua" + +if [ "$MUSIC" = "$MUSICDIR/urls" ]; then + MUSIC="$(cat "$MUSICDIR/urls/$(ls "$MUSICDIR/urls" | dmenu -i -p "Play ")")" + SCRIPT="$XDG_CONFIG_HOME/mpv/music/online.lua" +fi + +[ "$MUSIC" = "$MUSICDIR/" ] || [ -z "$MUSIC" ] && exit 1 + +if [ -z "$SHUFFLE" ] && [ -d "$MUSIC" ] || printf '%s' "$MUSIC" | grep -q playlist; then + SHUFFLE="$(printf 'yes\nno' | dmenu -i -p 'Shuffle?')" + [ -z "$SHUFFLE" ] && exit 1 +fi + +printf 'stop\n' | socat - /tmp/mpvsocket 2> /dev/null +mpv --vid=no --input-ipc-server=/tmp/mpvsocket --loop-playlist --volume=75\ + --ytdl-format="wv*+ba" --script="$SCRIPT" --shuffle="$SHUFFLE" "$MUSIC" |
