i3status-rust icon indicating copy to clipboard operation
i3status-rust copied to clipboard

Feature suggestion. Custom block lists

Open PremiumUsername opened this issue 2 years ago • 6 comments

An example user case: I would like to have some buttons for the windows currently in the scratchpad. I can't really see how I could have that using the custom block (without making it extremely convoluted) since I can't know beforehand how many windows would be in the scratchpad.

My suggestion is that you could have a custom block-type, which has a command that returns a list of block configurations in json form. That way I could supply i3status-rust with one block for each window.

This would enable a lot of functionality that's not currently possible, you could have a custom block could enumerate all Bluetooth devices currently connected without making a block for each possible device beforehand etc.

PremiumUsername avatar May 19 '22 08:05 PremiumUsername

Like this?

https://github.com/MaxVerevkin/swaystatus/blob/4e343dfc0711888aa5d8a63b26390ac53bb7ffec/src/blocks/custom.rs#L77-L91

(This is how my rewrite of i3status-rs (previously swaystatus, then "async" branch in this repo) used to implement custom block before this commit)

P.S. I probably misunderstood your suggestion. Can you please give some concrete examples?

MaxVerevkin avatar May 19 '22 12:05 MaxVerevkin

They want to be able to create multiple blocks from one command essentially. One script that returns a json list of custom blocks to display, in a way that can change the number of blocks with each update

GladOSkar avatar May 19 '22 13:05 GladOSkar

They want to be able to create multiple blocks from one command essentially. One script that returns a json list of custom blocks to display, in a way that can change the number of blocks with each update

Yes, that is what I mean. Another example use would would be that you would be able to use this feature in order to replace the sway provided workspace_buttons with your own version that could, for example, make the buttons different colours depending on what output they are displayed on.

P.S. I probably misunderstood your suggestion. Can you please give some concrete examples?

My rust is a bit rusty, so I might not understand what you are showing me, but I think your implementation is close to what I'm asking for. Only difference is that instead of retrieving one whole block you get a list of blocks instead.

PremiumUsername avatar May 20 '22 08:05 PremiumUsername

Can you please give some concrete examples?

My rust is a bit rusty

I meant the example of JSON

MaxVerevkin avatar May 20 '22 08:05 MaxVerevkin

I meant the example of JSON

I'm not putting forth a recommendation for a specific implementation, but something like:

{
    "foldable": false,
    "blocks": [
        {
             "icon": xx,
             "state": xx, 
             "text": xx,
             "on_click": xx,
             ...
        },
        {
             ...
        }
    ]
}

PremiumUsername avatar May 20 '22 11:05 PremiumUsername

It does seem like a very interesting idea, I look forward to seeing what can be done with it if implemented!

ammgws avatar Jun 19 '22 10:06 ammgws