Added error message support

This commit is contained in:
Dylan 2016-04-24 14:14:35 +10:00
parent db1f3851a7
commit 2e3e327190
1 changed files with 21 additions and 1 deletions

View File

@ -1890,6 +1890,9 @@ getwallpaper () {
# If img is an xml file don't use it. # If img is an xml file don't use it.
[ "${img/*\./}" == "xml" ] && img="" [ "${img/*\./}" == "xml" ] && img=""
[ -z "$img" ] && \
err "Wallpaper detection failed, falling back to ascii mode."
} }
# }}} # }}}
@ -1898,6 +1901,9 @@ getwallpaper () {
getascii () { getascii () {
if [ ! -f "$ascii" ] || [ "$ascii" == "distro" ]; then if [ ! -f "$ascii" ] || [ "$ascii" == "distro" ]; then
# Error message
[ ! -f "$ascii" ] && err "Ascii file not found, using distro ascii"
# Lowercase the distro name # Lowercase the distro name
if [ "$version" -le 3 ]; then if [ "$version" -le 3 ]; then
ascii=$(tr '[:upper:]' '[:lower:]' <<< "$ascii_distro") ascii=$(tr '[:upper:]' '[:lower:]' <<< "$ascii_distro")
@ -1921,6 +1927,7 @@ getascii () {
if [ ! -f "$script_dir/ascii/distro/${ascii/ *}" ]; then if [ ! -f "$script_dir/ascii/distro/${ascii/ *}" ]; then
padding="\033[0C" padding="\033[0C"
image="off" image="off"
err "Ascii file not found, falling back to text mode."
return return
fi fi
@ -2008,6 +2015,11 @@ getimage () {
if [ ! -f "$img" ] || [ ${#term_size} -le 5 ]; then if [ ! -f "$img" ] || [ ${#term_size} -le 5 ]; then
image="ascii" image="ascii"
getascii getascii
# Error messages
[ ! -f "$img" ] && err "\$img, isn't a file, falling back to ascii mode."
[ ${#term_size} -le 5 ] && err "Your terminal doesn't support \\\033[14t, falling back to ascii mode."
return return
fi fi
@ -2141,6 +2153,7 @@ getw3m_img_path () {
else else
image="ascii" image="ascii"
err "w3m-img wasn't found on your system, falling back to ascii mode."
fi fi
} }
@ -2582,6 +2595,9 @@ kdeconfigdir () {
# }}} # }}}
err () {
err+="$(color 1)[!]$(color fg) $1 \n"
}
# }}} # }}}
@ -2891,7 +2907,8 @@ while [ "$1" ]; do
} }
;; ;;
--verbose) set -x ;; -v) verbose="on" ;;
-vv) set -x; verbose="on" ;;
--help) usage ;; --help) usage ;;
esac esac
@ -2983,4 +3000,7 @@ if [ "$scrot" == "on" ]; then
takescrot takescrot
fi fi
# Show error messages
[ "$verbose" == "on" ] && printf "$err"
# }}} # }}}