Add D-Bus command logging and notify-send alerts for failed commands
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user