emacs-framebuffer

Emacs library to show images and documents in console using Linux framebuffer
Log | Files | Refs

commit 17d7ed1bea8cccb278a5d40733e1f2b6e3cef3da
parent af831889486704b83efd1f3a546c87bad4df9411
Author: Tomas Hlavaty <tom@logand.com>
Date:   Fri,  5 Jan 2024 22:23:47 +0100

add framebuffer-fbi viewer

Diffstat:
Memacs-framebuffer.el | 24++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/emacs-framebuffer.el b/emacs-framebuffer.el @@ -83,13 +83,19 @@ (defun framebuffer-file-format (file) (let ((name (file-name-sans-versions file))) (cond + ((string-match "\\.\\(3ga\\|3GA\\)\\'" name) '3ga) ((string-match "\\.\\(abw\\|ABW\\)\\'" name) 'abw) ((string-match "\\.\\(bmp\\|BMP\\)\\'" name) 'bmp) ((string-match "\\.\\(doc\\|DOC\\)\\'" name) 'doc) ((string-match "\\.\\(docx\\|DOCX\\)\\'" name) 'docx) ((string-match "\\.\\(gif\\|GIF\\)\\'" name) 'gif) ((string-match "\\.\\(jpe?g\\|JPE?G\\)\\'" name) 'jpeg) + ((string-match "\\.\\(m4a\\|M4A\\)\\'" name) 'm4a) + ((string-match "\\.\\(mkv\\|MKV\\)\\'" name) 'mkv) + ((string-match "\\.\\(mp3\\|MP3\\)\\'" name) 'mp3) + ((string-match "\\.\\(mp4\\|MP4\\)\\'" name) 'mp4) ((string-match "\\.\\(odt\\|ODT\\)\\'" name) 'odt) + ((string-match "\\.\\(ogg\\|OGG\\)\\'" name) 'ogg) ((string-match "\\.\\(pbm\\|PBM\\)\\'" name) 'pbm) ((string-match "\\.\\(pdf\\|PDF\\)\\'" name) 'pdf) ((string-match "\\.\\(pgm\\|PGM\\)\\'" name) 'pgm) @@ -99,6 +105,7 @@ ((string-match "\\.\\(rtf\\|RTF\\)\\'" name) 'rtf) ((string-match "\\.\\(svg\\|SVG\\)\\'" name) 'svg) ((string-match "\\.\\(tiff?\\|TIFF?\\)\\'" name) 'tiff) + ((string-match "\\.\\(webm\\|WEBM\\)\\'" name) 'webm) ((string-match "\\.\\(xbm\\|XBM\\)\\'" name) 'xbm) ((string-match "\\.\\(xpm\\|XPM\\)\\'" name) 'xpm) ))) @@ -670,6 +677,11 @@ (s (mod m 60))) (format "%d:%02d:%02d" (floor sec 3600) (floor (- m s) 60) s))))) +(defun framebuffer-fbi (filename) + (suspend-emacs + (format "fbi %s; fg" + (shell-quote-argument (expand-file-name filename))))) + (defun framebuffer-fbmpv (filename &optional position) (suspend-emacs (format "mpv --vo=drm --osd-level=3 %s%s %s; fg" @@ -686,12 +698,12 @@ (defun framebuffer-fbview () (interactive) - (let* ((filename (dired-file-name-at-point)) - (x (file-name-extension filename))) - (cond - ((member x '("pdf" "PDF")) (framebuffer-fbpdf filename)) - ((member x '("mkv" "MKV" "mp4" "MP4" "ogg" "OGG" "webm" "WEBM")) (framebuffer-fbmpv filename)) - ((member x '("mp3" "MP3" "3ga" "3GA")) (framebuffer-mocp filename))))) + (let ((filename (dired-file-name-at-point))) + (cl-case (framebuffer-file-format filename) + ((bmp gif jpeg png tiff) (framebuffer-fbpdf filename)) + (pdf (framebuffer-fbpdf filename)) + ((mkv mp4 ogg webm) (framebuffer-fbmpv filename)) + ((3ga m4a mp3) (framebuffer-mocp filename))))) (add-hook 'framebuffer-image-mode-hook