From 19526304bcc3ea3c4f82ff2e45912bd3e5c977b5 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Wed, 28 Sep 2016 12:58:49 +0200 Subject: [PATCH] included right-justification by default in all real names. #161 --- lib/lmsens.pm | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/lmsens.pm b/lib/lmsens.pm index 311659f..b8e8612 100644 --- a/lib/lmsens.pm +++ b/lib/lmsens.pm @@ -911,18 +911,18 @@ sub lmsens_cgi { undef(@tmp); undef(@tmpz); undef(@CDEF); - $str = $lmsens->{desc}->{'mb0'} ? substr($lmsens->{desc}->{'mb0'}, 0, 5) : "MB 0"; + $str = $lmsens->{desc}->{'mb0'} ? sprintf("%5s", substr($lmsens->{desc}->{'mb0'}, 0, 5)) : "MB 0"; push(@tmp, ("LINE2:mb_0#FFA500:$str\\g", "GPRINT:mb_0:LAST:\\:%3.0lf ")); - $str = $lmsens->{desc}->{'cpu0'} ? substr($lmsens->{desc}->{'cpu0'}, 0, 5) : "CPU 0"; + $str = $lmsens->{desc}->{'cpu0'} ? sprintf("%5s", substr($lmsens->{desc}->{'cpu0'}, 0, 5)) : "CPU 0"; push(@tmp, ("LINE2:cpu_0#4444EE:$str\\g", "GPRINT:cpu_0:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'cpu0'}; - $str = $lmsens->{desc}->{'cpu2'} ? substr($lmsens->{desc}->{'cpu2'}, 0, 5) : "CPU 2"; + $str = $lmsens->{desc}->{'cpu2'} ? sprintf("%5s", substr($lmsens->{desc}->{'cpu2'}, 0, 5)) : "CPU 2"; push(@tmp, ("LINE2:cpu_2#EE44EE:$str\\g", "GPRINT:cpu_2:LAST:\\:%3.0lf\\g")) unless !$lmsens->{list}->{'cpu2'}; push(@tmp, "COMMENT: \\n"); - $str = $lmsens->{desc}->{'mb1'} ? substr($lmsens->{desc}->{'mb1'}, 0, 5) : "MB 1"; + $str = $lmsens->{desc}->{'mb1'} ? sprintf("%5s", substr($lmsens->{desc}->{'mb1'}, 0, 5)) : "MB 1"; push(@tmp, ("LINE2:mb_1#44EEEE:$str\\g", "GPRINT:mb_1:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'mb1'}; - $str = $lmsens->{desc}->{'cpu1'} ? substr($lmsens->{desc}->{'cpu1'}, 0, 5) : "CPU 1"; + $str = $lmsens->{desc}->{'cpu1'} ? sprintf("%5s", substr($lmsens->{desc}->{'cpu1'}, 0, 5)) : "CPU 1"; push(@tmp, ("LINE2:cpu_1#EEEE44:$str\\g", "GPRINT:cpu_1:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'cpu1'}; - $str = $lmsens->{desc}->{'cpu3'} ? substr($lmsens->{desc}->{'cpu3'}, 0, 5) : "CPU 3"; + $str = $lmsens->{desc}->{'cpu3'} ? sprintf("%5s", substr($lmsens->{desc}->{'cpu3'}, 0, 5)) : "CPU 3"; push(@tmp, ("LINE2:cpu_3#44EE44:$str\\g", "GPRINT:cpu_3:LAST:\\:%3.0lf\\g")) unless !$lmsens->{list}->{'cpu3'}; push(@tmp, "COMMENT: \\n"); @@ -1039,25 +1039,25 @@ sub lmsens_cgi { undef(@tmp); undef(@tmpz); undef(@CDEF); - $str = $lmsens->{desc}->{'fan0'} ? substr($lmsens->{desc}->{'fan0'}, 0, 5) : "Fan 0"; + $str = $lmsens->{desc}->{'fan0'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan0'}, 0, 5)) : "Fan 0"; push(@tmp, ("LINE2:fan0#FFA500:$str\\g", "GPRINT:fan0:LAST:\\:%5.0lf")); - $str = $lmsens->{desc}->{'fan3'} ? substr($lmsens->{desc}->{'fan3'}, 0, 5) : "Fan 3"; + $str = $lmsens->{desc}->{'fan3'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan3'}, 0, 5)) : "Fan 3"; push(@tmp, ("LINE2:fan3#4444EE:$str\\g", "GPRINT:fan3:LAST:\\:%5.0lf")) unless !$lmsens->{list}->{'fan3'}; - $str = $lmsens->{desc}->{'fan6'} ? substr($lmsens->{desc}->{'fan6'}, 0, 5) : "Fan 6"; + $str = $lmsens->{desc}->{'fan6'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan6'}, 0, 5)) : "Fan 6"; push(@tmp, ("LINE2:fan6#EE44EE:$str\\g", "GPRINT:fan6:LAST:\\:%5.0lf\\g")) unless !$lmsens->{list}->{'fan6'}; push(@tmp, "COMMENT: \\n"); - $str = $lmsens->{desc}->{'fan1'} ? substr($lmsens->{desc}->{'fan1'}, 0, 5) : "Fan 1"; + $str = $lmsens->{desc}->{'fan1'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan1'}, 0, 5)) : "Fan 1"; push(@tmp, ("LINE2:fan1#44EEEE:$str\\g", "GPRINT:fan1:LAST:\\:%5.0lf")) unless !$lmsens->{list}->{'fan1'}; - $str = $lmsens->{desc}->{'fan4'} ? substr($lmsens->{desc}->{'fan4'}, 0, 5) : "Fan 4"; + $str = $lmsens->{desc}->{'fan4'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan4'}, 0, 5)) : "Fan 4"; push(@tmp, ("LINE2:fan4#448844:$str\\g", "GPRINT:fan4:LAST:\\:%5.0lf")) unless !$lmsens->{list}->{'fan4'}; - $str = $lmsens->{desc}->{'fan7'} ? substr($lmsens->{desc}->{'fan7'}, 0, 5) : "Fan 7"; + $str = $lmsens->{desc}->{'fan7'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan7'}, 0, 5)) : "Fan 7"; push(@tmp, ("LINE2:fan7#EEEE44:$str\\g", "GPRINT:fan7:LAST:\\:%5.0lf\\g")) unless !$lmsens->{list}->{'fan7'}; push(@tmp, "COMMENT: \\n"); - $str = $lmsens->{desc}->{'fan2'} ? substr($lmsens->{desc}->{'fan2'}, 0, 5) : "Fan 2"; + $str = $lmsens->{desc}->{'fan2'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan2'}, 0, 5)) : "Fan 2"; push(@tmp, ("LINE2:fan2#44EE44:$str\\g", "GPRINT:fan2:LAST:\\:%5.0lf")) unless !$lmsens->{list}->{'fan2'}; - $str = $lmsens->{desc}->{'fan5'} ? substr($lmsens->{desc}->{'fan5'}, 0, 5) : "Fan 5"; + $str = $lmsens->{desc}->{'fan5'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan5'}, 0, 5)) : "Fan 5"; push(@tmp, ("LINE2:fan5#EE4444:$str\\g", "GPRINT:fan5:LAST:\\:%5.0lf")) unless !$lmsens->{list}->{'fan5'}; - $str = $lmsens->{desc}->{'fan8'} ? substr($lmsens->{desc}->{'fan8'}, 0, 5) : "Fan 8"; + $str = $lmsens->{desc}->{'fan8'} ? sprintf("%5s", substr($lmsens->{desc}->{'fan8'}, 0, 5)) : "Fan 8"; push(@tmp, ("LINE2:fan8#963C74:$str\\g", "GPRINT:fan8:LAST:\\:%5.0lf\\g")) unless !$lmsens->{list}->{'fan8'}; push(@tmp, "COMMENT: \\n"); @@ -1171,26 +1171,26 @@ sub lmsens_cgi { undef(@tmp); undef(@tmpz); undef(@CDEF); - $str = $lmsens->{desc}->{'gpu0'} ? substr($lmsens->{desc}->{'gpu0'}, 0, 5) : "GPU 0"; + $str = $lmsens->{desc}->{'gpu0'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu0'}, 0, 5)) : "GPU 0"; push(@tmp, "LINE2:gpu_0#FFA500:$str\\g"); push(@tmp, "GPRINT:gpu_0:LAST:\\:%3.0lf "); - $str = $lmsens->{desc}->{'gpu3'} ? substr($lmsens->{desc}->{'gpu3'}, 0, 5) : "GPU 3"; + $str = $lmsens->{desc}->{'gpu3'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu3'}, 0, 5)) : "GPU 3"; push(@tmp, ("LINE2:gpu_3#4444EE:$str\\g", "GPRINT:gpu_3:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'gpu3'}; - $str = $lmsens->{desc}->{'gpu6'} ? substr($lmsens->{desc}->{'gpu6'}, 0, 5) : "GPU 6"; + $str = $lmsens->{desc}->{'gpu6'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu6'}, 0, 5)) : "GPU 6"; push(@tmp, ("LINE2:gpu_6#EE44EE:$str\\g", "GPRINT:gpu_6:LAST:\\:%3.0lf\\g")) unless !$lmsens->{list}->{'gpu6'}; push(@tmp, "COMMENT: \\n"); - $str = $lmsens->{desc}->{'gpu1'} ? substr($lmsens->{desc}->{'gpu1'}, 0, 5) : "GPU 1"; + $str = $lmsens->{desc}->{'gpu1'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu1'}, 0, 5)) : "GPU 1"; push(@tmp, ("LINE2:gpu_1#44EEEE:$str\\g", "GPRINT:gpu_1:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'gpu1'}; - $str = $lmsens->{desc}->{'gpu4'} ? substr($lmsens->{desc}->{'gpu4'}, 0, 5) : "GPU 4"; + $str = $lmsens->{desc}->{'gpu4'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu4'}, 0, 5)) : "GPU 4"; push(@tmp, ("LINE2:gpu_4#448844:$str\\g", "GPRINT:gpu_4:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'gpu4'}; - $str = $lmsens->{desc}->{'gpu7'} ? substr($lmsens->{desc}->{'gpu7'}, 0, 5) : "GPU 7"; + $str = $lmsens->{desc}->{'gpu7'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu7'}, 0, 5)) : "GPU 7"; push(@tmp, ("LINE2:gpu_7#EEEE44:$str\\g", "GPRINT:gpu_7:LAST:\\:%3.0lf\\g")) unless !$lmsens->{list}->{'gpu7'}; push(@tmp, "COMMENT: \\n"); - $str = $lmsens->{desc}->{'gpu2'} ? substr($lmsens->{desc}->{'gpu2'}, 0, 5) : "GPU 2"; + $str = $lmsens->{desc}->{'gpu2'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu2'}, 0, 5)) : "GPU 2"; push(@tmp, ("LINE2:gpu_2#44EE44:$str\\g", "GPRINT:gpu_2:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'gpu2'}; - $str = $lmsens->{desc}->{'gpu5'} ? substr($lmsens->{desc}->{'gpu5'}, 0, 5) : "GPU 5"; + $str = $lmsens->{desc}->{'gpu5'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu5'}, 0, 5)) : "GPU 5"; push(@tmp, ("LINE2:gpu_5#EE4444:$str\\g", "GPRINT:gpu_5:LAST:\\:%3.0lf ")) unless !$lmsens->{list}->{'gpu5'}; - $str = $lmsens->{desc}->{'gpu8'} ? substr($lmsens->{desc}->{'gpu8'}, 0, 5) : "GPU 8"; + $str = $lmsens->{desc}->{'gpu8'} ? sprintf("%5s", substr($lmsens->{desc}->{'gpu8'}, 0, 5)) : "GPU 8"; push(@tmp, ("LINE2:gpu_8#963C74:$str\\g", "GPRINT:gpu_8:LAST:\\:%3.0lf\\g")) unless !$lmsens->{list}->{'gpu8'}; push(@tmp, "COMMENT: \\n");