osd: add window-switcher custom field (#1670)

Add custom field with subset of printf style formatting
to replace the original field formats.

Example:

    <windowSwitcher preview="no" outlines="no" allWorkspaces="yes">
      <fields>
        <field content="custom" format="foobar %b %3s %-10o %-20W %-10i%t" width="100%" />
      </fields>
    </windowSwitcher>

Mono space font recommended. May need OSD width adjusted

Co-authored-by: @Consolatis (based on work done by them)
This commit is contained in:
droc12345 2024-04-10 17:39:31 -05:00 committed by GitHub
parent 2bf285a2c6
commit d672765ea7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 490 additions and 191 deletions

View file

@ -243,6 +243,30 @@ this is for compatibility with Openbox.
- *output* Show output id, if more than one output detected
- *custom* A printf style config that can replace all the above
fields are:
- 'B' - shell type, values [xwayland|xdg-shell]
- 'b' - shell type (short form), values [X|W]
- 'S' - state of window, values [M|m|F] (3 spaces allocated)
(maximized, minimized, fullscreen)
- 's' - state of window (short form), values [M|m|F] (1 space)
- 'I' - wm-class/app-id
- 'i' - wm-class/app-id trimmed, remove "org." if available
- 'W' - workspace name
- 'w' - workspace name (if more than 1 ws configured)
- 'O' - output name
- 'o' - output name (show if more than 1 monitor active)
- 'T' - title of window
- 't' - title of window (if different than wm-class/app-id)
Recommend using with a mono space font, to keep alignment.
- *custom - subset of printf options allowed -- man 3 printf*
- random text may be inserted
- field length, example "%10" use 10 spaces, even if text uses less
- left jusify text, example "%-"
- right justify text, example "%" instead of "%-"
- example, %-10 would left justify and make room for 10 charaters
- Only one custom format allowed now. Future enhancements may allow more than one.
*width* defines the width of the field expressed as a percentage of
the overall window switcher width. The "%" character is required.

View file

@ -77,7 +77,22 @@
<field content="output" width="9%" />
<field content="identifier" width="30%" />
<field content="title" width="50%" />
</fields>
</fields>
</windowSwitcher>
custom format - (introduced in 0.7.2)
It allows one to replace all the above "fields" with one line, using a
printf style format. For field explanations, "man 5 labwc-config".
The example below would print "foobar",then type of window (wayland, X),
then state of window (M/m/F), then output (shows if more than 1 active),
then workspace name, then identifier/app-id, then the window title.
Uses 100% of OSD window width.
<windowSwitcher show="yes" preview="no" outlines="no" allWorkspaces="yes">
<fields>
<field content="custom" format="foobar %b %3s %-10o %-20W %-10i %t" width="100%" />
</fields>
</windowSwitcher>
-->