Explorar el Código

[emacs] Add func for scrobbling in eww

Colin Powell hace 2 semanas
padre
commit
d177a8f6ec
Se han modificado 1 ficheros con 19 adiciones y 0 borrados
  1. 19 0
      emacs/.config/doom/config.el

+ 19 - 0
emacs/.config/doom/config.el

@@ -402,3 +402,22 @@ Returns the ID string."
       )))
 
 (add-hook 'org-after-todo-state-change-hook #'send-org-todo-to-endpoint-on-state-change)
+
+(defun life-scrobble-url ()
+  "Open https://life.lab.unbl.ink/ with scrobble_url set to a URL.
+- If in an `eww` buffer, use its current URL.
+- Otherwise, use the clipboard/kill ring.
+Always open the result in `eww`."
+  (interactive)
+  (let* ((url (cond
+               ;; In eww, grab current page URL
+               ((derived-mode-p 'eww-mode)
+                (plist-get eww-data :url))
+               ;; Else clipboard
+               (t (current-kill 0 t))))
+         (encoded (url-hexify-string url))
+         (scrobble-url (concat "https://life.lab.unbl.ink/?scrobble_url=" encoded)))
+    (eww scrobble-url)))
+
+;; Bind globally to C-c l
+(global-set-key (kbd "C-c l") #'life-scrobble-url)