sway/status.py: A few changes
- Switch to iwd for Wi-Fi - Remove unused code - Format with black
This commit is contained in:
parent
d0bf0819f7
commit
d39c0c7892
@ -1,7 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Install ttf-twemoji and make sure there are no other emoji fonts like
|
# Requires the following packages on Arch Linux:
|
||||||
# noto-fonts-emoji.
|
# - ttf-twemoji (and make sure there are no other emoji fonts like noto-fonts-emoji
|
||||||
|
# - networkmanager
|
||||||
|
# - pulsemixer
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
@ -18,7 +20,10 @@ def write(data):
|
|||||||
def refresh():
|
def refresh():
|
||||||
try:
|
try:
|
||||||
ssid = (
|
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()
|
.strip()
|
||||||
.decode("utf-8")
|
.decode("utf-8")
|
||||||
)
|
)
|
||||||
@ -27,31 +32,7 @@ def refresh():
|
|||||||
|
|
||||||
wifi_status = f"{ssid} 📶"
|
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)
|
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_icon = "🔋"
|
||||||
battery_status = f"{battery_percent} {battery_icon}"
|
battery_status = f"{battery_percent} {battery_icon}"
|
||||||
power_status = "🔌" if sensors_battery().power_plugged else ""
|
power_status = "🔌" if sensors_battery().power_plugged else ""
|
||||||
|
Loading…
Reference in New Issue
Block a user