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