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

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 UrlOpener.desktop# Returns nothing so thinks file validdesktop-file-install --dir=~/.local/share/applications UrlOpener.desktop# Install it to my user (Also tried without --dir)update-desktop-database ~/.local/share/applications# Update the database (Unsure if needed if using above command)# Returns a list of errors in form: Could not parse file "/home/archie/.local/share/applications/Rimworld.desktop": No such file or directory# None of these are the one I tried to install and all appear red when checking folder with "ls"ls ~/.local/share/applications# Does not show my new file so it is failing to install the .desktop file I think but I do not know whyxdg-mime query filetype myurl.url# This returns application/x-mswinurlxdg-mime default UrlOpener.desktop application/x-mswinurl# Unsure how to find a list of all xdg-mime links to check what this did

The .desktop file:

[Desktop Entry]Version=1.0Name=UrlOpener        Comment=Opens Windows .url files in default browserExec=sh /home/Programs/UrlOpener.shIcon=utilities-terminalTerminal=trueType=ApplicationCategories=Utility;

The .sh file

#!/bin/bashbash -c "cat %f | grep -e '^URL=' | cut -d'=' -f2- | xargs xdg-open &"# I do not think this works as I want it to but I just want to get # the .desktop stuff working before I make it work correctly

Running Ubuntu 24.04 LTS with GNOME 46


Viewing all articles
Browse latest Browse all 6025

Trending Articles



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