Skip to content

Instantly share code, notes, and snippets.

@aziem
Created October 8, 2013 21:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aziem/6892101 to your computer and use it in GitHub Desktop.
Save aziem/6892101 to your computer and use it in GitHub Desktop.
Basic elisp to control Spotify
(defun spotify-play () "Play Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play"))
(defun spotify-pause () "Pause Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause"))
(defun spotify-playpause () "Play/Pause Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"))
(defun spotify-next () "Next song in Spotify" (interactive)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"))
(defun spotify-previous () "Previous song in Spotify" (interactive)
(progn (shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous")
(sit-for 0.1)
(shell-command "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous")))
(global-set-key (kbd "C-c <C-S-right>") 'spotify-next)
(global-set-key (kbd "C-c <C-S-left>") 'spotify-previous)
(global-set-key (kbd "C-c <C-S-up>") 'spotify-playpause)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment