Skip to content
Snippets Groups Projects
Verified Commit 3efa1837 authored by JennaHuntsman's avatar JennaHuntsman Committed by Xenhat Hex
Browse files

Fix issue wherein handler directory would be set incorrectly, thus breaking SLURL handling

Removes some URL wrapping to fix handover upon viewer startup

Fix dumb pasting error & remove depreciated strings from desktop entry

Remove URL escape & patch out irrelevant echo

Swap out use of backticks for parenthesis  in handle_secondlifeprotocol.sh

Swap out use of backticks for parenthesis in register_secondlifeprotocol.sh

Remove backtick originating from pasting error (oops!) in handle_secondlifeprotocol.sh

Unjanktified viewer detection - No longer depends on binary names and instead looks at the presence of standard protocols within DBus in handle_secondlifeprotocol.sh

Ugh, backticks again.

Clean up in aisle register_secondlifeprotocol.sh

Useful value substitution in handle_secondlifeprotocol.sh
parent 85059ea2
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !53. Comments created here will be created in the context of that merge request.
...@@ -3,32 +3,28 @@ ...@@ -3,32 +3,28 @@
# Send a URL of the form secondlife://... to any running viewer, if not, launch Alchemy viewer. # 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" URL="$1"
if [ -z "$URL" ]; then if [ -z "$URL" ]; then
echo "Usage: $0 [ secondlife:// | hop:// ] ..." echo "Usage: $0 secondlife:// ..."
exit exit
fi fi
RUN_PATH=`dirname "$0" || echo .` RUN_PATH=$(dirname "$0" || echo .)
#ch "${RUN_PATH}" #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. #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
# pgrep -c returns 0 to show if process (any matching viewer) is not running, LIST=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames
if [ `pgrep -c do-not-directly` != 0 ]; then )
if [ $debug == 1 ]; then SERVICE="com.secondlife.ViewerAppAPIService" #Name of Second Life DBus service. This should be the same across all viewers.
zenity --info --text="pgrep passed\!" --title="secondlife_protocol" if echo "$LIST" | grep -q "$SERVICE"; then
fi echo "Second Life running, sending to DBus...";
exec dbus-send --type=method_call --dest=com.secondlife.ViewerAppAPIService /com/secondlife/ViewerAppAPI com.secondlife.ViewerAppAPI.GoSLURL string:"$1" exec dbus-send --type=method_call --dest=$SERVICE /com/secondlife/ViewerAppAPI com.secondlife.ViewerAppAPI.GoSLURL string:"$1"
else else
if [ $debug == 1 ]; then echo "Second Life not running, launching new instance...";
zenity --info --text="pgrep fail\!" --title="secondlife_protocol"
fi
cd "${RUN_PATH}"/.. cd "${RUN_PATH}"/..
#Go to .sh location (/etc), then up a directory to the viewer location #Go to .sh location (/etc), then up a directory to the viewer location
exec ./alchemy -url \'"${URL}"\' #exec ./alchemy -url \'"${URL}"\'
exec ./alchemy -url ${URL}
#Remove some of the wrapping around the URL, as this was breaking the handover upon startup
fi fi
`
...@@ -6,14 +6,12 @@ ...@@ -6,14 +6,12 @@
HANDLER="$1" HANDLER="$1"
RUN_PATH=`dirname "$0" || echo .` RUN_PATH=$(dirname "$0" || echo .)
cd "${RUN_PATH}/.." cd "${RUN_PATH}/.."
if [ -z "$HANDLER" ]; then if [ -z "$HANDLER" ]; then
HANDLER="$RUN_PATH/etc/handle_secondlifeprotocol.sh" #HANDLER="$RUN_PATH/etc/handle_secondlifeprotocol.sh"
#curdir=`pwd` HANDLER="$(pwd)/etc/handle_secondlifeprotocol.sh"
#echo $curdir
#HANDLER="$curdir/etc/handle_secondlifeprotocol.sh"
fi fi
# Register handler for GNOME-aware apps # Register handler for GNOME-aware apps
...@@ -26,8 +24,8 @@ fi ...@@ -26,8 +24,8 @@ fi
# Register handler for KDE-aware apps # Register handler for KDE-aware apps
for LLKDECONFIG in kde-config kde4-config; do for LLKDECONFIG in kde-config kde4-config; do
if [ `which $LLKDECONFIG` ]; then if [ $(which $LLKDECONFIG) ]; then
LLKDEPROTODIR=`$LLKDECONFIG --path services | cut -d ':' -f 1` LLKDEPROTODIR=$($LLKDECONFIG --path services | cut -d ':' -f 1)
if [ -d "$LLKDEPROTODIR" ]; then if [ -d "$LLKDEPROTODIR" ]; then
LLKDEPROTOFILE=${LLKDEPROTODIR}/secondlife.protocol LLKDEPROTOFILE=${LLKDEPROTODIR}/secondlife.protocol
cat > ${LLKDEPROTOFILE} <<EOF || echo Warning: Did not register secondlife:// handler with KDE: Could not write ${LLKDEPROTOFILE} cat > ${LLKDEPROTOFILE} <<EOF || echo Warning: Did not register secondlife:// handler with KDE: Could not write ${LLKDEPROTOFILE}
...@@ -51,13 +49,11 @@ done ...@@ -51,13 +49,11 @@ done
#Check if xdg-mime is present, if so, use it to register new protocol. #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 if command -v xdg-mime query default x-scheme-handler/secondlife > /dev/null 2>&1; then
#zenity --info --text="xdg-mime present\!" --title="register_secondlife_protocol" urlhandler=$(xdg-mime query default x-scheme-handler/secondlife)
urlhandler=`xdg-mime query default x-scheme-handler/secondlife`
localappdir="$HOME/.local/share/applications" localappdir="$HOME/.local/share/applications"
newhandler="handle_secondlifeprotocol.desktop" newhandler="handle_secondlifeprotocol.desktop"
cat >"$localappdir/$newhandler" <<EOFnew || echo Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler cat >"$localappdir/$newhandler" <<EOFnew || echo Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler
[Desktop Entry] [Desktop Entry]
Encoding=UTF-8
Version=1.5 Version=1.5
Name="Second Life URL handler" Name="Second Life URL handler"
Comment="secondlife:// URL handler" Comment="secondlife:// URL handler"
...@@ -82,7 +78,7 @@ EOFnew ...@@ -82,7 +78,7 @@ EOFnew
xdg-mime default $newhandler x-scheme-handler/secondlife 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 update-desktop-database $localappdir
echo -e "Registered secondlife:// protocol with xdg-mime\nNew default: `xdg-mime query default x-scheme-handler/secondlife`" echo -e "Registered secondlife:// protocol with xdg-mime\nNew default: $(xdg-mime query default x-scheme-handler/secondlife)"
else else
echo Warning: Cannot update desktop database, command missing - installation may be incomplete. echo Warning: Cannot update desktop database, command missing - installation may be incomplete.
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment