Added option --image_position to display the image on the left or right of the terminal

This commit is contained in:
dylan araps 2016-01-04 10:20:36 +11:00
parent c034067573
commit 7d9ce8923e
2 changed files with 22 additions and 6 deletions

View File

@ -135,7 +135,7 @@ Here's what's on my todo list
- Windows support (I'm almost done) - Windows support (I'm almost done)
- Option to swap the image and text around - OpenBSD support (Partially implemented, just needs testing)
- Imagemagick optimizations - Imagemagick optimizations

View File

@ -135,6 +135,10 @@ imgtempdir="$HOME/.fetchimages"
# --split_size num # --split_size num
split_size=2 split_size=2
# Image position
# --image_position left/right
image_position="left"
# Use current wallpaper as the image # Use current wallpaper as the image
# --wall on/off # --wall on/off
wall="on" wall="on"
@ -447,8 +451,18 @@ getimage () {
# Image size is half of the terminal # Image size is half of the terminal
imgsize=$((columns * font_width / split_size)) imgsize=$((columns * font_width / split_size))
# Where to draw the image
case "$image_position" in
"left")
# Padding is half the terminal width + gap # Padding is half the terminal width + gap
padding="$(tput cuf $((columns / split_size + gap)))" padding="$(tput cuf $((columns / split_size + gap)))"
;;
"right")
padding=$(tput cuf 0)
xoffset=$((columns * font_width / split_size - gap))
;;
esac
# If wall=on, Get image to display from current wallpaper. # If wall=on, Get image to display from current wallpaper.
if [ "$wall" == "on" ]; then if [ "$wall" == "on" ]; then
@ -555,9 +569,6 @@ clear="$(tput sgr0)"
# }}} # }}}
# Args {{{
# Usage {{{ # Usage {{{
@ -605,6 +616,7 @@ usage () {
printf "%s\n" " The image gets priority over other" printf "%s\n" " The image gets priority over other"
printf "%s\n" " images: (wallpaper, \$img)" printf "%s\n" " images: (wallpaper, \$img)"
printf "%s\n" " --font_width px Used to automatically size the image" printf "%s\n" " --font_width px Used to automatically size the image"
printf "&s\n" " --image_position Where to display the image: (Left/Right)"
printf "%s\n" " --split_size num Width of img/text splits" printf "%s\n" " --split_size num Width of img/text splits"
printf "%s\n" " A value of 2 makes each split half the terminal" printf "%s\n" " A value of 2 makes each split half the terminal"
printf "%s\n" " width and etc" printf "%s\n" " width and etc"
@ -635,6 +647,9 @@ usage () {
# }}} # }}}
# Args {{{
while [ ! -z "$1" ]; do while [ ! -z "$1" ]; do
case $1 in case $1 in
# Info # Info
@ -676,6 +691,7 @@ while [ ! -z "$1" ]; do
# Image # Image
--image) wall="off"; img="$2" ;; --image) wall="off"; img="$2" ;;
--font_width) font_width="$2" ;; --font_width) font_width="$2" ;;
--image_position) image_position="$2" ;;
--split_size) split_size="$2" ;; --split_size) split_size="$2" ;;
--crop_mode) crop_mode="$2" ;; --crop_mode) crop_mode="$2" ;;
--crop_offset) crop_offset="$2" ;; --crop_offset) crop_offset="$2" ;;