2025-06-24 16:57:29 -04:00
|
|
|
import subprocess
|
|
|
|
|
2025-07-15 15:51:07 -04:00
|
|
|
from duskwm_logging import log
|
2025-06-24 16:57:29 -04:00
|
|
|
from theme import current_theme, default
|
|
|
|
|
|
|
|
data = subprocess.run(
|
|
|
|
["wpctl", "get-volume", "@DEFAULT_AUDIO_SINK@"],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
encoding="utf-8",
|
|
|
|
).stdout.strip()
|
|
|
|
|
2025-07-15 15:51:07 -04:00
|
|
|
try:
|
|
|
|
_, decimal, *muted = data.split(" ")
|
|
|
|
except Exception:
|
|
|
|
log.warning(data)
|
|
|
|
decimal = "0.0"
|
|
|
|
muted = "[MUTED]"
|
2025-06-24 16:57:29 -04:00
|
|
|
|
|
|
|
decimal = float(decimal)
|
|
|
|
muted = muted[0] if muted else ""
|
|
|
|
|
|
|
|
icon = "" if muted == "[MUTED]" else ""
|
|
|
|
color = (
|
|
|
|
f"^c{current_theme.base7}^" if muted == "[MUTED]" else f"^c{current_theme.base8}^"
|
|
|
|
)
|
|
|
|
vol_string = f"{decimal:.0%}"
|
|
|
|
content = f"^v^{color}{icon} {vol_string:>4}^t^"
|