misc: cleanup

This commit is contained in:
Dylan Araps 2018-06-01 10:53:28 +10:00
parent 5cac0a8dc1
commit ffe94c26ee
1 changed files with 21 additions and 30 deletions

View File

@ -3389,12 +3389,8 @@ get_cols() {
# IMAGES # IMAGES
image_backend() { image_backend() {
if [[ ! "$image_backend" =~ ^(off|ascii)$ ]]; then [[ "$image_backend" != "off" ]] && ! type -p convert >/dev/null 2>&1 && \
if ! type -p convert >/dev/null 2>&1; then { image_backend="ascii"; err "Image: Imagemagick not found, falling back to ascii mode."; }
image_backend="ascii"
err "Image: Imagemagick not found, falling back to ascii mode."
fi
fi
case "${image_backend:-off}" in case "${image_backend:-off}" in
"ascii") get_ascii ;; "ascii") get_ascii ;;
@ -3404,26 +3400,22 @@ image_backend() {
"tycat" | "w3m" | "sixel" | "pixterm" | "kitty") "tycat" | "w3m" | "sixel" | "pixterm" | "kitty")
get_image_source get_image_source
if [[ ! -f "$image" ]]; then [[ ! -f "$image" ]] && {
to_ascii "Image: '$image_source' doesn't exist, falling back to ascii mode." to_ascii "Image: '$image_source' doesn't exist, falling back to ascii mode."
return return
fi }
get_term_size get_term_size
if [[ "$term_width" ]] && ((term_width >= 1)); then ((term_width < 1)) && {
printf "\e[2J\e[H"
else
to_ascii "Image: Failed to find terminal window size." to_ascii "Image: Failed to find terminal window size."
err "Image: Check the 'Images in the terminal' wiki page for more info," err "Image: Check the 'Images in the terminal' wiki page for more info,"
return return
fi }
printf '\e[2J\e[H'
get_image_size get_image_size
make_thumbnail make_thumbnail
[[ "$image_backend" == *"w3m"* ]] && zws="\xE2\x80\x8B\x20"
display_image display_image
;; ;;
@ -3514,17 +3506,14 @@ END
"Windows") "Windows")
case "$distro" in case "$distro" in
"Windows XP") "Windows XP")
case "$kernel_name" in image="/c/Documents and Settings/${USER}"
"CYGWIN"*) image="/cygdrive/c/Documents and Settings/${USER}" ;; image+="/Local Settings/Application Data/Microsoft/Wallpaper1.bmp"
"MSYS2"* | "MINGW*") image="/c/Documents and Settings/${USER}" ;;
esac [[ "$kernel_name" == *CYGWIN* ]] && image="/cygdrive${image}"
image+="/Local Settings/Application Data/Microsoft"
image+="/Wallpaper1.bmp"
;; ;;
"Windows"*) "Windows"*)
image="$APPDATA/Microsoft/Windows/Themes" image="${APPDATA}/Microsoft/Windows/Themes/TranscodedWallpaper.jpg"
image+="/TranscodedWallpaper.jpg"
;; ;;
esac esac
;; ;;
@ -3533,13 +3522,14 @@ END
# Get DE if user has disabled the function. # Get DE if user has disabled the function.
((de_run != 1)) && get_de ((de_run != 1)) && get_de
if type -p wal >/dev/null && [[ -f "${HOME}/.cache/wal/wal" ]]; then type -p wal >/dev/null && [[ -f "${HOME}/.cache/wal/wal" ]] && \
image="$(< "${HOME}/.cache/wal/wal")" { image="$(< "${HOME}/.cache/wal/wal")"; return; }
return
fi
case "$de" in case "$de" in
"MATE"*) image="$(gsettings get org.mate.background picture-filename)" ;; "MATE"*)
image="$(gsettings get org.mate.background picture-filename)"
;;
"Xfce"*) "Xfce"*)
image="$(xfconf-query -c xfce4-desktop -p \ image="$(xfconf-query -c xfce4-desktop -p \
"/backdrop/screen0/monitor0/workspace0/last-image")" "/backdrop/screen0/monitor0/workspace0/last-image")"
@ -3843,6 +3833,7 @@ display_image() {
"w3m") "w3m")
get_w3m_img_path get_w3m_img_path
zws='\xE2\x80\x8B\x20'
# Add a tiny delay to fix issues with images not # Add a tiny delay to fix issues with images not
# appearing in specific terminal emulators. # appearing in specific terminal emulators.
@ -3964,12 +3955,12 @@ get_line_break() {
get_bold() { get_bold() {
case "$ascii_bold" in case "$ascii_bold" in
"on") ascii_bold="\e[1m" ;; "on") ascii_bold="\e[1m" ;;
"off") ascii_bold="" ;; "off") ascii_bold="" ;;
esac esac
case "$bold" in case "$bold" in
"on") bold="\e[1m" ;; "on") bold="\e[1m" ;;
"off") bold="" ;; "off") bold="" ;;
esac esac
} }