From 7a03b0d585275fadf275c9b028ea9053334fcbcf Mon Sep 17 00:00:00 2001
From: Aryadev Chavali <aryadev@aryadevchavali.com>
Date: Tue, 1 Oct 2024 16:21:39 +0100
Subject: Move mpv module into configuration directly

---
 Emacs/.config/emacs/config.org | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org
index b99d649..185e5fb 100644
--- a/Emacs/.config/emacs/config.org
+++ b/Emacs/.config/emacs/config.org
@@ -2316,13 +2316,31 @@ and integrates slickly into image-dired.  Of course,
     "l" #'image-forward-hscroll))
 #+end_src
 ** mpv
-My [[file:elisp/mpv.el][custom mpv module]] for opening videos in
-Emacs.
-
+Little helper which launches an MPV process asynchronously.
 #+begin_src emacs-lisp
-(use-package mpv
+(use-package emacs
   :defer t
-  :load-path "elisp/"
+  :config
+  (defvar mpv-args "-v --profile=fast --hwdec=auto-copy"
+    "General arguments for mpv binary.")
+
+  (defun mpv-start-process (url)
+    (message "[mpv]: Starting mpv on `%s'" url)
+    (with-current-buffer (get-buffer-create "*mpv*")
+      (ansi-color-for-comint-mode-on)
+      (comint-mode))
+    (set-process-filter (start-process-shell-command
+                         "mpv" "*mpv*"
+                         (concat "mpv " mpv-args " \"" url "\""))
+                        #'comint-output-filter))
+
+  (defun mpv-open-video (&optional arg)
+    (interactive)
+    (let ((url (if (stringp arg)
+                   arg
+                 (expand-file-name (read-file-name "URL?: " default-directory "" t)))))
+      (mpv-start-process url)
+      (switch-to-buffer "*mpv*")))
   :general
   (app-leader
     "v" #'mpv-open-video))
-- 
cgit v1.2.3-13-gbd6f