Skip to content
Snippets Groups Projects

Fix Linux SLURL protocol handling

Merged Ghost User requested to merge xenhat/slurl-handler into main
2 files
+ 75
48
Compare changes
  • Side-by-side
  • Inline
Files
2
  • 0ee33d5f
    !52 takeover: Fix shellcheck warnings. · 0ee33d5f
    Xenhat Hex authored
    Various fixes and edits. Spaces in SLURL are broken atm.
    
    Revert quoting change in handler files
    
    Additional protocol handler tweaks
    This commit is mostly about refining the messages sent to the log.
    No functional changes.
#!/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.
#
URL="$1"
sl_url="$*"
if [ -z "$URL" ]; then
echo Usage: $0 secondlife://...
exit
echo "Got SLURL: ${sl_url}"
if [ -z "${sl_url}" ]; then
echo "Usage: $0 secondlife:// ..."
exit
fi
RUN_PATH=`dirname "$0" || echo .`
cd "${RUN_PATH}/.."
exec ./alchemy -url \'"${URL}"\'
run_path=$(dirname "$0" || echo .)
#Poll DBus to get a list of registered services, then look through the list for the Second Life API Service - if present, this means a viewer is running, if not, then no viewer is running and a new instance should be launched
service_name="com.secondlife.ViewerAppAPIService" #Name of Second Life DBus service. This should be the same across all viewers.
if dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -q "${service_name}"; then
echo "Second Life running, sending to DBus...";
exec dbus-send --type=method_call --dest="${service_name}" /com/secondlife/ViewerAppAPI com.secondlife.ViewerAppAPI.GoSLURL string:"${sl_url}"
else
echo "Second Life not running, launching new instance...";
cd "${run_path}"/.. || exit
#Go to .sh location (/etc), then up a directory to the viewer location
exec ./alchemy -url "${sl_url}"
fi
Loading