mirror of
https://github.com/dnlbauer/dotfiles.git
synced 2026-09-11 05:55:29 +00:00
antigen and laptop polybar
This commit is contained in:
@@ -333,7 +333,7 @@ format=GPU <label>
|
||||
|
||||
[module/spotify]
|
||||
type=custom/script
|
||||
exec=python3 ~/.config/polybar/spotify.py
|
||||
exec=python3 ~/.config/polybar/spotify.py "{artist} - {title}"
|
||||
interval=1
|
||||
tail=false
|
||||
format= <label>
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
#!/usr/bin/python2
|
||||
|
||||
import dbus
|
||||
from sys import argv
|
||||
|
||||
if len(argv) > 1:
|
||||
fmt = argv[1]
|
||||
else:
|
||||
fmt = None
|
||||
|
||||
def format_output(artist, title, fmt=None):
|
||||
if fmt is None:
|
||||
fmt = "{artist} - {title}"
|
||||
return fmt.format(artist=artist, title=title)
|
||||
|
||||
|
||||
try:
|
||||
bus = dbus.SessionBus()
|
||||
spotify = bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
|
||||
spotify_iface = dbus.Interface(spotify, 'org.freedesktop.DBus.Properties')
|
||||
props = spotify_iface.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
|
||||
try:
|
||||
out = str(props['xesam:artist'][0]) + " - " + str(props['xesam:title'])
|
||||
try:
|
||||
out = format_output((props['xesam:artist'][0]), str(props['xesam:title']), fmt)
|
||||
except IndexError:
|
||||
out = ''
|
||||
print(out)
|
||||
|
||||
Reference in New Issue
Block a user