tweaks to toggle changes and empv

This commit is contained in:
Chris Cochrun 2025-03-25 10:10:10 -05:00
parent 51e283e587
commit 476b820019
2 changed files with 187 additions and 154 deletions

View file

@ -581,6 +581,9 @@ Here let's try to add ligatures to our font system since the VictorMono Nerd Fon
There are two major packages we need to get the functionality I desire. Evil and general. There are two major packages we need to get the functionality I desire. Evil and general.
*** Evil *** Evil
:PROPERTIES:
:ID: 20250304T164537.064599
:END:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package evil (use-package evil
@ -614,6 +617,12 @@ This evil-collection package includes a lot of other evil based things.
:after evil :after evil
:init (evil-escape-mode +1) :init (evil-escape-mode +1)
:config :config
(defun chris/toggle-evil-escape-sequence ()
(interactive)
(if (string= evil-escape-key-sequence "ae")
(setq evil-escape-key-sequence "fd")
(setq evil-escape-key-sequence "ae")))
(setq evil-escape-key-sequence (kbd "ae") (setq evil-escape-key-sequence (kbd "ae")
evil-escape-delay 0.3)) evil-escape-delay 0.3))
#+end_src #+end_src
@ -5049,89 +5058,98 @@ With empv we can perhaps control mpv much more fine grainly and even search yout
(message args) (message args)
(empv-play-or-enqueue video)) (empv-play-or-enqueue video))
(defun chris/empv-yt-dlp () (defun chris/empv-yt-dlp (&optional file)
"Download the current video and and play it" "Download the current video and and play it"
(interactive) (interactive)
(let* ((item (empv-youtube-results--current-item)) (setq lexical-binding t)
(video-id (alist-get 'videoId item)) (let* ((item (when (not file) (empv-youtube-results--current-item)))
(playlist-id (alist-get 'playlistId item)) (video-id (when (not file) (alist-get 'videoId item)))
(title (alist-get 'title item)) (playlist-id (when (not file) (alist-get 'playlistId item)))
(url (format (title (if file (shell-command
"https://youtube.com/%s=%s" (format "yt-dlp --get-title %s" file))
(if video-id "watch?v" "playlist?list") (alist-get 'title item)))
(or video-id playlist-id)))) (url (if file file
(async-shell-command (concat (format
"yt-dlp" " -o '/home/chris/vids/%(title)s.%(ext)s'" "https://youtube.com/%s=%s"
" \"" url "\"")) (if video-id "watch?v" "playlist?list")
(let ((file (format "/home/chris/vids/%s.%s" title "webm"))) (or video-id playlist-id)))))
(empv-play file)) (message url)
(message url))) (async-start-process
"yt-dlp" "yt-dlp"
(lambda ()
(let ((file (format "/home/chris/vids/%s.%s" title "webm")))
(empv-play-or-enqueue file))
(message "here be the url %s" url))
"-o" "'/home/chris/vids/%(title)s.%(ext)s'" url)))
(defun chris/empv-yt-dlp-jellyfin () (get-process "yt-dlp")
"Grabs the current video at point and downloads it to my jellyfin server" (chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=qRE6kf30u4g")
(interactive)
(let* ((server "jelly.cochrun.xyz")
(item (empv-youtube-results--current-item))
(video-id (alist-get 'videoId item))
(playlist-id (alist-get 'playlistId item))
(title (alist-get 'title item))
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
(url (format
"https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list")
(or video-id playlist-id))))
(async-shell-command (concat
"ssh " server " \"" "yt-dlp"
" -o '/storage/media/media/chris/extras/yt/"
location
"/%(title)s.%(ext)s'"
" '" url "'" "\""))
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
(defun chris/empv-org-play-link (&optional link) (defun chris/empv-yt-dlp-jellyfin ()
"Play link in empv from either supplied link or link at point in org-mode" "Grabs the current video at point and downloads it to my jellyfin server"
(interactive) (interactive)
(let ((link (if link (let* ((server "jelly.cochrun.xyz")
link (item (empv-youtube-results--current-item))
(org-babel-read-link)))) (video-id (alist-get 'videoId item))
(empv-play link))) (playlist-id (alist-get 'playlistId item))
(title (alist-get 'title item))
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
(url (format
"https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list")
(or video-id playlist-id))))
(async-shell-command (concat
"ssh " server " \"" "yt-dlp"
" -o '/storage/media/media/chris/extras/yt/"
location
"/%(title)s.%(ext)s'"
" '" url "'" "\""))
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
(defun chris/dired-empv-play-or-enqueue () (defun chris/empv-org-play-link (&optional link)
"Play file at point in dired" "Play link in empv from either supplied link or link at point in org-mode"
(interactive) (interactive)
(let* ((file (dired-get-filename))) (let ((link (if link
(empv-play-or-enqueue file))) link
(org-babel-read-link))))
(empv-play link)))
(defun chris/empv-seek-forward () (defun chris/dired-empv-play-or-enqueue ()
"Seek forward 20 seconds" "Play file at point in dired"
(interactive) (interactive)
(empv-seek "20")) (let* ((file (dired-get-filename)))
(empv-play-or-enqueue file)))
:general (defun chris/empv-seek-forward ()
(chris/leader-keys "Seek forward 20 seconds"
:states 'normal (interactive)
:keymaps 'override (empv-seek "20"))
"vo" 'empv-play-or-enqueue
"vt" 'empv-toggle :general
"vv" 'empv-play-video (chris/leader-keys
"vx" 'empv-chapter-select :states 'normal
"vy" 'empv-youtube-tabulated :keymaps 'override
"vn" 'empv-playlist-next "vo" 'empv-play-or-enqueue
"vp" 'empv-playlist-prev "vt" 'empv-toggle
"vs" 'empv-playlist-select "vv" 'empv-play-video
"vS" 'chris/empv-seek-forward) "vx" 'empv-chapter-select
(general-def "vy" 'empv-youtube-tabulated
:states 'normal "vn" 'empv-playlist-next
:keymaps 'empv-youtube-results-mode-map "vp" 'empv-playlist-prev
"q" 'kill-current-buffer "vs" 'empv-playlist-select
"RET" 'empv-youtube-results-play-or-enqueue-current "vS" 'chris/empv-seek-forward)
"i" 'empv-youtube-results-inspect (general-def
"d" 'chris/empv-yt-dlp :states 'normal
"D" 'chris/empv-yt-dlp-jellyfin) :keymaps 'empv-youtube-results-mode-map
(general-def "q" 'kill-current-buffer
:states 'normal "RET" 'empv-youtube-results-play-or-enqueue-current
:keymaps 'dired-mode-map "i" 'empv-youtube-results-inspect
"vi" 'chris/dired-empv-play-or-enqueue)) "d" 'chris/empv-yt-dlp
"D" 'chris/empv-yt-dlp-jellyfin)
(general-def
:states 'normal
:keymaps 'dired-mode-map
"vi" 'chris/dired-empv-play-or-enqueue))
#+end_src #+end_src
I need to update the new normal mode pieces to this... I need to update the new normal mode pieces to this...
@ -5272,7 +5290,7 @@ q quit-window
(elfeed-search-untag-all-unread) (elfeed-search-untag-all-unread)
(if (process-live-p proc) (if (process-live-p proc)
(set-process-sentinel (set-process-sentinel
proc `(empv-play-or-enqueue proc `(empv-enqueue
,(concat "/home/chris/vids/" title ".webm"))) ,(concat "/home/chris/vids/" title ".webm")))
(message "No process running")))) (message "No process running"))))

169
init.el
View file

@ -350,6 +350,12 @@
:after evil :after evil
:init (evil-escape-mode +1) :init (evil-escape-mode +1)
:config :config
(defun chris/toggle-evil-escape-sequence ()
(interactive)
(if (string= evil-escape-key-sequence "ae")
(setq evil-escape-key-sequence "fd")
(setq evil-escape-key-sequence "ae")))
(setq evil-escape-key-sequence (kbd "ae") (setq evil-escape-key-sequence (kbd "ae")
evil-escape-delay 0.3)) evil-escape-delay 0.3))
@ -3698,89 +3704,98 @@ targets."
(message args) (message args)
(empv-play-or-enqueue video)) (empv-play-or-enqueue video))
(defun chris/empv-yt-dlp () (defun chris/empv-yt-dlp (&optional file)
"Download the current video and and play it" "Download the current video and and play it"
(interactive) (interactive)
(let* ((item (empv-youtube-results--current-item)) (setq lexical-binding t)
(video-id (alist-get 'videoId item)) (let* ((item (when (not file) (empv-youtube-results--current-item)))
(playlist-id (alist-get 'playlistId item)) (video-id (when (not file) (alist-get 'videoId item)))
(title (alist-get 'title item)) (playlist-id (when (not file) (alist-get 'playlistId item)))
(url (format (title (if file (shell-command
"https://youtube.com/%s=%s" (format "yt-dlp --get-title %s" file))
(if video-id "watch?v" "playlist?list") (alist-get 'title item)))
(or video-id playlist-id)))) (url (if file file
(async-shell-command (concat (format
"yt-dlp" " -o '/home/chris/vids/%(title)s.%(ext)s'" "https://youtube.com/%s=%s"
" \"" url "\"")) (if video-id "watch?v" "playlist?list")
(let ((file (format "/home/chris/vids/%s.%s" title "webm"))) (or video-id playlist-id)))))
(empv-play file)) (message url)
(message url))) (async-start-process
"yt-dlp" "yt-dlp"
(lambda ()
(let ((file (format "/home/chris/vids/%s.%s" title "webm")))
(empv-play-or-enqueue file))
(message "here be the url %s" url))
"-o" "'/home/chris/vids/%(title)s.%(ext)s'" url)))
(defun chris/empv-yt-dlp-jellyfin () (get-process "yt-dlp")
"Grabs the current video at point and downloads it to my jellyfin server" (chris/empv-yt-dlp "https://inv.cochrun.xyz/watch?v=qRE6kf30u4g")
(interactive)
(let* ((server "jelly.cochrun.xyz")
(item (empv-youtube-results--current-item))
(video-id (alist-get 'videoId item))
(playlist-id (alist-get 'playlistId item))
(title (alist-get 'title item))
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
(url (format
"https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list")
(or video-id playlist-id))))
(async-shell-command (concat
"ssh " server " \"" "yt-dlp"
" -o '/storage/media/media/chris/extras/yt/"
location
"/%(title)s.%(ext)s'"
" '" url "'" "\""))
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
(defun chris/empv-org-play-link (&optional link) (defun chris/empv-yt-dlp-jellyfin ()
"Play link in empv from either supplied link or link at point in org-mode" "Grabs the current video at point and downloads it to my jellyfin server"
(interactive) (interactive)
(let ((link (if link (let* ((server "jelly.cochrun.xyz")
link (item (empv-youtube-results--current-item))
(org-babel-read-link)))) (video-id (alist-get 'videoId item))
(empv-play link))) (playlist-id (alist-get 'playlistId item))
(title (alist-get 'title item))
(location (completing-read "location: " '("dev" "house" "ministry" "misc")))
(url (format
"https://youtube.com/%s=%s"
(if video-id "watch?v" "playlist?list")
(or video-id playlist-id))))
(async-shell-command (concat
"ssh " server " \"" "yt-dlp"
" -o '/storage/media/media/chris/extras/yt/"
location
"/%(title)s.%(ext)s'"
" '" url "'" "\""))
(message (format "%s is downloading to the %s folder on jellyfin" url location))))
(defun chris/dired-empv-play-or-enqueue () (defun chris/empv-org-play-link (&optional link)
"Play file at point in dired" "Play link in empv from either supplied link or link at point in org-mode"
(interactive) (interactive)
(let* ((file (dired-get-filename))) (let ((link (if link
(empv-play-or-enqueue file))) link
(org-babel-read-link))))
(empv-play link)))
(defun chris/empv-seek-forward () (defun chris/dired-empv-play-or-enqueue ()
"Seek forward 20 seconds" "Play file at point in dired"
(interactive) (interactive)
(empv-seek "20")) (let* ((file (dired-get-filename)))
(empv-play-or-enqueue file)))
:general (defun chris/empv-seek-forward ()
(chris/leader-keys "Seek forward 20 seconds"
:states 'normal (interactive)
:keymaps 'override (empv-seek "20"))
"vo" 'empv-play-or-enqueue
"vt" 'empv-toggle :general
"vv" 'empv-play-video (chris/leader-keys
"vx" 'empv-chapter-select :states 'normal
"vy" 'empv-youtube-tabulated :keymaps 'override
"vn" 'empv-playlist-next "vo" 'empv-play-or-enqueue
"vp" 'empv-playlist-prev "vt" 'empv-toggle
"vs" 'empv-playlist-select "vv" 'empv-play-video
"vS" 'chris/empv-seek-forward) "vx" 'empv-chapter-select
(general-def "vy" 'empv-youtube-tabulated
:states 'normal "vn" 'empv-playlist-next
:keymaps 'empv-youtube-results-mode-map "vp" 'empv-playlist-prev
"q" 'kill-current-buffer "vs" 'empv-playlist-select
"RET" 'empv-youtube-results-play-or-enqueue-current "vS" 'chris/empv-seek-forward)
"i" 'empv-youtube-results-inspect (general-def
"d" 'chris/empv-yt-dlp :states 'normal
"D" 'chris/empv-yt-dlp-jellyfin) :keymaps 'empv-youtube-results-mode-map
(general-def "q" 'kill-current-buffer
:states 'normal "RET" 'empv-youtube-results-play-or-enqueue-current
:keymaps 'dired-mode-map "i" 'empv-youtube-results-inspect
"vi" 'chris/dired-empv-play-or-enqueue)) "d" 'chris/empv-yt-dlp
"D" 'chris/empv-yt-dlp-jellyfin)
(general-def
:states 'normal
:keymaps 'dired-mode-map
"vi" 'chris/dired-empv-play-or-enqueue))
(use-package elfeed (use-package elfeed
:commands (elfeed) :commands (elfeed)
@ -3839,7 +3854,7 @@ targets."
(elfeed-search-untag-all-unread) (elfeed-search-untag-all-unread)
(if (process-live-p proc) (if (process-live-p proc)
(set-process-sentinel (set-process-sentinel
proc `(empv-play-or-enqueue proc `(empv-enqueue
,(concat "/home/chris/vids/" title ".webm"))) ,(concat "/home/chris/vids/" title ".webm")))
(message "No process running")))) (message "No process running"))))