Launch executable with xdg-open

112

xdg-open is just a shell script that detects Desktop Environment and call the corresponding program (gvfs-open for gnome , exo-open for XFCE, mate-open, etc.)

So the limitations for launching an executable are derived from the corresponding launcher of each DE, which is gvfs-open in your case.

Looking at gvfs-open man page, this app (similar to the other DE apps) just calls the default application registered per file type as it is defined by gvfs-mime settings.

In your case , gvfs-open tries (and fails) to find a corresponding application to launch a firefox file.

If you run xdg-open (or gvfs-open) with an html link like https://www.google.com , then should work correctly; gvfs-open will search mime database to find how to handle the html link, mime will advise to call firefox, and firefox will be called.

Looking at xdg-open shell script functions, there are some functions that extract the Exec entry out of the corresponding .desktop file and under some Desktop Environments the command found in Exec section of .desktop file is just executed as it is by xdg-open.

In other words, you do not have to call xdg-open or gvfs-open to launch executables like firefox.

Just launch "firefox" and should be executed (i.e popen "/usr/bin/firefox")

PS: Or you might even need to call (exec firefox &)

You could even extract Exec entries by all .desktop files with a grep loop like this:

for file in $(find /usr/share/applications/ -type f -name '*.desktop'); do
    executable=$(grep -m1 "^Exec=" "$file") #some files have more than one Exec entry
    echo "$file - $executable"
done
Share:
112

Related videos on Youtube

Eric H
Author by

Eric H

Updated on September 18, 2022

Comments

  • Eric H
    Eric H almost 2 years

    I'm coming from a windows/.net background and am fairly new to Heroku/Node.js. In windows, it was typical on a web or database server to be able to set up a scheduled job that would run some sort of custom exe you could build with the MS toolchain. In Node on Heroku, I've come across something similar in agenda:

    https://github.com/rschmukler/agenda

    What confuses me is - would I add agenda tasks as part of my node server? That seems fundamentally bad that I'm mixing the web server with starting my scheduled tasks. Would it be a new app that I spin up on heroku that connects to the same DB under the covers? What is the correct infrastructure for a "scheduled task" in this ecosystem?