From bff16a840a5a6b9a5de57b3e8e7b46ee9d84cd94 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 5 Oct 2018 11:21:43 +0200 Subject: [PATCH] spotify: use playerctl instead of dbus commands The module is still spotify-specific, but a bit less --- lib/spotify.lua | 20 +++++++++----------- requirements.txt | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/spotify.lua b/lib/spotify.lua index df48f31..f02f0d4 100644 --- a/lib/spotify.lua +++ b/lib/spotify.lua @@ -6,6 +6,8 @@ -- To get the complete interface: -- mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 +-- Updated to use playerctl instead. + local awful = require("awful") local dbg = dbg local pairs = pairs @@ -30,11 +32,7 @@ end -- Send a command to spotify local function cmd(command) - local client = spotify() - 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 + awful.util.spawn("playerctl " .. command, false) end -- Show spotify @@ -52,27 +50,27 @@ function show() end function playpause() - cmd("PlayPause") + cmd("play-pause") end function play() - cmd("Play") + cmd("play") end function pause() - cmd("Pause") + cmd("pause") end function stop() - cmd("Stop") + cmd("stop") end function next() - cmd("Next") + cmd("next") end function previous() - cmd("Previous") + cmd("previous") end function mixer() diff --git a/requirements.txt b/requirements.txt index 9c02492..ccf5da2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,3 +18,4 @@ alsa-utils pavucontrol pulseaudio numlockx +playerctl