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

Does not work with multiple bars #3

Closed
destinationunknown opened this issue Feb 18, 2021 · 4 comments
Closed

Does not work with multiple bars #3

destinationunknown opened this issue Feb 18, 2021 · 4 comments

Comments

@destinationunknown
Copy link

When using this module and starting multiple instances of the same bar (on two different monitors), the module displays "Received exit request" and this switches between the two bars every couple of seconds.

@destinationunknown destinationunknown changed the title Does not work with multiple bar Does not work with multiple bars Feb 18, 2021
@unode
Copy link
Owner

unode commented Feb 18, 2021

Hi @destinationunknown, this is intentional and by design.

The plugin implements a minimal server/client interface with communication happening through a socket.
When you run polypomo without arguments, a "server" is started. This is what happens when you add it to a polybar.
If you run multiple bars, you would be running multiple "servers" of polypomo and so they fight with each other when taking ownership of said socket.
I suggest you add polypomo to only one of the displays and use a different configuration for the others.

Technically, it's possible to add an additional command-line argument to identify each client/server to support running multiple independent polypomo instances, but this was never something I felt necessary. In the pomodoro technique you are supposed to focus on a single task at a time and therefore have only one timer running.

To have two widgets accessing a single "server" a completely different interface would be necessary and I found this would complicate the use of the plugin too much.

A workaround is to use:

[module/polypomo]
exec = tail -f /tmp/polypomo.status
tail = true

and then manually launch polypomo > /tmp/polypomo.status.
You will have to ensure this polypomo process is running through some other means.

This approach has the problem that the polypomo.status file will get larger the longer the process runs.
You could alternatively use a linux named pipe with mkfifo /tmp/polypomo.status and use cat /tmp/polypomo.status instead of tail -f. The caveat in this case is that the output will be sent to each client in an alternating fashion, so the widgets will be phased by 1 second for every additional client.

Hope this clarifies why the plugin works the way it does and why this limitation exists.

@destinationunknown
Copy link
Author

Thanks for the great response. I was indeed looking for ways to access the same server from multiple clients, not have multiple client/server instances running. The named pipe approach looks like a good fix, do you know if it is possible to increase the rate of alternation? If it alternated twice a second it seems it would be good enough for my needs.

@unode
Copy link
Owner

unode commented Feb 18, 2021

Given two clients A and B, alternation is always ABABAB.
The frequency depends on how many messages are sent to the pipe per second.
You can increase the number of messages per second by using a value smaller than 0.9 in

timeout = time.time() + 0.9

You can roughly divide this number by the number of clients, rounded down.

@destinationunknown
Copy link
Author

Thanks, will check this out.

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