music: abstract the functions used to control music player

We still use Spotify but we isolate the music functions into a
specific module. Other music player would implement the same
interface.
This commit is contained in:
Vincent Bernat 2013-11-01 15:27:20 +01:00
parent 51525044ae
commit 8f6b6733bc
2 changed files with 42 additions and 10 deletions

35
lib/spotify.lua Normal file
View file

@ -0,0 +1,35 @@
-- Drive spotify
local awful = require("awful")
module("vbe/spotify")
-- Send a command to spotify
local function spotify(command)
awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify " ..
"/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." .. command, false)
end
function playpause()
spotify("PlayPause")
end
function play()
spotify("Play")
end
function pause()
spotify("Pause")
end
function stop()
spotify("Stop")
end
function next()
spotify("Next")
end
function previous()
spotify("Previous")
end