Skip to content

Browser Extension not working on linux (URI scheme issues) #1220

@whiskycompiler

Description

@whiskycompiler

What happened?

The browser extension (https://github.com/LykosAI/SMChromeExtension) does not work out of the box in Kubuntu 24.10 (and probably other distros as well) and I could not find any documentation related to things I might have forgotten to setup.

I investigated it a bit and manged to set it up to work for me (although it is pretty hacky).

As far as I could observe the following relevant things happen when the StabilityMatrix.AppImage is stared:

  1. it generates the following .desktop file ~/.local/share/applications/stabilitymatrix.desktop
    [Desktop Entry]
    Name=StabilityMatrix
    Exec=/path/to/your/StabilityMatrix.AppImage %u
    Type=Application
    NoDisplay=true
    Categories=Utility
    X-Desktop-File-Install-Version=0.27
    MimeType=x-scheme-handler/stabilitymatrix;x-scheme-handler/stabilitymatrix
    
  2. It updates the ~/.config/mimeapps.list and sets the above .desktop file as default for the stabilitymatrix:// URL scheme.

The issue with the .desktop file seems to be the way parameters from the Exec field are passed/handled in the application.
Like above a passed URL seems to be entirely ignored and nothing is downloaded - instead everytime you click on the "Download with Stability Matrix" button a new instance is opened.
When I adjust the parameters at the end of the Exec field to be --uri "%u" it works until the application is restarted (then it will overwrite my changes).

So I did the following to make it do what I expect it to do:

  1. I created a new .desktop file ~/.local/share/applications/StabilityMatrixFix.desktop to use in my launcher and as a scheme URL handler.
    [Desktop Entry]
    Exec=/home/<username>/Applications/stability-matrix-fixed-start.sh %u
    Icon=StabilityMatrix.png
    Name=StabilityMatrix
    NoDisplay=false
    StartupNotify=true
    Terminal=false
    Type=Application
    X-KDE-SubstituteUID=false
    Categories=Graphics
    MimeType=x-scheme-handler/stabilitymatrix
    
  2. I created a bash script (thank you chatGPT) to handle normal launch and activation for scheme URL
    #!/bin/bash
    
    # Set the correct MIME type association
    xdg-mime default StabilityMatrixFix.desktop x-scheme-handler/stabilitymatrix
    
    # Prepare the command to run the AppImage with a dummy config
    COMMAND="XDG_CONFIG_HOME=./config-dummy /absolute/path/to/your/StabilityMatrix.AppImage"
    
    # If any parameters were passed we assume that an URI launch is requested
    if [ "$#" -gt 0 ]; then
        # if the application is not running we need to start it first (uri parameter prevents normal start)
        if ! ps aux | grep -v grep | grep "StabilityMatrix.AppImage" > /dev/null; then
            eval $COMMAND &
            sleep 15
        fi
    
        COMMAND+=" --uri \"$@\""
    fi
    
    # Run the command
    eval $COMMAND
    
    # Set the MIME type association again just to be sure
    xdg-mime default StabilityMatrixFix.desktop x-scheme-handler/stabilitymatrix
    

The bash script tries to prevent the AppImage from resetting the settings to its own .desktop file which does not work correctly by giving it a fake XDG_CONFIG_HOME directory and also setting my own desktop file as scheme handler on start and exit of the application.
It also handles the weird issue that StabilityMatrix does not start when the --uri parameter is used and no instance is running - it seems to only notify a running instance but simply does nothing if there is none 🤷.

Would be nice if that could be fixed. Otherwise feel free to put the workaround in some kind of readme or documentation.

Steps to reproduce

  1. Download StabilityMatrix for Linux and unpack it.
  2. Start it and set it up.
  3. Install the extension.
  4. Go to any model on Civitai and click the "Download with Stability Matrix" button

Expected Result

The model is downloaded.

Actual Result

A new StabilityMatrix instance opens and nothing is downloaded.

Version

2.13.4

What Operating System are you using?

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleStale issue or inactive for long period of time

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions