Skip to content

Commit

Permalink
Fix number of lines in "mini"
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <ckoenig@posteo.de>
  • Loading branch information
yubiuser committed Oct 1, 2022
1 parent c274b39 commit b375435
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
5 changes: 2 additions & 3 deletions padd.sh
Expand Up @@ -31,7 +31,7 @@ LastCheckSystemInformation=$(date +%s)
core_count=$(nproc --all 2> /dev/null)

# COLORS
CSI="$(printf '\033')["
CSI="$(printf '\033')[" # Control Sequence Introducer
red_text="${CSI}91m" # Red
green_text="${CSI}92m" # Green
yellow_text="${CSI}93m" # Yellow
Expand Down Expand Up @@ -685,8 +685,7 @@ PrintDashboard() {
printf " %-9s%-29s${clear_line}\n" "Top Ad:" "${top_blocked}"
fi
printf "%s${clear_line}\n" "${bold_text}NETWORK ================================${reset_text}"
printf " %-9s%-19s${clear_line}\n" "Host:" "${full_hostname}"
printf " %-9s%-19s${clear_line}\n" "IP:" "${pi_ip4_addr}"
printf " %-9s%-15s%-4s%-11s${clear_line}\n" "Host:" "${full_hostname}" "IP:" "${pi_ip4_addr}"
printf " %-9s%-8s %-4s%-5s %-4s%-5s${clear_line}\n" "Iface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}"
printf " %-9s%-10s${clear_line}\n" "DNS:" "${dns_information}"
if [ "${DHCP_ACTIVE}" = "true" ]; then
Expand Down
59 changes: 59 additions & 0 deletions pass_size_checker.sh
@@ -0,0 +1,59 @@
#!/usr/bin/env sh

SizeChecker(){
# Below Pico. Gives you nothing...
if [ "$console_width" -lt "20" ] || [ "$console_height" -lt "10" ]; then
# Nothing is this small, sorry
padd_size="ants"
# Below Nano. Gives you Pico.
elif [ "$console_width" -lt "24" ] || [ "$console_height" -lt "12" ]; then
padd_size="pico"
# Below Micro, Gives you Nano.
elif [ "$console_width" -lt "30" ] || [ "$console_height" -lt "16" ]; then
padd_size="nano"
# Below Mini. Gives you Micro.
elif [ "$console_width" -lt "40" ] || [ "$console_height" -lt "18" ]; then
padd_size="micro"
# Below Tiny. Gives you Mini.
elif [ "$console_width" -lt "53" ] || [ "$console_height" -lt "20" ]; then
padd_size="miprintf '\e[8;16;30t' > /dev/pts/0idth" -lt "60" ] || [ "$console_height" -lt "21" ]; then
padd_size="tiny"
# Below Regular. Gives you Slim.
elif [ "$console_width" -lt "80" ] || [ "$console_height" -lt "26" ]; then
if [ "$console_height" -lt "22" ]; then
padd_size="slim"
else
padd_size="regular"
fi
# Mega
else
padd_size="mega"
fi
}

clear
setterm -cursor off
trap "{ setterm -cursor on ; echo "" ; exit 0 ; }" INT TERM EXIT

while true; do
# Clear to end of screen (below the drawn dashboard)
tput ed

# Move the cursor to top left of console to redraw
tput cup 0 0


console_width=$(tput cols)
console_height=$(tput lines)
SizeChecker

echo "Columns: ${console_width}\033[0K"
echo "Lines: ${console_height}\033[0K"
echo ""
echo "Padd_size ${padd_size}\033[0K"


done

# Hint: to resize another terminal (e.g. connected via SSH)
# printf '\e[8;16;30t' > /dev/pts/0

0 comments on commit b375435

Please sign in to comment.