commit 4e0022a54c5264ef3d0aeaa3a02257bc3c662673 parent ffc230cbbe0554c04c44745b2a5417f41df21e08 Author: Alex Balgavy <alex@balgavy.eu> Date: Tue, 1 Jun 2021 14:52:27 +0200 mpc queuing now adds to the end Diffstat:
M | lf/lfrc | | | 14 | ++++++++++++++ |
M | scripts/mpcq | | | 32 | +++++++++++++++++++++++++++++++- |
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/lf/lfrc b/lf/lfrc @@ -88,6 +88,20 @@ cmd queue %{{ for i in $fx; do case "$i" in *.wav|*.flac|*.mp3|*.m4a|*.opus) + mpc -h ~/.local/share/mpd/socket add "file://$i" + printf "Queued: %s" "$i" + ;; + *.m3u) + mpc -h ~/.local/share/mpd/socket load "file://$i" + printf "Loaded playlist: %s" "$i" + ;; + esac + done +}} +cmd queuenext %{{ + for i in $fx; do + case "$i" in + *.wav|*.flac|*.mp3|*.m4a|*.opus) mpc -h ~/.local/share/mpd/socket insert "file://$i" printf "Queued: %s" "$i" ;; diff --git a/scripts/mpcq b/scripts/mpcq @@ -15,7 +15,8 @@ pgrep mpd >/dev/null 2>&1 || die "mpd is not running." queue() { case "$1" in *.wav|*.flac|*.mp3|*.m4a|*.opus) - mpc -h ~/.local/share/mpd/socket insert "file://$1" + { [ -n "$next" ] && queuecmd="insert"; } || queuecmd="add" + mpc -h ~/.local/share/mpd/socket "$queuecmd" "file://$1" printf "Queued: %s\n" "$1" ;; *.m3u) @@ -25,6 +26,35 @@ queue() { esac } +PARAMS="" +while [ $(($#)) -ne 0 ]; do + case "$1" in + -n|--next) + next=1 + shift + ;; + + -h|--help) + echo "Usage:" + echo "mpcq [-n] file1 [file2..]" + exit 0 + ;; + --) # end arg parsing + shift + break + ;; + -*) # unsupported flags + echo "Unsupported flag $1" >&2 + exit 1 + ;; + *) # preserve positional arguments + PARAMS="$PARAMS $1" + shift + ;; + esac +done +eval set -- "$PARAMS" + if ! [ -t 0 ]; then while read -r line; do fpath="$(realpath "$line")"