aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xytfzf22
1 files changed, 18 insertions, 4 deletions
diff --git a/ytfzf b/ytfzf
index 5b52028..4a9015a 100755
--- a/ytfzf
+++ b/ytfzf
@@ -7,10 +7,11 @@
############################
# Defaults #
############################
+
[ -z "$YTFZF_HIST" ] && YTFZF_HIST=1
[ -z "$YTFZF_LOOP" ] && YTFZF_LOOP=0
[ -z "$YTFZF_CUR" ] && YTFZF_CUR=1
-[ -z "$YTFZF_CACHE" ] && YTFZF_CACHE=~/.cache/ytfzf
+[ -z "$YTFZF_CACHE" ] && YTFZF_CACHE="$HOME/.cache/ytfzf"
[ -z "$YTFZF_PREF" ] && YTFZF_PREF=""
[ -z "$YTFZF_EXTMENU" ] && YTFZF_EXTMENU='dmenu -i -l 30 -p Search:'
[ -z "$YTFZF_EXTMENU_LEN" ] && YTFZF_EXTMENU_LEN=220
@@ -26,9 +27,21 @@
history_file="$YTFZF_CACHE"/ytfzf_hst
current_file="$YTFZF_CACHE"/ytfzf_cur
thumb_dir="$YTFZF_CACHE"/thumb
+#> make folders that don't exist
[ -d $YTFZF_CACHE ] || mkdir -p $YTFZF_CACHE
[ -d $thumb_dir ] || mkdir -p $thumb_dir
+#> Setting and reading the config file
+config_dir="$HOME/.config/ytfzf"
+config_file="$config_dir/ytfzf.sh"
+if [ -e $config_file ]
+then
+ #source config file if exists (overrides env variables)
+ . "$config_file"
+fi
+
+#> settings only set in config
+search_prompt="${search_prompt-Search Youtube: }"
# DEP CHECK
dep_ck () {
@@ -36,7 +49,8 @@ dep_ck () {
command -v "$dep" 1>/dev/null || { printf "$dep not found. Please install it.\n" ; exit 2; }
done
}
-dep_ck "jq" "youtube-dl" "$YTFZF_PLAYER";
+dep_ck "jq" "youtube-dl";
+[ "$YTFZF_PLAYER" = "mpv" ] && dep_ck "mpv"
############################
@@ -297,7 +311,7 @@ get_search_query () {
if [ $is_ext_menu -eq 1 ]; then
search_query="$(printf "" | $YTFZF_EXTMENU)"
else
- printf "Search Youtube: "
+ printf "$search_prompt"
read search_query
fi
[ -z "$search_query" ] && { exit 0; }
@@ -361,7 +375,7 @@ play_url () {
[ 4 -eq $? ] || eval "$YTFZF_PLAYER" "\"$(printf "$urls" | tr '\n' '\t' | sed 's_\t_" "_g' )\""
# Ctr-C in MPV results in a return code of 4
} || {
- printf "\033[31mERROR[#03]: Couldn't play the video/audio using the current player.\n\tTry updating youtube-dl\033[000m\n"; errinfo ; save_before_exit ; exit 2;
+ printf "\033[31mERROR[#03]: Couldn't play the video/audio using the current player: ${YTFZF_PLAYER}\n\t\033[000mTry updating youtube-dl\n"; errinfo ; save_before_exit ; exit 2;
}
}
save_before_exit () {
Un proyecto texto-plano.xyz