From be957ae973643c652652661eb577a3f278624118 Mon Sep 17 00:00:00 2001 From: JennaHuntsman <jenna.salem.sf@gmail.com> Date: Fri, 15 Oct 2021 16:46:40 -0400 Subject: [PATCH] Add dbus functionality to URL handler to send LM to any running viewers, instead of always attempting to launch a new instance --- .../linux_tools/handle_secondlifeprotocol.sh | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/indra/newview/linux_tools/handle_secondlifeprotocol.sh b/indra/newview/linux_tools/handle_secondlifeprotocol.sh index 53d875ee073..5d63c4514e8 100755 --- a/indra/newview/linux_tools/handle_secondlifeprotocol.sh +++ b/indra/newview/linux_tools/handle_secondlifeprotocol.sh @@ -1,17 +1,34 @@ #!/bin/bash -# Send a URL of the form secondlife://... to Second Life. +# Send a URL of the form secondlife://... to any running viewer, if not, launch Alchemy viewer. # +#enable or disable debugging code +debug=0 + URL="$1" if [ -z "$URL" ]; then - echo Usage: $0 secondlife://... + echo "Usage: $0 [ secondlife:// | hop:// ] ..." exit fi RUN_PATH=`dirname "$0" || echo .` -cd "${RUN_PATH}/.." - -exec ./alchemy -url \'"${URL}"\' +#ch "${RUN_PATH}" +# Use pgrep to return the NUMBER of matching processes, not their IDs. Stragely returning IDs via pidof will cause the script to fail at random, even when it shouldn't. +# pgrep -c returns 0 to show if process (any matching viewer) is not running, +if [ `pgrep -c do-not-directly` != 0 ]; then + if [ $debug == 1 ]; then + zenity --info --text="pgrep passed\!" --title="secondlife_protocol" + fi + exec dbus-send --type=method_call --dest=com.secondlife.ViewerAppAPIService /com/secondlife/ViewerAppAPI com.secondlife.ViewerAppAPI.GoSLURL string:"$1" +else + if [ $debug == 1 ]; then + zenity --info --text="pgrep fail\!" --title="secondlife_protocol" + fi + cd "${RUN_PATH}"/.. + #Go to .sh location (/etc), then up a directory to the viewer location + exec ./alchemy -url \'"${URL}"\' +fi +` -- GitLab