playerctl icon indicating copy to clipboard operation
playerctl copied to clipboard

potential race condition between playerctl and playerctld

Open IngoMeyer441 opened this issue 3 years ago • 0 comments

I try to use the really nice shift feature of playerctld to build a keyboard shortcut to quickly jump to the next player, pause all active players and activate only the newly selected one. For this, I use:

playerctl --all-players pause && playerctld shift && playerctl play

This works, but sometimes the previously selected player keeps the active one. An example to make it easier to understand:

  • Audacious is playing
  • The previously mentioned command is run
  • Audacious stops and the next player (for example Spotify) starts to play music
  • The next action (for example "play-pause") targets Spotify in most cases, but sometimes it is sent to Audacious, so both players play

I assume there is some kind of race condition between playerctl and playerctld because if I change the command to:

playerctl --all-players pause && sleep 1 && playerctld shift && playerctl play

and add a little delay, it always works as expected.

IngoMeyer441 avatar Mar 25 '22 13:03 IngoMeyer441