From 044360e2b7a5fd3eb51336401fe940f008fdac39 Mon Sep 17 00:00:00 2001 From: BirDt_ Date: Wed, 24 Sep 2025 19:10:55 +0800 Subject: [PATCH] Make emacs the default image viewer --- README.org | 3 +++ emacs-open | 6 ++++++ emacsclient.desktop | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100755 emacs-open create mode 100644 emacsclient.desktop diff --git a/README.org b/README.org index 9df2cc7..06e7fab 100644 --- a/README.org +++ b/README.org @@ -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. diff --git a/emacs-open b/emacs-open new file mode 100755 index 0000000..8cb226b --- /dev/null +++ b/emacs-open @@ -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 diff --git a/emacsclient.desktop b/emacsclient.desktop new file mode 100644 index 0000000..c9cbdfe --- /dev/null +++ b/emacsclient.desktop @@ -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