Merge pull request #519 from dylanaraps/main_cleanup
General: Cleanup main
This commit is contained in:
commit
a173afb6ec
1 changed files with 18 additions and 30 deletions
34
neofetch
34
neofetch
|
@ -1934,6 +1934,10 @@ get_image_backend() {
|
||||||
|
|
||||||
"ascii") get_ascii 2>/dev/null ;;
|
"ascii") get_ascii 2>/dev/null ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Set cursor position next to ascii art.
|
||||||
|
[[ "$image_backend" != "off" ]] && \
|
||||||
|
printf "%b" "\033[$((${lines:-0} - ${prompt_loc:-0}))A\033[9999999D"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ascii() {
|
get_ascii() {
|
||||||
|
@ -2944,12 +2948,15 @@ get_term_padding() {
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic_prompt() {
|
dynamic_prompt() {
|
||||||
if [[ "$image_backend" == "image" ]]; then
|
case "$image_backend" in
|
||||||
|
"image")
|
||||||
get_term_padding 2>/dev/null
|
get_term_padding 2>/dev/null
|
||||||
|
|
||||||
# Calculate image height in terminal cells.
|
# Calculate image height in terminal cells.
|
||||||
lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))"
|
lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))"
|
||||||
fi
|
;;
|
||||||
|
"off") return ;;
|
||||||
|
esac
|
||||||
|
|
||||||
# If the info is higher than the ascii/image place the prompt
|
# If the info is higher than the ascii/image place the prompt
|
||||||
# based on the info height instead of the ascii/image height.
|
# based on the info height instead of the ascii/image height.
|
||||||
|
@ -3327,42 +3334,23 @@ main() {
|
||||||
get_bold
|
get_bold
|
||||||
get_distro_colors
|
get_distro_colors
|
||||||
|
|
||||||
# Restore cursor and clear screen on ctrl+c
|
|
||||||
trap 'printf "\033[?25h"; clear; exit' 2
|
|
||||||
|
|
||||||
# If the script exits for any reason, unhide the cursor.
|
# If the script exits for any reason, unhide the cursor.
|
||||||
trap 'printf "\033[?25h"' EXIT
|
trap 'printf "\033[?25h\033[?7h"' EXIT
|
||||||
|
|
||||||
# Hide the cursor and disable line wrap
|
# Hide the cursor and disable line wrap
|
||||||
printf "\033[?25l\033[?7l"
|
printf "\033[?25l\033[?7l"
|
||||||
|
|
||||||
get_image_backend
|
get_image_backend
|
||||||
|
|
||||||
if [[ "$image_backend" != "off" ]]; then
|
|
||||||
# Set cursor position next to ascii art
|
|
||||||
printf "%b" "\033[$((${lines:-0} - ${prompt_loc:-0}))A"
|
|
||||||
|
|
||||||
# Reset horizontal cursor position
|
|
||||||
printf "\033[9999999D"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print the info
|
|
||||||
old_functions
|
old_functions
|
||||||
get_cache_dir
|
get_cache_dir
|
||||||
print_info 2>/dev/null
|
print_info 2>/dev/null
|
||||||
|
|
||||||
# Prompt calculation
|
|
||||||
if [[ "$image_backend" != "off" ]]; then
|
|
||||||
dynamic_prompt
|
dynamic_prompt
|
||||||
|
|
||||||
# w3m-img: Draw the image a second time to fix
|
# w3m-img: Draw the image a second time to fix
|
||||||
# rendering issues in specific terminal emulators.
|
# rendering issues in specific terminal emulators.
|
||||||
[[ "$image_backend" == "image" && "$image_program" == "w3m" ]] && display_image
|
[[ "$image_backend" == "image" && "$image_program" == "w3m" ]] && display_image
|
||||||
fi
|
|
||||||
|
|
||||||
# Re-enable line wrap
|
|
||||||
printf "%b" "\033[?7h"
|
|
||||||
|
|
||||||
|
# Take a screenshot
|
||||||
[[ "$scrot" == "on" ]] && take_scrot
|
[[ "$scrot" == "on" ]] && take_scrot
|
||||||
|
|
||||||
# Show error messages
|
# Show error messages
|
||||||
|
|
Loading…
Reference in a new issue