sway/status.py: A few changes

- Switch to iwd for Wi-Fi
- Remove unused code
- Format with black
This commit is contained in:
Alan Orth 2020-12-13 17:10:25 +02:00
parent d0bf0819f7
commit d39c0c7892
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
1 changed files with 8 additions and 27 deletions

View File

@ -1,7 +1,9 @@
#!/usr/bin/env python3
#
# Install ttf-twemoji and make sure there are no other emoji fonts like
# noto-fonts-emoji.
# Requires the following packages on Arch Linux:
# - ttf-twemoji (and make sure there are no other emoji fonts like noto-fonts-emoji
# - networkmanager
# - pulsemixer
from datetime import datetime
from subprocess import check_output
@ -18,7 +20,10 @@ def write(data):
def refresh():
try:
ssid = (
check_output("nmcli -g general.connection device show wlan0", shell=True)
check_output(
"iwctl station wlan0 show | grep 'Connected network' | awk '{print $3}'",
shell=True,
)
.strip()
.decode("utf-8")
)
@ -27,31 +32,7 @@ def refresh():
wifi_status = f"{ssid} 📶"
try:
vpn_state = (
check_output("nmcli -g general.state connection show wg0", shell=True)
.strip()
.decode("utf-8")
)
except Exception:
vpn_state = ""
if vpn_state == "activated":
wifi_status = f"{wifi_status} 🔐"
battery_percent = int(sensors_battery().percent)
# if battery_percent >= 90:
# battery_icon = ""
# elif battery_percent < 90 and battery_percent >= 75:
# battery_icon = "🔋"
# elif battery_percent < 75 and battery_percent >= 50:
# battery_icon = ""
# elif battery_percent < 50 and battery_percent >= 25:
# battery_icon = ""
# elif battery_percent < 25:
# battery_icon = ""
battery_icon = "🔋"
battery_status = f"{battery_percent} {battery_icon}"
power_status = "🔌" if sensors_battery().power_plugged else ""