Skip to content

Instantly share code, notes, and snippets.

@TeMPOraL
Created May 11, 2018 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TeMPOraL/d3a0b3065c43d41526bcb3fe2c9cfe27 to your computer and use it in GitHub Desktop.
Save TeMPOraL/d3a0b3065c43d41526bcb3fe2c9cfe27 to your computer and use it in GitHub Desktop.
Ad-hoc hydras for easier life
(defhydra hydra-host-os (:color teal :hint nil)
"
^Shell^ ^Other^
^^^^--------------------------------------
_e_: eshell _q_: quit
_E_: eshell here
_s_: shell command
_S_: shell command on region
_a_: async shell command
_L_: list shell buffers
"
;; TODO replace shell/async-shell commands with my variants that also rename buffers!
("e" eshell)
("E" eshell-here)
("s" shell-command)
("S" shell-command-on-region)
("a" async-shell-command)
("L" (ibuffer nil "*Ibuffer - shells*" '((derived-mode . shell-mode))))
("q" nil))
(global-set-key (kbd "<f9>") 'hydra-host-os/body)
(defun my/list-shells ()
(interactive)
(ibuffer nil "*Ibuffer - shells*" '((or (derived-mode . shell-mode)
(derived-mode . eshell-mode)))))
;; (...)
;;; Previous and next track based on:
;;; https://www.reddit.com/r/emacs/comments/8b0dqx/emms_updates_mpv_backend_opus_orgstyle_bindings/dx451dc/
(defun my/emms-track-description (track)
(my/track-simpler-description track))
(defun my/emms-next-track ()
(when emms-playlist-buffer
(with-current-buffer emms-playlist-buffer
(save-mark-and-excursion
(goto-char (if (and emms-playlist-selected-marker
(marker-position emms-playlist-selected-marker))
emms-playlist-selected-marker
(point-min)))
(emms-playlist-next)
(emms-playlist-track-at (point))))))
(defun my/emms-previous-track ()
(when emms-playlist-buffer
(with-current-buffer emms-playlist-buffer
(save-mark-and-excursion
(goto-char (if (and emms-playlist-selected-marker
(marker-position emms-playlist-selected-marker))
emms-playlist-selected-marker
(point-min)))
(emms-playlist-previous)
(emms-playlist-track-at (point))))))
(defhydra hydra-media-player (:color amaranth :hint nil)
"
Currently playing: %s(my/emms-track-description (emms-playlist-current-selected-track)) %s(if emms-repeat-track \"[loop]\" \"\").
Next up: %s(my/emms-track-description (my/emms-next-track))
Previous: %s(my/emms-track-description (my/emms-previous-track))
^Playback control^ ^^Volume: xxx^^ ^Playlist management^ ^Other^
--------------------------------------------------------------------------------
_n_: next _+_, _=_: louder _<f11>_: emms list _q_: quit
_p_: previous _-_: quieter^^ ^ ^ _g_: refresh
_l_: toggle loop ^ ^ ^ ^ ^ ^ _m_: mute
_SPC_: %s(if emms-player-paused-p \"unpause\" \"pause \")
_s_: stop
"
("n" emms-next)
("p" emms-previous)
("l" emms-toggle-repeat-track)
("SPC" emms-pause)
("s" emms-stop)
("+" emms-volume-raise)
("=" emms-volume-raise)
("-" emms-volume-lower)
("m" "TODO muting")
("<f11>" emms :color blue)
("q" nil :color blue)
("g" "refresh"))
;;; FIXME if stopped, SPC should show "play", and Currently playing should show "To play" or sth.
;;; FIXME error handling - right now, if emms is off/playlist is empty, the Hydra won't show at all.
(global-set-key (kbd "<f11>") 'hydra-media-player/body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment