dotfiles/.config/i3pystatus/rfkill-wifi.py

22 lines
512 B
Python
Executable file

#!/usr/bin/python
from subprocess import check_output
devices = {}
for line in check_output(['rfkill', '-rn']).decode('UTF-8').splitlines():
nr, identifier, device, soft, hard = line.split(' ')
devices[device] = {
'soft': True if soft == 'blocked' else False,
'hard': True if hard == 'blocked' else False,
}
if devices['phy0']['hard']:
wlan = '#FF0000'
elif devices['phy0']['soft']:
wlan = '#FF9900'
else:
wlan = '#00FF00'
print(f'<span color="{wlan}">WLAN</span>')