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

Window Titles should be Tab Titles in macOS #3893

Closed
typkrft opened this issue Aug 2, 2021 · 18 comments
Closed

Window Titles should be Tab Titles in macOS #3893

typkrft opened this issue Aug 2, 2021 · 18 comments
Labels

Comments

@typkrft
Copy link

typkrft commented Aug 2, 2021

Describe the bug
In macOS if I start kitty like this open -a kitty.app -n --args --single-instance --title="quake" -o tab_title_template="quake" I get a window tab title that is named quake and if I open new tabs they continue to be named quake. However subsequent tabs despite being named quake in the tab bar are not recognized by their tab name and instead are listed as zsh. This prevents me from setting rules for them properly in my window manager yabai.

To Reproduce
Steps to reproduce the behavior:

  1. open -a kitty.app -n --args --single-instance --title="quake" -o tab_title_template="quake"
  2. open new tab with cmd + t
  3. Tab bar says quake, but window title becoms zsh.

Screenshots
Screen Shot 2021-08-02 at 9 01 01 AM

  • With One Tab open you can see in the menu bar at the top it says quake. This is as expected.

Screen Shot 2021-08-02 at 9 00 56 AM

- With two tabs the menu bar now says zsh. This is unexpected in the tab bar of kitty it does say quake which you will see in the subsequent photos.

Screen Shot 2021-08-02 at 9 00 50 AM

- With two tabs you can see the Tab bar shows that the tab name is quake, but in the dock kitty shows zsh as the name of the window

Screen Shot 2021-08-02 at 9 00 42 AM

- Again with one tab you see in the dock kitty is named quake as expected.

Environment details

kitty 0.22.0 created by Kovid Goyal
Darwin Brandons-MacBook-Air-ARM.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64
ProductName:	macOS ProductVersion:	11.5.1 BuildVersion:	20G80
Loaded config files:
  /Users/brandon/.config/kitty/kitty.conf
Loaded config overrides:
  tab_title_template quake

Config options different from defaults:
active_border_color     Color(red=239, green=207, blue=185)
active_tab_background   Color(red=239, green=207, blue=185)
active_tab_foreground   Color(red=12, green=14, blue=59)
allow_remote_control    y
background              Color(red=12, green=14, blue=59)
bell_border_color       Color(red=229, green=47, blue=103)
bold_font               VictorMono Nerd Font Medium
bold_italic_font        VictorMono Nerd Font Medium Italic
cursor                  Color(red=239, green=207, blue=185)
font_family             VictorMono Nerd Font
font_size               14.0
foreground              Color(red=239, green=207, blue=185)
hide_window_decorations 2
inactive_border_color   Color(red=12, green=14, blue=59)
inactive_tab_background Color(red=12, green=14, blue=59)
inactive_tab_foreground Color(red=239, green=207, blue=185)
italic_font             VictorMono Nerd Font Italic
macos_option_as_alt     3
tab_bar_edge            1
tab_bar_margin_height   TabBarMarginHeight(outer=1.0, inner=1.0)
tab_bar_style           powerline
tab_title_template      quake
window_padding_width    FloatEdges(left=5.0, top=5.0, right=5.0, bottom=5.0)

Additional context
I have to use some options to set the title but this does continue to occur only setting the title or tab_title_template.

@typkrft typkrft added the bug label Aug 2, 2021
@typkrft
Copy link
Author

typkrft commented Aug 3, 2021

Wow! Thanks for addressing this so quickly. A couple of quick things to mention. First this works perfectly for what I need it for. However just so you are aware, new windows spun off of the Quake window with CMD+N do not show Quake in the menu bar/ dock even though that's whats in the tab bar. I am okay with this and maybe that's by design. If anything I think they should just revert back to your default config since its a new window anyway. Secondly for some strange reason if you do FN + CMD - T subsequent tabs are not named Quake pressing CMD - T again however results in a new tab being name Quake. I looked at the keyboard input viewer supplied with kitty but it doesn't seem to register FN. This is completely fine, I don't use the FN keys for anything anyway and it's probably bad practice to do so, but I thought I would mention it.

Also when I close the last window spun off of the Quake window even if Quake is minimized it reopens the Quake window. Is there a config option to stop that behavior?

Thanks again for this invaluable piece of software.

@basbebe
Copy link

basbebe commented Aug 17, 2021

for me --title now doesn't work for me anymore in conjunction with --single-instance as expected (also on macOS using yabai).

I open a scratchpad with this script:

kitty_cmd="kitty --title $SCRATCHPAD_TITLE \
  --directory $HOME
  --config="$HOME/.config/kitty/kitty.conf" \
  --config="$HOME/.config/kitty/themes/gruvbox-$(fish -c 'echo $OS_THEME').conf"
  --override macos_hide_from_tasks=yes \
  --single-instance \
  --instance-group=scratchpad"

however, all of them have the title of the first scratchpad I open this way (e.g. scratchpad_terminal instead of scratchpad_editor.

what would be the proper way to do this now if I wanted to have a single instance with individually named OS windows?

@typkrft
Copy link
Author

typkrft commented Aug 17, 2021

I think the ideal solution would be to disconnect the window name from the tab title. So when you run yabai query on a space it would show app: kitty title:scratchpad if it were named, then just let the tab titles show whatever you have setup in your rc like the current process. This is how I assumed it worked initially but was unable to get to work like that.

@kovidgoyal
Copy link
Owner

the proper solution is for apple to implement some way to give windows
a custom identifier. Of course this being apple, that will never happen.

And I pushed a fix for --title with --single-instance

@basbebe
Copy link

basbebe commented Aug 18, 2021

the proper solution is for apple to implement some way to give windows
a custom identifier. Of course this being apple, that will never happen.

And I pushed a fix for --title with --single-instance

I assume you are correct.

Thank you very much!

@typkrft
Copy link
Author

typkrft commented Aug 18, 2021

This seems to break everything again unfortunately. The Menu bar shows the running process (which is of no consequence), the dock shows the set title, which is what yabai/macOS see as the title. Now if kitty is started with open -a kitty.app -n --args -1 --title="Test" every new os-window created is named "Test" even if you give it another name. Just in case anyone sees this you can kind of work around it by not using single instance. Also if you use macos_hide_from_tasks=yes does not work if you title a window. Not the end of the world though.

@kovidgoyal
Copy link
Owner

Not sure what you mean. The behavior is if you use --title XXX -1 the OS
window thus created has its title set to Title. OS Windows created
through other means will have their titles set to whatever was the
original value of --title.

@typkrft
Copy link
Author

typkrft commented Aug 19, 2021

Basically what I am trying to do is to create a window named Quake and a window name Scratchpad. Essentially I want to be able to differentiate between the two with Yabai so that I can apply certain WM transformations to either one. If I open a window with open -a kitty.app -n --args -1 --title="Quake" and another with open -a kitty.app -n --args -1 --title="Scratchpad" or kitty @ launch --type="os-window" --title="Scratchpad" I end up getting two windows named Quake. When I query the window data with yabai I get something like the following.

$ yabai -m query --windows --space 1 | jq '.[]'

Space Windows JSON
{
  "id": 2389,
  "pid": 75927,
  "app": "kitty",
  "title": "Quake",
  "frame": {
    "x": 778,
    "y": 544,
    "w": 439,
    "h": 494
  },
  "level": 0,
  "role": "AXWindow",
  "subrole": "AXStandardWindow",
  "movable": 1,
  "resizable": 1,
  "display": 1,
  "space": 1,
  "visible": 1,
  "focused": 0,
  "split": "vertical",
  "floating": 0,
  "sticky": 0,
  "minimized": 0,
  "topmost": 0,
  "opacity": 0.95,
  "shadow": 0,
  "border": 1,
  "stack-index": 0,
  "zoom-parent": 0,
  "zoom-fullscreen": 0,
  "native-fullscreen": 0
}
{
  "id": 2402,
  "pid": 75927,
  "app": "kitty",
  "title": "Quake",
  "frame": {
    "x": 1229,
    "y": 544,
    "w": 439,
    "h": 494
  },
  "level": 0,
  "role": "AXWindow",
  "subrole": "AXStandardWindow",
  "movable": 1,
  "resizable": 1,
  "display": 1,
  "space": 1,
  "visible": 1,
  "focused": 0,
  "split": "vertical",
  "floating": 0,
  "sticky": 0,
  "minimized": 0,
  "topmost": 0,
  "opacity": 0.95,
  "shadow": 0,
  "border": 1,
  "stack-index": 0,
  "zoom-parent": 0,
  "zoom-fullscreen": 0,
  "native-fullscreen": 0
}

I suspect this is what you may have been referring too when you mentioned Apple's inability to give custom windows identifiers. I can remove the -1 flag but then I end up getting multiple kitty icons in my dock. I can hide them from the task manager which removes the icons but when they are minimized they still retreat to the dock. In most macOS programs windows are named (titled) differently despite running under the same occurrence. For instance in Mail you might have a window titled after the inbox you are in, but when you open another window, for let's say a reply, this new window is called whatever the subject of the email was is and that's reflected in title key of yabai. To go a bit further with this example it means I can sticky the reply window and move to a different space where I have notes are or whatever the case may be. Maybe I'm going about this all wrong, I did have a working solution in the original update though because I could create a single instance with the override tab title template options and because the tab title was the window name the new os-windows created would have a different name (the name of the command being executed) maybe this wasn't intentional however.

@kovidgoyal
Copy link
Owner

Running from current master, I get the follwoing:

  1. kitty -1 --title A
    gives a kitty window with A in the titlebar

  2. kitty -1 --title B
    gives another kitty window with B in the titlebar

@typkrft
Copy link
Author

typkrft commented Aug 19, 2021

$ kitty -v

kitty 0.23.1 created by Kovid Goyal

kitty -1 --title A
kitty -1 --title B

Both show A in the title bar for me currently. But that's exactly what I want to happen.

@kovidgoyal
Copy link
Owner

Yes, but that's not what is supposed to happen. If you want the second window to show title A. Dont specify --title B when running it.

@typkrft
Copy link
Author

typkrft commented Aug 19, 2021

No I'm sorry I mean I want what you are saying should happen. That wasn't clear on my end.

@kovidgoyal
Copy link
Owner

Yes and what I am saying is happening in master not in 0.23.1

@typkrft
Copy link
Author

typkrft commented Aug 19, 2021

Gotcha, I thought I was using --head in brew. Let me try that again. I assume you're absolutely right, I'll report back if that still doesn't work. Sorry for my ignorance and thank you!

Edit:
Works like a dream!

@exAspArk
Copy link

Hi! It looks like changes related to this issue cause a new bug. Starting with v0.24.0, tab titles can't be customized dynamically if launched without a custom title in ZSH in macOS:

echo -ne "\033]0;"Title goes here"\007" 
# ^ doesn't change the title anymore

Is it related to disallow_override_title=bool(args.title)? Can this option be potentially customized through the config file?

@page-down
Copy link
Contributor

@exAspArk

If you want to print the title yourself, you can disable the shell integration title feature.
https://sw.kovidgoyal.net/kitty/shell-integration/

@kovidgoyal
Copy link
Owner

You need to add no-title to shell_integration in kitty.conf

@exAspArk
Copy link

@page-down @kovidgoyal oh, nice! Thank you! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants