-
-
Save wjt/3bd8eeefb2f3bc52033cdf84c4dc8682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import argparse | |
import subprocess | |
import sys | |
import os | |
import shlex | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-o", "--output", metavar="OUTFILE") | |
parser.add_argument("-L", "--label") | |
parser.add_argument("--comparison-file") | |
args, argv = parser.parse_known_args() | |
pre = ["flatpak", "run", "--file-forwarding", "--filesystem=/tmp"] | |
post = ["org.gnome.meld"] | |
if os.environ.keys() & {"TOOLBOX_PATH", "FLATPAK_ID"}: | |
if "TOOLBOX_PATH" in os.environ: | |
fxu = "/usr/libexec/flatpak-xdg-utils" | |
if fxu not in os.environ["PATH"]: | |
os.environ["PATH"] = ":".join((fxu, os.environ["PATH"])) | |
pre[0:0] = ["flatpak-spawn", "--host"] | |
if args.output: | |
post.extend(("@@", args.output, "@@")) | |
if args.comparison_file: | |
post.extend(("@@", args.comparison_file, "@@")) | |
if args.label: | |
post.extend(("--label", args.label)) | |
for arg in argv: | |
if arg.startswith("-"): | |
post.append(arg) | |
else: | |
post.extend(("@@", arg, "@@")) | |
cmd = pre + post | |
sys.stderr.write("$ {}\n".format(" ".join(map(shlex.quote, cmd)))) | |
sys.stderr.flush() | |
os.execvp(cmd[0], cmd) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment