]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/__init__.py
Add first-launch command
[waydroid.git] / tools / __init__.py
index 7c948d452e36810cf97076ac0ba04aad56ae3ade..df427524901becd9d281269006948f4df45611e6 100644 (file)
@@ -5,6 +5,7 @@ import sys
 import logging
 import os
 import traceback
+import subprocess
 
 from . import actions
 from . import config
@@ -31,15 +32,26 @@ def main():
         args.sudo_timer = True
         args.timeout = 1800
 
-        if not os.path.isfile(args.config):
-            if args.action and args.action != "init":
-                print('ERROR: WayDroid is not initialized, run "waydroid init"')
-                return 0
+        if not actions.initializer.is_initialized(args):
+            if args.action and (args.action not in ("init", "first-launch", "log")):
+                if not args.wait_for_init:
+                    print('ERROR: WayDroid is not initialized, run "waydroid init"')
+                    return 0
+
+                print('WayDroid waiting for initialization...')
+                while helpers.ipc.listen(channel="init") != "done":
+                    pass
+
             elif os.geteuid() == 0 and args.action == "init":
                 if not os.path.exists(args.work):
                     os.mkdir(args.work)
             else:
-                args.log = "/tmp/tools.log"
+                # This branch is taken if:
+                # - waydroid is not yet initialized
+                # - waydroid is invoked with no command or with log
+                if not os.path.exists(args.log):
+                    # The log could have been already created if init was used and failed, if its not the case we use a temporary one
+                    args.log = "/tmp/tools.log"
 
         tools_logging.init(args)
 
@@ -80,6 +92,8 @@ def main():
                 actions.app_manager.remove(args)
             elif args.subaction == "launch":
                 actions.app_manager.launch(args)
+            elif args.subaction == "intent":
+                actions.app_manager.intent(args)
             elif args.subaction == "list":
                 actions.app_manager.list(args)
             else:
@@ -103,6 +117,10 @@ def main():
             helpers.lxc.logcat(args)
         elif args.action == "show-full-ui":
             actions.app_manager.showFullUI(args)
+        elif args.action == "first-launch":
+            subprocess.run(["pkexec", sys.argv[0], "init", "--gui"])
+            if actions.initializer.is_initialized(args):
+                actions.app_manager.showFullUI(args)
         elif args.action == "status":
             actions.status.print_status(args)
         elif args.action == "log":