add color support to some modules missing it (#735)

* add color support to some modules missing it

Affects:

amdgpu
calendar
deluge
net_speed
plexstatus
This commit is contained in:
chestm007 2019-04-23 00:50:14 +10:00 committed by GitHub
parent b9cb4af8ba
commit b5a232c4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 2 deletions

View File

@ -18,10 +18,12 @@ class Amdgpu(IntervalModule):
settings = (
'format',
'color',
('card', '[1, 2, ...] card to read (options are in /sys/class/drm/)')
)
card = 0
color = None
format = '{temp} {mclk} {sclk}'
def init(self):
@ -56,6 +58,8 @@ class Amdgpu(IntervalModule):
self.output = {
'full_text': self.format.format(**self.data)
}
if self.color:
self.output['color'] = self.color
@staticmethod
def parse_clk_reading(reading):

View File

@ -142,6 +142,7 @@ class Calendar(IntervalModule, ColorRangeModule):
('urgent_seconds', "When within this many seconds of the event, set the urgent flag"),
('urgent_blink', 'Whether or not to blink when within urgent_seconds of the event'),
('dynamic_color', 'Whether or not to change color as the event approaches'),
'color'
)
required = ('backend',)
@ -155,6 +156,7 @@ class Calendar(IntervalModule, ColorRangeModule):
dynamic_color = True
urgent_seconds = 300
urgent_blink = False
color = None
current_event = None
urgent_acknowledged = False
@ -204,9 +206,14 @@ class Calendar(IntervalModule, ColorRangeModule):
def run(self):
if self.current_event and self.current_event.time_remaining > timedelta(seconds=0):
color = None
if self.color is not None:
color = self.color
elif self.dynamic_color:
color = self.get_color()
self.output = {
"full_text": formatp(self.format, **self.current_event.formatters()),
"color": self.get_color() if self.dynamic_color else None,
"color": color,
"urgent": self.is_urgent()
}
else:

View File

@ -25,6 +25,7 @@ class Deluge(IntervalModule):
settings = (
'format',
'color',
('rounding', 'number of decimal places to round numbers too'),
('host', 'address of deluge server (default: 127.0.0.1)'),
('port', 'port of deluge server (default: 58846)'),
@ -38,6 +39,7 @@ class Deluge(IntervalModule):
host = '127.0.0.1'
port = 58846
path = None
color = None
libtorrent_stats = False
rounding = 2
offline_string = 'offline'
@ -79,6 +81,8 @@ class Deluge(IntervalModule):
self.output = {
'full_text': self.format.format(**self.data)
}
if self.color:
self.output['color'] = self.color
def parse_values(self, values):
for k, v in values.items():

View File

@ -19,7 +19,8 @@ class NetSpeed(IntervalModule):
settings = (
("units", "Valid values are B, b, bytes, or bits"),
"format"
"format",
'color'
)
color = "#FFFFFF"
interval = 300

View File

@ -21,6 +21,7 @@ class Plexstatus(IntervalModule):
settings = (
"format",
"color",
("apikey", "Your Plex API authentication key"),
("address", "Hostname or IP address of the Plex Media Server"),
("port", "Port which Plex Media Server is running on"),