mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 00:47:47 +00:00
refactored partition data output to be fully dynamic, not silly like it was.
Also fixed small line length bug where if color scheme 0, no colors is used, the lines would be too long, since the byte count is then less than for irc or shell colors.
This commit is contained in:
parent
8eaecad89c
commit
688e10e858
114
inxi
114
inxi
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.8.3
|
#### version: 0.8.4
|
||||||
#### Date: December 3 2008
|
#### Date: December 4 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif
|
||||||
#### As time permits functionality improvements and recoding will occur.
|
#### As time permits functionality improvements and recoding will occur.
|
||||||
|
@ -2626,14 +2626,17 @@ print_networking_ip_data()
|
||||||
|
|
||||||
print_partition_data()
|
print_partition_data()
|
||||||
{
|
{
|
||||||
local a_partition_working='' partition_used='' swap='' partition_data='' partition_data_2=''
|
local a_partition_working='' partition_used='' swap='' partition_data=''
|
||||||
local partition_data_3='' partition_data_4='' partition_data_5='' partition_data_6=''
|
local counter=0 line_max=160 i=0 a_partition_data='' line_starter=''
|
||||||
local partition_data_7='' partition_data_8='' partition_data_9='' counter=1 line_max=160
|
|
||||||
|
|
||||||
# this handles the different, shorter, irc colors strings embedded in variable data
|
# this handles the different, shorter, irc colors strings embedded in variable data
|
||||||
if [[ $B_RUNNING_IN_SHELL != 'true' ]];then
|
if [[ $B_RUNNING_IN_SHELL != 'true' ]];then
|
||||||
line_max=130
|
line_max=130
|
||||||
fi
|
fi
|
||||||
|
# and no color string data at all
|
||||||
|
if [[ $SCHEME -eq 0 ]];then
|
||||||
|
line_max=75
|
||||||
|
fi
|
||||||
|
|
||||||
# set A_PARTITION_DATA
|
# set A_PARTITION_DATA
|
||||||
get_partition_data
|
get_partition_data
|
||||||
|
@ -2656,98 +2659,23 @@ print_partition_data()
|
||||||
swap=''
|
swap=''
|
||||||
fi
|
fi
|
||||||
# because these lines can vary widely, using dynamic length handling here
|
# because these lines can vary widely, using dynamic length handling here
|
||||||
case $counter in
|
a_partition_data[$counter]="${a_partition_data[$counter]}${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
||||||
1)
|
if [[ $( wc -c <<< ${a_partition_data[$counter]} ) -gt $line_max ]];then
|
||||||
partition_data="$partition_data${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
((counter++))
|
||||||
if [[ $( wc -c <<< $partition_data ) -gt $line_max ]];then
|
|
||||||
counter=2
|
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
2)
|
|
||||||
partition_data_2="$partition_data_2${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_2 ) -gt $line_max ]];then
|
|
||||||
counter=3
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
partition_data_3="$partition_data_3${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_3 ) -gt $line_max ]];then
|
|
||||||
counter=4
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
4)
|
|
||||||
partition_data_4="$partition_data_4${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_4 ) -gt $line_max ]];then
|
|
||||||
counter=5
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
5)
|
|
||||||
partition_data_5="$partition_data_5${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_5 ) -gt $line_max ]];then
|
|
||||||
counter=6
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
6)
|
|
||||||
partition_data_6="$partition_data_6${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_6 ) -gt $line_max ]];then
|
|
||||||
counter=7
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
7)
|
|
||||||
partition_data_7="$partition_data_7${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_7 ) -gt $line_max ]];then
|
|
||||||
counter=8
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
8)
|
|
||||||
partition_data_8="$partition_data_8${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
if [[ $( wc -c <<< $partition_data_8 ) -gt $line_max ]];then
|
|
||||||
counter=9
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
partition_data_9="$partition_data_9${C1}ID:${C2}$swap${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]}$partition_used "
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# create the first line
|
# print out all lines, line starter on first line
|
||||||
partition_data=$( create_print_line "Partition:" "$partition_data" )
|
for (( i=0; i < ${#a_partition_data[@]};i++ ))
|
||||||
|
do
|
||||||
|
if [[ $i -eq 0 ]];then
|
||||||
|
line_starter='Partition:'
|
||||||
|
else
|
||||||
|
line_starter=' '
|
||||||
|
fi
|
||||||
|
partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}" )
|
||||||
print_screen_output "$partition_data"
|
print_screen_output "$partition_data"
|
||||||
|
done
|
||||||
# then the rest, if required
|
|
||||||
if [[ -n $partition_data_2 ]];then
|
|
||||||
partition_data_2=$( create_print_line " " "$partition_data_2" )
|
|
||||||
print_screen_output "$partition_data_2"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_3 ]];then
|
|
||||||
partition_data_3=$( create_print_line " " "$partition_data_3" )
|
|
||||||
print_screen_output "$partition_data_3"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_4 ]];then
|
|
||||||
partition_data_4=$( create_print_line " " "$partition_data_4" )
|
|
||||||
print_screen_output "$partition_data_4"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_5 ]];then
|
|
||||||
partition_data_5=$( create_print_line " " "$partition_data_5" )
|
|
||||||
print_screen_output "$partition_data_5"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_6 ]];then
|
|
||||||
partition_data_6=$( create_print_line " " "$partition_data_6" )
|
|
||||||
print_screen_output "$partition_data_6"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_7 ]];then
|
|
||||||
partition_data_7=$( create_print_line " " "$partition_data_7" )
|
|
||||||
print_screen_output "$partition_data_7"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_8 ]];then
|
|
||||||
partition_data_8=$( create_print_line " " "$partition_data_8" )
|
|
||||||
print_screen_output "$partition_data_8"
|
|
||||||
fi
|
|
||||||
if [[ -n $partition_data_9 ]];then
|
|
||||||
partition_data_9=$( create_print_line " " "$partition_data_9" )
|
|
||||||
print_screen_output "$partition_data_9"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_system_data()
|
print_system_data()
|
||||||
|
|
Loading…
Reference in a new issue