Added config path argument

This commit is contained in:
Mark Qvist 2024-04-01 15:02:50 +02:00
parent 8375ea224a
commit 19bfe35fe3
2 changed files with 26 additions and 9 deletions

View File

@ -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)

View File

@ -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,9 +139,13 @@ class SidebandCore():
self.service_context = service_context
self.owner_service = owner_service
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