18

I have a .desktop file to start a python program in a specific conda environment, like this:

[Desktop Entry]
Version=1.0
Name=Qutebrowser
GenericName=Web Browser
Comment=View and edit files
MimeType=text/html;
Exec=bash -c "source /vol/home/kaipingga/anaconda3/bin/activate qutebrowser; qutebrowser"
Icon=/vol/home/kaipingga/.config/qutebrowser.svg
Type=Application
Terminal=false
Categories=Network;Utility;X-Python;
StartupWMClass=Qutebrowser
X-Desktop-File-Install-Version=0.20

This used to work, but I tweaked my python environment recently.

Now, in a terminal the same command

$ bash -c "source /vol/home/kaipingga/anaconda3/bin/activate qutebrowser; qutebrowser"

runs the application, but the .desktop file does not. How do I find out due to what error that is?

My other .desktop files run fine, I assume something goes wrong with my Python environment, which is quite hackish for the moment (which is the main reason to run this in a dedicated conda environment to start with).

Zachary Brady originally suggested (but there are issues) xdg-open might run .desktop files, but it gives me a message box saying

Error

Failed to add a plugin to the panel

No running instance of xfce4-panel was found

both for this .desktop and for another one that otherwise works. (I'm running plain Ubuntu, no xfce).

Anaphory
  • 692
  • 1
  • 5
  • 17
  • I deleted my answer after reading more into it [`xdg-open` has been bugged for quite a while](https://bugzilla.gnome.org/show_bug.cgi?id=343896) and only opens the desktop icons in text editors... – Zachary Brady Oct 27 '16 at 15:05
  • It turns out that the problem was an unsubstituted `~` (appearing as “`~`”, not as “`/home/anaphory`”) in the Python path, which I found out by adding `env > check;` in the middle of the command. But I'm sure there is a better way to debug this! – Anaphory Oct 27 '16 at 15:23
  • Desktop files are executed via menus, panels, or file managers. Which one are you using? – Nathaniel M. Beaver Aug 10 '20 at 14:30

5 Answers5

11

You can also use the validation tool desktop-file-validate to find more problems.

(see also: How to validate/verify .desktop files?)

# Result for your example
$ desktop-file-validate qutebrowser.desktop 
test.desktop: hint: value "Network;Utility;X-Python;" for key "Categories"
in group "Desktop Entry" contains more than one main category; application
might appear more than once in the application menu
Jonas Stein
  • 3,898
  • 4
  • 34
  • 55
  • That could be a useful program. Alas I tried it with a deliberately non-existant file path for the `Icon` and it reported nothing wrong. – user7543 May 31 '23 at 11:42
8

I normally add the following to see what is being executed:

Terminal=true
TerminalOptions=\s--noclose
user375770
  • 81
  • 1
  • 1
  • 1
    Please note: [TerminalOptions has been deprecated](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#deprecated-items) – Lockszmith Jun 03 '22 at 21:53
  • @Lockszmith do you know what should be used instead? The documentation seems only to say that TerminalOptions is deprecated, but it does not say why, or what to use instead. – gillesB Mar 29 '23 at 12:06
  • 2
    @gillesB take a look [here](https://www.linuxquestions.org/questions/linux-newbie-8/keep-terminal-window-open-after-running-a-desktop-launcher-4175722256-print/) - at the bottom, the suggestion to add `; read -n1` to the command might do the trick. – Lockszmith Mar 29 '23 at 15:11
1

On Linux Mint, the File Manager service is named nemo, nemo can be exited by issuing:

nemo -q

With your file manager stopped, you can open it in a terminal

nemo

It will now print its log to this terminal, when you go to open your *.desktop file, you should be able to see the stdout of your *.desktop's Exec line.

ThorSummoner
  • 4,312
  • 6
  • 30
  • 47
  • Oh, and when your done debugging, Ctrl+C the terminal running nemo, and open it via your start menu, or relog your desktop session. – ThorSummoner Mar 23 '17 at 02:14
  • It is rather the file manager of Cinnamon desktop which is maintained by the mint project https://github.com/linuxmint/nemo – Jonas Stein May 17 '23 at 09:26
0

xdg-open and exo-open are used for opening files (in their respective associated program). They were never meant to execute anything on their own. For executing the command defined by a desktop, you may use dex.

Hermann
  • 5,789
  • 2
  • 17
  • 32
0

I've been debugging a desktop file and found this useful article on the archlinux website.

https://wiki.archlinux.org/title/desktop_entries#Run_a_desktop_file_from_a_terminal

If gtk3 is installed, run gtk-launch application.desktop.
Or install the dex package and run dex /path/to/application.desktop.

It helped me see there was something wrong when misquoting my arguments. But in my case, I've got a successful result with gtk-launch application.desktop but not when launching through the Ubuntu 20.04 launcher

iNulty
  • 101
  • 1