Hammerspoon: hs.menubar icons/titles are sometimes trunctated

Created on 6 Jun 2016  路  5Comments  路  Source: Hammerspoon/hammerspoon

There seems to be an issue with setting both the title and icon for a menubar, where the title gets cut off -- the width is too small. Interestingly, if you reverse the order (set the icon before the title, or the other way around), in both cases the title is cut off, but the amount that's cut off is different.

I'm on a retina display, El Capitan (10.11.5), Hammerspoon 0.9.46.

Here's a simple init.lua to demonstrate:

local iconPath = '/Applications/Hammerspoon.app/Contents/Resources/statusicon.pdf'
local menu = hs.menubar.new()
local title = 'title'

menu:setIcon(iconPath)
menu:setTitle(title)

-- try this, too... different result
-- menu:setTitle(title)
-- menu:setIcon(iconPath)

Icon first:
icon_first

Title first:
title_first

bug

All 5 comments

Thanks, this has been a known issue for a while, but I don't think we had a GitHub issue, so thanks for filing that!

Fixing this is going to be.... interesting. The API that we currently use for those menubar items was deprecated in 10.10 and a new API was introduced, but we currently support older releases of OS X, so I can't rewrite hs.menubar to use the newer APIs (which, if anyone cares, is basically moving everything to being subviews of the NSStatusBarButton property of NSStatusItem).

I'm going to close this out - it could only be resolved by rewriting hs.menubar to use the newer macOS NSStatusItem APIs, and if/when we do that, this issue would automatically be resolved.

FYI: For some reason setting the title to " " before changing the icon and title fixes things in El Capitan. This bug also seems to be fixed in Sierra.

The upcoming rewrite also allows specifying an explicit width and adjusting position of image in relation to text when both are set

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaronjensen picture aaronjensen  路  3Comments

BigSully picture BigSully  路  3Comments

jiahut picture jiahut  路  3Comments

jasonrudolph picture jasonrudolph  路  4Comments

specter78 picture specter78  路  3Comments