-
-
Save zhasm/1099252 to your computer and use it in GitHub Desktop.
open for ubuntu
This file contains hidden or 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/env python | |
import gnomevfs | |
import sys | |
import commands | |
import os | |
try: | |
filename=os.path.abspath(sys.argv[1]) | |
except Exception, e: | |
print "Usage: %s <Filename>" % sys.argv[0] | |
exit() | |
try: | |
file_mimetype = gnomevfs.get_mime_type(filename) | |
except Exception, e: | |
print str(e) | |
exit() | |
try: | |
default_app= gnomevfs.mime_get_default_application(file_mimetype)[2] | |
cmd="%s %s" % (default_app, filename) | |
commands.getoutput(cmd) | |
except Exception, e: | |
print str(e) | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment