Add D-Bus command logging and notify-send alerts for failed commands

This commit is contained in:
2026-03-19 04:06:46 -04:00
parent 06f43992d6
commit 21afe7650a
2 changed files with 12 additions and 5 deletions

View File

@@ -83,10 +83,17 @@ class WinampMPRIS:
self._last_update_ts = time.time()
def _request(self, endpoint):
print(f"COMMAND RECEIVED: {endpoint}")
try:
requests.get(f"{BASE_URL}/{endpoint}", auth=AUTH, timeout=2)
r = requests.get(f"{BASE_URL}/{endpoint}", auth=AUTH, timeout=2)
if r.status_code != 200:
msg = f"Failed to send '{endpoint}' to Winamp (Status {r.status_code})."
print(f"ERROR: {msg}")
subprocess.run(["notify-send", "-u", "critical", "-t", "3000", "Winamp Bridge Error", msg])
except Exception as e:
print(f"Request failed: {e}")
msg = f"Connection error while sending '{endpoint}': {e}"
print(f"ERROR: {msg}")
subprocess.run(["notify-send", "-u", "critical", "-t", "3000", "Winamp Bridge Offline", msg])
# MPRIS Methods
def Next(self): self._request("next")