-###############
-# KEYBINDINGS #
-###############
+###############################################################################
+# LIGHTCARDS DEFAULT CONFIG FILE #
+###############################################################################
+
+###############################################################################
+# STARTUP OPTIONS
+
+alphabetize = False
+shuffle = False
+reverse = False
+cache = True
+
+default_view = 1
+
+###############################################################################
+# APPEARANCE
+
+disp_progress = True
+progress_char = "ยป"
+disp_sidebar = True
+disp_bar = True
+
+bar_sections = ["starred_status", "starred_count", "side", "view"]
+
+highlight_color = "green"
+starred_color = "yellow"
+
+###############################################################################
+# KEYBINDINGS
card_prev = ["h", "KEY_LEFT"]
card_next = ["l", "KEY_RIGHT"]
view_one = "1"
view_two = "2"
view_three = "3"
+
+###############################################################################
+# OTHER
+
+confirm_quit = True
+debug = False
+
+###############################################################################
sys.exit(4)
-def find_file(file):
+def read_file(file):
+ config = {}
file = str(file)
+ files = []
local_xdg = f"{os.path.expanduser('~')}/{os.environ.get('XDG_CACHE_HOME')}/lightcards/config.py"
local = f"{os.path.expanduser('~')}/.config/lightcards/config.py"
world = "/etc/lightcards/config.py"
f"{os.path.expanduser('~')}/.local/share/doc/lightcards/config.py"
)
+ if os.path.exists(world_default):
+ files.append(world_default)
+ if os.path.exists(local_default):
+ files.append(local_default)
+ if os.path.exists(world):
+ files.append(world)
+ if os.path.exists(local_xdg):
+ files.append(local_xdg)
+ if os.path.exists(local):
+ files.append(local)
if os.path.exists(file):
- return file
- elif os.path.exists(local_xdg):
- return local_xdg
- elif os.path.exists(local):
- return local
- elif os.path.exists(world):
- return world
- elif os.path.exists(world_default):
- return world_default
- elif os.path.exists(local_default):
- return local_default
-
+ files.append(file)
-def read_file(file):
- config = {}
- exec(Path(str(find_file(file))).read_text(), {}, config)
+ for f in files:
+ exec(Path(str(f)).read_text(), {}, config)
return config
import textwrap
import time
-from . import runner, progress, parse, config
+from . import runner, progress, parse
def panel_create(x, y):
class Display:
- def __init__(self, stack, headers, obj, view, args):
+ def __init__(self, stack, headers, obj, view, args, conf):
self.stack = stack
self.headers = headers
self.obj = obj
self.view = view
self.input_file = args.inp[0]
- self.config = config.read_file(args.config)
+ self.config = conf
def run(self, stdscr):
"""Set important options that require stdscr before starting"""
import argparse
import curses
-import os
import pkg_resources
from random import shuffle
import sys
-from . import parse, progress
+from . import parse, progress, config
from .display import Display, CursesError
from .deck import Status
return parser.parse_args()
-def show(args, stack, headers, input_file):
+def show(args, stack, headers, conf):
"""
Get objects from cache, manipulate deck according to passed arguments, and
send it to the display functions
stack.reverse()
# Send to display
- win = Display(stack, headers, idx, args.view, input_file)
+ win = Display(stack, headers, idx, args.view, args, conf)
try:
curses.wrapper(win.run)
except curses.error as e:
def main(args=sys.argv):
- sys.tracebacklimit = 0
args = parse_args()
global headers, stack
(headers, stack) = parse.parse_html(parse.md2html(args.inp[0]))
- show(args, stack, headers, args)
+ conf = config.read_file(args.config)
+
+ if not conf["debug"]:
+ sys.tracebacklimit = 0
+
+ show(args, stack, headers, conf)
if __name__ == "__main__":