use widget.watch
This commit is contained in:
parent
2d2684587d
commit
bd1d147280
|
@ -1,18 +1,17 @@
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
|
local watch = require("awful.widget.watch")
|
||||||
|
|
||||||
spotify_widget = wibox.widget.textbox()
|
spotify_widget = wibox.widget.textbox()
|
||||||
spotify_widget:set_font('Play 9')
|
spotify_widget:set_font('Play 9')
|
||||||
|
|
||||||
function updateSpotifyWidget(widget)
|
-- optional icon, could be replaced by spotfiy logo (https://developer.spotify.com/design/)
|
||||||
awful.spawn.easy_async([[bash -c 'sp current-oneline']],
|
spotify_icon = wibox.widget.imagebox()
|
||||||
function(stdout, stderr, reason, exit_code)
|
spotify_icon:set_image("/usr/share/icons/Arc-Icons/places/symbolic/folder-music-symbolic.svg")
|
||||||
widget:set_text(stdout)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
spotify_timer = timer ({timeout = 10})
|
watch(
|
||||||
spotify_timer:connect_signal ("timeout", function() updateSpotifyWidget(spotify_widget) end)
|
"sp current-oneline", 1,
|
||||||
spotify_timer:start()
|
function(widget, stdout, stderr, exitreason, exitcode)
|
||||||
|
spotify_widget:set_text(stdout)
|
||||||
spotify_timer:emit_signal("timeout")
|
end
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue