From a0d1d54170f6bd12cc4429d808133701f999fe91 Mon Sep 17 00:00:00 2001 From: linyimin <18316471919@139.com> Date: Thu, 25 Dec 2025 14:25:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=83=A7=E5=BD=95?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- set_autostart.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 set_autostart.py diff --git a/set_autostart.py b/set_autostart.py new file mode 100644 index 0000000..38de82b --- /dev/null +++ b/set_autostart.py @@ -0,0 +1,56 @@ +import configparser, os + +def parse_apps_info(): + info_path = "/maixapp/apps/app.info" + conf = configparser.ConfigParser() + conf.read(info_path) + version = conf["basic"]["version"] + apps = {} + for id in list(conf.keys()): + if id in ["basic", "DEFAULT"]: + continue + apps[id] = conf[id] + return apps + +def list_apps(): + apps = parse_apps_info() + print(f"APP num: {len(apps)}") + for i, (id, info) in enumerate(apps.items()): + name_zh = info.get("name[zh]", "") + print(f"{i + 1}. [{info['name']}] {name_zh}:") + print(f" id: {id}") + print(f" exec: {info['exec']}") + print(f" author: {info['author']}") + print(f" desc: {info['desc']}") + print(f" desc_zh: {info.get('desc', 'None')}") + print("") + + +def get_curr_autostart_app(): + path = "/maixapp/auto_start.txt" + if os.path.exists(path): + with open(path, "r") as f: + app_id = f.readline().strip() + return app_id + return None + +def set_autostart_app(app_id): + path = "/maixapp/auto_start.txt" + if not app_id: + if os.path.exists(path): + os.remove(path) + return + with open(path, "w") as f: + f.write(app_id) + os.sync() + +if __name__ == "__main__": + new_autostart_app_id = "t11" # change to app_id you want to set + # new_autostart_app_id = None # remove autostart + + list_apps() + print("Before set autostart appid:", get_curr_autostart_app()) + set_autostart_app(new_autostart_app_id) + print("Current autostart appid:", get_curr_autostart_app()) + +