summaryrefslogtreecommitdiff
path: root/scripts/music
diff options
context:
space:
mode:
authormarcellus <msimon_fr@hotmail.com>2023-05-02 18:30:47 +0200
committermarcellus <msimon_fr@hotmail.com>2023-05-02 18:30:47 +0200
commit7e1032434d90db737e319d3eb21721b7fed388be (patch)
tree292b4bc560edd33f1fbcd9655c9b76b49b75b404 /scripts/music
parent7d1e4e8fbcb57d7e3b04f730f6e51c0e00b76456 (diff)
add: scripts from ratakor's repo
Diffstat (limited to 'scripts/music')
-rwxr-xr-xscripts/music30
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"