ctrl-a key works again
This commit is contained in:
69
src/main.sh
69
src/main.sh
@@ -11,6 +11,7 @@ VIEW_LIST_ARTISTS="list-artists"
|
|||||||
VIEW_LIST_ALBUMS="list-albums"
|
VIEW_LIST_ALBUMS="list-albums"
|
||||||
VIEW_SELECT_ARTIST="select-artist"
|
VIEW_SELECT_ARTIST="select-artist"
|
||||||
VIEW_PLAYLIST="playlist"
|
VIEW_PLAYLIST="playlist"
|
||||||
|
VIEW_QUIT="quit"
|
||||||
MODE_NORMAL="hidden"
|
MODE_NORMAL="hidden"
|
||||||
MODE_INSERT="show"
|
MODE_INSERT="show"
|
||||||
|
|
||||||
@@ -85,6 +86,26 @@ case "${1:-}" in
|
|||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
"--jumpto-artist")
|
||||||
|
mode=$2
|
||||||
|
view=$3
|
||||||
|
mbid_cur="${4:-}"
|
||||||
|
mbid="${5:-}"
|
||||||
|
case "$view" in
|
||||||
|
"$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") j="$(mb_releasegroup "$mbid" | $JQ -r --compact-output '."artist-credit"')" ;;
|
||||||
|
"$VIEW_RELEASEGROUP") j="$(mb_release "$mbid" | $JQ -r --compact-output '."artist-credit"')" ;;
|
||||||
|
"$VIEW_RELEASE") j="$(mb_release "$mbid_cur" | $JQ -r --compact-output ".media | map(.tracks) | flatten[] | select(.id == \"$mbid\") | .\"artist-credit\"")" ;;
|
||||||
|
"$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") aid="$mbid" ;;
|
||||||
|
esac
|
||||||
|
if [ "${j:-}" ]; then
|
||||||
|
cnt=$(echo "$j" | $JQ 'length')
|
||||||
|
[ "$cnt" -eq 1 ] && aid="$(echo "$j" | $JQ -r '.[0].artist.id')"
|
||||||
|
debug "cnt=$cnt; artistid=${artistid:-}"
|
||||||
|
fi
|
||||||
|
[ "${aid:-}" ] && debug "$0 --draw \"$mode\" \"$VIEW_ARTIST\" \"$aid\"" || debug "$(printf "print(%s)+print(%s)+accept" "$VIEW_SELECT_ARTIST" "$j")"
|
||||||
|
[ "${aid:-}" ] && $0 --draw "$mode" "$VIEW_ARTIST" "$aid" || printf "print(%s)+print(%s)+accept" "$VIEW_SELECT_ARTIST" "$j"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
"--draw")
|
"--draw")
|
||||||
debug "call to $*"
|
debug "call to $*"
|
||||||
# Generate fzf command to draw screen.
|
# Generate fzf command to draw screen.
|
||||||
@@ -338,12 +359,10 @@ mpv_start
|
|||||||
IN_NORMAL_MODE="[ \"\$FZF_INPUT_STATE\" = \"hidden\" ]"
|
IN_NORMAL_MODE="[ \"\$FZF_INPUT_STATE\" = \"hidden\" ]"
|
||||||
PUT_FZF_KEY_LOGIC="case \"\$FZF_KEY\" in \"space\") echo \"put( )\";; \"backspace\"|\"bspace\"|\"bs\") echo \"backward-delete-char\";; \"delete\"|\"del\") echo \"delete-char\";; *) echo \"put(\$FZF_KEY)\";; esac"
|
PUT_FZF_KEY_LOGIC="case \"\$FZF_KEY\" in \"space\") echo \"put( )\";; \"backspace\"|\"bspace\"|\"bs\") echo \"backward-delete-char\";; \"delete\"|\"del\") echo \"delete-char\";; *) echo \"put(\$FZF_KEY)\";; esac"
|
||||||
while true; do
|
while true; do
|
||||||
mode=$(state_get_mode)
|
|
||||||
args=$(state_get_args)
|
|
||||||
case "$VIEW" in
|
case "$VIEW" in
|
||||||
"$VIEW_SELECT_ARTIST")
|
"$VIEW_SELECT_ARTIST")
|
||||||
sel=$(
|
sel=$(
|
||||||
echo "$args" |
|
echo "$ARGS" |
|
||||||
list_artists_from_json |
|
list_artists_from_json |
|
||||||
$FZF \
|
$FZF \
|
||||||
--bind="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,\
|
--bind="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,\
|
||||||
@@ -360,7 +379,10 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--accept-nth="{3}" \
|
--accept-nth="{3}" \
|
||||||
--with-nth="{1}" || true
|
--with-nth="{1}" || true
|
||||||
)
|
)
|
||||||
[ "$sel" ] && state_update "$VIEW_ARTIST" "$mode" "$sel" || state_revert
|
[ "$sel" ] || continue
|
||||||
|
MODE="$MODE_NORMAL"
|
||||||
|
VIEW="$VIEW_ARTIST"
|
||||||
|
MBID="$sel"
|
||||||
;;
|
;;
|
||||||
"$VIEW_PLAYLIST")
|
"$VIEW_PLAYLIST")
|
||||||
list_playlist |
|
list_playlist |
|
||||||
@@ -376,6 +398,10 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--with-nth="{1}" >/dev/null
|
--with-nth="{1}" >/dev/null
|
||||||
;;
|
;;
|
||||||
|
"$VIEW_QUIT")
|
||||||
|
debug "Quitting..."
|
||||||
|
break
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# Main instance
|
# Main instance
|
||||||
#
|
#
|
||||||
@@ -388,33 +414,7 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
# naturally printable or modifications of the input string. See
|
# naturally printable or modifications of the input string. See
|
||||||
# `$PUT_FZF_KEY_LOGIC` for details.
|
# `$PUT_FZF_KEY_LOGIC` for details.
|
||||||
#
|
#
|
||||||
# Here is a list of all keys grouped by type.
|
# Here is a list of all keys grouped by type (see `src/sh/keys.sh`).
|
||||||
#
|
|
||||||
# Mode selection:
|
|
||||||
# - $KEYS_I_NORMAL: Switch to normal mode (insert mode)
|
|
||||||
# - $KEYS_N_INSERT: Switch to insert mode (normal mode)
|
|
||||||
#
|
|
||||||
# Vertical navigation:
|
|
||||||
# - $KEYS_DOWN: Move cursor to the next line
|
|
||||||
# - $KEYS_UP: Move cursor to the previous line
|
|
||||||
# - $KEYS_HALFPAGE_UP: Move cursor half a page up
|
|
||||||
# - $KEYS_HALFPAGE_DOWN: Move cursor half a page up
|
|
||||||
# - $KEYS_N_DOWN: Move cursor to the next line (normal mode)
|
|
||||||
# - $KEYS_N_UP: Move cursor to the previous line (normal mode)
|
|
||||||
# - $KEYS_N_BOT: Move cursor to the last line (normal mode)
|
|
||||||
# - $KEYS_N_TOP: Move cursor to the first line (normal mode)
|
|
||||||
#
|
|
||||||
# Horizontal navigation:
|
|
||||||
# - $KEYS_IN: Enter into selected item, down the hierarchy
|
|
||||||
# - $KEYS_OUT: Leave current item, up the hierarchy
|
|
||||||
#
|
|
||||||
# Filtering:
|
|
||||||
#
|
|
||||||
# Playback:
|
|
||||||
#
|
|
||||||
# Extras:
|
|
||||||
# - $KEYS_BROWSE: Open MusicBrainz webpage of the selected item
|
|
||||||
# - $KEYS_OPEN: Open file manager in the directory of the selected item
|
|
||||||
#--bind="start:change-border-label($VIEW)+change-list-label($MBID)+$MODE-input+transform:$0 --display" \
|
#--bind="start:change-border-label($VIEW)+change-list-label($MBID)+$MODE-input+transform:$0 --display" \
|
||||||
sel=$(
|
sel=$(
|
||||||
printf "" | $FZF \
|
printf "" | $FZF \
|
||||||
@@ -437,6 +437,7 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--bind="$KEYS_OUT:transform:[ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\"" \
|
--bind="$KEYS_OUT:transform:[ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\"" \
|
||||||
--bind="$KEYS_N_IN:transform:$IN_NORMAL_MODE && ([ {3} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {3} \"+1\") || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_IN:transform:$IN_NORMAL_MODE && ([ {3} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {3} \"+1\") || $PUT_FZF_KEY_LOGIC" \
|
||||||
--bind="$KEYS_N_OUT:transform:$IN_NORMAL_MODE && ([ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\") || $PUT_FZF_KEY_LOGIC" \
|
--bind="$KEYS_N_OUT:transform:$IN_NORMAL_MODE && ([ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\") || $PUT_FZF_KEY_LOGIC" \
|
||||||
|
--bind="$KEYS_JUMPTO_ARTIST:transform:$0 --jumpto-artist \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} {3}" \
|
||||||
--bind="$KEYS_BROWSE:execute-silent:
|
--bind="$KEYS_BROWSE:execute-silent:
|
||||||
[ {3} ] || exit 0
|
[ {3} ] || exit 0
|
||||||
case \"\$FZF_BORDER_LABEL\" in
|
case \"\$FZF_BORDER_LABEL\" in
|
||||||
@@ -460,11 +461,13 @@ open \"\$(dirname {4})\"" \
|
|||||||
--bind="$KEYS_PLAY:" \
|
--bind="$KEYS_PLAY:" \
|
||||||
--bind="$KEYS_QUEUE:" \
|
--bind="$KEYS_QUEUE:" \
|
||||||
--bind="$KEYS_SHOW_PLAYLIST:" \
|
--bind="$KEYS_SHOW_PLAYLIST:" \
|
||||||
--expect="ctrl-c" \
|
--bind="$KEYS_QUIT:print($VIEW_QUIT)+accept" \
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--with-nth="{1}" || true
|
--with-nth="{1}" || true
|
||||||
)
|
)
|
||||||
[ "$(echo "$sel" | head -1)" = "ctrl-c" ] && break
|
VIEW="$(echo "$sel" | head -1)"
|
||||||
|
ARGS="$(echo "$sel" | head -2 | tail -1)"
|
||||||
|
debug "FZF terminated: view=$VIEW, ARGS=$ARGS"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# See comment in `src/main.sh` on key bindings.
|
# List of keys, organized in groups
|
||||||
#
|
#
|
||||||
# Mode selection:
|
# Mode selection:
|
||||||
# - $KEYS_I_NORMAL: Switch to normal mode (insert mode)
|
# - $KEYS_I_NORMAL: Switch to normal mode (insert mode)
|
||||||
@@ -19,14 +19,17 @@
|
|||||||
# - $KEYS_OUT: Leave current item, up the hierarchy
|
# - $KEYS_OUT: Leave current item, up the hierarchy
|
||||||
# - $KEYS_N_IN: Enter into selected item, down the hierarchy (normal mode)
|
# - $KEYS_N_IN: Enter into selected item, down the hierarchy (normal mode)
|
||||||
# - $KEYS_N_OUT: Leave current item, up the hierarchy (normal mode)
|
# - $KEYS_N_OUT: Leave current item, up the hierarchy (normal mode)
|
||||||
|
# - $KEYS_JUMPTO_ARTIST: Go to artist of selected entry (in case of multiple
|
||||||
|
# artists, provide a choice)
|
||||||
#
|
#
|
||||||
# Filtering:
|
# Filtering:
|
||||||
#
|
#
|
||||||
# Playback:
|
# Playback:
|
||||||
#
|
#
|
||||||
# Extras:
|
# Specials:
|
||||||
# - $KEYS_BROWSE: Open MusicBrainz webpage of the selected item
|
# - $KEYS_BROWSE: Open MusicBrainz webpage of the selected item
|
||||||
# - $KEYS_OPEN: Open file manager in the directory of the selected item
|
# - $KEYS_OPEN: Open file manager in the directory of the selected item
|
||||||
|
# - $KEYS_QUIT: Quit application
|
||||||
|
|
||||||
# Mode selection:
|
# Mode selection:
|
||||||
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
|
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
|
||||||
@@ -47,6 +50,12 @@ KEYS_IN="${KEYS_IN:-"ctrl-l"}"
|
|||||||
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
|
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
|
||||||
KEYS_N_IN="${KEYS_N_IN:-"l"}"
|
KEYS_N_IN="${KEYS_N_IN:-"l"}"
|
||||||
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
|
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
|
||||||
|
KEYS_JUMPTO_ARTIST="${KEYS_JUMPTO_ARTIST:-"ctrl-a"}"
|
||||||
|
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# Specials:
|
||||||
|
KEYS_QUIT="${KEYS_QUIT:-"ctrl-c"}"
|
||||||
|
|
||||||
## Not yet characterized
|
## Not yet characterized
|
||||||
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
|
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
|
||||||
|
Reference in New Issue
Block a user