keys configurable, multiple keys support, decreasesd fzf processes

This commit is contained in:
2025-08-27 17:38:11 +02:00
parent 9aa1413a51
commit a1ae20fa82
5 changed files with 157 additions and 368 deletions

View File

@@ -37,7 +37,7 @@ mpv_quit() {
mpv_start() {
MPV_SOCKET="$(mktemp --suffix=.sock)"
trap 'mpv_quit; rm -f "$MPV_SOCKET"' EXIT INT
trap 'mpv_quit >/dev/null; rm -f "$MPV_SOCKET"' EXIT INT
$MPV --no-config --no-terminal --input-ipc-server="$MPV_SOCKET" --idle --no-osc --no-input-default-bindings &
}

24
src/sh/keys.sh Normal file
View File

@@ -0,0 +1,24 @@
KEYS_HALFPAGE_DOWN="${KEYS_HALFPAGE_DOWN:-"ctrl-d"}"
KEYS_HALFPAGE_UP="${KEYS_HALFPAGE_UP:-"ctrl-u"}"
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
KEYS_FILTER_PRIMARY="${KEYS_FILTER_PRIMARY:-"alt-1"}"
KEYS_FILTER_SECONDARY="${KEYS_FILTER_SECONDARY:-"alt-2"}"
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
KEYS_SWITCH_LOCAL_REMOTE="${KEYS_SWITCH_LOCAL_REMOTE:-"ctrl-/"}"
KEYS_PLAY="${KEYS_PLAY:-"enter"}"
KEYS_QUEUE="${KEYS_QUEUE:-"alt-enter"}"
KEYS_TOGGLE_PLAY_PAUSE="${KEYS_TOGGLE_PLAY_PAUSE:-"space"}"
KEYS_PLAY_NEXT="${KEYS_PLAY_NEXT:-"l"}"
KEYS_PLAY_PREV="${KEYS_PLAY_PREV:-"h"}"
KEYS_SEEK_FORWARD="${KEYS_SEEK_FORWARD:-"shift-right"}"
KEYS_SEEK_BACKWARD="${KEYS_SEEK_BACKWARD:-"shift-left"}"
export KEYS_HALFPAGE_DOWN KEYS_HALFPAGE_UP KEYS_BROWSE KEYS_OUT KEYS_IN \
KEYS_SELECT_ARTIST KEYS_FILTER_LOCAL KEYS_FILTER_PRIMARY KEYS_FILTER_SECONDARY \
KEYS_SWITCH_ARTIST_ALBUM KEYS_SWITCH_LOCAL_REMOTE KEYS_PLAY KEYS_QUEUE \
KEYS_TOGGLE_PLAY_PAUSE KEYS_PLAY_NEXT KEYS_PLAY_PREV KEYS_SEEK_FORWARD \
KEYS_SEEK_BACKWARD

View File

@@ -139,3 +139,29 @@ list_local_releasegroups() {
list_local_releases() {
cat "$LOCALDATA_RELEASES_VIEW" 2>/dev/null
}
# Generate playlist from MB release ID and path to decoration
# @argument $1: MusicBrainz Release ID
# @argument $2: Path to decoration file
generate_playlist() {
dir="$(dirname "$2")"
mb_release "$1" |
$JQ -r --slurpfile deco "$2" --arg base "$dir" '$deco[].tracks as $filenames |
.media[] |
.position as $pos |
.tracks |
map({
$pos,
number: .number,
file: $filenames[.id]
}) |
map(
if(.number | type == "string" and test("^[0-9]+$")) then
.number |= tonumber
else
.
end
) |
sort_by([.pos, .number]) |
map($base + "/" + .file)[]'
}

View File

@@ -1,5 +1,5 @@
if command -v "fzf" >/dev/null; then
FZF="fzf --black --ansi --reverse --cycle"
FZF="fzf --black --ansi --cycle"
else
err "Did not find the command-line fuzzy finder fzf."
exit 1