-
Notifications
You must be signed in to change notification settings - Fork 99
Linux: Wrapper and scripts modernizations #4982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop-linux
Are you sure you want to change the base?
Conversation
…on and SLURL handling
|
Thanks - I'll check this out when I'm in front of my Linux box again (currently on a work trip). |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
precommit is complaining about spaces in install.sh line 105 |
Fixes precommit check
|
This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or it will be closed in 7 days |
|
This branch is not stale, it is awaiting review. |
Removed the label. But probably not going anywhere without Rye or at least Geenz. |
clairem-sl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments.
| build_data_file="build_data.json" | ||
| if [ -f "${build_data_file}" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if install.sh is not executed as ./install.sh.
Better to put this part after the detection of RUN_PATH, and embed $RUN_PATH in the build_data_file string.
| [Desktop Entry]\n\ | ||
| Name=Second Life\n\ | ||
| Version=1.4\n\ | ||
| Name=${launcher_name}\n\ | ||
| GenericName=Second Life Viewer\n\ | ||
| Comment=Client for the On-line Virtual World, Second Life\n\ | ||
| Comment=Client for the Online Virtual World, Second Life\n\ | ||
| Path=${installation_prefix}\n\ | ||
| Exec=${installation_prefix}/secondlife\n\ | ||
| Icon=${installation_prefix}/secondlife_icon.png\n\ | ||
| Icon=${desktopfilename}\n\ | ||
| Terminal=false\n\ | ||
| Type=Application\n\ | ||
| Categories=Game;Simulation;\n\ | ||
| StartupNotify=true\n\ | ||
| StartupWMClass="com.secondlife.indra.viewer"\n\ | ||
| X-Desktop-File-Install-Version=3.0" | ||
| StartupWMClass=\"com.secondlife.indra.viewer\"\n\ | ||
| X-Desktop-File-Install-Version=3.0 | ||
| PrefersNonDefaultGPU=true\n\ | ||
| Actions=DefaultGPU;AssociateMIME;\n\ | ||
| \n\ | ||
| [Desktop Action DefaultGPU]\n\ | ||
| Exec=env __GLX_VENDOR_LIBRARY_NAME=\"\" ${installation_prefix}/secondlife\n\ | ||
| Name=Launch on default GPU\n\ | ||
| \n\ | ||
| [Desktop Action AssociateMIME]\n\ | ||
| Exec=${installation_prefix}/etc/register_secondlifeprotocol.sh\n\ | ||
| Name=Associate SLURLs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does every line end with \n\ ? We can remove all of them. The quoting during printf should keep the line breaks.
| mv "$1" "$backup_dir" || die "Failed to create backup of existing installation!" | ||
| } | ||
|
|
||
| set_slurl_handler() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using function
Though it is not strictly necessary, the convention seems to be using the function keyword. In addition using function makes the function stand out more.
| echo | ||
| prompt "Would you like to set Second Life as your default SLurl handler? [Y/N]: " | ||
| if [ $? -eq 0 ]; then | ||
| exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be return 0 instead?
exit 0 ends the script completely, meaning there are steps in root_install() that will not be executed (involving "refresh_desktop_app_entry")
| @@ -1,57 +1,66 @@ | |||
| #!/bin/bash | |||
| #!/bin/env sh | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no benefits running this script with sh instead of bash.
It is understandable for the actual handler to be executed by sh (which is likely much lighter -- unless it's a symlink to bash), but for this script that is invoked only during installation, better to just use bash, enabling us to use bash's powerful features.
| # Check if xdg-mime is present, if so, use it to register new protocol. | ||
| if command -v xdg-mime >/dev/null 2>&1; then | ||
| urlhandler=$(xdg-mime query default x-scheme-handler/secondlife) | ||
| localappdir="${HOME}/.local/share/applications" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be using ${XDG_DATA_HOME}/applications instead?
Also, this causes breakage if installation was done using sudo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R.E. XDG_DATA_HOME - possibly, however on most systems this isn't actually set and according to the XDG spec, if it's not set then we should assume $HOME/.local/share instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the Linux viewer installation and SLURL handling scripts to use XDG standard tools for improved cross-distribution compatibility. The changes enable multiple viewer channels to coexist on a single system and improve the SLURL handling workflow by prioritizing running viewer instances.
- Replaced custom desktop registration with XDG-compliant tools (xdg-mime, xdg-desktop-menu, xdg-icon-resource)
- Updated SLURL handler to check for running viewers via DBus before launching new instances
- Modified installation paths to use XDG_DATA_HOME and support channel-specific installation directories
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| wrapper.sh | Commented out legacy registration calls, now handled via XDG during installation |
| register_secondlifeprotocol.sh | Complete rewrite to use XDG tools for protocol handler registration with channel-specific desktop files |
| refresh_desktop_app_entry.sh | Updated to use XDG tools for desktop entry creation, added GPU selection support and channel-based naming |
| install.sh | Modified to support channel-specific installation paths and prompt user for SLURL handler association |
| handle_secondlifeprotocol.sh | Enhanced to check for running viewers via DBus before launching new instances |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cat >"${handlerpath}" <<EOFnew || print "Warning: Did not register secondlife:// handler with xdg-mime: Could not write $newhandler" | ||
| [Desktop Entry] | ||
| Version=1.4 | ||
| Name="Second Life URL handler" | ||
| Comment="secondlife:// URL handler" | ||
| Type=Application | ||
| Exec=$desired_handler %u | ||
| Terminal=false | ||
| StartupNotify=true | ||
| NoDisplay=true | ||
| MimeType=x-scheme-handler/secondlife | ||
| EOFnew |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message on line 29 is missing proper error handling. The 'cat' command will fail if it cannot write to the file, but the script continues execution regardless. The '|| print ...' only handles the output, but doesn't prevent the subsequent xdg-mime commands from running with a potentially invalid or missing desktop file. Consider using proper error handling with 'exit' or returning early.
| { | ||
| install_dir=$1 | ||
| echo | ||
| prompt "Would you like to set Second Life as your default SLurl handler? [Y/N]: " |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent capitalization of 'SLurl' - should be 'SLURL' (all caps) to match the usage throughout the rest of the codebase and documentation, as seen in other files in this PR.
| prompt "Would you like to set Second Life as your default SLurl handler? [Y/N]: " | |
| prompt "Would you like to set Second Life as your default SLURL handler? [Y/N]: " |
| NoDisplay=true\n\ | ||
| MimeType=x-scheme-handler/secondlife\n\ | ||
| X-Desktop-File-Install-Version=3.0" | ||
| # Ensure the handle_secondlifeprotocol.sh file is executeable (otherwise, xdg-mime won't work) |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: 'executeable' should be spelled 'executable'.
| # Ensure the handle_secondlifeprotocol.sh file is executeable (otherwise, xdg-mime won't work) | |
| # Ensure the handle_secondlifeprotocol.sh file is executable (otherwise, xdg-mime won't work) |
|
|
||
| cp -a "${tarball_path}"/* "$1/" || die "Failed to complete the installation!" | ||
|
|
||
| "$1"/etc/refresh_desktop_app_entry.sh || echo "Failed to integrate into DE via XDG." |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message 'Failed to integrate into DE via XDG.' is somewhat unclear. Consider providing more actionable information, such as 'Failed to register desktop entry. You may need to manually add the application to your menu.' This helps users understand what failed and what they might need to do.
| "$1"/etc/refresh_desktop_app_entry.sh || echo "Failed to integrate into DE via XDG." | |
| "$1"/etc/refresh_desktop_app_entry.sh || echo "Failed to register desktop entry via XDG. You may need to manually add the application to your desktop menu." |
| @@ -1,57 +1,66 @@ | |||
| #!/bin/bash | |||
| #!/bin/env sh | |||
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shebang should be '#!/usr/bin/env sh' instead of '#!/bin/env sh'. The standard location for 'env' on most Unix-like systems is '/usr/bin/env', not '/bin/env'. Using '/bin/env' may cause the script to fail on systems where 'env' is not in '/bin/'.
| #!/bin/env sh | |
| #!/usr/bin/env sh |
| install_dir=$1 | ||
| echo | ||
| prompt "Would you like to set Second Life as your default SLurl handler? [Y/N]: " | ||
| if [ $? -eq 0 ]; then | ||
| exit 0 | ||
| fi | ||
| "$install_dir"/etc/register_secondlifeprotocol.sh #Successful association comes with a notification to the user. |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'install_dir' is assigned but its naming is inconsistent with the rest of the codebase which uses 'installation_prefix' or 'install_prefix'. Using a consistent naming convention would improve code maintainability.
| install_dir=$1 | |
| echo | |
| prompt "Would you like to set Second Life as your default SLurl handler? [Y/N]: " | |
| if [ $? -eq 0 ]; then | |
| exit 0 | |
| fi | |
| "$install_dir"/etc/register_secondlifeprotocol.sh #Successful association comes with a notification to the user. | |
| install_prefix=$1 | |
| echo | |
| prompt "Would you like to set Second Life as your default SLurl handler? [Y/N]: " | |
| if [ $? -eq 0 ]; then | |
| exit 0 | |
| fi | |
| "$install_prefix"/etc/register_secondlifeprotocol.sh #Successful association comes with a notification to the user. |
| X-Desktop-File-Install-Version=3.0" | ||
| StartupWMClass=\"com.secondlife.indra.viewer\"\n\ | ||
| X-Desktop-File-Install-Version=3.0 | ||
| PrefersNonDefaultGPU=true\n\ |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing newline escape sequence '\n' after 'PrefersNonDefaultGPU=true' will result in an empty line being added to the desktop file, which may not be intended. The backslash should be removed if you want the line to end there without continuation.
| # | ||
|
|
||
| URL="$1" | ||
| sl_url="$*" |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using '$' instead of '"$@"' for capturing command-line arguments can cause issues with arguments containing spaces. The variable will contain all arguments as a single string with spaces, which means SLURLs with query parameters or special characters may not be properly preserved. Consider using '"$@"' or at least quoting '$' as '"$*"' to ensure proper argument handling.
| sl_url="$*" | |
| sl_url="$1" |
| if command -v xdg-mime >/dev/null 2>&1; then | ||
| urlhandler=$(xdg-mime query default x-scheme-handler/secondlife) | ||
| localappdir="${HOME}/.local/share/applications" | ||
| newhandler="secondlifeprotocol_$(basename "${PWD%}").desktop" |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'PWD%' on line 27 appears to have a typo with the trailing '%' character. This should likely be just 'PWD' without the '%' suffix, as the '%' has no meaning in this context and will be treated as a literal character.
| newhandler="secondlifeprotocol_$(basename "${PWD%}").desktop" | |
| newhandler="secondlifeprotocol_$(basename "${PWD}").desktop" |
| if [ -d "$XDG_DATA_HOME" ] ; then | ||
| install_to_prefix "$XDG_DATA_HOME/$installdir_name" #$XDG_DATA_HOME is a synonym for $HOME/.local/share/ unless the user has specified otherwise (unlikely). | ||
| else | ||
| install_to_prefix "$HOME/.local/share/$installdir_name" #XDG_DATA_HOME not set, so use default path as defined by XDG spec. | ||
| fi |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check 'if [ -d "$XDG_DATA_HOME" ]' tests if the variable is a directory, but should check if the variable is non-empty instead. If XDG_DATA_HOME is set but the directory doesn't exist yet, this will fall back to the hardcoded path instead of using the user's configured XDG_DATA_HOME. Consider using 'if [ -n "$XDG_DATA_HOME" ]' to check if the variable is set, or create the directory if it doesn't exist.
| if [ -d "$XDG_DATA_HOME" ] ; then | |
| install_to_prefix "$XDG_DATA_HOME/$installdir_name" #$XDG_DATA_HOME is a synonym for $HOME/.local/share/ unless the user has specified otherwise (unlikely). | |
| else | |
| install_to_prefix "$HOME/.local/share/$installdir_name" #XDG_DATA_HOME not set, so use default path as defined by XDG spec. | |
| fi | |
| if [ -n "$XDG_DATA_HOME" ] ; then | |
| local xdg_data_dir="$XDG_DATA_HOME" # $XDG_DATA_HOME is a synonym for $HOME/.local/share/ unless the user has specified otherwise. | |
| else | |
| local xdg_data_dir="$HOME/.local/share" # XDG_DATA_HOME not set, so use default path as defined by XDG spec. | |
| fi | |
| mkdir -p "$xdg_data_dir" || die "Failed to create data directory: $xdg_data_dir" | |
| install_to_prefix "$xdg_data_dir/$installdir_name" |
|
Converting to draft status while working on further modernizations and addressing feedback from other users and CoPilot's review. |
Description
Related Issues
Checklist
Please ensure the following before requesting review:
Additional Notes
These changes have been live in Alchemy's release viewers for some time now. This PR is to merge them upstream.
Suggest review from @RyeMutt .