How to fix xdg-open in Mate DE

Users of Linux Mint or other GNU/Linux distributions that use MATE Desktop environment have surely encountered this problem where xdg-open does not work properly.

This is most often seen when using Chromium  browser and trying to open a downloaded file. Almost every time it fails to open the file with the right software. To fix this you have to fix xdg-open.

Here is a quick fix:

  1. Go to Menu > Terminal
  2. Enter gksu pluma /usr/bin/xdg-open
  3. Search for detectDE(), then above this line else DE=””, insert a new line:
    elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=mate;
    
  4. Search for open_gnome(), then after the section of open_gnome() {…}, insert a new section:
    open_mate()
    {
    if gvfs-open --help 2>/dev/null 1>&2; then
    gvfs-open "$1"
    else
    mate-open "$1"
    fi
    if [ $? -eq 0 ]; then
    exit_success
    else
    exit_failure_operation_failed
    fi
    }
    
  5. Search for this line case “$DE” in, and after this line, add a new section:
    mate)
    open_mate "$url"
    ;;
    
  6. Save the file and retry the download links.

Leave a Reply

Your email address will not be published. Required fields are marked *