From 19bfe35fe3728a52127e57ebf8126a9cc8862eb2 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 1 Apr 2024 15:02:50 +0200 Subject: [PATCH] Added config path argument --- sbapp/main.py | 21 +++++++++++++++++---- sbapp/sideband/core.py | 14 +++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/sbapp/main.py b/sbapp/main.py index e936a15..e3dc64e 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -7,6 +7,7 @@ import sys import argparse parser = argparse.ArgumentParser(description="Sideband LXMF Client") parser.add_argument("-v", "--verbose", action='store_true', default=False, help="increase logging verbosity") +parser.add_argument("-c", "--config", action='store', default=None, help="specify path of config directory") parser.add_argument("-d", "--daemon", action='store_true', default=False, help="run as a daemon, without user interface") parser.add_argument("--version", action="version", version="sideband {version}".format(version=__version__)) args = parser.parse_args() @@ -182,10 +183,15 @@ class SidebandApp(MDApp): self.no_transition = NoTransition() self.slide_transition = SlideTransition() - if RNS.vendor.platformutils.get_platform() == "android": - self.sideband = SidebandCore(self, is_client=True, android_app_dir=self.app_dir, verbose=__debug_build__) + if args.config != None: + self.config_path = os.path.expanduser(args.config) else: - self.sideband = SidebandCore(self, is_client=False, verbose=(args.verbose or __debug_build__)) + self.config_path = None + + if RNS.vendor.platformutils.get_platform() == "android": + self.sideband = SidebandCore(self, config_path=self.config_path, is_client=True, android_app_dir=self.app_dir, verbose=__debug_build__) + else: + self.sideband = SidebandCore(self, config_path=self.config_path, is_client=False, verbose=(args.verbose or __debug_build__)) self.set_ui_theme() self.font_config() @@ -4972,7 +4978,14 @@ if not args.daemon: def run(): if args.daemon: RNS.log("Starting Sideband in daemon mode") - sideband = SidebandCore(None, is_client=False, verbose=(args.verbose or __debug_build__), is_daemon=True) + sideband = SidebandCore( + None, + config_path=args.config, + is_client=False, + verbose=(args.verbose or __debug_build__), + is_daemon=True + ) + sideband.start() while True: time.sleep(5) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index d457f7a..ba64c47 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -106,7 +106,7 @@ class SidebandCore(): # stream logger self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter) - def __init__(self, owner_app, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False): + def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False): self.is_service = is_service self.is_client = is_client self.is_daemon = is_daemon @@ -139,10 +139,14 @@ class SidebandCore(): self.service_context = service_context self.owner_service = owner_service - self.app_dir = plyer.storagepath.get_home_dir()+"/.config/sideband" - if self.app_dir.startswith("file://"): - self.app_dir = self.app_dir.replace("file://", "") - self.cache_dir = self.app_dir+"/cache" + if config_path == None: + self.app_dir = plyer.storagepath.get_home_dir()+"/.config/sideband" + if self.app_dir.startswith("file://"): + self.app_dir = self.app_dir.replace("file://", "") + else: + self.app_dir = config_path + + self.cache_dir = self.app_dir+"/cache" self.rns_configdir = None if RNS.vendor.platformutils.is_android():