From 0d0c62f6f5f7ae99c8204c82bf942432e796a270 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Wed, 31 Jan 2018 08:43:43 +1030 Subject: first code commit --- urlopen.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 urlopen.py diff --git a/urlopen.py b/urlopen.py new file mode 100755 index 0000000..ee16a13 --- /dev/null +++ b/urlopen.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python2.7 +import sys, os; + +def run(process, arg): + L = []; + for each in process: + L.append(each); + L.append(arg); + os.spawnvpe(os.P_NOWAIT, L[0], L, os.environ) + +def main(args): + images = ["jpg", "png"]; imageapp = ["feh"]; + videos = ["gif", "webm", "mp4"]; videoapp = ["mpv", "--loop"]; + pdf = ["pdf"]; pdfapp = ["mupdf"]; + defaultapp = ["/home/daniel_j/compiled/waterfox/waterfox"]; + x = 0; + for each in args: + if (each.endswith(tuple(images))): + print("image {}".format(each)); + run(imageapp, each); + elif (each.endswith(tuple(videos))): + print("video {}".format(each)); + run(videoapp, each); + elif (each.endswith(tuple(pdf))): + print("pdf {}".format(each)); + run(pdfapp, each); + else: + print("running with default application {}".format(each)); + run(defaultapp, each); + x += 1; + +if __name__ == "__main__": + if sys.argv > 0: + main(sys.argv[1:]); -- cgit v1.2.3