diff options
| -rw-r--r-- | README.rst | 1 | ||||
| -rwxr-xr-x | py3status/__init__.py | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -77,6 +77,7 @@ You can see the help of py3status by issuing `py3status -h`: -s, --standalone standalone mode, do not use i3status -t CACHE_TIMEOUT default injection cache timeout in seconds (default 60 sec) + -v, --version show py3status version and exit Control ======= diff --git a/py3status/__init__.py b/py3status/__init__.py index fb452bd..e453cda 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -598,6 +598,14 @@ class Py3statusWrapper(): 'interval': 1 } + # package version + try: + import pkg_resources + version = pkg_resources.get_distribution('py3status').version + except: + version = 'unknown' + config['version'] = version + # command line options parser = argparse.ArgumentParser( description='The agile, python-powered, i3status wrapper') @@ -626,8 +634,21 @@ class Py3statusWrapper(): default=config['cache_timeout'], help="""default injection cache timeout in seconds (default 60 sec)""") + parser.add_argument('-v', '--version', action="store_true", + help="""show py3status version and exit""") options = parser.parse_args() + # only asked for version + if options.version: + from platform import python_version + print( + 'py3status version {} (python {})'.format( + config['version'], + python_version() + ) + ) + sys.exit(0) + # override configuration and helper variables config['cache_timeout'] = options.cache_timeout config['debug'] = options.debug |
