The officially official Devuan Forum!

You are not logged in.

#1 2025-11-01 20:16:11

Gnostic
Member
Registered: 2023-11-11
Posts: 9  

Using Windows URL files on Linux machines?

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

#2 2025-11-01 20:48:30

JWM-Kit
Member
Registered: 2020-06-29
Posts: 156  
Website

Re: Using Windows URL files on Linux machines?

wouldn't something like this be much simpler

#!/bin/sh
xdg-open $(grep -oP http.+ "${1}")

Offline

#3 Today 00:10:35

Gnostic
Member
Registered: 2023-11-11
Posts: 9  

Re: Using Windows URL files on Linux machines?

@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

#4 Today 05:56:23

stargate-sg1-cheyenne-mtn
Member
Registered: 2023-11-27
Posts: 412  

Re: Using Windows URL files on Linux machines?

man xdg-open

Be 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

Board footer