[main] Add available themes to listing output

This commit is contained in:
Tobias Witek 2016-10-31 16:47:34 +01:00
parent c0421163d4
commit f02c49286b
2 changed files with 16 additions and 2 deletions

View file

@ -1,13 +1,16 @@
import os import os
import json import json
def getpath():
return os.path.dirname("{}/themes/".format(os.path.dirname(os.path.realpath(__file__))))
class Theme: class Theme:
_cycle_index = 0 _cycle_index = 0
_cycle = None _cycle = None
def __init__(self, name="default"): def __init__(self, name="default"):
self._data = None self._data = None
path = os.path.dirname(os.path.realpath(__file__)) path = os.path.dirname(os.path.realpath(__file__))
with open("{}/themes/{}.json".format(path, name)) as f: with open("{}/{}.json".format(getpath(), name)) as f:
self._data = json.load(f) self._data = json.load(f)
self._defaults = self._data.get("defaults", {}) self._defaults = self._data.get("defaults", {})
self._cycle = self._defaults.get("cycle", []) self._cycle = self._defaults.get("cycle", [])

View file

@ -3,6 +3,7 @@
import os import os
import sys import sys
import time import time
import glob
import pkgutil import pkgutil
import argparse import argparse
import textwrap import textwrap
@ -25,7 +26,16 @@ def print_module_list():
print textwrap.fill("Description: {}".format(desc), 80, initial_indent=" ", subsequent_indent=" ") 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("Usage : {}".format(usage), 80, initial_indent=" ", subsequent_indent=" ")
print textwrap.fill("Notes : {}".format(notes), 80, initial_indent=" ", subsequent_indent=" ") print textwrap.fill("Notes : {}".format(notes), 80, initial_indent=" ", subsequent_indent=" ")
print "\n" print ""
def print_theme_list():
d = bumblebee.theme.getpath()
print "available themes:"
print textwrap.fill(", ".join(
[ os.path.basename(f).replace(".json", "") for f in glob.iglob("{}/*.json".format(d)) ]),
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")
@ -42,6 +52,7 @@ def main():
if args.list: if args.list:
print_module_list() print_module_list()
print_theme_list()
sys.exit(0) sys.exit(0)
modules = [] modules = []