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

Is IPC really needed? #12

Open
fuadsaud opened this issue Dec 31, 2020 · 6 comments
Open

Is IPC really needed? #12

fuadsaud opened this issue Dec 31, 2020 · 6 comments

Comments

@fuadsaud
Copy link

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?

@stale
Copy link

stale bot commented Jan 7, 2021

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.

@stale stale bot added the stale label Jan 7, 2021
@PrayagS
Copy link
Owner

PrayagS commented Jan 7, 2021

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.

@stale stale bot removed the stale label Jan 7, 2021
@fuadsaud
Copy link
Author

fuadsaud commented Jan 7, 2021

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.

@PrayagS
Copy link
Owner

PrayagS commented Jan 8, 2021

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.

@fuadsaud
Copy link
Author

fuadsaud commented Jan 8, 2021

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.

@stale
Copy link

stale bot commented Jan 15, 2021

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.

@stale stale bot added the stale label Jan 15, 2021
@stale stale bot closed this as completed Jan 23, 2021
@PrayagS PrayagS added Big Picture and removed stale labels Feb 26, 2021
@PrayagS PrayagS reopened this Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants