Nyxt launches mpv with a hinted url now

This commit is contained in:
Chris Cochrun 2021-07-06 06:48:09 -05:00
parent 5935064a00
commit 7fdc04e4d4

View file

@ -25,15 +25,19 @@
;; Create a function to launch mpv with given url ;; Create a function to launch mpv with given url
(defun mpv (url) (defun mpv (url)
"MPV launches with given url" "MPV launches with given url using the fast profile."
(uiop:run-program (list "mpv" url))) (uiop:run-program (list "mpv" "--profile=fast" url)))
;; Let's create a function to hint videos and play them in MPV ;; Let's create a function to hint videos, convert the url to a sting, and play them in MPV
(define-command hint-mpv (&key nyxt/web-mode::annotate-visible-only-p) (define-command hint-mpv (&key nyxt/web-mode::annotate-visible-only-p)
"Show a set of element hints, and copy the URL of the user inputted one." "Show a set of element hints, and copy the URL of the user inputted one."
(nyxt/web-mode:query-hints "Copy element URL" (nyxt/web-mode:query-hints "Copy element URL"
(lambda (nyxt/web-mode::result) (lambda (nyxt/web-mode::result)
(mpv nyxt/web-mode::result)) ;; this converts the url to a string to be used in mpv
(let* ((url (format nil "~a"
(url (first nyxt/web-mode::result)))))
;; here we take that string and pipe it into mpv
(mpv url)))
:annotate-visible-only-p :annotate-visible-only-p
nyxt/web-mode::annotate-visible-only-p)) nyxt/web-mode::annotate-visible-only-p))