Skip to content

Instantly share code, notes, and snippets.

@R3tr0BoiDX
Last active December 11, 2021 11:41
Show Gist options
  • Save R3tr0BoiDX/bbe044e0ec1c07a8fbe650923413df21 to your computer and use it in GitHub Desktop.
Save R3tr0BoiDX/bbe044e0ec1c07a8fbe650923413df21 to your computer and use it in GitHub Desktop.
Opens .desktop files in webbrowser. They are created by Cinnamon, when dropping a link from your webbrowser on the desktop. Windows (and often Cinnamon itself) can't open them. Open a .desktop file with this tool and it will open the URL in your default webbrowser.
import sys
import webbrowser
searchFor = "URL"
file = open(sys.argv[1])
for line in file:
if searchFor in line:
url = line[4:]
webbrowser.open(url)
print(url)
file.close()
@R3tr0BoiDX
Copy link
Author

Known bug: I don't know which character encoding Python is using, but it has problems parsing files with Cyrillic, Chinese, Greek, Japanese,... characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment