是否有一种方法可以使发射器使用相对路径?如果没有,是否有另一种方法可以实现我想要的功能(即使用相对路径指定的带有图标和可执行文件的快捷方式)?解决方案不支持相对路径*.一种解决方案是拥有安装程序.该脚本根据脚本运行的位置来更新桌面文件.使脚本可执行,用户可以单击它进行安装.该脚本要求桌面文件可写.这是在考虑Linux的情况下完成的.该文件名为 autorun.sh ;但这只是一个约定,通常不会自动运行.如果您将其部署在Linux以外的其他操作系统上,请将该文件命名为其他名称( autorun.linux ),或者根据平台将其改编为执行其他操作.#! /bin/sh#### Fixup $APPNAME.desktop.APPNAME=xvscatterICONNAME=xv_logo.pngcd $(dirname "$0")APPDIR="$PWD/$APPNAME"EXEC="$APPDIR/$APPNAME"ICON="$APPDIR/$ICONNAME"sed -i -e "s@^Icon=.*@Icon=$ICON@" \ -e "s@^Exec.*@Exec=$EXEC@" "$APPNAME.desktop" * freedesktop的约定将在$ HOME/.icons,/usr/share/icons或/usr/share/pixmaps中具有图标.在这些目录下是不同图标大小和类型的子目录.使用这些目录之一存储图标时,桌面文件中仅列出图标名称(不带目录);否则,记录文件的完整路径.可执行文件(如果在路径中)可以列出而没有路径名(不安全).最好列出完整路径.想象一下由于未指定完整路径而启动了错误的程序.另一种可能性是将桌面文件复制到用户桌面或/usr/share/applications ,然后在此处进行编辑.当程序位于只读媒体上时,请执行此操作.由于以上所有内容均未导致真正的安装,因此,请尽可能使用平台的本机安装程序和打包工具(rpm,dep,portage等).这些工具提供了完整安装的框架,其中包括适当的文件许可权(例如selinux)和桌面菜单.它们还提供了易于卸载的功能.如果程序必须从可移动媒体运行,请考虑使用系统安装程序仅安装符号链接,也许是/opt/vendor/progname.We're developing an app that needs to run on a removable device (e.g. USB stick). On Linux, we're using Gnome launchers to place a shortcut to the app on the root of the device. However, we need to use relative paths for the executable and icon since we don't know in advance where the device will mount. In the .desktop file I have something like:Exec=../myapp/myexecutableIcon=../myapp/myicon.pngNeither the executable or icon is found. I read the spec on icon lookup in .desktop files (http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#icon_lookup) but it didn't enlighten me.Is there a way to get launchers to use a relative path? If not, is there another approach to achieve what I want (i.e. a shortcut with an icon and an executable, specified using relative paths)? 解决方案 Relative paths are not supported*.One solution is to have an installer. This script updates the desktop file according to the location the script is run from. Make the script executable, and the user can click it to install. The script requires the desktop file to be writable.This was done with Linux in mind. The file is named autorun.sh; but that is just a convention, it usually won't run automatically. If you deploy this on something other than Linux, then name the file something else(autorun.linux), or adapt it to do different things according to the platform.#! /bin/sh#### Fixup $APPNAME.desktop.APPNAME=xvscatterICONNAME=xv_logo.pngcd $(dirname "$0")APPDIR="$PWD/$APPNAME"EXEC="$APPDIR/$APPNAME"ICON="$APPDIR/$ICONNAME"sed -i -e "s@^Icon=.*@Icon=$ICON@" \ -e "s@^Exec.*@Exec=$EXEC@" "$APPNAME.desktop"*The convention for the freedesktop is to have the icons in $HOME/.icons, /usr/share/icons or /usr/share/pixmaps. Under those directories are subdirectories for different icon sizes and types. When using one of those directories to store the icon, only the icon name(without the directory) is listed in the desktop file; otherwise record the full path to the file.The executable, if in the path, can be listed with no pathname(unsafe). It's best to list the full path. Imagine the wrong program getting launched because the full path isn't specified.Another possibility is to copy the desktop file to the user's desktop or to /usr/share/applications, and edit it there. Do this when the program is on read-only media.Because none of the above results in a true install, if possible, use the platform's native installer and packaging tools(rpm,dep,portage, etc.). Those tools provide a framework for complete installation including the proper file permissions(think selinux), and desktop menus. They also provide for easy uninstall.If the program has to run from the removable media, consider using the system install for just installing symlinks, maybe to /opt/vendor/progname. 这篇关于使用Gnome启动器的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 17:42