playerctl icon indicating copy to clipboard operation
playerctl copied to clipboard

`playerctl --follow` misses updates from `playerctld`

Open ffwng opened this issue 4 years ago • 11 comments

E.g. the command playerctl metadata --follow -f '{{playerName}}' does not print a new line when the prioritized player tracked by playerctld changes (after which a new invocation of playerctl would target the new player).

It works better with other formats, for example playerctl metadata --follow -f '{{status}} {{playerName}}' does update when the prioritized player changes due to a status update. But this also does not update, for instance, when the player is changed with playerctld shift.

ffwng avatar Sep 04 '21 15:09 ffwng

I observed a similar problem when I use markup_escape in the format string with --follow. The update for Paused is missed and then flushed together with Playing when I resume the song.

nayaabkhan avatar Sep 10 '21 13:09 nayaabkhan

@ffwng did the player change from one player to another with the same value of playerName? If so, that is the expected behavior.

acrisci avatar Sep 10 '21 13:09 acrisci

@acrisci player names were different. I tested it once with Firefox and Spotify and in another test with SMPlayer and VLC.

I also noticed in particular that even restarting playerctl --follow did not help. This means that e.g. playerctl metadata -f '{{playerName}}' had output vlc while at the same time executing playerctl metadata --follow -f '{{playerName}}' printed smplayer as first line.

In this example, vlc would be correct, because in that state all playerctl commands would target VLC, so playerctl --follow just printed the wrong output.

ffwng avatar Sep 10 '21 16:09 ffwng

I can't seem to reproduce this. I just played around a little with the command and it always does what I expect it to do. But maybe your expectations are different than mine. Try to see if master branch fixes your issue.

I have tests for --follow for all the common scenarios I've seen you can look at. If you think there's a missing test, let me know.

https://github.com/altdesktop/playerctl/blob/master/test/test_follow.py

acrisci avatar Sep 21 '21 03:09 acrisci

Thanks, @acrisci! Do you think adding a case with markup_escape could make it more resilient? I seem to be having a problem when using it with --follow: https://github.com/altdesktop/playerctl/issues/247#issuecomment-916885445.

nayaabkhan avatar Sep 21 '21 03:09 nayaabkhan

@nayaabkhan go make your own issue. Test on master first because it's most likely fixed in d8a36b504b039081f18e93f48be36797705eff67 .

acrisci avatar Sep 21 '21 03:09 acrisci

I have checked the master branch and the issue still persists. I even changed the version in meson.build and verified with playerctl --version that it is using the correct binaries.

Prerequisite: I have playerctld running and start both VLC and SMPlayer simultaneously, both paused (it can also be reproduced with Spotify or Firefox and probably other players as well). Then I start playerctl metadata -Ff '{{playerName}}'. Output: smplayer (for instance). Now I unpause VLC. At this point, I would expect the new output vlc, but there is no new output.

In the same scenario but with the format '{{playerName}} {{status}}', the output does change from smplayer Paused to vlc Playing. But running playerctld shift does not produce a new output, which I would have expected.

My expectation would be that the most recent output is the player that would be targeted by the next invocation of playerctl COMMAND.

I also have found playerctl metadata -p playerctld -F… as possible workaround, which almost works as expected, except after all players have been closed.

ffwng avatar Sep 25 '21 07:09 ffwng

Can I use --follow to create a script that will auto-pause other sources when starting a new one?

For instance if I play firefox I want strawberry to pause etc.

madprops avatar Sep 27 '21 13:09 madprops

Everyone please stop hijacking this poor man's issue. @madprops make a new issue or come to the chat for support.

acrisci avatar Sep 27 '21 14:09 acrisci

I'm experiencing the same issue. playerctl output doesn't get updated when pausing if running

playerctl -p 'spotify' -f "{{ markup_escape(artist) }} - {{ markup_escape(title) }} {{ status }}" -F metadata

The issue is not present if markup_escape is removed.

ignamartinoli avatar Jan 13 '23 02:01 ignamartinoli