My personal dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spotify-remote.el 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ;; spotify-remote.el --- Spotify.el remote minor mode
  2. ;; Copyright (C) 2014-2016 Daniel Fernandes Martins
  3. ;; Code:
  4. (defvar spotify-remote-mode-map
  5. (let ((map (make-sparse-keymap)))
  6. (define-key map (kbd "M-p M-s") 'spotify-toggle-shuffle)
  7. (define-key map (kbd "M-p M-r") 'spotify-toggle-repeat)
  8. (define-key map (kbd "M-p M-p") 'spotify-toggle-play)
  9. (define-key map (kbd "M-p M-b") 'spotify-previous-track)
  10. (define-key map (kbd "M-p M-f") 'spotify-next-track)
  11. map)
  12. "Local keymap for `spotify-remote-mode' buffers.")
  13. (defvar spotify-mode-line-prefix " \u266b")
  14. (defvar spotify-mode-line spotify-mode-line-prefix)
  15. (define-minor-mode spotify-remote-mode
  16. "Toggles Spotify Remote mode.
  17. A positive prefix argument enables the mode, any other prefix
  18. argument disables it. From Lisp, argument omitted or nil enables
  19. the mode, `toggle' toggles the state.
  20. When Spotify Remote mode is enabled, it's possible to toggle
  21. the repeating and shuffling status of the running Spotify process.
  22. See commands \\[spotify-toggle-repeating] and
  23. \\[spotify-toggle-shuffling]."
  24. :group 'spotify
  25. :init-value nil
  26. :lighter spotify-mode-line)
  27. (defun spotify-update-mode-line (str)
  28. "Sets the given str to the mode line, prefixed with the mode identifier."
  29. (let ((normalized-str (replace-regexp-in-string "\n$" "" str)))
  30. (if (eq "" normalized-str)
  31. (setq spotify-mode-line spotify-mode-line-prefix)
  32. (setq spotify-mode-line (concat spotify-mode-line-prefix " " normalized-str)))
  33. (when (bound-and-true-p spotify-remote-mode)
  34. (force-mode-line-update))))
  35. (defun turn-on-spotify-remote-mode ()
  36. "Turns the `spotify-remote-mode' on in the current buffer."
  37. (spotify-remote-mode 1))
  38. (define-globalized-minor-mode global-spotify-remote-mode
  39. spotify-remote-mode turn-on-spotify-remote-mode)
  40. (provide 'spotify-remote)