summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xurlopen.py34
1 files changed, 34 insertions, 0 deletions
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:]);