Reduce the amount of stuff we do in the image size while loop.
This commit is contained in:
parent
ba67112434
commit
aa1272ffa9
21
fetch
21
fetch
|
@ -1794,6 +1794,10 @@ getimage () {
|
||||||
# Get terminal lines
|
# Get terminal lines
|
||||||
lines=$(tput lines)
|
lines=$(tput lines)
|
||||||
|
|
||||||
|
# If we're in a screen session, fallback to
|
||||||
|
# ascii mode.
|
||||||
|
[ -n "$STY" ] && image="ascii"
|
||||||
|
|
||||||
# Call function based on $image
|
# Call function based on $image
|
||||||
case "$image" in
|
case "$image" in
|
||||||
"wall") getwallpaper ;;
|
"wall") getwallpaper ;;
|
||||||
|
@ -1811,23 +1815,26 @@ getimage () {
|
||||||
|
|
||||||
# The ascape code above prints the output AFTER the prompt so this
|
# The ascape code above prints the output AFTER the prompt so this
|
||||||
# loop below reads it as input. wtf xterm
|
# loop below reads it as input. wtf xterm
|
||||||
index=0
|
|
||||||
while IFS= read -s -r -n 1 -t 0.25 char; do
|
while IFS= read -s -r -n 1 -t 0.25 char; do
|
||||||
case "$index" in
|
[ "$char" == "t" ] && break
|
||||||
"0") [ "$char" == ";" ] && index=$((index + 1)) ;;
|
term_size+=$char
|
||||||
"1") [ "$char" == ";" ] && index=$((index + 1)) || term_height="${term_height}${char}" ;;
|
|
||||||
"2") [ "$char" == "t" ] && break || term_width="${term_width}${char}"
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# If $img isn't a file or the terminal doesn't support xterm escape sequences,
|
# If $img isn't a file or the terminal doesn't support xterm escape sequences,
|
||||||
# fallback to ascii mode.
|
# fallback to ascii mode.
|
||||||
if [ ! -f "$img" ] || [ -z "$term_height" ]; then
|
if [ ! -f "$img" ] || [ -z "$term_size" ]; then
|
||||||
image="ascii"
|
image="ascii"
|
||||||
getascii
|
getascii
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Split the string
|
||||||
|
term_size=${term_size//'['}
|
||||||
|
term_size=${term_size/';'}
|
||||||
|
term_size=${term_size/$'\E4'}
|
||||||
|
term_height=${term_size/';'*}
|
||||||
|
term_width=${term_size/*';'}
|
||||||
|
|
||||||
# Get terminal columns
|
# Get terminal columns
|
||||||
columns=$(tput cols)
|
columns=$(tput cols)
|
||||||
|
|
||||||
|
|
Reference in New Issue