minor improvements
This commit is contained in:
74
src/main.sh
74
src/main.sh
@@ -50,38 +50,32 @@ set -eu
|
|||||||
# FZF handlers
|
# FZF handlers
|
||||||
. "sh/fzf.sh"
|
. "sh/fzf.sh"
|
||||||
|
|
||||||
if [ "${1:-}" = "--fzf-reload" ]; then
|
case "${1:-}" in
|
||||||
|
"--fzf-reload")
|
||||||
fzf_handle_reload
|
fzf_handle_reload
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--fzf-load")
|
||||||
if [ "${1:-}" = "--fzf-load" ]; then
|
|
||||||
fzf_handle_load
|
fzf_handle_load
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--fzf-info")
|
||||||
if [ "${1:-}" = "--fzf-info" ]; then
|
|
||||||
fzf_info
|
fzf_info
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--fzf-change-reload")
|
||||||
if [ "${1:-}" = "--fzf-change-reload" ]; then
|
|
||||||
fzf_reload_after_change
|
fzf_reload_after_change
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--fzf-change")
|
||||||
if [ "${1:-}" = "--fzf-change" ]; then
|
|
||||||
fzf_handle_change
|
fzf_handle_change
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--fzf-key")
|
||||||
if [ "${1:-}" = "--fzf-key" ]; then
|
|
||||||
fzf_handle_key "${2:-}" "${3:-}" "${4:-}"
|
fzf_handle_key "${2:-}" "${3:-}" "${4:-}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--decorate")
|
||||||
# Support of local music files
|
|
||||||
if [ "${1:-}" = "--decorate" ]; then
|
|
||||||
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
||||||
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
||||||
if ! decorate "$2"; then
|
if ! decorate "$2"; then
|
||||||
@@ -89,23 +83,24 @@ if [ "${1:-}" = "--decorate" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--reload")
|
||||||
if [ "${1:-}" = "--reload" ]; then
|
|
||||||
[ ! "${2:-}" ] && err "Path to decorated music is missing." && exit 1
|
[ ! "${2:-}" ] && err "Path to decorated music is missing." && exit 1
|
||||||
[ ! -d "$2" ] && err "Path does not point to a directory." && exit 1
|
[ ! -d "$2" ] && err "Path does not point to a directory." && exit 1
|
||||||
info "Reloading information of local music directory $2"
|
info "Reloading information of local music directory $2"
|
||||||
load_local "$2" || err "Failed to load local data"
|
load_local "$2" || err "Failed to load local data"
|
||||||
info "Done"
|
info "Done"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--internal-preview-artist")
|
||||||
if [ "${1:-}" = "--internal-preview-artist" ]; then
|
|
||||||
__preview_artist "$2"
|
__preview_artist "$2"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--playlist")
|
||||||
if [ "${1:-}" = "--help" ]; then
|
list_playlist
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
"--help")
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $0 [OPTION]
|
Usage: $0 [OPTION]
|
||||||
|
|
||||||
@@ -123,15 +118,15 @@ GENERAL OPTIONS:
|
|||||||
|
|
||||||
MANAGE LOCAL MUSIC:
|
MANAGE LOCAL MUSIC:
|
||||||
--decorate <path> Decorate directory containing a tagged release
|
--decorate <path> Decorate directory containing a tagged release
|
||||||
--reload <path> Populate da$KEYS_SWITCH_ARTIST_ALBUMase with decorated local music from <path>
|
--reload <path> Populate database with decorated local music from <path>
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
"--refresh-view")
|
||||||
if [ "${1:-}" = "--refresh-view" ]; then
|
|
||||||
precompute_view
|
precompute_view
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Set window title
|
# Set window title
|
||||||
printf '\033]0;%s\007' "$WINDOW_TITLE"
|
printf '\033]0;%s\007' "$WINDOW_TITLE"
|
||||||
@@ -152,16 +147,6 @@ ARGSFILE_LAST="$statedir/state-args2"
|
|||||||
touch "$STATEFILE" "$ARGSFILE" "$STATEFILE_LAST" "$ARGSFILE_LAST"
|
touch "$STATEFILE" "$ARGSFILE" "$STATEFILE_LAST" "$ARGSFILE_LAST"
|
||||||
export STATEFILE ARGSFILE STATEFILE_LAST ARGSFILE_LAST
|
export STATEFILE ARGSFILE STATEFILE_LAST ARGSFILE_LAST
|
||||||
|
|
||||||
if [ "${1:-}" = "--ni-search-artist" ]; then
|
|
||||||
$0 --internal-search "artist" "$2"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${1:-}" = "--ni-search-album" ]; then
|
|
||||||
$0 --internal-search "releasegroup" "$2"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Views and modes
|
# Views and modes
|
||||||
VIEW_ARTIST="artist"
|
VIEW_ARTIST="artist"
|
||||||
VIEW_RELEASEGROUP="rg"
|
VIEW_RELEASEGROUP="rg"
|
||||||
@@ -241,6 +226,7 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
|||||||
--no-input \
|
--no-input \
|
||||||
--margin="2%,10%" \
|
--margin="2%,10%" \
|
||||||
--bind="$KEYS_ALL:transform:$0 --fzf-key {2} {3} {4}" \
|
--bind="$KEYS_ALL:transform:$0 --fzf-key {2} {3} {4}" \
|
||||||
|
--bind="r,ctrl-r:reload:$0 --playlist" \
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
--with-nth="{1}" >/dev/null
|
--with-nth="{1}" >/dev/null
|
||||||
;;
|
;;
|
||||||
|
@@ -2,15 +2,18 @@ ERR="\033[38;5;196m"
|
|||||||
INFO="\033[38;5;75m"
|
INFO="\033[38;5;75m"
|
||||||
DBG=$ERR
|
DBG=$ERR
|
||||||
OFF="\033[m"
|
OFF="\033[m"
|
||||||
|
LOGDIR="$HOME/.local/state/$APPNAME"
|
||||||
|
[ -d "$LOGDIR" ] || mkdir -p "$LOGDIR"
|
||||||
|
LOGFILE="$LOGDIR/log"
|
||||||
|
|
||||||
err() {
|
err() {
|
||||||
echo "${ERR}ERROR:${OFF} ${1:-}" >/dev/stderr
|
echo "${ERR}ERROR:${OFF} ${1:-}" >>"$LOGFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
echo "${INFO}Info:${OFF} ${1:-}" >/dev/stderr
|
echo "${INFO}Info:${OFF} ${1:-}" >>"$LOGFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
echo "${DBG}DEBUG${OFF} ${INFO} [$$] $(date)${OFF}: $*" >>"$APP_NAME.debug.log"
|
echo "${DBG}DEBUG${OFF} ${INFO} [$$] $(date)${OFF}: $*" >>"$LOGFILE"
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ mpv_start() {
|
|||||||
mpv_play_list() {
|
mpv_play_list() {
|
||||||
t=$(mktemp)
|
t=$(mktemp)
|
||||||
cat >"$t"
|
cat >"$t"
|
||||||
|
debug "Playing $(cat "$t")"
|
||||||
__mpv_command_with_arg "loadlist" "$t"
|
__mpv_command_with_arg "loadlist" "$t"
|
||||||
rm -f "$t"
|
rm -f "$t"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user