You are not logged in.

#1 2025-03-15 16:00:29

tassio
Member
Registered: 2015-04-12
Posts: 16

[SOLVED] Trouble making xdg-open and emacsclient work together

I am trying to get xdg-open to use emacsclient, but seem to be missing something.

To me it seems that both `.tex` files and `.org` files should be opened with emacs, but
somehow the latter refuses to work. Any ideas?

$ cat /usr/share/applications/emacs.desktop
[Desktop Entry]
Name=Emacs (Client)
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;text/x-org;
Exec=emacsclient -c %f
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupNotify=true
StartupWMClass=Emacs
$ xdg-mime query filetype PLANNING.org
text/plain
$ xdg-mime query default text/plain
emacsclient.desktop
$ xdg-mime query filetype good.tex
text/x-tex
$ xdg-open good.tex # opens good.tex with emacsclient
Waiting for Emacs...
$ xdg-open PLANNING.org
[: -c: line 1: unexpected EOF while looking for matching `"'

Last edited by tassio (2025-03-15 16:18:04)

Offline

#2 2025-03-15 16:17:10

tassio
Member
Registered: 2015-04-12
Posts: 16

Re: [SOLVED] Trouble making xdg-open and emacsclient work together

Just sorted it out now! Found the problem by running the following.

$ xdg-mime query default text/plain
emacsclient.desktop

Note that the result is `emacsclient.desktop`, rather than `emacs.desktop` !!

As a solution (perhaps a bad one?) I have created a link

sudo ln -s /usr/share/applications/emacs.desktop /usr/share/applications/emacsclient.desktop

And now all seems good.

Offline

#3 2025-03-16 11:51:14

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,473

Re: [SOLVED] Trouble making xdg-open and emacsclient work together

As a solution (perhaps a bad one?)

yep, a bad one that will have to be redone every time emacs gets an update.

Create a custom mimeapps.list in your ~/.config (user-specific) or /etc/xdg (systemwide) folder with your desired solution , see https://wiki.archlinux.org/title/XDG_MI … eapps.list


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#4 2025-04-01 05:08:53

tassio
Member
Registered: 2015-04-12
Posts: 16

Re: [SOLVED] Trouble making xdg-open and emacsclient work together

Thank you so much! Indeed, much better!

Offline

Board footer

Powered by FluxBB