summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el41
1 files changed, 40 insertions, 1 deletions
diff --git a/init.el b/init.el index 73a7c5d..48dd80c 100644 --- a/init.el +++ b/init.el
@@ -89,12 +89,51 @@
89 browse-url-firefox-arguments '("--new-tab") ; for firefox 89 browse-url-firefox-arguments '("--new-tab") ; for firefox
90 browse-url-firefox-new-window-is-tab t) 90 browse-url-firefox-new-window-is-tab t)
91 91
92 (defvar browse-url-mpv-arguments nil
93 "Arguments to pass to mpv in `browse-url-mpv'.")
94
95 (defun browse-url-mpv (url &optional new-window)
96 "Play `URL' in mpv."
97 (interactive (browse-url-interactive-arg "Video URL: "))
98 (ignore new-window) ;; mpv always opens a new window
99 (let* ((url (browse-url-encode-url url))
100 (process-environment (browse-url-process-environment)))
101 (message "Playing %s in mpv..." url)
102 (apply #'start-process
103 (concat "mpv " url) nil
104 "mpv"
105 (append
106 browse-url-mpv-arguments
107 (list url)))))
108
109 (defvar browse-url-feh-arguments '("--auto-zoom"
110 "--geometry" "800x600")
111 "Arguments to pass to feh in `browse-url-feh'.")
112
113 (defun browse-url-feh (url &optional new-window)
114 "Open `URL' in feh."
115 (interactive (browse-url-interactive-arg "Video URL: "))
116 (ignore new-window) ;; mpv always opens a new window
117 (let* ((url (browse-url-encode-url url))
118 (process-environment (browse-url-process-environment)))
119 (message "Opening %s in feh..." url)
120 (apply #'start-process
121 (concat "feh " url) nil
122 "feh"
123 (append
124 browse-url-feh-arguments
125 (list url)))))
126
92 ;; `browse-url-browser-function' as an alist is deprecated in Emacs 28 for 127 ;; `browse-url-browser-function' as an alist is deprecated in Emacs 28 for
93 ;; `browse-url-handlers'. 128 ;; `browse-url-handlers'.
94 (set-default (if (version<= emacs-version "28") 129 (set-default (if (version<= emacs-version "28")
95 'browse-url-browser-function 130 'browse-url-browser-function
96 'browse-url-handlers) 131 'browse-url-handlers)
97 '(("." . eww-browse-url))) 132 `(,(when (executable-find "feh")
133 '("\\.jpe?g\\'" . browse-url-feh))
134 ,(when (executable-find "mpv")
135 '("youtube\\.com\\|youtu\\.be" . browse-url-mpv))
136 ("." . eww-browse-url)))
98 137
99 ;; Buttonize gemini:// links. 138 ;; Buttonize gemini:// links.
100 (acdw/add-button-url-regexp-protocol "gemini")) 139 (acdw/add-button-url-regexp-protocol "gemini"))