[core/output] allow specification of per-widget modified

make it possible to specify the minimum width of all widgets via:

`-m cpu -p cpu.theme.minwidth=20`

or

`-m cpu -p cpu.theme.minwidth=aaaaaa`

multiple widgets are comma-separated (missing entries will have no
minwidth)

`-m sensors2 -p sensors2.theme.minwidth=10,20,10`

see #606

TODO add to documentation
This commit is contained in:
tobi-wan-kenobi 2020-05-01 20:25:10 +02:00
parent 87915a34e9
commit a8ab4f9509
2 changed files with 27 additions and 2 deletions

View file

@ -1,6 +1,8 @@
import core.input
import core.decorators
import util.store
import util.format
class Widget(util.store.Store, core.input.Object):
def __init__(self, full_text='', name=None, module=None):
@ -9,6 +11,24 @@ class Widget(util.store.Store, core.input.Object):
self.module = module
self.name = name
def index(self):
if not self.module: return 0
idx = 0
for w in self.module.widgets():
if w.id == self.id:
return idx
idx = idx + 1
return -1 # not found
def theme(self, attribute):
attr = 'theme.{}'.format(attribute)
if self.module:
param = util.format.aslist(self.module.parameter(attr))
if param and len(param) > self.index():
return param[self.index()]
return self.get(attr)
def full_text(self, value=None):
if value:
self.__full_text = value