Skip to main content
4 of 5
improved formatting

In your .desktop file write:

Exec=sh -c 'java -jar "$HOME"/.minecraft/Minecraft.jar'

Sample 2:

Exec=sh -c "u=%u; k=%k; c=%c;"' kd="$k"; [ -f "$kd" ] && kd=`dirname "$k"`; xx'

Explanation:

  • All terms like double-quote, quoting, meta-chars (like $ and ~) are always s h e l l - r e l a t e d - the shell (command-interpreter like bash or dash) is (by the way) independent from any terminal (like xterm).

  • When you want the tilde or the shell-var $HOME to be EXPANDED to sth. like /home/myloginname this can only be done by /bin/bash or /bin/sh (==/bin/dash).

  • The xdg-desktop-interpreter's Exec-line needs a real program (path-to-a-bin-file) and will never expand any shell-stuff directly, but by providing the sh-command with the option -c 'command-string; cmd... ; cmd...' all should work fine.

  • %u is a "xdg-placeholder" and is changed into DnD-URL independently (before the shell-command-line is executed)

  • Note that you can comment out lines in a .desktop file with # ...

P.S.:

! case   coproc   do  done elif else esac fi for function if in select
then until while { } time [[ ]]

are all "reserved words" (don't confuse this with the shell's built-in-cmds), but ~ and $ are meta-chars (the tilde must be un-quoted to be expanded, while $MYVAR may be quoted, if it contain SPACES inside a path)

kind regards EOF