diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index b39aebb4..27659938 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -117,20 +117,31 @@ def chroot(args): not suffix.startswith("buildroot_")): raise RuntimeError("--user is only supported for native or" " buildroot_* chroots.") + if args.xauth and suffix != "native": + raise RuntimeError("--xauth is only supported for native chroot.") # apk: check minimum version, install packages pmb.chroot.apk.check_min_version(args, suffix) if args.add: pmb.chroot.apk.install(args, args.add.split(","), suffix) + # Xauthority + env = {} + if args.xauth: + pmb.chroot.other.copy_xauthority(args) + env["DISPLAY"] = os.environ.get("DISPLAY") + env["XAUTHORITY"] = "/home/pmos/.Xauthority" + # Run the command as user/root if args.user: logging.info("(" + suffix + ") % su pmos -c '" + " ".join(args.command) + "'") - pmb.chroot.user(args, args.command, suffix, output=args.output) + pmb.chroot.user(args, args.command, suffix, output=args.output, + env=env) else: logging.info("(" + suffix + ") % " + " ".join(args.command)) - pmb.chroot.root(args, args.command, suffix, output=args.output) + pmb.chroot.root(args, args.command, suffix, output=args.output, + env=env) def config(args): diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index 212cdfde..7d34dd89 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -493,6 +493,10 @@ def arguments(): default="tui") chroot.add_argument("command", default=["sh", "-i"], help="command" " to execute inside the chroot. default: sh", nargs='*') + chroot.add_argument("-x", "--xauth", action="store_true", + help="Copy .Xauthority and set environment variables," + " so X11 applications can be started (native" + " chroot only)") for action in [build_init, chroot]: suffix = action.add_mutually_exclusive_group() if action == chroot: