From 0a3679510e058ba44e13bf27007c516fa7dff54e Mon Sep 17 00:00:00 2001 From: Igor Sharonov Date: Tue, 14 Jun 2016 21:37:08 +0300 Subject: [PATCH 1/2] Treat i3pystatus as launcher --- i3pystatus/__init__.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/i3pystatus/__init__.py b/i3pystatus/__init__.py index e6c4ac8..9b9ce8d 100644 --- a/i3pystatus/__init__.py +++ b/i3pystatus/__init__.py @@ -5,6 +5,8 @@ from i3pystatus.core.modules import Module, IntervalModule from i3pystatus.core.settings import SettingsBase from i3pystatus.core.util import formatp, get_module +import argparse +import imp import logging import os @@ -25,9 +27,23 @@ logger.addHandler(handler) logger.setLevel(logging.CRITICAL) -def main(): +def clock_example(): from i3pystatus.clock import Clock status = Status() status.register(Clock()) status.run() + + +def main(): + parser = argparse.ArgumentParser(description=''' + run i3pystatus configuration file. Starts i3pystatus clock example if no arguments were provided + ''') + parser.add_argument('-c', '--config', help='path to configuration file', default=None, required=False) + args = parser.parse_args() + + if args.config: + module_name = "i3pystatus-config" + imp.load_source(module_name, args.config) + else: + clock_example() From d3ca35ccfb70153cfe8a5d79748abbaf3e6dcb59 Mon Sep 17 00:00:00 2001 From: Igor Sharonov Date: Tue, 12 Jul 2016 23:23:30 +0300 Subject: [PATCH 2/2] Update docs --- docs/configuration.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index 4ff694e..56852c1 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -123,6 +123,16 @@ Also change your i3wm config to the following: .. note:: Don't name your config file ``i3pystatus.py``, as it would make ``i3pystatus`` un-importable and lead to errors. +Another way to launch your configuration file is to use ``i3pystatus`` script +from installation: + +.. code:: bash + + i3pystatus -c ~/.path/to/your/config/file.py + +If no arguments were provided, ``i3pystatus`` script works as an example of +``Clock`` module. + .. _credentials: Credentials