diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2014-11-23 20:55:53 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2014-11-23 20:55:53 +0100 |
| commit | d9747b64e1e62abee12ef0bafd365cf380ff7fe9 (patch) | |
| tree | 11a1d156c38ec96b83b4a1780719fc856cbbebad /py3status/modules/whoami.py | |
| parent | 62b2bd2251997bf8608e9620d91f688585221040 (diff) | |
move modules folder so we can install it as a module of py3status
Diffstat (limited to 'py3status/modules/whoami.py')
| -rw-r--r-- | py3status/modules/whoami.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/py3status/modules/whoami.py b/py3status/modules/whoami.py new file mode 100644 index 0000000..f930991 --- /dev/null +++ b/py3status/modules/whoami.py @@ -0,0 +1,26 @@ +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/ + """ + 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) |
