How can I specify an icon with a RELATIVE path for a Linux desktop entry file?

后端 未结 3 1704
梦谈多话
梦谈多话 2021-02-05 10:04

For one of my Linux applications, I have the application binary, a launcher.sh script (for the LD_LIBRARY_PATH) and a .desktop file, all in the same folder.

I\'d like to

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 10:31

    After doing some more research it doesn't look like it's possible to specify relative paths for an icon in a desktop entry file as far as I can see.

    The workaround I used was to add the following code to the end of my launcher.sh script:

    mv myapp.desktop myapp.desktop-bak
    sed -e "s,Icon=.*,Icon=$PWD/app.svg,g" myapp.desktop-bak > myapp.desktop
    rm myapp.desktop-bak
    

    This will update the path of the icon each time the launcher script is run, and since the .desktop file points to the launcher script, clicking the .desktop file effectively updates its icon.

    I know you could use cat or the -i option to shorten the above code but I've read that the solution I used is more reliable. If anyone has further information on that please do post a comment.

提交回复
热议问题