Thunar implements Freedesktop's desktop entry specification, so a .desktop
entry is the answer you are looking for. Try saving this to $XDG_DATA_HOME/applications/emacs.desktop
or $HOME/.local/share/applications/emacs.desktop
if you don't have that set.
[Desktop Entry]
Name=Emacs
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++;
Exec=emacsclient -c -a "" %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
This will take precedence over any emacs.desktop
in /usr/share/applications
. You may need to logout and and login again before it works, but now when you select Emacs from "open with" it will either attach to the running daemon, or start one and attach if it was not already running.
Exec=emacsclient -c -a 'emacs -Q' %F
. It launches Emacs, not as a server, in case it's not already running. It's very fast due to-Q
. I don't prefer the silent server start (-a ""
), since I have(unless (server-running-p) (server-start))
in my.emacs
. – legends2k Nov 12 '19 at 13:27