Skip to content
Snippets Groups Projects
Commit ab266f02 authored by Xenhat Hex's avatar Xenhat Hex Committed by Rye Mutt
Browse files

bash variable code styling fixes

parent 3297f85b
No related branches found
No related tags found
1 merge request!53Fix Linux SLURL protocol handling
This commit is part of merge request !53. Comments created here will be created in the context of that merge request.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# URLs of the form secondlife://... # URLs of the form secondlife://...
# #
desired_handler="$1" desired_handler="${1}"
print() { print() {
log_prefix="RegisterSLProtocol:" log_prefix="RegisterSLProtocol:"
...@@ -56,9 +56,9 @@ fi ...@@ -56,9 +56,9 @@ fi
#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
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="secondlifeprotocol_$(basename "$(dirname "${desired_handler}")").desktop" newhandler="secondlifeprotocol_$(basename "$(dirname "${desired_handler}")").desktop"
handlerpath="$localappdir/$newhandler" handlerpath="${localappdir}/${newhandler}"
cat >"${handlerpath}" <<EOFnew || print "Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler"s cat >"${handlerpath}" <<EOFnew || print "Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler"s
[Desktop Entry] [Desktop Entry]
Version=1.5 Version=1.5
...@@ -75,21 +75,21 @@ EOFnew ...@@ -75,21 +75,21 @@ EOFnew
# TODO: use absolute path for the desktop file # 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: 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: Better detection of what the handler actually is, as other viewer projects may use the same filename
if [ -z "$urlhandler" ]; then if [ -z "${urlhandler}" ]; then
print No SLURL handler currently registered, creating new... print No SLURL handler currently registered, creating new...
else else
#xdg-mime uninstall $localappdir/$urlhandler #xdg-mime uninstall $localappdir/$urlhandler
#Clean up handlers from other viewers #Clean up handlers from other viewers
if [ "$urlhandler" != "$newhandler" ]; then if [ "${urlhandler}" != "${newhandler}" ]; then
print "Current SLURL Handler: ${urlhandler} - Setting ${newhandler} as the new default..." print "Current SLURL Handler: ${urlhandler} - Setting ${newhandler} as the new default..."
mv "$localappdir"/"$urlhandler" "$localappdir"/"$urlhandler".bak mv "${localappdir}"/"${urlhandler}" "${localappdir}"/"${urlhandler}".bak
else else
print "SLURL Handler has not changed, leaving as-is." print "SLURL Handler has not changed, leaving as-is."
fi fi
fi fi
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}"
print "Registered ${desired_handler} as secondlife:// protocol handler with xdg-mime." print "Registered ${desired_handler} as secondlife:// protocol handler with xdg-mime."
else else
print "Warning: Cannot update desktop database, command missing - installation may be incomplete." print "Warning: Cannot update desktop database, command missing - installation may be incomplete."
......
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