Config: Strip down and simplify Emacs config
- Remove consult-dir, nerd-icons-completion, org-contrib and some other unused package - Delete init-org-refile.el and related keybindings - Prune EMMS config - Remove EXWM flatpak launcher helpers (vscodium, localsend, steam) - Extract Windows dirvish video preview fix to standalone module - Drop built-in settings moved elsewhere (startup defaults, whitespace, etc.) - Clean up trailing whitespace / process list prettify configs
This commit is contained in:
44
lisp/fix-dirvish-preview.el
Normal file
44
lisp/fix-dirvish-preview.el
Normal file
@@ -0,0 +1,44 @@
|
||||
;;; fix-dirvish-preview.el --- fix dirvish preview on windows -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Fix video-mtn preview issue on Windows
|
||||
;; The problem: mtn generates thumbnails with filename like "video.mp4.jpg",
|
||||
;; but dirvish expects MD5-based filename like "a1b2c3d4.jpg"
|
||||
(with-eval-after-load 'dirvish
|
||||
;; Function to find mtn output file for a given video file in cache directory
|
||||
(defun my/dirvish-find-mtn-output (video-file cache-dir ext)
|
||||
"Find mtn-generated thumbnail for VIDEO-FILE in CACHE-DIR with extension EXT."
|
||||
(let* ((file-base (file-name-base video-file))
|
||||
;; mtn generates: [filename].[ext].jpg
|
||||
(mtn-pattern (format "%s.%s.jpg" (regexp-quote file-base) ext))
|
||||
(files (directory-files cache-dir t mtn-pattern)))
|
||||
(car files)))
|
||||
|
||||
;; Advice to fix the sentinel after mtn generates the thumbnail
|
||||
(defun my/dirvish-media--cache-sentinel-advice (orig-fun proc exit-code)
|
||||
"Advice to rename mtn output to MD5 format after generation."
|
||||
(let* ((video-path (process-get proc 'path))
|
||||
(ext (downcase (or (file-name-extension video-path) "")))
|
||||
(dv (dirvish-curr)))
|
||||
(when (and (memq system-type '(ms-dos windows-nt))
|
||||
(member ext dirvish-video-exts)
|
||||
dv)
|
||||
;; Try to find and rename mtn output to MD5 format
|
||||
(let* ((width (dirvish-media--img-size (dv-preview-window dv)))
|
||||
(cache (dirvish--img-thumb-name video-path width ".jpg"))
|
||||
(cache-dir (dirvish--get-parent-path cache))
|
||||
(mtn-file (my/dirvish-find-mtn-output video-path cache-dir ext)))
|
||||
(when (and mtn-file (file-exists-p mtn-file) (not (file-exists-p cache)))
|
||||
(rename-file mtn-file cache)))))
|
||||
;; Call original function
|
||||
(funcall orig-fun proc exit-code))
|
||||
|
||||
;; Apply advice
|
||||
(advice-add 'dirvish-media--cache-sentinel :around #'my/dirvish-media--cache-sentinel-advice))
|
||||
|
||||
(provide 'fix-dirvish-preview)
|
||||
|
||||
;;; fix-dirvish-preview.el ends here
|
||||
Reference in New Issue
Block a user