diff --git a/fuzique b/fuzique index 1614931..4a9be8d 100755 --- a/fuzique +++ b/fuzique @@ -4,6 +4,39 @@ set -eu APP_NAME="fuzique" +if [ "${1:-}" = "--mpv-play" ]; then + if [ "$3" = "$MODE_PLAYLIST" ]; then + echo "{ \"command\": [\"set\", \"playlist-pos-1\", \"$FZF_POS\"] }" | socat - "$MPV_SOCKET" + else + echo "{ \"command\": [\"loadfile\", \"$2\"] }" | socat - "$MPV_SOCKET" + fi + exit 0 +fi +if [ "${1:-}" = "--mpv-queue" ]; then + echo "{ \"command\": [\"loadfile\", \"$2\", \"append-play\"] }" | socat - "$MPV_SOCKET" + exit 0 +fi +if [ "${1:-}" = "--mpv-next" ]; then + echo '{ "command": ["playlist-next"] }' | socat - "$MPV_SOCKET" + exit 0 +fi +if [ "${1:-}" = "--mpv-prev" ]; then + echo '{ "command": ["playlist-prev"] }' | socat - "$MPV_SOCKET" + exit 0 +fi +if [ "${1:-}" = "--mpv-seekf" ]; then + echo '{ "command": ["seek", "10"] }' | socat - "$MPV_SOCKET" + exit 0 +fi +if [ "${1:-}" = "--mpv-seekb" ]; then + echo '{ "command": ["seek", "-10"] }' | socat - "$MPV_SOCKET" + exit 0 +fi +if [ "${1:-}" = "--mpv-toggle-pause" ]; then + echo '{ "command": ["cycle", "pause"] }' | socat - "$MPV_SOCKET" + exit 0 +fi + if [ "${1:-}" = "--prompt" ]; then shift file="$1" @@ -172,8 +205,7 @@ OFF="\033[m" AFMT="${AFTM:-"🎤 ${ARTIST_COLOR}%s${OFF}"}" RFMT="${RFMT:-"💽 ${RELEASE_COLOR}%s${OFF}"}" TFMT="${TFMT:-"🎵 ${TRACK_COLOR}%s${OFF}"}" -PLAYLIST_POINTER="${PLAYLIST_POINTER:-☞}" -#PLAYLIST_POINTER="${PLAYLIST_POINTER:-👉}" +PLAYLIST_POINTER="${PLAYLIST_POINTER:-👉}" # Modes MODE_BROWSE="B" @@ -245,16 +277,47 @@ $FZF \ --with-nth="{1}" \ --cycle \ --bind="ctrl-d:half-page-down,ctrl-u:half-page-up" \ - --bind="enter:execute:printf '{ \"command\": [\"loadfile\", \"%s\"] }\n' {2} | socat - \"$MPV_SOCKET\"" \ - --bind="alt-enter:execute:printf '{ \"command\": [\"loadfile\", \"%s\", \"append-play\"] }\n' {2} | socat - \"$MPV_SOCKET\"" \ + --preview-window="down" \ --preview="$0 --preview {2}" \ --bind="alt-1:reload:column -t -s '|' -E 0 \"$artists_file_search\"" \ --bind="alt-2:reload:column -t -s '|' -E 0 \"$release_file_search\"" \ --bind="alt-3:reload:column -t -s '|' -E 0 \"$tracks_file_search\"" \ --bind="ctrl-p:reload:$0 --show-playlist" \ + --bind="enter:execute-silent:$0 --mpv-play {2} {3}" \ + --bind="alt-enter:execute-silent:$0 --mpv-queue {2}" \ + --bind="l:execute-silent:$0 --mpv-next" \ + --bind="h:execute-silent:$0 --mpv-prev" \ + --bind="right:execute-silent:$0 --mpv-seekf" \ + --bind="left:execute-silent:$0 --mpv-seekb" \ + --bind="space:execute-silent:$0 --mpv-toggle-pause" \ --bind="load:transform: - [ {3} = \"$MODE_SEARCH\" ] && printf \"+hide-preview\" || printf \"+show-preview\" - [ {3} = \"$MODE_PLAYLIST\" ] && printf \"+hide-input\" || printf \"+show-input\" + if [ {3} = \"$MODE_PLAYLIST\" ]; then + printf \"+hide-input\" + printf \"+show-preview\" + printf \"+rebind(l)\" + printf \"+rebind(h)\" + printf \"+rebind(right)\" + printf \"+rebind(left)\" + printf \"+rebind(space)\" + fi + if [ {3} = \"$MODE_SEARCH\" ]; then + printf \"+show-input\" + printf \"+hide-preview\" + printf \"+unbind(l)\" + printf \"+unbind(h)\" + printf \"+unbind(right)\" + printf \"+unbind(left)\" + printf \"+unbind(space)\" + fi + if [ {3} = \"$MODE_BROWSE\" ]; then + printf \"+show-input\" + printf \"+show-preview\" + printf \"+unbind(l)\" + printf \"+unbind(h)\" + printf \"+unbind(right)\" + printf \"+unbind(left)\" + printf \"+unbind(space)\" + fi printf \"+transform-prompt:$0 --prompt {2} {3}\" " \ --bind="ctrl-l:transform: