Skip to content
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

i3bar: protocol for workspace buttons #3818

Open
xzfc opened this issue Oct 10, 2019 · 4 comments
Assignees

Comments

@xzfc
Copy link
Contributor

@xzfc xzfc commented Oct 10, 2019

Proposal

I am proposing to add ws_command option to i3bar. It should be similar to status_command but for controlling workspace buttons instead of statusline blocks.

This would allow the user to define arbitrary complex customizations without introducing actual complexity into the i3bar code or i3bar configuration syntax.

Examples of customizations are:

  • Show empty workspaces #2617
  • Hide certain workspaces #2333
  • Groups of workspaces #1808
  • Sort workspaces alphabetically #3548

Examples of per-button customizations:

  • "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.

Diagram

i3bar_ws

Example configurations

bar {
	ws_command ~/bin/ws_command_default.sh
}

ws_command_default.sh - recreate the default i3bar behavior.

#!/bin/sh
i3-msg -t subscribe -m '["workspace"]' | {
	i3-msg -t get_workspaces;
	while read; do i3-msg -t get_workspaces; done;
}

ws_command_hide.sh - hide workspace named foo unless it is visible.

#!/bin/sh
i3-msg -t subscribe -m '["workspace"]' | {
	i3-msg -t get_workspaces;
	while read; do i3-msg -t get_workspaces; done;
} | jq -c '[ .[] | select(.name != "foo" or .visible) ]'

ws_command_show_empty.sh - show empty workspaces foo and bar on LVDS1 even if they do not exist at the moment.

#!/bin/sh
i3-msg -t subscribe -m '["workspace"]' | {
	i3-msg -t get_workspaces;
	while read; do i3-msg -t get_workspaces; done;
} | jq -c '
	def fake_ws(name): {
		num: -1, name: name,
		visible: false,
		focused: false,
		urgent: false,
		output: "LVDS1",
		"colors":["#191919", "#111111", "#444444"], # dimmed inactive_workspace
	};
	. + [ fake_ws("foo"), fake_ws("bar") ] | unique_by(.name)
'
@i3bot i3bot added the enhancement label Oct 10, 2019
@orestisfl

This comment has been minimized.

Copy link
Member

@orestisfl orestisfl commented Oct 10, 2019

I like the idea and since we have the infrastructure to support IPC and JSON parsing this will not be very complex. @Airblader will have to approve though.

Btw, are you willing to implement this?

@xzfc

This comment has been minimized.

Copy link
Contributor Author

@xzfc xzfc commented Oct 10, 2019

@Airblader

This comment has been minimized.

Copy link
Member

@Airblader Airblader commented Oct 10, 2019

Yes, I think this is a great, extensible solution. I'd say we for now start with a protocol that only covers what we currently need and leave additional features (such as separators) for follow-up work. So it would be good to define what that protocol could look like and then get the PR going.

Something we need to decide is whether coloring focused / urgent workspaces is left up to that interface as well or whether this will still be done by i3bar.

@Airblader

This comment has been minimized.

Copy link
Member

@Airblader Airblader commented Oct 10, 2019

Another thing, I would not support multiple protocols here like we do in the status command and go for JSON right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.