Open fuadsaud opened 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The play-pause icons that are being changed are of the button generated by Polybar. Sure you can write a script to echo out the correct icon but you would have to do a lot more to make that work as a button. Polybar provides handy click handlers (see more here). Hence, to change the button text, we need to use their inter process messaging API.
Feel free to ask more questions if you have.
So, I was thinking about something like this:
[module/playerctl-pp]
type = custom/script
tail = true
exec = dpolybar-player-status-pp
format = <label>
format-background = ${xrdb:color6}
format-foreground = ${xrdb:color0}
click-left = playerctl play-pause
# dpolybar-player-status-pp
set -euo pipefail
function status_to_icon {
while read -r status; do
if [ "$status" = "Stopped" ]; then
echo <play-icon>
elif [ "$status" = "Paused" ]; then
echo <play-icon>
else
echo <pause-icon>
fi
done
}
playerctl status --follow 2>/dev/null | status_to_icon
Do you see any significant differences? Btw, I'm using playerctl
in a generic way, not specifically for Spotify; this assumes playerctld
is running.
I see what you're trying to do. I'm also using this module along with playerctld
running. The difference is clear that we're not using the IPC API but I don't see any point in switching to scripts unless there's really a need for it. Please let me know if there's more to your approach. Because for now, I'm just seeing it as another way to do it with no additional benefits.
I'm still learning my ways around polybar, so this is mostly exploratory work that I'm doing.
One advantage I see in my approach is the fact that the bar name doesn't need to be replicated in the script, it's a simple one way relationship (bar calls script).
On the other hand, your IPC solution may perform better but I haven't tested that yet.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Maybe I'm missing something, and if I am please enlighten me, but couldn't the play-pause behavior be implemented with a simple script component with an if statement?