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
Implement "title_format" #1747
Implement "title_format" #1747
Conversation
I completely forgot the documentation. Will add that, of course. :) |
I think you should just use the glib implementation. |
You mean just blindly use their logic? I'm not so much a fan of committing code I don't understand. |
I think you just made the case against using any libraries at all. The truth is that nobody understands how computers work. |
But this isn't a library, this is own code that we need to maintain, so we should understand it. Or did you mean pulling in glib as a dependency? |
We get glib for free with pango. |
Oh okay. Then it's definitely better than reimplementing this. I'll change it. |
The documentation for
|
OK, I've switched to the glib implementation and added the documentation. |
Nice! I'll try to give it a go this weekend. I still think having some kind of left/right/center region would be useful, and the size balancing not as hard to handle as you have implied. Having the ability to change the appearance of the mark as shown on your window would be one benefit. |
Yeah, I did come around and think alignment options are a superior solution, though we should still define clear behavior about the balancing part upfront. This PR is just the first version of this feature (iterative process), see #1750 for the followup. |
First of all thanks for working on this and for all the rest of your work. I've tried the examples given in your doc and I succeed in adding a prefix in front of my title with your binding. |
Thanks for the feedback!
Could you maybe take a screenshot? It works fine for me. Also, can you upload your config somewhere? Finally, please post your reply in the issue, it probably shouldn't be in the PR. Thanks!
I already found myself wanting to play with animations ;) |
Feedback; it seems to be working pretty well for me. I tried @teto's example as well and could not reproduce the issue he was having. One issue I found, with large fonts (size='xx-large') and stacked windows, the text is drawn partially outside of the window title area onto the title area of the window above. |
Thanks for the feedback. I think the issue you mentioned is not something we can reasonably fix. |
I was surprised by the 4.8 so I rechecked the PR and my git log on the pulled PR is:
and |
@teto I just checked your config. You're not using a pango font, but rather xft. Of course pango markup cannot work in this case. :) |
Thanks !! I had no idea what a pango font was (even though you speak of it in yourt first post, shame on me). Now it works as intended ! Once again thanks for your many contributions on i3. |
Great. Thanks for testing this and the feedback. |
=== Window title format | ||
|
||
By default, i3 will simply print the window's title. Using +title_format+, this can be customized | ||
by setting the format to the desired output. This directive supports pango markup and the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should link to pango markup.
@acrisci Done |
int buffer_len = strlen(format) + 1; | ||
for (char *walk = format; *walk != '\0'; walk++) { | ||
if (STARTS_WITH(walk, "%title")) { | ||
buffer_len += strlen(escaped_title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be buffer_len = buffer_len - strlen("%title") + strlen(escaped_title)
, shouldn’t it?
Can you please squash the two commits that deal with the escaping function? I.e., I don’t like to have the commit in the history which adds code that is never used and replaced a commit later :). |
I forgot one comment… |
@stapelberg Adressed the last comment now, too. |
bindsym $mod+p title_format "Important | %title" | ||
|
||
# print all window titles bold | ||
for_window [class="^.*"] title_format "<b>%title</b>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the shortest way to match all windows is for_window [class="."]
, but I can see how .*
might be more familiar, i.e. people might more easily recognize that as a regular expression. The current form of ^.*
I don’t quite understand — why the anchoring in the beginning? It doesn’t seem to have any purpose, so please remove it.
@@ -2048,6 +2050,35 @@ Alternatively, if you do not want to mess with +i3-input+, you could create | |||
seperate bindings for a specific set of labels and then only use those labels. | |||
/////////////////////////////////////////////////////////////////// | |||
|
|||
=== Window title format | |||
|
|||
By default, i3 will simply print the window's title. Using +title_format+, this can be customized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to mention that the application defines the title. In the criteria section of the userguide, we use this terminology:
title
Compares the X11 window title (_NET_WM_NAME or WM_NAME as fallback).
So, I think changing “window's title” to “X11 window title” here would be good for consistency.
This directive will be used to customize the window title.
…ormat was set. The format string set with "title_format" can contain the placeholder "%title" which will be replaced with the actual window title. By not overwriting window->name itself, we make sure that assignment matching still works as expected. fixes i3#1723
@stapelberg Done. |
and the following placeholders which will be replaced: | ||
|
||
+%title+:: | ||
The X11 window title. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should read “The X11 window title (_NET_WM_NAME or WM_NAME as fallback).”.
@stapelberg But now, hopefully. :) |
I verified that not using a pango font doesn't mistakenly escape the window title. I do strongly suggest we get at least someone else (@acrisci, @ambihelical being canonical candidates) to play around with this first.
One open question for me is if we need to handle other characters when escaping pango markup. The glib implementation seems to do something (see my comment in #1723 where I pasted their implementation), but I don't really understand what's happening there, so input is much appreciated.
Here are some quick screenshots:
fixes #1723