Refine vuiet
This commit is contained in:
parent
0c2b5aaffc
commit
63ee4bea74
@ -5778,6 +5778,10 @@ A music browser and player:
|
|||||||
|
|
||||||
(use-package vuiet
|
(use-package vuiet
|
||||||
:straight (vuiet :host github :repo "mihaiolteanu/vuiet")
|
:straight (vuiet :host github :repo "mihaiolteanu/vuiet")
|
||||||
|
:commands (vuiet-playing-artist
|
||||||
|
vuiet-playing-track-name
|
||||||
|
vuiet--playing-track-duration
|
||||||
|
vuiet--playing-track)
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
(defvar vuiet-interactive-map (make-sparse-keymap))
|
(defvar vuiet-interactive-map (make-sparse-keymap))
|
||||||
@ -5788,11 +5792,20 @@ A music browser and player:
|
|||||||
(jdormit/define-prefix "avp" "player")
|
(jdormit/define-prefix "avp" "player")
|
||||||
(jdormit/define-prefix "avb" "browser")
|
(jdormit/define-prefix "avb" "browser")
|
||||||
:config
|
:config
|
||||||
(advice-add 'vuiet-update-mode-line :around
|
(defun vuiet-safe-update-mode-line ()
|
||||||
(lambda (oldfn &rest args)
|
(interactive)
|
||||||
(when (vuiet--playing-track)
|
(with-local-quit
|
||||||
(apply oldfn args))))
|
(ignore-errors
|
||||||
(run-at-time t 1 #'vuiet-update-mode-line)
|
(vuiet-update-mode-line))))
|
||||||
|
(defvar vuiet-mode-line-update-timer nil)
|
||||||
|
(defun vuiet-reset-mode-line ()
|
||||||
|
(interactive)
|
||||||
|
(when vuiet-mode-line-update-timer
|
||||||
|
(cancel-timer vuiet-mode-line-update-timer))
|
||||||
|
(vuiet-safe-update-mode-line)
|
||||||
|
(setq vuiet-mode-line-update-timer
|
||||||
|
(run-at-time t 1 #'vuiet-safe-update-mode-line)))
|
||||||
|
(vuiet-reset-mode-line)
|
||||||
:general
|
:general
|
||||||
(vuiet-player-map "p" #'vuiet-play-pause)
|
(vuiet-player-map "p" #'vuiet-play-pause)
|
||||||
(vuiet-player-map "s" #'vuiet-stop)
|
(vuiet-player-map "s" #'vuiet-stop)
|
||||||
@ -5819,9 +5832,11 @@ And a handy hydra for it:
|
|||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun now-playing (length)
|
(defun now-playing (length)
|
||||||
(let* ((str (s-truncate length
|
(let* ((str (s-truncate length
|
||||||
(format "%s - %s"
|
(if (vuiet--playing-track)
|
||||||
(vuiet-playing-artist)
|
(format "%s - %s"
|
||||||
(vuiet-playing-track-name))))
|
(vuiet-playing-artist)
|
||||||
|
(vuiet-playing-track-name))
|
||||||
|
"----")))
|
||||||
(remainder (- length (length str))))
|
(remainder (- length (length str))))
|
||||||
(if (> remainder 0)
|
(if (> remainder 0)
|
||||||
(let* ((left-pad (/ remainder 2))
|
(let* ((left-pad (/ remainder 2))
|
||||||
@ -5831,36 +5846,43 @@ And a handy hydra for it:
|
|||||||
str)))
|
str)))
|
||||||
|
|
||||||
(defun track-pos ()
|
(defun track-pos ()
|
||||||
(format "[%s/%s]"
|
(if (vuiet--playing-track)
|
||||||
(format-time-string "%M:%S" (mpv-get-playback-position))
|
(format "[%s/%s]"
|
||||||
(format-time-string "%M:%S" (vuiet--playing-track-duration))))
|
(format-time-string "%M:%S" (mpv-get-playback-position))
|
||||||
|
(format-time-string "%M:%S" (vuiet--playing-track-duration)))
|
||||||
|
"[00:00/00:00]"))
|
||||||
|
|
||||||
(defvar hydra-vuiet-body-timer)
|
(defvar hydra-vuiet-body-timer)
|
||||||
|
(defun refresh-hydra-vuiet ()
|
||||||
|
(interactive)
|
||||||
|
(hydra-show-hint hydra-vuiet/hint 'refresh-hydra-vuiet))
|
||||||
(defhydra hydra-vuiet (:hint nil
|
(defhydra hydra-vuiet (:hint nil
|
||||||
:body-pre (setq hydra-vuiet-body-timer
|
:body-pre (setq hydra-vuiet-body-timer
|
||||||
(run-at-time t 1 (lambda ()
|
(run-at-time t 1 #'refresh-hydra-vuiet))
|
||||||
(hydra-show-hint hydra-vuiet/hint 'hydra-vuiet))))
|
:post (cancel-function-timers 'refresh-hydra-vuiet))
|
||||||
:post (cancel-timer hydra-vuiet-body-timer))
|
|
||||||
"
|
"
|
||||||
--- ^^ ^^ ^^ ^^ ---
|
--- ^^ ^^ ^^ ---
|
||||||
+------------------/ / ^^ ^^ ^^ ^^+------------------/ /
|
+------------------/ / ^^ ^^ ^^ +------------------/ /
|
||||||
| - ------- / / ^^ ^^ ^^ ^^| - ------- / /
|
| - ------- / / ^^ ^^ ^^ | - ------- / /
|
||||||
|(-) .d########b. //)|+------------^^----------------^^------------^^-----+^^|(-) .d########b. //)|
|
|(-) .d########b. //)|+------------^^----------------^^------------^^-----+|(-) .d########b. //)| Play [_t_]ag(s)
|
||||||
| .d############// ||+-----------^^----------------^^------------^^----+|^^| .d############// |
|
| .d############// ||+-----------^^----------------^^------------^^----+|| .d############// | Play [_a_]rtist
|
||||||
| .d######''####//b. |||%s(now-playing 43)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^||^^| .d######''####//b. |
|
| .d######''####//b. |||%s(now-playing 43)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^||| .d######''####//b. | Play a[_l_]bum
|
||||||
| 9######( )#-//##P ||+-----------^^--+-------------^^+-----------^^----+|^^| 9######( )#-//##P |
|
| 9######( )#-//##P ||+-----------^^--+-------------^^+-----------^^----+|| 9######( )#-//##P |
|
||||||
| 'b######++#/-/##d' || ^^ |%s(track-pos)^^| ^^ |^^| 'b######++#/-/##d' |
|
| 'b######++#/-/##d' || ^^ |%s(track-pos)^^| ^^ || 'b######++#/-/##d' |
|
||||||
| '9############P' || ^^ +-------------^^+ ^^ |^^| '9############P' |
|
| '9############P' || ^^ +-------------^^+ ^^ || '9############P' |
|
||||||
| -'9a#######aP' || +---------^^+---------------^^--+---------^^--+ |^^| -'9a#######aP' |
|
| -'9a#######aP' || +---------^^+---------------^^--+---------^^--+ || -'9a#######aP' |
|
||||||
| |-| `'''''' || | _s_top | _p_lay/pause | _n_ext | |^^| |-| `'''''' |
|
| |-| `'''''' || | _s_top | _p_lay/pause | _n_ext | || |-| `'''''' |
|
||||||
| ---..----------- || +---------^^+---------------^^--+---------^^--+ |^^| ---..----------- |
|
| ---..----------- || +---------^^+---------------^^--+---------^^--+ || ---..----------- |
|
||||||
| |---||-----------| |+------------^^----------------^^------------^^-----+^^| |---||-----------| |
|
| |---||-----------| |+------------^^----------------^^------------^^-----+| |---||-----------| |
|
||||||
| | ^^ ^^ ^^ ^^| |
|
| | ^^ ^^ ^^ | | [_q_]uit
|
||||||
+--------------------+ [_q_]uit ^^ ^^ ^^ +--------------------+
|
+--------------------+ ^^ ^^ ^^ +--------------------+
|
||||||
"
|
"
|
||||||
("s" vuiet-stop :color blue)
|
("s" vuiet-stop :color blue)
|
||||||
("p" vuiet-play-pause)
|
("p" vuiet-play-pause)
|
||||||
("n" vuiet-next)
|
("n" vuiet-next)
|
||||||
|
("t" vuiet-play-tag-similar)
|
||||||
|
("a" vuiet-play-artist)
|
||||||
|
("l" vuiet-play-album)
|
||||||
("q" nil :color blue))
|
("q" nil :color blue))
|
||||||
(general-def "C-c v" #'hydra-vuiet/body)
|
(general-def "C-c v" #'hydra-vuiet/body)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
Loading…
Reference in New Issue
Block a user