From a32b2493537d39a1170bada8adaf4533c410de6f Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Thu, 4 Dec 2014 19:23:52 +0100 Subject: module whoami QA and config --- py3status/modules/whoami.py | 27 +++++++++++++++------------ 1 file 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 -- cgit v1.3