From 3702bc54a8679fbf4031d32fe079f28f139b45b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Thu, 11 Sep 2025 13:59:27 +0200 Subject: [PATCH] bugfix and keys bugfix: playing failed with tracks of unknown length keys: added yank keys --- src/main.sh | 2 ++ src/sh/keys.sh | 7 ++++++- src/sh/playback.sh | 2 +- src/sh/tools.sh | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.sh b/src/main.sh index 0021866..266b5b8 100755 --- a/src/main.sh +++ b/src/main.sh @@ -638,6 +638,8 @@ open \"https://musicbrainz.org/\$t/{r3}\"" \ --bind="$KEYS_OPEN:execute-silent: [ {4} ] || exit 0 open \"\$(dirname {4})\"" \ + --bind="$KEYS_N_YANK:transform:$IN_NORMAL_MODE && echo \"execute-silent(printf {3} | $CLIP)\" || $PUT_FZF_KEY_LOGIC" \ + --bind="$KEYS_YANK_CURRENT:execute-silent:printf {2} | $CLIP" \ --bind="$KEYS_SHOW_PLAYLIST:transform:echo \"print($VIEW_PLAYLIST)+print()+print($FZF_CURRENT_VIEW)+print({2})+accept\"" \ --bind="$KEYS_QUIT:print($VIEW_QUIT)+accept" \ --bind="$KEYS_N_QUIT:transform:$IN_NORMAL_MODE && ($IN_LIST_ARTISTS_VIEW && echo \"print($VIEW_QUIT)+accept\" || $0 --action-draw $MODE_NORMAL $VIEW_LIST_ARTISTS) || $PUT_FZF_KEY_LOGIC" \ diff --git a/src/sh/keys.sh b/src/sh/keys.sh index 79d4660..a6bf6e9 100644 --- a/src/sh/keys.sh +++ b/src/sh/keys.sh @@ -48,6 +48,8 @@ # Specials: # - KEYS_BROWSE: Open MusicBrainz webpage of the selected item # - KEYS_OPEN: Open file manager in the directory of the selected item +# - KEYS_N_YANK: Copy MusicBrainz ID of selected item to clipboard +# - KEYS_YANK_CURRENT: Copy MusicBrainz ID of current item to clipboard # - KEYS_SHOW_PLAYLIST: Switch to playlist view # - KEYS_QUIT: Quit application # - KEYS_N_QUIT: Quit application if we are in VIEW_LIST_ARTISTS, else go to @@ -133,10 +135,13 @@ export KEYS_FILTER_LOCAL KEYS_FILTER_1 KEYS_FILTER_2 KEYS_FILTER_3 \ # Specials: KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}" KEYS_OPEN="${KEYS_OPEN:-"alt-o"}" +KEYS_N_YANK="${KEYS_N_YANK:-"y"}" +KEYS_YANK_CURRENT="${KEYS_YANK_CURRENT:-"ctrl-y"}" KEYS_SHOW_PLAYLIST="${KEYS_SHOW_PLAYLIST:-"ctrl-p"}" KEYS_QUIT="${KEYS_QUIT:-"ctrl-c"}" KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}" -export KEYS_BROWSE KEYS_OPEN KEYS_SHOW_PLAYLIST KEYS_QUIT KEYS_N_QUIT +export KEYS_BROWSE KEYS_OPEN KEYS_N_YANK KEYS_YANK_CURRENT KEYS_SHOW_PLAYLIST \ + KEYS_QUIT KEYS_N_QUIT # Playback: KEYS_PLAY="${KEYS_PLAY:-"enter"}" diff --git a/src/sh/playback.sh b/src/sh/playback.sh index eac9ec3..12f911e 100644 --- a/src/sh/playback.sh +++ b/src/sh/playback.sh @@ -73,7 +73,7 @@ __generate_playlist() { (."artist-credit" | map([.name, .joinphrase] | join("")) | join("")), $deco ] | join("\t"), - length: (.length / 1000 | round | tostring), + length: (.length // 0 / 1000 | round | tostring), $pos, number: .number, file: $filenames[.id] diff --git a/src/sh/tools.sh b/src/sh/tools.sh index 7d5ac08..bae5237 100644 --- a/src/sh/tools.sh +++ b/src/sh/tools.sh @@ -39,5 +39,8 @@ if [ ! "${TOOLS_LOADED:-}" ]; then fi export SOCAT + command -v "xsel" >/dev/null && CLIP="xsel" || CLIP="true" + export CLIP + export TOOLS_LOADED=1 fi