From f35461cc50186b27eee32d39f11ba8544e3901f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Mon, 8 Sep 2025 13:06:50 +0200 Subject: [PATCH] shuffle and unshuffle of playlist --- src/main.sh | 2 ++ src/sh/keys.sh | 10 +++++++--- src/sh/mpv.sh | 8 ++++++++ src/sh/playlist.sh | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main.sh b/src/main.sh index b35a6d8..7d95cf0 100755 --- a/src/main.sh +++ b/src/main.sh @@ -563,6 +563,8 @@ while true; do --bind="$KEYS_PLAYLIST_CLEAR:execute-silent($0 --playlist $PLAYLIST_CMD_CLEAR)+$FZF_RELOAD_PLAYLIST" \ --bind="$KEYS_PLAYLIST_CLEAR_ABOVE:execute-silent($0 --playlist $PLAYLIST_CMD_CLEAR_ABOVE)+$FZF_RELOAD_PLAYLIST" \ --bind="$KEYS_PLAYLIST_CLEAR_BELOW:execute-silent($0 --playlist $PLAYLIST_CMD_CLEAR_BELOW)+$FZF_RELOAD_PLAYLIST" \ + --bind="$KEYS_PLAYLIST_SHUFFLE:execute-silent($0 --playlist $PLAYLIST_CMD_SHUFFLE)+$FZF_RELOAD_PLAYLIST" \ + --bind="$KEYS_PLAYLIST_UNSHUFFLE:execute-silent($0 --playlist $PLAYLIST_CMD_UNSHUFFLE)+$FZF_RELOAD_PLAYLIST" \ --bind="$KEYS_PLAYLIST_GOTO_RELEASE:print($VIEW_RELEASE)+accept" \ --delimiter="\t" \ --with-nth="{1}" \ diff --git a/src/sh/keys.sh b/src/sh/keys.sh index f5f7bb9..79d4660 100644 --- a/src/sh/keys.sh +++ b/src/sh/keys.sh @@ -72,7 +72,9 @@ # - KEYS_PLAYLIST_CLEAR: Clear playlist # - KEYS_PLAYLIST_CLEAR_ABOVE: Remove all items above incl. the selected one # - KEYS_PLAYLIST_CLEAR_BELOW: Remove all items below incl. the selected one -# - KEYS_PLAYLIST_GOTO_RELEASE: Jump to release or seleted enry +# - KEYS_PLAYLIST_SHUFFLE: Shuffle playlist +# - KEYS_PLAYLIST_UNSHUFFLE: Unshuffle previously shuffled playlist +# - KEYS_PLAYLIST_GOTO_RELEASE: Jump to release or selected entry # - KEYS_PLAYLIST_STORE: Store current playlist as file # - KEYS_PLAYLIST_LOAD: Load playlist from file # - KEYS_PLAYLIST_QUIT: Quit playlist view @@ -169,10 +171,12 @@ KEYS_PLAYLIST_DOWN="${KEYS_PLAYLIST_DOWN:-"d"}" KEYS_PLAYLIST_CLEAR="${KEYS_PLAYLIST_CLEAR:-"C"}" KEYS_PLAYLIST_CLEAR_ABOVE="${KEYS_PLAYLIST_CLEAR_ABOVE:-"U"}" KEYS_PLAYLIST_CLEAR_BELOW="${KEYS_PLAYLIST_CLEAR_BELOW:-"D"}" +KEYS_PLAYLIST_SHUFFLE="${KEYS_PLAYLIST_SHUFFLE:-"s"}" +KEYS_PLAYLIST_UNSHUFFLE="${KEYS_PLAYLIST_UNSHUFFLE:-"S"}" KEYS_PLAYLIST_GOTO_RELEASE="${KEYS_PLAYLIST_GOTO_RELEASE:-"ctrl-g"}" KEYS_PLAYLIST_STORE="${KEYS_PLAYLIST_STORE:-"ctrl-s"}" KEYS_PLAYLIST_LOAD="${KEYS_PLAYLIST_LOAD:-"ctrl-o"}" export KEYS_PLAYLIST_RELOAD KEYS_PLAYLIST_REMOVE KEYS_PLAYLIST_UP \ KEYS_PLAYLIST_DOWN KEYS_PLAYLIST_CLEAR KEYS_PLAYLIST_CLEAR_ABOVE \ - KEYS_PLAYLIST_CLEAR_BELOW KEYS_PLAYLIST_GOTO_RELEASE KEYS_PLAYLIST_STORE \ - KEYS_PLAYLIST_LOAD + KEYS_PLAYLIST_CLEAR_BELOW KEYS_PLAYLIST_SHUFFLE KEYS_PLAYLIST_UNSHUFFLE \ + KEYS_PLAYLIST_GOTO_RELEASE KEYS_PLAYLIST_STORE KEYS_PLAYLIST_LOAD diff --git a/src/sh/mpv.sh b/src/sh/mpv.sh index 4fac3fc..2ed0d96 100644 --- a/src/sh/mpv.sh +++ b/src/sh/mpv.sh @@ -30,6 +30,14 @@ mpv_playlist_clear() { __mpv_command "playlist-clear" } +mpv_playlist_shuffle() { + __mpv_command "playlist-shuffle" +} + +mpv_playlist_unshuffle() { + __mpv_command "playlist-unshuffle" +} + mpv_quit() { __mpv_command "quit" } diff --git a/src/sh/playlist.sh b/src/sh/playlist.sh index 9881d44..5d8ce94 100644 --- a/src/sh/playlist.sh +++ b/src/sh/playlist.sh @@ -4,6 +4,8 @@ PLAYLIST_CMD_DOWN="down" PLAYLIST_CMD_CLEAR="clear" PLAYLIST_CMD_CLEAR_ABOVE="clear-above" PLAYLIST_CMD_CLEAR_BELOW="clear-below" +PLAYLIST_CMD_SHUFFLE="shuffle" +PLAYLIST_CMD_UNSHUFFLE="unshuffle" # Run playback commands # @@ -28,5 +30,7 @@ playlist() { mpv_rm_index $((FZF_POS - 1)) done ;; + "$PLAYLIST_CMD_SHUFFLE") mpv_playlist_shuffle ;; + "$PLAYLIST_CMD_UNSHUFFLE") mpv_playlist_unshuffle ;; esac }