Add ascii support to fetch

This commit is contained in:
Dylan 2016-01-27 22:33:22 +11:00
parent a5951cedb2
commit 74b94e1769
2 changed files with 57 additions and 3 deletions

View file

@ -208,7 +208,8 @@ alias fetch2="fetch \
Image: Image:
--image Image source. Where and what image we display. --image Image source. Where and what image we display.
Possible values: wall, shuffle, /path/to/img, off Possible values: wall, shuffle, ascii,
/path/to/img, off
--image_backend Which program to use to draw images. --image_backend Which program to use to draw images.
--shuffle_dir Which directory to shuffle for an image. --shuffle_dir Which directory to shuffle for an image.
--font_width px Used to automatically size the image --font_width px Used to automatically size the image
@ -234,6 +235,12 @@ alias fetch2="fetch \
move the text closer to the left side. move the text closer to the left side.
--clean Remove all cropped images --clean Remove all cropped images
Ascii:
--ascii path/to/ascii File to get ascii from
--ascii_color Color to print the ascii art
Screenshot: Screenshot:
--scrot /path/to/img Take a screenshot, if path is left empty --scrot /path/to/img Take a screenshot, if path is left empty
the screenshot function will use the screenshot function will use

51
fetch
View file

@ -204,7 +204,7 @@ prompt_height=1
# Image Source # Image Source
# --image wall, shuffle, /path/to/img, off # --image wall, shuffle, ascii, /path/to/img, off
image="wall" image="wall"
# Thumbnail directory # Thumbnail directory
@ -261,6 +261,20 @@ yoffset=0
xoffset=0 xoffset=0
# }}}
# Ascii Options {{{
# Default ascii image to use
# --ascii path/to/ascii.txt
ascii="$HOME/hi.txt"
# Ascii color
# --ascii_color
ascii_color="4"
# }}} # }}}
# Other Options {{{ # Other Options {{{
@ -1184,6 +1198,23 @@ getshuffle () {
shuf -n1 -z) shuf -n1 -z)
} }
# }}}
# Ascii {{{
getascii () {
# Get length of longest line
length="$(wc -L "$ascii")"
length=${length/ *}
# Set the text padding
padding="\e[$((length + gap))C"
# Print the ascii
printf "%s" "$(color $ascii_color)$(<$ascii)"
}
# }}} # }}}
# Image {{{ # Image {{{
@ -1218,6 +1249,11 @@ getimage () {
getshuffle getshuffle
;; ;;
"ascii")
getascii
return
;;
*) *)
img="$image" img="$image"
;; ;;
@ -1465,7 +1501,8 @@ usage () { cat << EOF
Image: Image:
--image Image source. Where and what image we display. --image Image source. Where and what image we display.
Possible values: wall, shuffle, /path/to/img, off Possible values: wall, shuffle, ascii,
/path/to/img, off
--image_backend Which program to use to draw images. --image_backend Which program to use to draw images.
--shuffle_dir Which directory to shuffle for an image. --shuffle_dir Which directory to shuffle for an image.
--font_width px Used to automatically size the image --font_width px Used to automatically size the image
@ -1491,6 +1528,12 @@ usage () { cat << EOF
move the text closer to the left side. move the text closer to the left side.
--clean Remove all cropped images --clean Remove all cropped images
Ascii:
--ascii path/to/ascii File to get ascii from
--ascii_color Color to print the ascii art
Screenshot: Screenshot:
--scrot /path/to/img Take a screenshot, if path is left empty --scrot /path/to/img Take a screenshot, if path is left empty
the screenshot function will use the screenshot function will use
@ -1561,6 +1604,10 @@ while [ "$1" ]; do
--gap) gap="$2" ;; --gap) gap="$2" ;;
--clean) rm -rf "$imgtempdir" || exit ;; --clean) rm -rf "$imgtempdir" || exit ;;
# Ascii
--ascii) image="ascii"; ascii="$2" ;;
--ascii_color) ascii_color="$2" ;;
# Screenshot # Screenshot
--scrot | -s) scrot="on"; \ --scrot | -s) scrot="on"; \
[ "$2" ] && scrot_path="$2" ;; [ "$2" ] && scrot_path="$2" ;;