Skip to content

Commit

Permalink
tweak(media): automatically open Youtube links in MPV
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed May 23, 2023
1 parent c35356b commit 1fcc323
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion modules/me-media.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@

;;; Code:

(defcustom +mpv-command (executable-find "mpv")
"The MPV command."
:group 'minemacs-utils)

(defvar +mpv-buffer-name " *MPV*")
(defvar +mpv-process-name "mpv")

(when (executable-find +mpv-command)
(defun +browse-url-mpv (url &optional args)
"Open URL with MPV."
(start-process +mpv-process-name +mpv-buffer-name +mpv-command url))

(setq browse-url-browser-function
`((,(rx (seq "http" (? ?s) "://" (? "www.") (or "youtube.com" "youtu.be"))) . +browse-url-mpv)
("." . browse-url-default-browser))))

(use-package empv
:straight (:host github :repo "isamert/empv.el")
:preface
(defconst +mpv-available-p (executable-find "mpv"))
(defconst +mpv-available-p (executable-find +mpv-command))
:when +mpv-available-p
:init
(+map! :infix "o"
Expand Down

0 comments on commit 1fcc323

Please sign in to comment.