Created
October 18, 2014 02:07
-
-
Save a0726h77/57c40427f948a1ca14f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Qtile 0.8.0 | |
# sysd widget sample | |
class Sysd(base.ThreadedPollText): | |
defaults = [ | |
( | |
'api_url_root', | |
'http://127.0.0.1:8080/', | |
'API URL Root' | |
), | |
( | |
'api_url_path', | |
'sysinfo', | |
'API URL Path' | |
), | |
( | |
'format', | |
'Uptime: {Uptime} sec', | |
'Display format' | |
), | |
] | |
def __init__(self, **config): | |
base.ThreadedPollText.__init__(self, **config) | |
self.add_defaults(Sysd.defaults) | |
def poll(self): | |
url = self.api_url_root + self.api_url_path | |
response = urlopen(url).read() | |
data = json.loads(response) | |
return self.format.format(**data) | |
screens = [ | |
Screen( | |
top=bar.Bar( | |
[ | |
Sysd(update_interval=1, foreground=foreground, background=background), | |
Sysd(api_url_path='sysinfo', format="Free: {Freeram}", update_interval=1, foreground=foreground, background=background), | |
], | |
30, | |
), | |
), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment