From bd8c68235e8251e96877aa42c46e54315781cf80 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 19 Mar 2022 10:31:01 +0100 Subject: [PATCH] i3pystatus/ice-status: only show net info if we actually have information --- .config/i3pystatus/ice-status.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.config/i3pystatus/ice-status.py b/.config/i3pystatus/ice-status.py index c4fab99..1f41417 100755 --- a/.config/i3pystatus/ice-status.py +++ b/.config/i3pystatus/ice-status.py @@ -66,12 +66,22 @@ try: else: next_stop = 'Endstation, bitte Aussteigen' - print('{}km/h > {} (Net: {} > [{}] {})'.format( + net_current = ice_status['connectivity']['currentState'] + net_future = ice_status['connectivity']['nextState'] + + if net_current not in (None, 'NO_INFO') or net_future not in (None, 'NO_INFO'): + net = ' (Net: {} > [{}] {})'.format( + net_current, + format_time(ice_status['connectivity']['remainingTimeSeconds']), + net_future, + ) + else: + net = '' + + print('{}km/h > {}{}'.format( ice_status['speed'], next_stop, - ice_status['connectivity']['currentState'], - format_time(ice_status['connectivity']['remainingTimeSeconds']), - ice_status['connectivity']['nextState'], + net, )) except Exception as e: print(repr(e))