Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No players found" not returned as string in status #125

Closed
kaustubhhiware opened this issue Mar 7, 2019 · 3 comments
Closed

"No players found" not returned as string in status #125

kaustubhhiware opened this issue Mar 7, 2019 · 3 comments

Comments

@kaustubhhiware
Copy link

kaustubhhiware commented Mar 7, 2019

When some media is playing, playerctl status returns appropriate string which can be logged, but not when nothing is playing. Basically,

$ x=$(playerctl status) # When vlc is playing
$ echo $x
Playing
$ x=$(playerctl status) # When vlc is paused
$ echo $x
Paused
$ x=$(playerctl status) # No media
No players found
$ echo $x

$

This was working fine till the most recent update, version v2.0.1 breaks this.

OS: Arch Linux, kernel x86_64 Linux 5.0.0-arch1-1-ARCH
The fixes mentioned in #119 and elsewhere do not work. I'm using this to dictate buttons in polybar.

@kaustubhhiware kaustubhhiware changed the title "No players found" not returned as status "No players found" not returned as string in status Mar 7, 2019
@Baviste
Copy link

Baviste commented Mar 8, 2019

This is because the status is sent in stderr in that case.
You can redirect stderr to stdout to solve your problem:

$ x=$(playerctl status 2>&1)
$ echo $x
No players found

@kaustubhhiware
Copy link
Author

Thanks for the fix, it works well !
Closing the issue now.

@kaustubhhiware
Copy link
Author

kaustubhhiware commented Mar 8, 2019

What finally worked for me was the following:

player_status=$(playerctl status 2>&1)

if [ "$player_status" == "No players found" ] ; then
	echo "Off"
else
      echo "On"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants