2013-11-01 15:27:20 +01:00
|
|
|
-- Drive spotify
|
|
|
|
|
2013-11-01 15:56:21 +01:00
|
|
|
-- Spotify uses the MPRIS D-BUS interface. See more information here:
|
|
|
|
-- http://specifications.freedesktop.org/mpris-spec/latest/
|
|
|
|
|
|
|
|
-- To get the complete interface:
|
|
|
|
-- mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2
|
|
|
|
|
2013-11-02 19:06:51 +01:00
|
|
|
local awful = require("awful")
|
|
|
|
local pairs = pairs
|
|
|
|
local capi = {
|
|
|
|
client = client
|
|
|
|
}
|
2013-11-01 15:27:20 +01:00
|
|
|
|
|
|
|
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()
|
2013-11-01 15:48:07 +01:00
|
|
|
-- Play seems unable to play in many situations, let's use
|
|
|
|
-- PlayPause instead.
|
|
|
|
spotify("PlayPause")
|
2013-11-01 15:27:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function pause()
|
|
|
|
spotify("Pause")
|
|
|
|
end
|
|
|
|
|
|
|
|
function stop()
|
|
|
|
spotify("Stop")
|
|
|
|
end
|
|
|
|
|
|
|
|
function next()
|
|
|
|
spotify("Next")
|
|
|
|
end
|
|
|
|
|
|
|
|
function previous()
|
|
|
|
spotify("Previous")
|
|
|
|
end
|
2013-11-01 15:53:35 +01:00
|
|
|
|
|
|
|
function show()
|
|
|
|
-- This should work, but no:
|
|
|
|
-- spotify("Raise")
|
2013-11-02 19:06:51 +01:00
|
|
|
local clients = capi.client.get()
|
|
|
|
for k, c in pairs(clients) do
|
|
|
|
if awful.rules.match(c, { instance = "spotify",
|
|
|
|
class = "Spotify" }) then
|
|
|
|
if not c:isvisible() then
|
|
|
|
awful.tag.viewonly(c:tags()[1])
|
|
|
|
end
|
|
|
|
capi.client.focus = c
|
|
|
|
c:raise()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
2014-05-22 09:57:36 +02:00
|
|
|
awful.util.spawn("spotify --ui.track_notifications_enabled=false")
|
2013-11-01 15:53:35 +01:00
|
|
|
end
|