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

@@ -32,13 +32,13 @@ To ensure the bridge can extract correct metadata, you must configure Winamp to
*(Note: The separator between Artist, Album, and Title should be an en-dash `` or a simple dash `-`)*.
### 3. Linux Dependencies
Install the required Python libraries and `wmctrl`:
Install the required Python libraries, `wmctrl`, and `libnotify` (for notifications):
```bash
# Python dependencies
pip install requests pydbus beautifulsoup4 pygobject
# System tool
sudo dnf install wmctrl # or sudo apt install wmctrl
# System tools
sudo dnf install wmctrl libnotify # or sudo apt install wmctrl libnotify
```
## Installation & Setup

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")