Skip to content
Snippets Groups Projects

Linux - Replace legacy desktop integration with modern XDG-based integration

Closed JennaHuntsman requested to merge JennaHuntsman/xdg-integration:main into main
Compare and Show latest version
1 file
+ 14
4
Compare changes
  • Side-by-side
  • Inline
@@ -2,11 +2,19 @@
VIEWERNAME="Alchemy" #Store the viewer's name as a variable, for portability. This should be correctly capitalized.
CHANNELNAME="AgileAkita" #THIS CAN BE BLANK! Store the viewer's channel (i.e. alpha, beta, etc.) as a variable, for portability. This should be correctly capitalized. Release versions should leave this blank, so the DE will show just VIEWERNAME, not VIEWERNAME CHANNELNAME
SCRIPTSRC="$(readlink -f "$0" || echo "$0")"
RUN_PATH="$(dirname "${SCRIPTSRC}" || echo .)"
install_prefix=$(builtin cd "${RUN_PATH}/.." || exit; pwd) #This is a cleaner way of getting the absolute path for the install directory.
function print() {
log_prefix="${VIEWERNAME}${CHANNELNAME}DesktopIntegration:"
echo -e "${log_prefix} $*"
}
function install_desktop_entry()
{
local installation_prefix="${1}"
@@ -15,7 +23,7 @@ function install_desktop_entry()
cat >"${desktoppath}" <<desktopfile || print "Warning: Could not write $desktoppath"s
[Desktop Entry]
Version=1.4
Name=${VIEWERNAME}
Name=${VIEWERNAME} ${CHANNELNAME}
GenericName=Second Life Viewer
Comment=Client for the Online Virtual World, Second Life
Exec=${installation_prefix}/${VIEWERNAME,,}
@@ -24,7 +32,7 @@ Terminal=false
Type=Application
Categories=Game;Simulation;
StartupNotify=true
StartupWMClass=${VIEWERNAME}
StartupWMClass=${VIEWERNAME} ${CHANNELNAME}
PrefersNonDefaultGPU=true
Actions=DefaultGPU;AssociateMIME;
@@ -40,14 +48,16 @@ Name=Associate SLURLs
Comment=Set this viewer as the default handler for secondlife:// links.
desktopfile
#The above adds some options when the shortcut is right-clicked, to launch on the default (usually integrated) GPU, and to force MIME type association.
#The "PrefersNonDefaultGPU" line should automatically run the viewer on the most powerful GPU in the system, if it is not default. If it is, this is ignored.
# NOTE: DO NOT CHANGE THE "GenericName" FIELD - ONLY CHANGE THE "Name" FIELD. (This is to ensure that searching "Second Life" will show all the viewers installed in a user's system, regardless of their canonical name.)
echo " - Installing menu entries via XDG..."
print "Installing menu entries via XDG..."
xdg-icon-resource install --novendor --size 256 "${install_prefix}/${VIEWERNAME,,}_icon.png" ${VIEWERNAME}-Viewer
#NOTE: Above command takes the path to the icon to install && The name of the icon to be used by XDG. This should always be in the format of "x-Viewer" to avoid potential naming conflicts, as per XDG spec.
xdg-desktop-menu install --novendor ./${VIEWERNAME,,}-viewer.desktop
xdg-desktop-menu install --novendor "${installation_prefix}"/${VIEWERNAME,,}-${CHANNELNAME}-viewer.desktop
}
if [ "$UID" == "0" ]; then
Loading