i3pystatus/ice-status: only show net info if we actually have information

This commit is contained in:
Franzi 2022-03-19 10:31:01 +01:00
parent b295fd359a
commit bd8c68235e
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -66,12 +66,22 @@ try:
else: else:
next_stop = 'Endstation, bitte Aussteigen' next_stop = 'Endstation, bitte Aussteigen'
print('<span color="#999999">{}km/h</span> > {} <span color="#999999">(Net: {} > [{}] {})</span>'.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 = ' <span color="#999999">(Net: {} > [{}] {})</span>'.format(
net_current,
format_time(ice_status['connectivity']['remainingTimeSeconds']),
net_future,
)
else:
net = ''
print('<span color="#999999">{}km/h</span> > {}{}'.format(
ice_status['speed'], ice_status['speed'],
next_stop, next_stop,
ice_status['connectivity']['currentState'], net,
format_time(ice_status['connectivity']['remainingTimeSeconds']),
ice_status['connectivity']['nextState'],
)) ))
except Exception as e: except Exception as e:
print(repr(e)) print(repr(e))