[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:
parent
87915a34e9
commit
a8ab4f9509
2 changed files with 27 additions and 2 deletions
|
@ -84,7 +84,7 @@ class block(object):
|
|||
for k in [
|
||||
'name', 'instance', 'separator_block_width', 'border', 'border_top',
|
||||
'border_bottom', 'border_left', 'border_right', 'markup',
|
||||
'_raw', '_suffix', '_prefix'
|
||||
'_raw', '_suffix', '_prefix', 'min_width'
|
||||
]:
|
||||
assign(self.__attributes, result, k)
|
||||
|
||||
|
@ -153,7 +153,12 @@ class i3(object):
|
|||
|
||||
def __content_block(self, module, widget):
|
||||
blk = block(self.__theme, module, widget)
|
||||
blk.set('min_width', widget.get('theme.minwidth'))
|
||||
minwidth = widget.theme('minwidth')
|
||||
if minwidth is not None:
|
||||
try:
|
||||
blk.set('min-width', '-'*int(minwidth))
|
||||
except:
|
||||
blk.set('min-width', minwidth)
|
||||
blk.set('full_text', self.__content[widget])
|
||||
if widget.get('pango', False):
|
||||
blk.set('markup', 'pango')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue