spotify: use playerctl instead of dbus commands

The module is still spotify-specific, but a bit less
This commit is contained in:
Vincent Bernat 2018-10-05 11:21:43 +02:00
parent 194da94c77
commit bff16a840a
2 changed files with 10 additions and 11 deletions

View file

@ -6,6 +6,8 @@
-- To get the complete interface: -- To get the complete interface:
-- mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 -- mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2
-- Updated to use playerctl instead.
local awful = require("awful") local awful = require("awful")
local dbg = dbg local dbg = dbg
local pairs = pairs local pairs = pairs
@ -30,11 +32,7 @@ end
-- Send a command to spotify -- Send a command to spotify
local function cmd(command) local function cmd(command)
local client = spotify() awful.util.spawn("playerctl " .. command, false)
if client then
awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify " ..
"/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." .. command, false)
end
end end
-- Show spotify -- Show spotify
@ -52,27 +50,27 @@ function show()
end end
function playpause() function playpause()
cmd("PlayPause") cmd("play-pause")
end end
function play() function play()
cmd("Play") cmd("play")
end end
function pause() function pause()
cmd("Pause") cmd("pause")
end end
function stop() function stop()
cmd("Stop") cmd("stop")
end end
function next() function next()
cmd("Next") cmd("next")
end end
function previous() function previous()
cmd("Previous") cmd("previous")
end end
function mixer() function mixer()

View file

@ -18,3 +18,4 @@ alsa-utils
pavucontrol pavucontrol
pulseaudio pulseaudio
numlockx numlockx
playerctl