minor improvements
This commit is contained in:
74
src/main.sh
74
src/main.sh
@@ -50,38 +50,32 @@ set -eu
|
||||
# FZF handlers
|
||||
. "sh/fzf.sh"
|
||||
|
||||
if [ "${1:-}" = "--fzf-reload" ]; then
|
||||
case "${1:-}" in
|
||||
"--fzf-reload")
|
||||
fzf_handle_reload
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--fzf-load" ]; then
|
||||
;;
|
||||
"--fzf-load")
|
||||
fzf_handle_load
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--fzf-info" ]; then
|
||||
;;
|
||||
"--fzf-info")
|
||||
fzf_info
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--fzf-change-reload" ]; then
|
||||
;;
|
||||
"--fzf-change-reload")
|
||||
fzf_reload_after_change
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--fzf-change" ]; then
|
||||
;;
|
||||
"--fzf-change")
|
||||
fzf_handle_change
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--fzf-key" ]; then
|
||||
;;
|
||||
"--fzf-key")
|
||||
fzf_handle_key "${2:-}" "${3:-}" "${4:-}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Support of local music files
|
||||
if [ "${1:-}" = "--decorate" ]; then
|
||||
;;
|
||||
"--decorate")
|
||||
[ ! "${2:-}" ] && err "You did not specify a directory." && exit 1
|
||||
[ ! -d "$2" ] && err "Path $2 does not point to a directory." && exit 1
|
||||
if ! decorate "$2"; then
|
||||
@@ -89,23 +83,24 @@ if [ "${1:-}" = "--decorate" ]; then
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--reload" ]; then
|
||||
;;
|
||||
"--reload")
|
||||
[ ! "${2:-}" ] && err "Path to decorated music is missing." && exit 1
|
||||
[ ! -d "$2" ] && err "Path does not point to a directory." && exit 1
|
||||
info "Reloading information of local music directory $2"
|
||||
load_local "$2" || err "Failed to load local data"
|
||||
info "Done"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--internal-preview-artist" ]; then
|
||||
;;
|
||||
"--internal-preview-artist")
|
||||
__preview_artist "$2"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--help" ]; then
|
||||
;;
|
||||
"--playlist")
|
||||
list_playlist
|
||||
exit 0
|
||||
;;
|
||||
"--help")
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTION]
|
||||
|
||||
@@ -123,15 +118,15 @@ GENERAL OPTIONS:
|
||||
|
||||
MANAGE LOCAL MUSIC:
|
||||
--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
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--refresh-view" ]; then
|
||||
;;
|
||||
"--refresh-view")
|
||||
precompute_view
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set 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"
|
||||
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
|
||||
VIEW_ARTIST="artist"
|
||||
VIEW_RELEASEGROUP="rg"
|
||||
@@ -241,6 +226,7 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
||||
--no-input \
|
||||
--margin="2%,10%" \
|
||||
--bind="$KEYS_ALL:transform:$0 --fzf-key {2} {3} {4}" \
|
||||
--bind="r,ctrl-r:reload:$0 --playlist" \
|
||||
--delimiter="\t" \
|
||||
--with-nth="{1}" >/dev/null
|
||||
;;
|
||||
|
@@ -2,15 +2,18 @@ ERR="\033[38;5;196m"
|
||||
INFO="\033[38;5;75m"
|
||||
DBG=$ERR
|
||||
OFF="\033[m"
|
||||
LOGDIR="$HOME/.local/state/$APPNAME"
|
||||
[ -d "$LOGDIR" ] || mkdir -p "$LOGDIR"
|
||||
LOGFILE="$LOGDIR/log"
|
||||
|
||||
err() {
|
||||
echo "${ERR}ERROR:${OFF} ${1:-}" >/dev/stderr
|
||||
echo "${ERR}ERROR:${OFF} ${1:-}" >>"$LOGFILE"
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "${INFO}Info:${OFF} ${1:-}" >/dev/stderr
|
||||
echo "${INFO}Info:${OFF} ${1:-}" >>"$LOGFILE"
|
||||
}
|
||||
|
||||
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() {
|
||||
t=$(mktemp)
|
||||
cat >"$t"
|
||||
debug "Playing $(cat "$t")"
|
||||
__mpv_command_with_arg "loadlist" "$t"
|
||||
rm -f "$t"
|
||||
}
|
||||
|
Reference in New Issue
Block a user