diff options
| author | Pavel Makhov <streetturtle@users.noreply.github.com> | 2017-01-25 22:47:50 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-25 22:47:50 -0500 | 
| commit | bd1d147280ec76a5a517be437b664602d049b0d4 (patch) | |
| tree | a6d05848ecdd235ae2177b744703e99f57b42d75 | |
| parent | 2d2684587d61b294ef1f0c7f1a1d251a0aaf884a (diff) | |
use widget.watch
| -rw-r--r-- | spotify-widget-v4/spotify.lua | 21 | 
1 files changed, 10 insertions, 11 deletions
diff --git a/spotify-widget-v4/spotify.lua b/spotify-widget-v4/spotify.lua index 83fdca9..f61c249 100644 --- a/spotify-widget-v4/spotify.lua +++ b/spotify-widget-v4/spotify.lua @@ -1,18 +1,17 @@  local wibox = require("wibox")  local awful = require("awful") +local watch = require("awful.widget.watch")  spotify_widget = wibox.widget.textbox()  spotify_widget:set_font('Play 9') -function updateSpotifyWidget(widget) -    awful.spawn.easy_async([[bash -c 'sp current-oneline']], -    function(stdout, stderr, reason, exit_code) -        widget:set_text(stdout) -    end) -end +-- optional icon, could be replaced by spotfiy logo (https://developer.spotify.com/design/) +spotify_icon = wibox.widget.imagebox() +spotify_icon:set_image("/usr/share/icons/Arc-Icons/places/symbolic/folder-music-symbolic.svg") -spotify_timer = timer ({timeout = 10}) -spotify_timer:connect_signal ("timeout", function() updateSpotifyWidget(spotify_widget) end)  -spotify_timer:start() - -spotify_timer:emit_signal("timeout") +watch( +    "sp current-oneline", 1, +    function(widget, stdout, stderr, exitreason, exitcode) +        spotify_widget:set_text(stdout) +    end +)  | 
