-
-
Save wjt/707fe6017be058d8ea81fce2d90c8b3f to your computer and use it in GitHub Desktop.
I save this file as ~/.local/bin/meld
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"] | |
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