Add a color map for mpd states (#640)

This commit is contained in:
Егор 2018-03-31 15:35:15 +03:00 committed by enkore
parent c37dd115e5
commit 3efbd56bb7

View File

@ -1,3 +1,4 @@
from collections import defaultdict
import socket import socket
from os.path import basename from os.path import basename
from math import floor from math import floor
@ -65,6 +66,7 @@ socket."),
("format", "formatp string"), ("format", "formatp string"),
("status", "Dictionary mapping pause, play and stop to output"), ("status", "Dictionary mapping pause, play and stop to output"),
("color", "The color of the text"), ("color", "The color of the text"),
("color_map", "The mapping from state to color of the text"),
("max_field_len", "Defines max length for in truncate_fields defined \ ("max_field_len", "Defines max length for in truncate_fields defined \
fields, if truncated, ellipsis are appended as indicator. It's applied \ fields, if truncated, ellipsis are appended as indicator. It's applied \
*before* max_len. Value of 0 disables this."), *before* max_len. Value of 0 disables this."),
@ -90,6 +92,7 @@ cleartext to the server.)"),
"stop": "", "stop": "",
} }
color = "#FFFFFF" color = "#FFFFFF"
color_map = {}
max_field_len = 25 max_field_len = 25
max_len = 100 max_len = 100
truncate_fields = ("title", "album", "artist") truncate_fields = ("title", "album", "artist")
@ -175,9 +178,10 @@ cleartext to the server.)"),
fdict[key] = fdict[key][:shrink] + "" fdict[key] = fdict[key][:shrink] + ""
full_text = formatp(self.format, **fdict).strip() full_text = formatp(self.format, **fdict).strip()
color_map = defaultdict(lambda: self.color, self.color_map)
self.output = { self.output = {
"full_text": full_text, "full_text": full_text,
"color": self.color, "color": color_map[playback_state],
} }
def switch_playpause(self): def switch_playpause(self):