From ed7807cb7c8de3133cd1b503c0bbdeced1a5e6ab Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 6 Apr 2024 20:43:08 +0300 Subject: yeetube-mpv: Add yeetube-mpv-modeline-mode --- yeetube-mpv.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index 141e6e9..4bab5e9 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -46,6 +46,12 @@ Accepted values include: 1080, 720, 480, 360, 240, 144") (defvar yeetube-mpv-currently-playing nil "Currently playing information.") +(defun yeetube-mpv-modeline-string () + "Return modeline string for yeetube-mpv." + (if yeetube-mpv-currently-playing + (format "%s" yeetube-mpv-currently-playing) + "nil")) + (defun yeetube-mpv-change-video-quality () "Change video quality." (interactive) @@ -103,6 +109,22 @@ to play local files." "yeetube: Starting mpv process")) (setf yeetube-mpv-currently-playing (format "[%s]" info)))) +(define-minor-mode yeetube-mpv-modeline-mode + "Minor mode for showing currently playing information on the modeline." + :global t + :group 'yeetube + :lighter nil + (if yeetube-mpv-modeline-mode + (progn + (add-to-list 'global-mode-string '(:eval + (format " ♫:%s" (yeetube-mpv-modeline-string)))) + (force-mode-line-update)) + (setf global-mode-string + (seq-remove (lambda (item) + (and (listp item) (eq (car item) :eval) + (string-prefix-p " ♫:" (format "%s" (eval (cadr item)))))) + global-mode-string)) + (force-mode-line-update))) (defun yeetube-mpv-toggle-no-video-flag () "Toggle no video flag for mpv player." -- cgit v1.2.3