From 4e9ec5f5b62c2a62890dc10355175f70085ef450 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 1 Apr 2020 15:34:14 -0400 Subject: [PATCH] Make hydra even better --- emacs/init.org | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/emacs/init.org b/emacs/init.org index 5be392b..962bc98 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -5807,17 +5807,40 @@ A music browser and player: And a handy hydra for it: #+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############// || ^^ ^^ ^^ |^^| .d############// | - | .d######''####//b. || ^^ ^^ ^^ |^^| .d######''####//b. | - | 9######( )#-//##P || ^^ ^^ ^^ |^^| 9######( )#-//##P | - | 'b######++#/-/##d' || ^^ ^^ ^^ |^^| 'b######++#/-/##d' | - | '9############P' || ^^ ^^ ^^ |^^| '9############P' | + | .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 | |^^| |-| `'''''' | | ---..----------- || +---------^^+---------------^^--+---------^^--+ |^^| ---..----------- |