use dbus to check is spotify is playing

This commit is contained in:
pmakhov 2017-12-02 13:50:14 -05:00
parent 8b4c5e7fa0
commit bec18633e6
3 changed files with 4 additions and 14 deletions

View File

@ -15,8 +15,6 @@ This widget displays currently playing song on [Spotify for Linux](https://www.s
Note that widget uses the Arc icon theme, so it should be [installed](https://github.com/horst3180/arc-icon-theme#installation) first under **/usr/share/icons/Arc/** folder.
Also this widget uses the output of the **spotify_stat** script which could be found in the widget folder.
## Installation
First you need to have spotify CLI installed. Here is how you can do it (except widget part): [pavelmakhov.com/2016/02/awesome-wm-spotify](http://pavelmakhov.com/2016/02/awesome-wm-spotify)
@ -33,10 +31,3 @@ s.mytasklist, -- Middle widget
spotify_widget,
...
```
## Troubleshooting
_Status icon (play/pause) is not shown_:
- make **spotify_stat** script executable (by `sudo chmod +x spotify_stat`) and run it in terminal, output should be either `RUNNING` or `CORKED`;
- the **spotify_stat** script is called by **spotify.lua** so make sure that `get_spotify_status_cmd` in **spotify.lua** contains the right path to the script;
- create an issue :octocat:.

View File

@ -2,7 +2,8 @@ local awful = require("awful")
local wibox = require("wibox")
local watch = require("awful.widget.watch")
local GET_SPOTIFY_STATUS_CMD = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/spotify-widget/spotify_stat'
-- local GET_SPOTIFY_STATUS_CMD = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/spotify-widget/spotify_stat'
local GET_SPOTIFY_STATUS_CMD = 'sp status'
local GET_CURRENT_SONG_CMD = 'sp current-oneline'
local PATH_TO_ICONS = "/usr/share/icons/Arc"
@ -27,9 +28,9 @@ spotify_widget = wibox.widget {
local update_widget_icon = function(widget, stdout, _, _, _)
stdout = string.gsub(stdout, "\n", "")
if (stdout == 'RUNNING') then
if (stdout == 'Playing') then
widget:set_image(PATH_TO_ICONS .. "/actions/24/player_play.png")
elseif (stdout == "CORKED") then
elseif (stdout == "Paused") then
widget:set_image(PATH_TO_ICONS .. "/actions/24/player_pause.png")
else
widget:set_image(nil)

View File

@ -1,2 +0,0 @@
#!/bin/sh
pacmd list-sink-inputs | grep -e 'state:' -e 'application.name' | grep -B 1 -i spotify | grep -P -o '(?<=: )[A-Za-z]*'