Invocation changed
-t/--test run test -c/--config specify config file
This commit is contained in:
parent
c86ab5e3ab
commit
42ab76dd3a
@ -1,11 +1,12 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import argparse
|
||||||
|
|
||||||
from .core import Status
|
from i3pystatus.core import Status
|
||||||
from .core.modules import Module, IntervalModule
|
from i3pystatus.core.modules import Module, IntervalModule
|
||||||
from .core.settings import SettingsBase
|
from i3pystatus.core.settings import SettingsBase
|
||||||
from .core.config import Config
|
from i3pystatus.core.config import Config
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"SettingsBase",
|
"SettingsBase",
|
||||||
@ -14,8 +15,13 @@ __all__ = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = Config()
|
parser = argparse.ArgumentParser(description='A replacement for i3status')
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == "test":
|
parser.add_argument("-c", "--config", action="store", help="Config file")
|
||||||
|
parser.add_argument("-t", "--test", action="store_true", help="Test modules")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
config = Config(config_file=args.config)
|
||||||
|
if args.test:
|
||||||
config.test()
|
config.test()
|
||||||
else:
|
else:
|
||||||
config.run()
|
config.run()
|
||||||
|
@ -39,9 +39,9 @@ class ConfigFinder:
|
|||||||
raise RuntimeError("Didn't find a config file, tried\n * {mods}".format(mods="\n * ".join(failed)))
|
raise RuntimeError("Didn't find a config file, tried\n * {mods}".format(mods="\n * ".join(failed)))
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self):
|
def __init__(self, config_file=None):
|
||||||
self.finder = ConfigFinder()
|
self.finder = ConfigFinder()
|
||||||
self.config_file = self.finder.find_config_file()
|
self.config_file = config_file or self.finder.find_config_file()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
runpy.run_path(self.config_file, run_name="i3pystatus._config")
|
runpy.run_path(self.config_file, run_name="i3pystatus._config")
|
||||||
|
@ -30,6 +30,9 @@ class Module(SettingsBase):
|
|||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def on_click(self, button):
|
def on_click(self, button):
|
||||||
if button == 1: # Left mouse button
|
if button == 1: # Left mouse button
|
||||||
self.on_leftclick()
|
self.on_leftclick()
|
||||||
|
Loading…
Reference in New Issue
Block a user