Make hydra even better

This commit is contained in:
Jeremy Dormitzer 2020-04-01 15:34:14 -04:00
parent 0ce08e6c83
commit 4e9ec5f5b6

View File

@ -5807,17 +5807,40 @@ A music browser and player:
And a handy hydra for it: And a handy hydra for it:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(defhydra hydra-vuiet (:hint nil) (defun now-playing (length)
(let* ((str (s-truncate length
(format "%s - %s"
(vuiet-playing-artist)
(vuiet-playing-track-name))))
(remainder (- length (length str))))
(if (> remainder 0)
(let* ((left-pad (/ remainder 2))
(right-pad (- remainder left-pad)))
(s-prepend (s-repeat left-pad " ")
(s-append (s-repeat right-pad " ") str)))
str)))
(defun track-pos ()
(format "[%s/%s]"
(format-time-string "%M:%S" (mpv-get-playback-position))
(format-time-string "%M:%S" (vuiet--playing-track-duration))))
(defvar hydra-vuiet-body-timer)
(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))
" "
--- ^^ ^^ ^^ ^^ --- --- ^^ ^^ ^^ ^^ ---
+------------------/ / ^^ ^^ ^^ ^^+------------------/ / +------------------/ / ^^ ^^ ^^ ^^+------------------/ /
| - ------- / / ^^ ^^ ^^ ^^| - ------- / / | - ------- / / ^^ ^^ ^^ ^^| - ------- / /
|(-) .d########b. //)|+------------^^----------------^^------------^^-----+^^|(-) .d########b. //)| |(-) .d########b. //)|+------------^^----------------^^------------^^-----+^^|(-) .d########b. //)|
| .d############// || ^^ ^^ ^^ |^^| .d############// | | .d############// ||+-----------^^----------------^^------------^^----+|^^| .d############// |
| .d######''####//b. || ^^ ^^ ^^ |^^| .d######''####//b. | | .d######''####//b. |||%s(now-playing 43)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^||^^| .d######''####//b. |
| 9######( )#-//##P || ^^ ^^ ^^ |^^| 9######( )#-//##P | | 9######( )#-//##P ||+-----------^^--+-------------^^+-----------^^----+|^^| 9######( )#-//##P |
| 'b######++#/-/##d' || ^^ ^^ ^^ |^^| '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 | |^^| |-| `'''''' |
| ---..----------- || +---------^^+---------------^^--+---------^^--+ |^^| ---..----------- | | ---..----------- || +---------^^+---------------^^--+---------^^--+ |^^| ---..----------- |