diff options
author | Weitian LI <liweitianux@gmail.com> | 2014-06-13 21:12:21 +0800 |
---|---|---|
committer | Weitian LI <liweitianux@gmail.com> | 2014-06-13 21:12:21 +0800 |
commit | 78f7be4e4b6501b15b5fefc9f7824bbadf0daf2a (patch) | |
tree | b761e28709e4a6f45458c323b8870150827ef831 /.i3/py3status/backup/whoami.py | |
parent | e1ce158f65c472b7c8d14c04fce94c85bc881a6c (diff) | |
download | dotfiles-78f7be4e4b6501b15b5fefc9f7824bbadf0daf2a.tar.bz2 |
Added various dotfiles.
* Xresources
* profile, xprofile, xinitrc
* bash (aliases, logout, profile, rc, completion)
* gitconfig
* gtkrc and gtk-bookmarks
* i3 configs (with py3status configs)
* i3status.conf
* lftp/rc
* tmux.conf
* xbindkeysrc
* mpdconf
* ncmpcpp (config and keys)
* sbclrc
* vifm (vifmrc, colors)
* urxvt (perl extensions)
* conkyrc (and conky/cronograph configs)
Diffstat (limited to '.i3/py3status/backup/whoami.py')
-rw-r--r-- | .i3/py3status/backup/whoami.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/.i3/py3status/backup/whoami.py b/.i3/py3status/backup/whoami.py new file mode 100644 index 0000000..f930991 --- /dev/null +++ b/.i3/py3status/backup/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) |