Skip to content

Commit

Permalink
Merge pull request #21 from Jenna-Huntsman/main
Browse files Browse the repository at this point in the history
Additional fixes to Linux install/wrapper scripts
  • Loading branch information
DarlCat authored Jun 24, 2024
2 parents 1483bea + bfbba68 commit d3b9714
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
21 changes: 18 additions & 3 deletions indra/newview/linux_tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ homedir_install()
exit 0
fi

install_to_prefix "$HOME/.local/share/${installdir_name}"
"$HOME/.local/share/${installdir_name}/etc/refresh_desktop_app_entry.sh"
if [ -d "$XDG_DATA_HOME" ] ; then
install_to_prefix "$XDG_DATA_HOME/$installdir_name" #$XDG_DATA_HOME is a synonym for $HOME/.local/share/ unless the user has specified otherwise (unlikely).
else
install_to_prefix "$HOME/.local/share/$installdir_name" #XDG_DATA_HOME not set, so use default path as defined by XDG spec.
fi

}

root_install()
Expand All @@ -88,7 +92,6 @@ root_install()
install_to_prefix "$install_prefix"

mkdir -p /usr/local/share/applications
"${install_prefix}"/etc/refresh_desktop_app_entry.sh
}

install_to_prefix()
Expand Down Expand Up @@ -134,6 +137,8 @@ install_to_prefix()
rm "$1/bin/llplugin/.user_does_not_want_chrome_sandboxing_and_accepts_the_risks" 2> /dev/null
pkexec "$1/etc/chrome_sandboxing_permissions_setup.sh" || die "Failed to set permissions on chrome-sandbox"
fi
"$1"/etc/refresh_desktop_app_entry.sh || echo "Failed to integrate into DE via XDG."
set_slurl_handler "$1"
}

backup_previous_installation()
Expand All @@ -144,6 +149,16 @@ backup_previous_installation()
mv "$1" "$backup_dir" || die "Failed to create backup of existing installation!"
}

set_slurl_handler()
{
install_dir=$1
echo
prompt "Would you like to set Alchemy as your default SLurl handler? [Y/N]: "
if [ $? -eq 0 ]; then
exit 0
fi
"$install_dir"/etc/register_secondlifeprotocol.sh #Successful association comes with a notification to the user.
}

if [ "$(id -u)" = "0" ]; then
root_install
Expand Down
31 changes: 25 additions & 6 deletions indra/newview/linux_tools/refresh_desktop_app_entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ -f "${build_data_file}" ]; then
version=$(sed -n 's/.*"Version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${build_data_file}")
channel_base=$(sed -n 's/.*"Channel Base"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${build_data_file}")
channel=$(sed -n 's/.*"Channel"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "${build_data_file}")
desktopfilename=$(echo "$channel" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' )-viewer.desktop
desktopfilename=$(echo "$channel" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' )-viewer
else
echo "Error: File ${build_data_file} not found." >&2
exit 1
Expand All @@ -30,20 +30,39 @@ install_desktop_entry()

desktop_entry="\
[Desktop Entry]\n\
Version=1.4\n\
Name=${launcher_name}\n\
GenericName=Second Life Viewer\n\
Comment=Client for the On-line Virtual World, Second Life\n\
Exec=${installation_prefix}/alchemy\n\
Icon=${installation_prefix}/alchemy_icon.png\n\
Icon=${desktopfilename}\n\
Terminal=false\n\
Type=Application\n\
Categories=Game;Simulation;\n\
StartupNotify=true\n\
StartupWMClass=${channel}\n\
X-Desktop-File-Install-Version=3.0"
PrefersNonDefaultGPU=true\n\
Actions=DefaultGPU;AssociateMIME;\n\
\n\
[Desktop Action DefaultGPU]\n\
Exec=env __GLX_VENDOR_LIBRARY_NAME="" ${installation_prefix}/alchemy\n\
Name=Launch on default GPU\n\
\n\
[Desktop Action AssociateMIME]\n\
Exec=${installation_prefix}/etc/register_secondlifeprotocol.sh\n\
Name=Associate SLURLs"
#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.)

printf "Installing menu entries via XDG..."
printf "%b" "${desktop_entry}" > "${installation_prefix}/${desktopfilename}".desktop || echo "Failed to install application menu!"
xdg-icon-resource install --novendor --size 256 "${installation_prefix}/alchemy_icon.png" "${desktopfilename}"
#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 "${installation_prefix}"/"${desktopfilename}".desktop

printf " - Installing menu entries in %s\n" "${desktop_entries_dir}"
mkdir -vp "${desktop_entries_dir}"
printf "%b" "${desktop_entry}" > "${desktop_entries_dir}/${desktopfilename}" || echo "Failed to install application menu!"
}

if [ "$(id -u)" = "0" ]; then
Expand Down
8 changes: 5 additions & 3 deletions indra/newview/linux_tools/register_secondlifeprotocol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ chmod +x "$desired_handler"
if command -v xdg-mime >/dev/null 2>&1; then
urlhandler=$(xdg-mime query default x-scheme-handler/secondlife)
localappdir="${HOME}/.local/share/applications"
newhandler="secondlifeprotocol_$(basename "$(dirname "${desired_handler}")").desktop"
newhandler="secondlifeprotocol_$(basename "${PWD%}").desktop"
handlerpath="${localappdir}/${newhandler}"
cat >"${handlerpath}" <<EOFnew || print "Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler"
[Desktop Entry]
Expand All @@ -49,7 +49,8 @@ EOFnew
#Clean up handlers from other viewers
if [ "${urlhandler}" != "${newhandler}" ]; then
print "Current SLURL Handler: ${urlhandler} - Setting ${newhandler} as the new default..."
mv "${localappdir}"/"${urlhandler}" "${localappdir}"/"${urlhandler}".bak
#mv "${localappdir}"/"${urlhandler}" "${localappdir}"/"${urlhandler}".bak #Old method, now replaced with XDG.
xdg-desktop-menu install --novendor "${localappdir}"/"$urlhandler"
else
print "SLURL Handler has not changed, leaving as-is."
fi
Expand All @@ -74,4 +75,5 @@ else
print "Failed to register secondlife:// handler with (deprecated) gconf."
fi
fi
fi
fi
notify-send -t 5000 -i info "Second Life URL Handler" "SLURL association created"

0 comments on commit d3b9714

Please sign in to comment.