1

Im trying to make a .desktop file run a .sh which is stored in the same directory as the .desktop. The whole directory needs to be portable and moved from machine to machine.

Now I can get the current path for EXEC command using the method from :

Getting the current path in .desktop EXEC command

Exec=bash -c '"$(dirname "$1")"/run.sh' dummy %k

But now I also want it to load icon from the same directory so that it becomes completely portable. But didn't get any success but using the approach as suggested for EXEC command.

This is what I tried:

Icon=bash -c '"$(dirname "$1")"/run.sh' dummy %k

and

Icon=bash -c '"$(pwd)"/data/planet_image_gray.png'

But none seem to work. I hope there is a solution to this.

Thanks in advance.

4

That trick works for the EXEC entry because it runs a command, but it doesn't work for ICON because it expects either a standard icon name that it can locate in the /usr/share/icons/ directories, or an absolute pathname to a custom image. Modern versions of Desktop don't even accept relative pathnames for custom images.

If you really must have a custom image in your portable directory it's possible, but a bit messy. You could do it by having an install script that you run when you move the directory to a new location. The install script would generate a new .desktop file customised for its current location, either using details stored in the script itself, or by using a template file. But that sounds like a lot of messing around to me...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.