OmarCastro / rofi-blocks

A Rofi modi that allows controlling rofi content throug communication with an external program
GNU General Public License v3.0
107 stars 9 forks source link

adds `active-entry` event which is always emitted before `custom key` #5

Closed fogine closed 4 years ago

fogine commented 4 years ago

Currently custom-key event does not have many use cases as there is no way to get actively selected line/record with it.

This fixes that, and basically emits 2 events when custom key is pressed.
First it emits active-entry with currently selected record followed by custom-key event which signalizes which key was pressed.

This implementation is compatible with current design, that is, writes events in any user defined format (default json) delimited by \n (new line) control character.
To parse the custom key event in default format, the user has to split incoming data with \n and then parse individual segment as json messages. This is not ideal but its the only way how to not break to current design...

In the future it would be good choice to drop custom event format feature and support only json. It would make rofi-blocks more scalable and consistent.

OmarCastro commented 4 years ago

I will accept this pull request, however, I am planning to make active-entry trigger when an active entry changed, so it does not get confusing. About custom entry format, I should have made it explicit that quotes in {{ }} are reserved to prevent breaking changes. Its purpose is to allow easy parse for scripts that does not have json parser included out-of-the-box like bash, and creating a parser is no easy feat, while generating is simple enough, you only have to worry about escaping the text on dynamic content.