diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-12-04 19:23:52 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-12-04 19:23:52 +0100 |
| commit | a32b2493537d39a1170bada8adaf4533c410de6f (patch) | |
| tree | b172d81db1ea699d664ceca02d08980851c857ad | |
| parent | 67b7b5f44c765f0bfa0b19b57535b366d465803d (diff) | |
module whoami QA and config
| -rw-r--r-- | py3status/modules/whoami.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/py3status/modules/whoami.py b/py3status/modules/whoami.py index f930991..11ca9bf 100644 --- a/py3status/modules/whoami.py +++ b/py3status/modules/whoami.py @@ -1,26 +1,29 @@ +""" +Simply output the currently logged in user in i3bar. + +Inspired by i3 FAQ: + https://faq.i3wm.org/question/1618/add-user-name-to-status-bar/ +""" + from getpass import getuser from time import time class Py3status: - """ - Simply output the currently logged in user in i3bar. - Inspired by i3 FAQ: - https://faq.i3wm.org/question/1618/add-user-name-to-status-bar/ - """ + # available configuration parameters + cache_timeout = 1800 + def whoami(self, i3status_output_json, i3status_config): """ We use the getpass module to get the current user. """ - # the current user doesnt change so much, cache it good - CACHE_TIMEOUT = 600 - # here you can change the format of the output # default is just to show the username username = '{}'.format(getuser()) - # set, cache and return the output - response = {'full_text': username, 'name': 'whoami'} - response['cached_until'] = time() + CACHE_TIMEOUT - return (0, response) + response = { + 'cached_until': time() + self.cache_timeout, + 'full_text': username + } + return response |
