Fixes for the playerctl_lib signals (#77)
* Only send artUrl to the signal if it's not empty * Fix for double signals What I've found while using dbus-monitor is that playerctl sends a bunch of messages whenever media is changed, with the first one always having the artUrl empty. If the media does have an artUrl, the next messages will contain the artUrl resulting in artUrl ~= last_artUrl becoming true and triggering another signal The hacky method in the commit will only trigger a new signal if artUrl is not empty, or on the second message sent (as some media don't provide any art) * Revert "Only send artUrl to the signal if it's not empty" This reverts commite74671094a
. * Fix artUrl staying the same when the new value is empty * Revert "Fix artUrl staying the same when the new value is empty" This reverts commitaa4ddbe863
. * Fix artUrl staying the same again * Prevent signal with no information from being emitted * A better workaround for the double signal issue with YouTube
This commit is contained in:
parent
ac0427a737
commit
5ca27551da
|
@ -74,6 +74,7 @@ local last_player = nil
|
|||
local last_title = ""
|
||||
local last_artist = ""
|
||||
local last_artUrl = ""
|
||||
local index = 0
|
||||
local function metadata_cb(player, metadata)
|
||||
if update_on_activity then
|
||||
manager:move_player_to_top(player)
|
||||
|
@ -95,18 +96,33 @@ local function metadata_cb(player, metadata)
|
|||
if player == manager.players[1] then
|
||||
-- Callback can be called even though values we care about haven't
|
||||
-- changed, so check to see if they have
|
||||
if player ~= last_player or title ~= last_title or
|
||||
artist ~= last_artist or artUrl ~= last_artUrl
|
||||
index = index + 1
|
||||
if (player ~= last_player or title ~= last_title or
|
||||
artist ~= last_artist) and (artUrl ~= "" or index >= 2)
|
||||
then
|
||||
awful.spawn.with_line_callback(get_album_art(artUrl), {
|
||||
stdout = function(line)
|
||||
awesome.emit_signal("bling::playerctl::title_artist_album",
|
||||
title,
|
||||
artist,
|
||||
line,
|
||||
player.player_name)
|
||||
end
|
||||
})
|
||||
if (title == "" and artist == "" and artUrl == "") then return end
|
||||
index = 0
|
||||
if artUrl ~= "" then
|
||||
awful.spawn.with_line_callback(get_album_art(artUrl), {
|
||||
stdout = function(line)
|
||||
awesome.emit_signal(
|
||||
"bling::playerctl::title_artist_album",
|
||||
title,
|
||||
artist,
|
||||
line,
|
||||
player.player_name
|
||||
)
|
||||
end
|
||||
})
|
||||
else
|
||||
awesome.emit_signal(
|
||||
"bling::playerctl::title_artist_album",
|
||||
title,
|
||||
artist,
|
||||
"",
|
||||
player.player_name
|
||||
)
|
||||
end
|
||||
-- Re-sync with position timer when track changes
|
||||
position_timer:again()
|
||||
last_player = player
|
||||
|
|
Loading…
Reference in New Issue