From b295fd359a1f3686ae184bce9fbb5851770f102f Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 6 Mar 2022 18:05:56 +0100 Subject: [PATCH] i3pystatus: fix wifi device detection --- .config/i3pystatus/rfkill-wifi.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.config/i3pystatus/rfkill-wifi.py b/.config/i3pystatus/rfkill-wifi.py index 29f9b63..b338d21 100755 --- a/.config/i3pystatus/rfkill-wifi.py +++ b/.config/i3pystatus/rfkill-wifi.py @@ -12,11 +12,20 @@ for line in check_output(['rfkill', '-rn']).decode('UTF-8').splitlines(): 'hard': True if hard == 'blocked' else False, } -if devices['phy0']['hard']: - wlan = '#FF0000' -elif devices['phy0']['soft']: - wlan = '#FF9900' -else: - wlan = '#00FF00' +wifi_dev = None +for device in devices: + if device.startswith('phy'): + wifi_dev = device + break -print(f'WLAN') +if not wifi_dev: + print('No WLAN?') +else: + if devices[wifi_dev]['hard']: + wlan = '#FF0000' + elif devices[wifi_dev]['soft']: + wlan = '#FF9900' + else: + wlan = '#00FF00' + + print(f'WLAN')