diff options
author | Tom Gundersen <teg@jklm.no> | 2011-06-20 19:34:07 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2011-06-20 19:34:07 +0200 |
commit | 3498c2a1b387fb83a960e6ed1faaa3e5fd68fa50 (patch) | |
tree | 521ac44f8000b1a4df9b526b5c85ce841d3302a3 | |
parent | 60191a3cdf4923fea04ae1fb383b9367db9227a0 (diff) | |
download | initscripts-3498c2a1b387fb83a960e6ed1faaa3e5fd68fa50.tar.xz |
status: adjust number of columns after loading modules
In case loading modules enables a frambuffer with higher resolution than the
standard 80 columns, we recalculate the number of columns after all modules
have been loaded.
Original-patch-by: Aaron Griffin <aaronmgriffin@gmail.com>
Original-patch-by: Søren Poulsen <nikorpoulsen@gmail.com>
Signed-off-by: Tom Gundersen <teg@jklm.no>
-rw-r--r-- | functions | 60 | ||||
-rwxr-xr-x | rc.sysinit | 3 |
2 files changed, 35 insertions, 28 deletions
@@ -4,26 +4,40 @@ # width: -STAT_COL=80 -if [[ ! -t 1 ]]; then - USECOLOR="" -elif [[ -t 0 ]]; then - # stty will fail when stdin isn't a terminal - STAT_COL="$(/bin/stty size)" - # stty gives "rows cols"; strip the rows number, we just want columns - STAT_COL="${STAT_COL##* }" -elif /bin/tput cols &>/dev/null; then - # is /usr/share/terminfo already mounted, and TERM recognized? - STAT_COL=$(/bin/tput cols) -fi -if ((STAT_COL==0)); then - # if output was 0 (serial console), set default width to 80 +calc_columns () { STAT_COL=80 - USECOLOR="" -fi + if [[ ! -t 1 ]]; then + USECOLOR="" + elif [[ -t 0 ]]; then + # stty will fail when stdin isn't a terminal + STAT_COL="$(/bin/stty size)" + # stty gives "rows cols"; strip the rows number, we just want columns + STAT_COL="${STAT_COL##* }" + elif /bin/tput cols &>/dev/null; then + # is /usr/share/terminfo already mounted, and TERM recognized? + STAT_COL=$(/bin/tput cols) + fi + if ((STAT_COL==0)); then + # if output was 0 (serial console), set default width to 80 + STAT_COL=80 + USECOLOR="" + fi + + # we use 13 characters for our own stuff + STAT_COL=$(($STAT_COL - 13)) + + if [[ -t 1 ]]; then + SAVE_POSITION="\e[s" + RESTORE_POSITION="\e[u" + DEL_TEXT="\e[$(($STAT_COL+4))G" + else + SAVE_POSITION="" + RESTORE_POSITION="" + DEL_TEXT="" + fi +} -# we use 13 characters for our own stuff -STAT_COL=$(($STAT_COL - 13)) +calc_columns # disable colors on broken terminals TERM_COLORS="$(/bin/tput colors 2>/dev/null)" @@ -76,16 +90,6 @@ if [[ $USECOLOR =~ yes|YES ]]; then fi fi -if [[ -t 1 ]]; then - SAVE_POSITION="\e[s" - RESTORE_POSITION="\e[u" - DEL_TEXT="\e[$(($STAT_COL+4))G" -else - SAVE_POSITION="" - RESTORE_POSITION="" - DEL_TEXT="" -fi - # prefixes: PREFIX_REG="::" @@ -95,6 +95,9 @@ unset mods status "Waiting for UDev uevents to be processed" \ udevadm settle --timeout=${UDEV_TIMEOUT:-30} +# in case loading a module changed the display mode +calc_columns + run_hook sysinit_udevsettled # bring up the loopback interface |