3

I have a .desktop file that launches an app, and it uses the .desktop icon:

[Desktop Entry]
Name=My Ro
Type=Application
Comment=Web Application
Exec=/path/to/myapp -test
Icon=/opt/giteye/icon.xpm
Name[en_US]=My Ro

I want to use a shell script instead to launch this app because with shell script i can pass the script command line arguments which then get passed to the launching app.

#!/bin/sh
nohup /path/to/myapp -test "$@" &

However with shell script the icon is not that of the shell file. It uses the default icon of the myapp. Is there anyway to make this behave as the .desktop and make the shell launch the app with custom icon?

EDIT - I tried giving the desktop entry path to shell

One desktop entry:

[Desktop Entry]
Name=Firefox
Type=Application
Comment=Web Application
Exec=/home/yasir/Desktop/launchers/Mozilla\ Firefox\ -\ test.sh
Icon=/home/yasir/Desktop/customFx.png
Name[en_US]=Firefox

Another desktop:

[Desktop Entry]
Name=Firefox Safe Mode
Type=Application
Comment=Web Application
Exec=/home/yasir/Desktop/launchers/Mozilla\ Firefox\ -\ test.sh -safe-mode
Icon=/home/yagt/Documents/fxSafe.png
Name[en_US]=Firefox Safe Mode

Shell:

#!/bin/sh
nohup /usr/lib/firefox/firefox "$@" &
yatg
  • 131
  • Have you tried giving the path to script as Exec in .desktop file? – Ron Jul 03 '15 at 11:12
  • Thanks @Ron please see my updated topic post. I added the code for two of my desktop entries. First one launches the shell script with no args, it launches Firefox no problem, it doesnt use my custom icon however. My second desktop entry launches firefox with -safe-mode and it doesnt take the icon. :( – yatg Jul 06 '15 at 16:57
  • I know I can bypass the .sh by putting this code directly into the exec line of the .desktop and it does take the custom icon, however desktop entries cannot take command line arguments which is what i badly need. http://stackoverflow.com/questions/31196869/desktop-with-command-line-args-passed-to-exec-similar-to-shell-script/31196950#31196950 – yatg Jul 06 '15 at 16:59
  • I am hoping for the shell to use the custom icon, as .desktop files as an intermediary defeats the purpose of having a single file that accepts command line arguments. – yatg Jul 06 '15 at 17:01

1 Answers1

1

There arises no reason to do this. That's exactly why it is not possible. If you are going to pass arguments other than the arguments allowed, then you will be invoking it from a command line, in which case there is not reason to have an icon. In that case, you wont be using a .desktop file, but a script directly.

Add...  Accepts...
%f  a single filename.
%F  multiple filenames.
%u  a single URL.
%U  multiple URLs.
%d  a single directory. Used in conjunction with %f to locate a file.
%D  multiple directories. Used in conjunction with %F to locate files.
%n  a single filename without a path.
%N  multiple filenames without paths.
%k  a URI or local filename of the location of the desktop file.
%v  the name of the Device entry.

These are the allowed arguments, which are passed from within the GUI, like for example, by dragging a file to the .desktop file.

Here is an example usage.

daltonfury42
  • 5,499