use widget.watch

This commit is contained in:
Pavel Makhov 2017-01-25 22:47:50 -05:00 committed by GitHub
parent 2d2684587d
commit bd1d147280
1 changed files with 10 additions and 11 deletions

View File

@ -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
)