Closed Morantoine closed 3 years ago
Yes, you definitely can! Using polybar
's IPC, we can toggle the visibility of a given bar or all the running bars. See the toggle
command here.
I think I should create a separate branch where this feature is enabled. You can always try it yourself and open a PR. I would be happy to accept your contributions!
Thanks for the idea! Keep 'em coming!
Thanks for the answer ! Id love to help but sadly my skill isnt good enough XD
@Morantxu Take a look at my version of the module on my github page https://github.com/J0eKing/polybar-spotify
It has support for hiding the module when nothing is playing.
@PrayagS if you're interested you can add it as a branch of your main project.
@J0eKing Sure thing. I'll add it eventually.
I'd also like to know how to hide it when there's nothing playing. I already have the IPC flag set to enabled but I need further information on how to use the "toggle" flag to switch it on/off whenever the music is playing or not.
That wiki page barely says what it does let alone how to actually make use of it. Perhaps someone can help me out here.
@TechieAndroid The general format is
polybar-msg -p <pid> <type> <payload>
So if you want to toggle the visibility of a bar, that would be
polybar-msg -p <pid> cmd toggle
How you get the pid depends on how you launch the bar. Just pgrep
the launch command to get the required PID. Take a look at get_spotify_status.sh for an example.
The above solution will work if you want to completely hide polybar. If you want to just hide the module you will need to use hooks in conjunction with polybar-msg.
polybar-msg -p <pid> hook next 1
polybar-msg -p <pid> hook next 0
and then you need to have your module setup like this.
[module/next]
type = custom/ipc
hook-0 = echo ""
hook-1 = echo ""
so that when the hook is 1 it will display nothing and then just do this for all the modules. If you need an example take a look at https://github.com/J0eKing/polybar-spotify
@J0eKing I'm afraid you're mistaken. What I proposed will in fact completely hide the bar, but in that case, you just split your modules into multiple bars and launch them separately. So if you have a separate bar with the now playing text and the music controls, you can use polybar-msg
to directly hide the bar.
If we use hooks to delete the label text, that will still display the empty bar which some people might not want.
I understand what you mean. My solution is there for people who don't want to create a second polybar just for 1 module, and wish to include it in their current bar along with other modules.
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.
Now that I got this to work, I thought it would be a good idea