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
feat(ipc): allow receiving arbitrary text on IPC socket #2463
feat(ipc): allow receiving arbitrary text on IPC socket #2463
Conversation
Instead of just allowing hook numbers to be executed, the user can send arbitrary text and the IPC module will put it in the bar. The IPC payload format is extended to accept an arbitrary string if the first character after the module name is ':'. polybar-msg hook test :'%{F#4444ff}hello%{F-}' Fix polybar#2455
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, these changes are indeed very minimal 😮
I think the polybar-msg hook
command is becoming too limited for the ipc module. We have a very capable module action system that would be better suited. It allows us to have named actions per module with optional data.
For example here, we could add a send
action whose data will be set as the module's content.
If your ipc module is named ipc
, this could look like this:
polybar-msg -p ... action "#ipc.send.abc"
The big advantage of this is that this also works for click commands: click-left = #ipc.send.abc
will deliver this to the correct module on the clicked bar.
I have added those changes locally, I will push them shortly.
Codecov Report
@@ Coverage Diff @@
## master #2463 +/- ##
==========================================
- Coverage 10.13% 10.13% -0.01%
==========================================
Files 147 147
Lines 10178 10181 +3
==========================================
Hits 1032 1032
- Misses 9146 9149 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Just to show an example, here is a piece of code to display Network Manager state: https://github.com/vincentbernat/i3wm-configuration/blob/7df5011824cc55ffa9d3ac8b32bb680d63ac083d/bin/i3-companion#L454. [module/network]
type = custom/ipc
hook-0 = cat $XDG_RUNTIME_DIR/i3/network.txt
initial = 1 |
What type of PR is this? (check all applicable)
Description
Instead of just allowing hook numbers to be executed, the user can
send arbitrary text and the IPC module will put it in the bar. The IPC
payload format is extended to accept an arbitrary string if the first
character after the module name is ':'.
I did not make a new module as requested by @patrick96 as the modifications to the IPC module are minimal and the actions are reused as is. Tell me what you think.
Related Issues & Documents
Fix #2455
Documentation (check all applicable)