Skip to content

Commit e1398b8

Browse files
authored
Merge pull request #1 from EddiePoulter/master
Centered text and added artist
2 parents 00aecc2 + 4711335 commit e1398b8

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"refresh_interval": 500,
33
"is_notification": false,
44
"notification_min_interval": 2,
5-
"widget_length": 20,
5+
"widget_length": 50,
66
"sepchar": "",
77
"surface_color": "@backgroundlight",
88
"overlay_color": "@backgrounddark",

src/mediaplayer

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ def write_output(text=None, class_=None, tooltip=""):
129129
global config
130130
# Default values if not explicitly set
131131
if not text:
132-
text = "" + (" " * (config["widget_length"] - 1))
132+
# text = "r" + (" " * (config["widget_length"] - 1))
133+
text = (" " * (config["widget_length"]))
133134
if not class_:
134135
class_ = gen_class(0.0)
135136
if not tooltip:
@@ -167,7 +168,7 @@ def gen_widget_text(player):
167168
global last_rot, last_rot_time, is_text_rotating
168169

169170
metadata = player.props.metadata
170-
# artist = player.get_artist()
171+
artist = player.get_artist()
171172
# artist = metadata["xesam:artist"][0]
172173
title = player.get_title() or ""
173174
# title = metadata["xesam:title"]
@@ -181,10 +182,10 @@ def gen_widget_text(player):
181182
):
182183
song_info = "AD PLAYING"
183184
else:
184-
song_info = title.strip()
185+
song_info = f"{title.strip()} - {artist.strip()}"
185186

186187
if not is_text_rotating:
187-
text = left_text(icon + song_info)
188+
text = icon + song_info
188189
else:
189190
song_info += " " + config["sepchar"] + " "
190191
elapsed = (time.time() - last_rot_time) * 1000
@@ -362,15 +363,6 @@ def get_new_lyrics(artist, title):
362363
lyrics["secs"].append(lyrics["secs"][-1] + 1)
363364

364365

365-
def left_text(s):
366-
le = len(s)
367-
if le > config["widget_length"]:
368-
return s
369-
missing = config["widget_length"] - le
370-
s = s + " " * (missing)
371-
return s
372-
373-
374366
def center_text(s, ml=None):
375367
if not ml:
376368
ml = max([len(x) for x in s])

0 commit comments

Comments
 (0)