Last active
September 29, 2017 12:01
-
-
Save larsemil/2f20262c6d8e52272647df39a7ee09f8 to your computer and use it in GitHub Desktop.
pip install dmenu
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/python | |
from dmenu import dmenu | |
import sys | |
import os | |
browser = 'xdg-open %s' | |
choices = { | |
'Open in thunar' : 'thunar %s', | |
'Open in firefox':'firefox %s', | |
} | |
if len(sys.argv) <2: | |
print("Call this with file url as argument.") | |
sys.exit() | |
if sys.argv[1][0:7] == 'file://': | |
# The url passed in to url-handler is a file:// url. | |
cmd = dmenu.show(choices.keys(), prompt='Choose application') | |
full_command = choices[cmd] % sys.argv[1] | |
else: | |
full_command = browser % sys.argv[1] | |
print(os.system(full_command)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment