The officially official Devuan Forum!

You are not logged in.

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

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

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: 157  
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 2025-11-04 00:10:35

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

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 2025-11-04 05:56:23

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

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

#5 2025-11-05 14:15:51

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

Re: Using Windows URL files on Linux machines?

@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

Board footer