skip to Main Content

My system is Debian 12. I try to use xdg-open to open an image file, yet it blocks when the image file is opened. The image viewer has to be closed before xdg-open returns.

While many people state that xdg-open returns immediately in their environment. I wonder whether this is a configuration or distribution issue. If possible, is there any option to let xdg-open detach and return immediately. I searched the xdg-open document yet didn’t find anything.

2

Answers


  1. try to install/reinstall the package xdg-utils:

    sudo apt install --reinstall xdg-utils
    

    If this one doesn’t work, try:

    sudo apt-get install --reinstall xdg-utils
    

    If that doesn’t work, try to update your packages:

    sudo apt update
    sudo apt upgrade
    
    Login or Signup to reply.
  2. xdg-open is just a wrapper to open a file with an application that can handle it.

    As such, it doesn’t make any guarantees about whether it will block or return immediately: this is up to the delegated application (so if xdg-open ends up calling display-im6.q16, then it is display-im6.q16 that is blocking (or not).

    Of course things are a bit more complicated.
    E.g. if i run xdg-open file.jpg then i also get display-im6.q16, but without blocking. Why? Because i have also installed the exo-utils, so xdg-open does not call display-im6.q16 directly, but instead calls exo-open which (for whatever reasons) does not block.

    Now, i haven’t found any documentation that guarantees that exo-open will not block.
    If you want to xdg-open to return immediately, just background it:

    xdg-open myfile &
    

    If you don’t want to remember having to do this, you could also create an excutable file /usr/local/bin/xdg-open which (depending on your PATH) should take precedence over the system installed /usr/bin/xdg-open:

    #!/bin/sh
    /usr/bin/xdg-open "$@" &
    

    Or install some lightweight (at least I think it is lightweight) middleware like exo-utils

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search