You are not logged in.
Pages: 1
Folks on my local network like to bookmark websites by dragging & dropping from the browser address bar into their file manager.
On Windows machines that creates an Internet Shortcut URL file.
For example, for Pi-Hole it will contain this:
[InternetShortcut]
URL=https://pi-hole.net/
How to make that useful on a Linux machine?
I've written a tiny bit of Python that seems to work.
# UseDesktopLink.py
import sys
import webbrowser
script, filename = sys.argv
file_object = open(filename,'r')
for line in file_object:
#print(line)
if line[0:4]=="URL=":
url=line[4:]
#print("url=",url)
# just in case the line has msdos cr-lf, remove that
url=url.replace('\x0d\x0a', '')
# or just Linux LF
url=url.replace('\x0a', '')
webbrowser.open_new(url)
file_object.close()
I intended it to work with a right-click on the URL file and "Open with ..", "Set default application" then a custom command.
python UseDesktopLink.py %f
But it's not working.
What might I have forgotten to do?
Offline
wouldn't something like this be much simpler
#!/bin/sh
xdg-open $(grep -oP http.+ "${1}")Offline
@jwm-kit
Thanks, and please excuse my ignorance, how can I use that with "Open with" ?
Would it be "Open with other application" or "Set default application" ?
Or something else?
Offline
man xdg-openBe Excellent to each other and Party On!
https://www.youtube.com/watch?v=rph_1DODXDU
https://en.wikipedia.org/wiki/Bill_%26_Ted%27s_Excellent_Adventure
Do unto others as you would have them do instantaneously back to you!
Offline
@Gnostic
The set default application is probably what you want. How you configure it in file manager will vary depending on the file manager.
With Thunar (XFCE)
Give the script exec permission.
Right click on a file that is of the type you want to make the default, and choose Open With > Set Default Application
Enter the path to the script in the custom command entry ( or use the browse button to find the script)
Ensure the "Use as default for this kind of file" is checked and then click open.
NOTE : adding the %f after the path is not needed.
Offline
Pages: 1