nikitabobko / AeroSpace

AeroSpace is an i3-like tiling window manager for macOS
https://nikitabobko.github.io/AeroSpace/guide
MIT License
7.97k stars 130 forks source link

Monospaced font for menu bar? #56

Open MatthiasGrandl opened 11 months ago

MatthiasGrandl commented 11 months ago

So I really love the subtle menubar that shows the current space. However the default font doesn't lend itself very well to this purpose as the different numbers/letters, have different widths, causing other menubar items to jump when switching spaces. The use of a monospaced font would alleviate this.

For example the MacOS default clock in the right of the menu bar seems to be using the equivalent of CSS: font-variant-numeric: tabular-nums; to prevent jumping.

nikitabobko commented 11 months ago

I'm 100% agree that it needs to be monospaced. The menu bar is programmed in Swift UI and I tried to make it monospaced but it didn't work.

I suspect that macOS simply doesn't allow changing the font of the tray items. Are there any known apps that show their tray item in monospaced? macOS clock doesn't count. It's a system thing, it can have more privileges

MatthiasGrandl commented 11 months ago

So could it be worked around with icons? I am not at all familiar with SwiftUI MacOS programming.

But yeah I expected this to not be super straightforward :)

nikitabobko commented 11 months ago

So could it be worked around with icons?

The tray icon shows workspace names. Workspace names are not necessarily single-lettered

rami3l commented 9 months ago

When I was using Amethyst, I also used a companion app called SpaceId, and the latter seems to be using Swift code to generate the tray icon.

It works pretty well actually:

Unfortunately I have to stop using it due to AeroSpace having its own virtual desktop system (which is great in general except for this tiny detail).

I imagine having as many icons as my active monitors (the current ordering seems fine), each showing the identifier of the current virtual desktop of that monitor (just considering the case of 1-2 letters would be fine for most cases I believe). If a monitor is unbound, a ? is used instead.

ELLIOTTCABLE commented 9 months ago

SpaceId looks fantastic, and of course I find it via this thread, right as it becomes useless to me since I'm switching to Aerospace.

:+1: to adding a list of spaces to the titlebar, that doesn't shift around often.

(My vote would be: show all spaces that have ≥1 window; with the current one highlighted dynamically switch around between them.)

graywolf commented 3 months ago

I wonder if generating a tiny image with the text would work.

Yixuan-Wang commented 1 month ago

I tried copying SpaceId's source code in and here is how it looks

SpaceId style tray icon 4 SpaceId style tray icon Q

So could it be worked around with icons?

The tray icon shows workspace names. Workspace names are not necessarily single-lettered

Sadly this currently doesn't work with [s] prefixes and multiple letters (but should be technically feasible)

Yixuan-Wang commented 1 month ago

I suspect that macOS simply doesn't allow changing the font of the tray items. Are there any known apps that show their tray item in monospaced? macOS clock doesn't count. It's a system thing, it can have more privileges

Following SpaceId's code, making it monospace should be possible by drawing an image just as @graywolf said

steliyan commented 4 weeks ago

I have something working, anyone willing to give it a try? https://github.com/steliyan/AeroSpace/tree/menubar-monospaced

Screenshot:

image

To be honest, not sure if this is the best way (using @MainActor), but haven't really got the time to understand how SwiftUI works.

The cool thing is we can keep everything else the same, still a text is rendered, not fancy custom drawing logic. Also, this provides the ability to have something like the 2nd line (the 1st line is what we currently have):

image
frostplexx commented 3 weeks ago

The only way to display custom items in the menubar appears to be through the use of AppKit. I successfully implemented this approach: https://github.com/frostplexx/AeroSpace/tree/monospace-menubar, and it generally works well, except for a few minor fixable bugs.

image image image

The code is a bit messy, but it would also allow us to use any arbitrary SwiftUI view as the menu bar icon. Additionally, it would enable the use of custom fonts (configured by the user in the config file). For instance, users can set the workspace names to icons of their choice using a nerd font.

image