adding eww-mpv command to launch mpv from eww with link

This commit is contained in:
Chris Cochrun 2022-08-30 09:41:03 -05:00
parent a04670f1c0
commit 4d5a97bd8e
2 changed files with 60 additions and 6 deletions

View file

@ -1278,7 +1278,23 @@ These two packages created by Prot are interesting to me and may help to make su
Builtin webbrowser for emacs. Trying it out as a text only browser for things.
#+begin_src emacs-lisp
(defun chris/eww-mpv ()
"Launch the url in mpv"
(interactive)
(let ((pt (avy-with ace-link-eww
(avy-process
(mapcar #'cdr (ace-link--eww-collect))
(avy--style-fn avy-style)))))
(when (number-or-marker-p pt)
(goto-char pt)
(let ((url (get-text-property (point) 'shr-url)))
(if (start-process "mpv" "mpv-output" "mpv" url)
(message (concat"mpv started => " url))
(message "mpv failed, maybe this isn't a link?"))))))
(general-def 'normal eww-mode-map
"gv" 'chris/eww-mpv)
#+end_src
** Completion
@ -1853,7 +1869,10 @@ Ace link provides an avy like search for links. Upon using the keybindings prese
("\\*Bongo-Elfeed Queue\\*"
(display-buffer-in-side-window)
(side . bottom)
(window-height . 0.25))))
(window-height . 0.25))
("\\*Async Shell Command\\*"
(display-buffer-no-window))
))
#+end_src
Since I like to make my window manager handle a lot of the window management, I will create a helper function for closing windows.
@ -2498,9 +2517,9 @@ Let's add org-msg to write emails in org-mode
'(cfw:face-saturday ((t :weight bold)))
'(cfw:face-holiday ((t :weight bold)))
;; '(cfw:face-grid ((t :foreground "DarkGrey")))
;; '(cfw:face-default-content ((t :foreground "#bfebbf")))
'(cfw:face-default-content ((t :height 0.7)))
;; '(cfw:face-periods ((t :foreground "cyan")))
'(cfw:face-day-title ((t :background nil)))
'(cfw:face-day-title ((t (:background nil))))
'(cfw:face-default-day ((t :weight bold :inherit cfw:face-day-title)))
'(cfw:face-annotation ((t :inherit cfw:face-day-title)))
'(cfw:face-disable ((t :inherit cfw:face-day-title)))
@ -2510,6 +2529,14 @@ Let's add org-msg to write emails in org-mode
'(cfw:face-toolbar ((t :foreground "Steelblue4" :background "Steelblue4")))
'(cfw:face-toolbar-button-off ((t :weight bold)))
'(cfw:face-toolbar-button-on ((t :weight bold))))
(setq cfw:fchar-junction ?╋
cfw:fchar-vertical-line ?┃
cfw:fchar-horizontal-line ?━
cfw:fchar-left-junction ?┣
cfw:fchar-right-junction ?┫
cfw:fchar-top-junction ?┯
cfw:fchar-top-left-corner ?┏
cfw:fchar-top-right-corner ?┓)
:general
(chris/leader-keys
:states 'normal

33
init.el
View file

@ -938,7 +938,23 @@ If on a:
(add-hook 'imenu-after-jump-hook #'pulsar-recenter-top)
(add-hook 'imenu-after-jump-hook #'pulsar-reveal-entry))
(defun chris/eww-mpv ()
"Launch the url in mpv"
(interactive)
(let ((pt (avy-with ace-link-eww
(avy-process
(mapcar #'cdr (ace-link--eww-collect))
(avy--style-fn avy-style)))))
(when (number-or-marker-p pt)
(goto-char pt)
(let ((url (get-text-property (point) 'shr-url)))
(if (start-process "mpv" "mpv-output" "mpv" url)
(message (concat"mpv started => " url))
(message "mpv failed, maybe this isn't a link?"))))))
(general-def 'normal eww-mode-map
"gv" 'chris/eww-mpv)
(use-package vertico
:init
@ -1313,7 +1329,10 @@ targets."
("\\*Bongo-Elfeed Queue\\*"
(display-buffer-in-side-window)
(side . bottom)
(window-height . 0.25))))
(window-height . 0.25))
("\\*Async Shell Command\\*"
(display-buffer-no-window))
))
(defun chris/kill-buffer-frame ()
"Kills the active buffer and frame"
@ -1731,9 +1750,9 @@ targets."
'(cfw:face-saturday ((t :weight bold)))
'(cfw:face-holiday ((t :weight bold)))
;; '(cfw:face-grid ((t :foreground "DarkGrey")))
;; '(cfw:face-default-content ((t :foreground "#bfebbf")))
'(cfw:face-default-content ((t :height 0.7)))
;; '(cfw:face-periods ((t :foreground "cyan")))
'(cfw:face-day-title ((t :background nil)))
'(cfw:face-day-title ((t (:background nil))))
'(cfw:face-default-day ((t :weight bold :inherit cfw:face-day-title)))
'(cfw:face-annotation ((t :inherit cfw:face-day-title)))
'(cfw:face-disable ((t :inherit cfw:face-day-title)))
@ -1743,6 +1762,14 @@ targets."
'(cfw:face-toolbar ((t :foreground "Steelblue4" :background "Steelblue4")))
'(cfw:face-toolbar-button-off ((t :weight bold)))
'(cfw:face-toolbar-button-on ((t :weight bold))))
(setq cfw:fchar-junction ?╋
cfw:fchar-vertical-line ?┃
cfw:fchar-horizontal-line ?━
cfw:fchar-left-junction ?┣
cfw:fchar-right-junction ?┫
cfw:fchar-top-junction ?┯
cfw:fchar-top-left-corner ?┏
cfw:fchar-top-right-corner ?┓)
:general
(chris/leader-keys
:states 'normal