forked from rohanverma2007/tidal-waybar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtidal-waybar.py
More file actions
39 lines (31 loc) · 1.1 KB
/
tidal-waybar.py
File metadata and controls
39 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3
import requests
import os
import sys
TIDAL_STATUS_URL = "http://localhost:47837/current"
TIDAL_CONTROL_URL = "http://localhost:47837/player"
def get_current_song():
try:
response = requests.get(TIDAL_STATUS_URL)
data = response.json()
if data.get("status") == "playing":
title = data.get("title", "Unknown Track")
artist = data.get("artists", "Unknown Artist")
# Limit artist name to 30 characters
if len(artist) > 20:
artist = artist[:27] + "..."
return f" {artist} - {title}"
else:
return " Paused "
except requests.RequestException:
return ""
if __name__ == "__main__":
button = os.getenv("WAYBAR_BUTTON")
if button == "1": # Left click → Previous song
send_command("previous")
elif button == "2": # Middle click → Play/Pause toggle
send_command("playpause")
elif button == "3": # Right click → Next song
send_command("next")
else:
print(get_current_song()) # Default output for Waybar