Make emacs the default image viewer

This commit is contained in:
BirDt_ 2025-09-24 19:10:55 +08:00
parent e34d6dd120
commit 044360e2b7
3 changed files with 31 additions and 0 deletions

View file

@ -47,6 +47,9 @@ If using =bspwm= and =sxhkd=, I suggest the following keyinds to make use of eve
#+end_src
** Open Images Automatically With Emacsclient
To automatically open images with ~emacsclient~ (useful, for example, to open them as a new buffer from Gomuks with ~/open~), copy ~emacs-open~ to ~/usr/bin/~ and make it executable. Then replace ~emacsclient.desktop~ with the one in this repository. Finally, run ~xdg-mime default emacsclient.desktop $(grep '^image/*' /usr/share/mime/types)~ to update emacsclient to be the default mimetype handler.
* Opinionated Stuff
This is a list of files/flows that are very opinionated and you may wish to delete from the configuration, or heavily modify.

6
emacs-open Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
if [ -n "$*" ]; then
exec /usr/bin/emacsclient --alternate-editor= --display="$DISPLAY" "$@"
else
exec emacsclient --alternate-editor= --create-frame
fi

22
emacsclient.desktop Normal file
View file

@ -0,0 +1,22 @@
[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++;x-scheme-handler/org-protocol;
Exec=emacs-open %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupNotify=true
StartupWMClass=Emacs
Keywords=emacsclient;
Actions=new-window;new-instance;
[Desktop Action new-window]
Name=New Window
Exec=/usr/bin/emacsclient --alternate-editor= --create-frame %F
[Desktop Action new-instance]
Name=New Instance
Exec=emacs %F