From bec18633e67513363265e79e28358e5089f3e85c Mon Sep 17 00:00:00 2001 From: pmakhov Date: Sat, 2 Dec 2017 13:50:14 -0500 Subject: use dbus to check is spotify is playing --- spotify-widget/README.md | 9 --------- spotify-widget/spotify.lua | 7 ++++--- spotify-widget/spotify_stat | 2 -- 3 files changed, 4 insertions(+), 14 deletions(-) delete mode 100755 spotify-widget/spotify_stat (limited to 'spotify-widget') diff --git a/spotify-widget/README.md b/spotify-widget/README.md index df84927..547c9eb 100644 --- a/spotify-widget/README.md +++ b/spotify-widget/README.md @@ -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:. diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua index 4ecce79..be3225c 100644 --- a/spotify-widget/spotify.lua +++ b/spotify-widget/spotify.lua @@ -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) diff --git a/spotify-widget/spotify_stat b/spotify-widget/spotify_stat deleted file mode 100755 index b4d4783..0000000 --- a/spotify-widget/spotify_stat +++ /dev/null @@ -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]*' -- cgit v1.2.3