Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

How do you create a .desktop file to run an .sh script?

$
0
0

Problem:
I want to open Windows's .url files in linux

Attempted Solution:
I set application/x-mswinurl's default program to run a script that parses the .url file as text then opens the URL in my default browser.

What I have tried:

desktop-file-validate archiev1-UrlOpener.desktop# Returns nothing so thinks file validdesktop-file-install --dir=~/.local/share/applications UrlOpener.desktop# Install it to my userupdate-desktop-database# Update the database (Unsure if needed if using above command)# I would expect it to appear now in the Gnome search but it does notls ~/.local/share/applications -l# Shows my new file (With same permissions as the others, not +x)xdg-mime query filetype myurl.url# This returns application/x-mswinurlxdg-mime default archiev1-UrlOpener.desktop application/x-mswinurlxdg-mime query default application/x-mswinurl# Returns my file so it did register it# Does not appear as an option in the Nautilus file explorer under "open with" (Likely because it is not registered as a program?)

The .desktop file:

[Desktop Entry]Version=1.0Name=UrlOpenerComment=Opens Windows url files in default browserExec=/home/Programs/UrlOpener/UrlOpener.shIcon=utilities-terminalTerminal=trueType=ApplicationMimeType=application/x-mswinurl;Categories=Utility;

The .sh file

#!/bin/bashcat %f | grep -e '^URL=' | cut -d'=' -f2- | xargs xdg-open &

Running Ubuntu 24.04 LTS with GNOME 46

EDIT 2024/06/24:Updated with my new attempts fixing all issues @Tim mentioned


Viewing all articles
Browse latest Browse all 6015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>