diff --git a/indra/newview/linux_tools/register_secondlifeprotocol.sh b/indra/newview/linux_tools/register_secondlifeprotocol.sh index c79db822b8040653f636549b29434e03aeea6d1d..fa4831f1868ec92bc8110b4ff040757306e81114 100755 --- a/indra/newview/linux_tools/register_secondlifeprotocol.sh +++ b/indra/newview/linux_tools/register_secondlifeprotocol.sh @@ -14,70 +14,52 @@ run_path=$(dirname "$0" || echo .) cd "${run_path}/.." || exit if [ -z "${desired_handler}" ]; then - #desired_handler="$run_path/etc/handle_secondlifeprotocol.sh" - desired_handler="$(pwd)/etc/handle_secondlifeprotocol.sh" + desired_handler="$(pwd)/etc/handle_secondlifeprotocol.sh" fi -print "Requested Handler: ${desired_handler}" - -# Register handler for gconf-aware apps -# TODO: use dconf or another modern alternative -gconftool=$(command -v "${LLGCONFTOOL:=gconftool-2}") -if [[ -z "${gconftool}" ]]; then - print "gconf not found, skipped. (This is good)" - else - if "${gconftool}" -s -t string /desktop/gnome/url-handlers/secondlife/command "${desired_handler} \"%s\"" \ - && ${gconftool} -s -t bool /desktop/gnome/url-handlers/secondlife/enabled true; then - print "Registered secondlife:// handler with (deprecated) gconf." - else - print "Failed to register secondlife:// handler with (deprecated) gconf." - fi -fi +# # Register handler for KDE-aware apps +# for kdeconfig in ${LLKDECONFIG} kf5-config kde4-config kde-config; do +# if command -v "${kdeconfig}" >/dev/null 2>&1; then +# kde_protocols_folder=$("${kdeconfig}" --path services | cut -d ':' -f 1) +# mkdir -p "${kde_protocols_folder}" +# if [ -d "${kde_protocols_folder}" ]; then +# kde_proto_file=${kde_protocols_folder}/secondlife.protocol +# kde_handler_string=" +# [Protocol] +# exec=${desired_handler} %U +# protocol=secondlife +# input=none +# output=none +# helper=true +# listing= +# reading=false +# writing=false +# makedir=false +# deleting=false" +# if echo "${kde_handler_string}" > "${kde_proto_file}"; then +# print "Registered secondlife:// handler with KDE" +# success=1 +# else +# print 'Warning: Did not register secondlife:// handler with KDE: Could not write '"${kde_proto_file}" +# fi +# else +# print 'Warning: Did not register secondlife:// handler with KDE: Directory '"${kde_protocols_folder}"' does not exist.' +# fi +# # else +# # print "Warning: KDE-Config binary '${kdeconfig}' not found" +# fi +# done +# if [[ -z "${success}" ]]; then +# print "Warning: secondlife:// protocol not registered with KDE: could not find any configuration utility. You can still register the application manually by editing ${HOME}/.local/share/mimeapps.list" +# fi -# Register handler for KDE-aware apps -for kdeconfig in ${LLKDECONFIG} kf5-config kde4-config kde-config; do - if command -v "${kdeconfig}" >/dev/null 2>&1; then - kde_protocols_folder=$("${kdeconfig}" --path services | cut -d ':' -f 1) - mkdir -p "${kde_protocols_folder}" - if [ -d "${kde_protocols_folder}" ]; then - kde_proto_file=${kde_protocols_folder}/secondlife.protocol - kde_handler_string=" -[Protocol] -exec=${desired_handler} %u -protocol=secondlife -input=none -output=none -helper=true -listing= -reading=false -writing=false -makedir=false -deleting=false" - if echo "${kde_handler_string}" > "${kde_proto_file}"; then - print "Registered secondlife:// handler with KDE" - success=1 - else - print 'Warning: Did not register secondlife:// handler with KDE: Could not write '"${kde_proto_file}" - fi - else - print 'Warning: Did not register secondlife:// handler with KDE: Directory '"${kde_protocols_folder}"' does not exist.' - fi - # else - # print "Warning: KDE-Config binary '${kdeconfig}' not found" - fi -done -if [[ -z "${success}" ]]; then - print "Warning: secondlife:// protocol not registered with KDE: could not find any configuration utility. You can still register the application manually by editing ${HOME}/.local/share/mimeapps.list" -fi -# if [[ -n "${FALLBACK}" ]]; then - #Check if xdg-mime is present, if so, use it to register new protocol. -if command -v xdg-mime query default x-scheme-handler/secondlife > /dev/null 2>&1; then +#Check if xdg-mime is present, if so, use it to register new protocol. +if command -v xdg-mime query default x-scheme-handler/secondlife >/dev/null 2>&1; then urlhandler=$(xdg-mime query default x-scheme-handler/secondlife) localappdir="$HOME/.local/share/applications" - newhandler="handle_secondlifeprotocol.desktop" + newhandler="secondlifeprotocol_$(basename "$(dirname "${desired_handler}")").desktop" handlerpath="$localappdir/$newhandler" - print "New handler file: ${handlerpath}" - cat >"${handlerpath}" <<EOFnew || print Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler + cat >"${handlerpath}" <<EOFnew || print "Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler"s [Desktop Entry] Version=1.5 Name="Second Life URL handler" @@ -85,14 +67,14 @@ Comment="secondlife:// URL handler" Type=Application Exec=$desired_handler %u Terminal=false -StartupNotify=false +StartupNotify=true NoDisplay=true MimeType=x-scheme-handler/secondlife EOFnew -# TODO: use absolute path for the desktop file -# TODO: Ensure that multiple channels behave properly due to different desktop file names in /usr/share/applications/ -# TODO: Better detection of what the handler actually is, as other viewer projects may use the same filename + # TODO: use absolute path for the desktop file + # TODO: Ensure that multiple channels behave properly due to different desktop file names in /usr/share/applications/ + # TODO: Better detection of what the handler actually is, as other viewer projects may use the same filename if [ -z "$urlhandler" ]; then print No SLURL handler currently registered, creating new... else @@ -106,13 +88,23 @@ EOFnew fi fi xdg-mime default $newhandler x-scheme-handler/secondlife - if command -v update-desktop-database > /dev/null 2>&1; then + if command -v update-desktop-database >/dev/null 2>&1; then update-desktop-database "$localappdir" - print "Registered secondlife:// protocol with xdg-mime. New default: $(xdg-mime query default x-scheme-handler/secondlife)" + print "Registered ${desired_handler} as secondlife:// protocol handler with xdg-mime." else print "Warning: Cannot update desktop database, command missing - installation may be incomplete." fi else print "Warning: Did not register secondlife:// handler with xdg-mime: Package not found." + # TODO: use dconf or another modern alternative + gconftool=$(command -v "${LLGCONFTOOL:=gconftool-2}") + if [[ -n "${gconftool}" ]]; then + print "=== USING DEPRECATED GCONF API ===" + if "${gconftool}" -s -t string /desktop/gnome/url-handlers/secondlife/command "${desired_handler} \"%s\"" && + ${gconftool} -s -t bool /desktop/gnome/url-handlers/secondlife/enabled true; then + print "Registered ${desired_handler} as secondlife:// handler with (deprecated) gconf." + else + print "Failed to register secondlife:// handler with (deprecated) gconf." + fi + fi fi -# fi