Skip to content

Instantly share code, notes, and snippets.

@dmpayton
Created June 27, 2012 21:18
Show Gist options
  • Save dmpayton/3006925 to your computer and use it in GitHub Desktop.
Save dmpayton/3006925 to your computer and use it in GitHub Desktop.
from libqtile.widgets.base import _TextBox
from libqtile import hook, bar, manager
class _StatusWidget(_TextBox):
''' Status Widget Base Class
'''
defaults = manager.Defaults(
## Required defaults
('font', 'Arial', 'Font'),
('fontsize', None, 'Pixel size, calculated if None.'),
('padding', None, 'Padding, calculated if None.'),
('background', '000000', 'Background colour'),
('foreground', 'ffffff', 'Foreground colour'),
## Additional config options here
('update_interval', 600, 'Update interval in seconds'),
)
def __init__(self, **config):
base._TextBox.__init__(self, 'N/A', width=bar.CALCULATED, **config)
def _configure(self, qtile, bar):
## Configure and set the timer
base._TextBox._configure(self, qtile, bar)
self.timeout_add(self.update_interval, self.update)
def click(self, x, y, button):
## Manually update the widget by clicking it
self.update()
def update(self):
raise NotImplemented
class TopBarStatus(_StatusWidget):
def update(self):
## Do stuff to update the widget text.
self.text = 'this is the top bar'
self.bar.draw()
return True
class BottomBarStatus(_StatusWidget):
def update(self):
## Do stuff to update the widget text.
self.text = 'this is the bottom bar'
self.bar.draw()
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment