Xdg-open (or kde-open) doesn't work when called from emacs

When I run xdg-open xyz.pdf in Konsole, Okular opens the file without any issue.

When I run xdg-open xyz.pdf in emacs eshell, my cursor blinks with the Okular icon for a few seconds and then nothing happens.

When I run okular xyz.pdf in emacs eshell, Okular opens.

In both 2nd and 3rd case, I get a warning: Qt session management error, could not open network socket

My emacs workflow involves opening a lot of pdf externally and by default the emacs packages use the xdg-open command, which is not working. Any idea how to troubleshoot this?

1 Like

Try setting process-connection-type to nil. I has the same issue and this worked for me.

Found this solution from → Re: [O] org-open-file with xdg-open not working?

Thanks for the tip. Even though I prefer to open the pdfs in pdf-tools inside Emacs now, glad to know that a solution exists.