[main] Initial support for "-l" parameter
List all available modules and query their description, notes and usage.
This commit is contained in:
parent
b2e9515861
commit
598f3e70e9
2 changed files with 31 additions and 3 deletions
|
@ -1,6 +1,15 @@
|
||||||
import datetime
|
import datetime
|
||||||
import bumblebee.module
|
import bumblebee.module
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
return "battery::<battery ID, defaults to BAT0>"
|
||||||
|
|
||||||
|
def notes():
|
||||||
|
return "Reads /sys/class/power_supply/<ID>/[capacity|status]"
|
||||||
|
|
||||||
|
def description():
|
||||||
|
return "Displays battery status, percentage and whether it's charging or discharging"
|
||||||
|
|
||||||
class Module(bumblebee.module.Module):
|
class Module(bumblebee.module.Module):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
super(Module, self).__init__(args)
|
super(Module, self).__init__(args)
|
||||||
|
|
25
i3bumblebee
25
i3bumblebee
|
@ -1,22 +1,41 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import pkgutil
|
||||||
import argparse
|
import argparse
|
||||||
|
import textwrap
|
||||||
import importlib
|
import importlib
|
||||||
import bumblebee.theme
|
import bumblebee.theme
|
||||||
|
import bumblebee.modules
|
||||||
import bumblebee.outputs.i3
|
import bumblebee.outputs.i3
|
||||||
|
|
||||||
def print_module_list():
|
def print_module_list():
|
||||||
# TODO
|
print "available modules:"
|
||||||
pass
|
path = os.path.dirname(bumblebee.modules.__file__)
|
||||||
|
for mod in [ name for _, name, _ in pkgutil.iter_modules([path])]:
|
||||||
|
m = importlib.import_module("bumblebee.modules.{}".format(mod))
|
||||||
|
|
||||||
|
desc = "n/a" if not hasattr(m, "description") else getattr(m, "description")()
|
||||||
|
usage = "n/a" if not hasattr(m, "usage") else getattr(m, "usage")()
|
||||||
|
notes = "n/a" if not hasattr(m, "notes") else getattr(m, "notes")()
|
||||||
|
|
||||||
|
print " {}: ".format(mod)
|
||||||
|
print textwrap.fill("Description: {}".format(desc), 80, initial_indent=" ", subsequent_indent=" ")
|
||||||
|
print textwrap.fill("Usage : {}".format(usage), 80, initial_indent=" ", subsequent_indent=" ")
|
||||||
|
print textwrap.fill("Notes : {}".format(notes), 80, initial_indent=" ", subsequent_indent=" ")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="display system data in the i3bar")
|
parser = argparse.ArgumentParser(description="display system data in the i3bar")
|
||||||
parser.add_argument("-m", "--modules", nargs="+", help="List of modules to load. The order of the list determines their order in the i3bar (from left to right)")
|
parser.add_argument("-m", "--modules", nargs="+", help="List of modules to load. The order of the list determines their order in the i3bar (from left to right)")
|
||||||
parser.add_argument("-l", "--list", action="store_true", help="List all available modules and themes")
|
parser.add_argument("-l", "--list", action="store_true", help="List all available modules and themes")
|
||||||
parser.add_argument("-t", "--theme", help="Specify which theme to use for drawing the modulemoduless")
|
parser.add_argument("-t", "--theme", help="Specify which theme to use for drawing the modulemoduless")
|
||||||
parser.add_argument("-i", "--interval", help="Specify the update interaval", default=1, type=int)
|
parser.add_argument("-i", "--interval", help="Specify the update interval", default=1, type=int)
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
parser.print_help()
|
||||||
|
parser.exit()
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue