Skip to content

Commit af60060

Browse files
committed
Fix registration of secondlife protocol handler on linux
Signed-off-by: Rye <rye@alchemyviewer.org>
1 parent af7416f commit af60060

File tree

1 file changed

+42
-33
lines changed

1 file changed

+42
-33
lines changed

indra/newview/linux_tools/register_secondlifeprotocol.sh

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,52 @@
66

77
HANDLER="$1"
88

9-
RUN_PATH=`dirname "$0" || echo .`
9+
SCRIPTSRC=`readlink -f "$0" || echo "$0"`
10+
RUN_PATH=`dirname "${SCRIPTSRC}" || echo .`
11+
12+
install_prefix="$(realpath -- "${RUN_PATH}/..")"
13+
1014
cd "${RUN_PATH}/.."
1115

1216
if [ -z "$HANDLER" ]; then
13-
HANDLER=`pwd`/etc/handle_secondlifeprotocol.sh
17+
HANDLER=$install_prefix/etc/handle_secondlifeprotocol.sh
1418
fi
1519

16-
# Register handler for GNOME-aware apps
17-
LLGCONFTOOL2=gconftool-2
18-
if which ${LLGCONFTOOL2} >/dev/null; then
19-
(${LLGCONFTOOL2} -s -t string /desktop/gnome/url-handlers/secondlife/command "${HANDLER} \"%s\"" && ${LLGCONFTOOL2} -s -t bool /desktop/gnome/url-handlers/secondlife/enabled true) || echo Warning: Did not register secondlife:// handler with GNOME: ${LLGCONFTOOL2} failed.
20-
else
21-
echo Warning: Did not register secondlife:// handler with GNOME: ${LLGCONFTOOL2} not found.
22-
fi
20+
function install_desktop_entry()
21+
{
22+
local installation_prefix="$1"
23+
local desktop_entries_dir="$2"
24+
25+
local desktop_entry="\
26+
[Desktop Entry]\n\
27+
Name=Second Life SLURL handler\n\
28+
Path=${installation_prefix}\n\
29+
Exec=${HANDLER} %u\n\
30+
Icon=${installation_prefix}/secondlife_icon.png\n\
31+
Terminal=false\n\
32+
Type=Application\n\
33+
StartupNotify=true\n\
34+
StartupWMClass="com.secondlife.indra.viewer"\n\
35+
NoDisplay=true\n\
36+
MimeType=x-scheme-handler/secondlife\n\
37+
X-Desktop-File-Install-Version=3.0"
2338

24-
# Register handler for KDE-aware apps
25-
for LLKDECONFIG in kde-config kde4-config; do
26-
if [ `which $LLKDECONFIG` ]; then
27-
LLKDEPROTODIR=`$LLKDECONFIG --path services | cut -d ':' -f 1`
28-
if [ -d "$LLKDEPROTODIR" ]; then
29-
LLKDEPROTOFILE=${LLKDEPROTODIR}/secondlife.protocol
30-
cat > ${LLKDEPROTOFILE} <<EOF || echo Warning: Did not register secondlife:// handler with KDE: Could not write ${LLKDEPROTOFILE}
31-
[Protocol]
32-
exec=${HANDLER} '%u'
33-
protocol=secondlife
34-
input=none
35-
output=none
36-
helper=true
37-
listing=
38-
reading=false
39-
writing=false
40-
makedir=false
41-
deleting=false
42-
EOF
43-
else
44-
echo Warning: Did not register secondlife:// handler with KDE: Directory $LLKDEPROTODIR does not exist.
45-
fi
46-
fi
47-
done
39+
echo " - Installing protocol entries in ${desktop_entries_dir}"
40+
WORK_DIR=`mktemp -d`
41+
PROTOCOL_HANDLER="secondlife-protocol.desktop"
42+
echo -e $desktop_entry > "${WORK_DIR}/${PROTOCOL_HANDLER}" || "Failed to create desktop file!"
43+
desktop-file-install --dir="${desktop_entries_dir}" "${WORK_DIR}/${PROTOCOL_HANDLER}" || "Failed to install desktop file!"
44+
rm -r $WORK_DIR
4845

46+
xdg-mime default "${desktop_entries_dir}/${PROTOCOL_HANDLER}" x-scheme-handler/secondlife
47+
48+
update-desktop-database "${desktop_entries_dir}"
49+
}
50+
51+
if [ "$UID" == "0" ]; then
52+
# system-wide
53+
install_desktop_entry "$install_prefix" /usr/local/share/applications
54+
else
55+
# user-specific
56+
install_desktop_entry "$install_prefix" "$HOME/.local/share/applications"
57+
fi

0 commit comments

Comments
 (0)