From 3efbd56bb7a851f16173ec6f0eef472b6e96c7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B3=D0=BE=D1=80?= Date: Sat, 31 Mar 2018 15:35:15 +0300 Subject: [PATCH] Add a color map for mpd states (#640) --- i3pystatus/mpd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/i3pystatus/mpd.py b/i3pystatus/mpd.py index ab4809c..df0432c 100644 --- a/i3pystatus/mpd.py +++ b/i3pystatus/mpd.py @@ -1,3 +1,4 @@ +from collections import defaultdict import socket from os.path import basename from math import floor @@ -65,6 +66,7 @@ socket."), ("format", "formatp string"), ("status", "Dictionary mapping pause, play and stop to output"), ("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 \ fields, if truncated, ellipsis are appended as indicator. It's applied \ *before* max_len. Value of 0 disables this."), @@ -90,6 +92,7 @@ cleartext to the server.)"), "stop": "◾", } color = "#FFFFFF" + color_map = {} max_field_len = 25 max_len = 100 truncate_fields = ("title", "album", "artist") @@ -175,9 +178,10 @@ cleartext to the server.)"), fdict[key] = fdict[key][:shrink] + "…" full_text = formatp(self.format, **fdict).strip() + color_map = defaultdict(lambda: self.color, self.color_map) self.output = { "full_text": full_text, - "color": self.color, + "color": color_map[playback_state], } def switch_playpause(self):