From c1fe3d853889f009d53e6a8efc07a4d436dd7a50 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Tue, 26 Dec 2017 14:35:47 -0700 Subject: [PATCH] Added --nocolor option to hw-sensors * Going to use it to export the "final" temps before killing Prime95 --- .bin/Scripts/hw-sensors | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.bin/Scripts/hw-sensors b/.bin/Scripts/hw-sensors index 07c98460..da5427d0 100755 --- a/.bin/Scripts/hw-sensors +++ b/.bin/Scripts/hw-sensors @@ -49,10 +49,10 @@ def color_temp(temp): color = COLORS['BLUE'] else: color = COLORS['CLEAR'] - return '{color}{prefix}{temp:2}°C{CLEAR}'.format( + return '{color}{prefix}{temp:2.0f}°C{CLEAR}'.format( color = color, prefix = '+' if temp>0 else '-', - temp = int(temp), + temp = temp, **COLORS) def get_feature_string(chip, feature): @@ -74,7 +74,17 @@ def get_feature_string(chip, feature): if 'alarm' in name: # Skip continue - data[name] = color_temp(val) + if '--nocolor' in sys.argv: + try: + temp = float(val) + except ValueError: + data[name] = ' {}°C'.format(val) + else: + data[name] = '{}{:2.0f}°C'.format( + '+' if temp>0 else '-', + temp) + else: + data[name] = color_temp(val) main_temp = data.pop('input', None) if main_temp: @@ -101,7 +111,6 @@ def join_columns(column1, column2, width=55): if __name__ == '__main__': try: # Prep - clear_screen() sensors.init() # Get sensor data