Add ascii support to fetch
This commit is contained in:
parent
a5951cedb2
commit
74b94e1769
|
@ -208,7 +208,8 @@ alias fetch2="fetch \
|
|||
|
||||
Image:
|
||||
--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.
|
||||
--shuffle_dir Which directory to shuffle for an 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.
|
||||
--clean Remove all cropped images
|
||||
|
||||
|
||||
Ascii:
|
||||
--ascii path/to/ascii File to get ascii from
|
||||
--ascii_color Color to print the ascii art
|
||||
|
||||
|
||||
Screenshot:
|
||||
--scrot /path/to/img Take a screenshot, if path is left empty
|
||||
the screenshot function will use
|
||||
|
|
51
fetch
51
fetch
|
@ -204,7 +204,7 @@ prompt_height=1
|
|||
|
||||
|
||||
# Image Source
|
||||
# --image wall, shuffle, /path/to/img, off
|
||||
# --image wall, shuffle, ascii, /path/to/img, off
|
||||
image="wall"
|
||||
|
||||
# Thumbnail directory
|
||||
|
@ -261,6 +261,20 @@ yoffset=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 {{{
|
||||
|
@ -1184,6 +1198,23 @@ getshuffle () {
|
|||
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 {{{
|
||||
|
@ -1218,6 +1249,11 @@ getimage () {
|
|||
getshuffle
|
||||
;;
|
||||
|
||||
"ascii")
|
||||
getascii
|
||||
return
|
||||
;;
|
||||
|
||||
*)
|
||||
img="$image"
|
||||
;;
|
||||
|
@ -1465,7 +1501,8 @@ usage () { cat << EOF
|
|||
|
||||
Image:
|
||||
--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.
|
||||
--shuffle_dir Which directory to shuffle for an 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.
|
||||
--clean Remove all cropped images
|
||||
|
||||
|
||||
Ascii:
|
||||
--ascii path/to/ascii File to get ascii from
|
||||
--ascii_color Color to print the ascii art
|
||||
|
||||
|
||||
Screenshot:
|
||||
--scrot /path/to/img Take a screenshot, if path is left empty
|
||||
the screenshot function will use
|
||||
|
@ -1561,6 +1604,10 @@ while [ "$1" ]; do
|
|||
--gap) gap="$2" ;;
|
||||
--clean) rm -rf "$imgtempdir" || exit ;;
|
||||
|
||||
# Ascii
|
||||
--ascii) image="ascii"; ascii="$2" ;;
|
||||
--ascii_color) ascii_color="$2" ;;
|
||||
|
||||
# Screenshot
|
||||
--scrot | -s) scrot="on"; \
|
||||
[ "$2" ] && scrot_path="$2" ;;
|
||||
|
|
Reference in New Issue