i3 icon indicating copy to clipboard operation
i3 copied to clipboard

i3bar: Support customizations in workspace buttons protocol

Open orestisfl opened this issue 2 years ago • 5 comments

I'm submitting a…

[ ] Bug
[x] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

The i3bar workspace button protocol only supports the standard key-values of the GET_WORKSPACES command

Desired Behavior

We can enhance the protocol with configuration that is already supported by i3bar (examples copied from https://github.com/i3/i3/issues/3818):

  • "min_width":32 (related to #3711)
  • "separator":true — personally I find it is useful to visually separate groups of workspaces.
  • "color":[...] — could be used to distinguish fake empty workspaces.

Impact

[ ] This feature requires new configuration and/or commands

Environment

Output of i3 --moreversion 2>&-:

i3 version: 4.22

orestisfl avatar Jan 22 '23 18:01 orestisfl

Please note that new features which require additional configuration will usually not be considered. We are happy with the feature set of i3 and want to focus in fixing bugs instead. We do accept feature requests, however, and will evaluate whether the added benefit (clearly) outweighs the complexity it adds to i3.

Keep in mind that i3 provides a powerful way to interact with it through its IPC interface: https://i3wm.org/docs/ipc.html.

i3bot avatar Jan 22 '23 18:01 i3bot

I think this would be a great addition, it's a pitty that you got no response yet after over 2 years. Even though they say that usually don't accept new features, I think this one would be a really beneficial addition since it would enable a lot of customization that isn't possible with external scripts or through the IPC interface.

For example, I would like to assign a different color to my last used workspace, to allow me to see where I would go with workspace back_and_forth even if it has been a while since I've changed workspace

It would also be neat to be able to define strip_workspace_name and strip_workspace_numbers on each individual workspace.

CTXO avatar Nov 01 '25 00:11 CTXO

@CTXO, what you are describing can be implementend using the existing i3bar workspace protocol. But you have to implement the logic in your script.

Changing colors isn't so flexible, but can be achieved using the Pango markup.

If you want to change the border or background color of the buttons, your options are quite limited though. But if you have a simple use case like distinguishing the previous workspace, you can set the desired color using the active_workspace attribute of the i3bar in the configuration file and then dynamically assign the visible attribute of the previous workspace in your script for the bar. Workspaces with the visible attribute set to true will be rendered using active_workspace color instead of the default.

The active_workspace color is usually applied when you use multiple monitors, so it's quite redundant in a single-monitor setup. If you have multiple monitors, you can combine the above approach with some Pango markup.

cdlscpmv avatar Nov 02 '25 18:11 cdlscpmv

Thanks! That was really helpful. Should've thought of that.

The pango markup is a really good solution and does the job. But the workspace buttons seem to have an inherent padding on them that make the background of the <span> tag in pango not take the whole button

Image

The workspace 3 is the last one visited, see how there is a little padding that shows the default background color inside the button?

I can live with it, but it would be nice to remove this intrinsic padding on the workspace buttons. Do you know if there is a way to accomplish that?

I've tried to set workspace_min_width 0 but it didn't help

I've searched the documentation, forums, the issues and discussions in the repo, asked several LLM's and found no solution to this.

Here is the relevant output that my script sends to the workspace protocol when the workspaces are in the state of the screenshot above:

> ./workspace_buttons.sh | jq '.[] | select(.num == 3 or .num == 10) | del(.rect, .output)'

{
  "id": 109967567095392,
  "num": 3,
  "name": "<span bgcolor=\"#5E81AC\" color=\"#E6E6E6\">3: brave  </span>",
  "visible": false,
  "focused": false,
  "urgent": false
}
{
  "id": 109967567108336,
  "num": 10,
  "name": "10: terminals  ",
  "visible": true,
  "focused": true,
  "urgent": false
}

CTXO avatar Nov 03 '25 13:11 CTXO

I can live with it, but it would be nice to remove this intrinsic padding on the workspace buttons. Do you know if there is a way to accomplish that?

Yes, using the active_workspace color attribute instead of the Pango markup. I mentioned it in my previous answer. But you are limited to choosing only one background color in this case.

cdlscpmv avatar Nov 03 '25 14:11 cdlscpmv