summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/qtile/spotify_widget.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/.config/qtile/spotify_widget.py b/.config/qtile/spotify_widget.py
index a34e962..5e069b0 100644
--- a/.config/qtile/spotify_widget.py
+++ b/.config/qtile/spotify_widget.py
@@ -14,37 +14,36 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import dbus
-import dbus_next
import subprocess
from functools import partial
from libqtile.widget import base
-
class Spotify(base.ThreadPoolText):
- """A simple Spotify widget.
+ """A simple Spotify widget, made using dbus-python.
Show the song and artist of now listening song and allow basic mouse
- control from the bar using spotify-control:
+ control from the bar using spotify-control(
+ Github: https://github.com/J00LZ/spotify-control
+ AUR: https://aur.archlinux.org/packages/spotify-control
+ ):
- toggle pause (or play if stopped) on left click;
- skip forward in playlist on scroll up;
- skip backward in playlist on scroll down.
"""
defaults = [
- ("play_color", "00ff00", "Text colour when playing."),
- ("noplay_color", "cecece", "Text colour when not playing."),
+ ("color", "00ff00", "Text"),
("update_interval", 0.5, "Update Time in seconds."),
]
def __init__(self, **config):
base.ThreadPoolText.__init__(self, "", **config)
self.add_defaults(Spotify.defaults)
- self.status = "PLAY"
self.local = None
self.add_callbacks(
{
"Button1": partial(subprocess.Popen, ["spotify-control", "play-pause"]),
- "Button2": partial(subprocess.Popen, ["spotify-control", "previous"]),
- "Button3": partial(subprocess.Popen, ["spotify-control", "next"]),
+ "Button4": partial(subprocess.Popen, ["spotify-control", "next"]),
+ "Button5": partial(subprocess.Popen, ["spotify-control", "previous"]),
}
)
@@ -59,10 +58,13 @@ class Spotify(base.ThreadPoolText):
"artist" : next(iter(metadata.get("xesam:albumArtist"))),
"song" : metadata.get("xesam:title")
}
- song = data["song"] + " | " + data["artist"]
- self.layout.colour = self.play_color
+ song = data["song"] + " ♫ " + data["artist"]
+ self.layout.colour = self.color
return song
def poll(self):
"""Poll content for the text box."""
- return self.now_playing()
+ try:
+ return self.now_playing()
+ except :
+ return "Spotify is not responding"