Bartender controversy, tutorial on how to manage menubar status items via BTT

@Shreman can you post a screenshot? Is it maybe just disabled?

This is weirdly sporadic. I had quit BTT. I launched it to do the screenshot and ... it was fine!!! So I quit again, launched again, and here is the screenshot with Settings greyed out.

Weird, I have not seen that before. However you can also access the settings here:

I have NO windows for BTT.

Ah because your BTT menubar icon is hidden? In that case you can "launch" BTT again while it is already running, then it will open its preferences.

Thanks for this post! After some tinkering, I have a very simple Bartender replacement preset I'm pretty happy with. Hope I did this right: BetterTouchTool Community

Edited: I think this is the correct permalink -> toggleMenuBar

A couple notes that might help someone else:

  • There are two triggers, a placeholder and a toggle button. They should be positioned next to each other (with the placeholder to the left of the toggle).
  • The toggle uses a state variable to remember whether the menu icons are shown or hidden. This avoids the issue from the BTT built-in where you can't use a delay to re-hide the icons unless you are committed to never clicking the toggle to manually re-hide them. It also means the toggle arrow indicator can't get out of sync with the placeholder.
  • The thing that makes this work is having a "placeholder" trigger that has either no title, or a very long title of empty space. This is why the built-in can only hide elements to the left of the BTT icon, including the BTT icon. I found that changing the title of a single toggle button did not work, as OSX seems to hide the entire item when it's too long. I'm also LOL to learn that this is the trick Bartender was doing all along, it's so hacky :joy:
  • The placeholder does not have an icon, and changes its text via AppleScript return value based on the value of the variable.
  • The toggle button has left and right arrow icons, and uses the "alternate regex" to change depending on the value of the variable.
  • There's a script hooked to the toggle button that changes the value of the variable and then refreshes both triggers. You'll need to make sure it has the right UUIDs (I'm not sure if these persist through an export/import or if you'll need to right-click on them after importing to get the new values).
  • I included a third trigger I'm using which calls the toggle button's action when the menubar is double-clicked on.

I did find a bunch of random issues while trying to do this, some of which are almost certainly down to the fact that I'd never scripted anything in BTT before. But I'll list them here in case anyone else sees the same:

  • While the JS docs recommend using it over AppleScript, I was unable to get the regex to work with JavaScript at all. Tried returning it all sorts of ways and putting a lot of different types of strings in the regex field with no luck. I couldn't find good documentation about how to use this field, and did notice that the help text seems to imply it only works for AppleScript.
  • I also tried to use the JS functions without the callBTT wrappers, which did not work. And I wasn't able to get persistent variables working either. I'm on the latest BTT (4.572), but not alpha, so perhaps that is why.
  • Lots of bugginess in the cute little code editor, including code reverting to a previous state after save, options getting reverted (I can't seem to unselect "run in background" on the placeholder, when I save it is checked again), long pauses trying to delete lines, the Save button not appearing after making changes, the editor being blank/taking some seconds to reload after switching to another window and back, and once when I made the mistake of editing code that was also set to run every 1s, I had not yet closed the bracket and BTT beachballed, then kept crashing on re-open until I somehow managed to uncheck the button after loading it.
  • There's no way to hide the placeholder completely based on the AppleScript result. It always takes up some space even when it's only an empty string with no icon.
  • If you try to use update_trigger to set the options on a trigger programattically, it only works the first time. For example I was able to toggle the "show icon only" option once, but was unable to toggle it back. (I was thinking this might be a good workaround for the above issue)
  • More of a docs issue, but I don't really understand when or why I'd want to use options such as "run in background" or "always run when the widget becomes visible" (isn't it always visible?)
  • When something refreshes in the menubar, sometimes it ends up in a "hidden" state but with the icons showing. I haven't figured out if that's caused by anything other than updating the triggers in BTT. If it's just an issue when I make changes to a trigger, I can live with that.

This got long but hope it helps someone else!! And if anyone has suggestions for how to simplify or improve this preset please LMK!

2 Likes

Ah, I see. Yes, if I double-click BTT in the Applications folder while it is already running, it does indeed open that main window, and I have access to preferences. If I quit, and then double-click to launch it, once again I do not have any windows in BTT. Is this normal behavior? Is this because of the BTT menu bar icon being "hidden" behind the notch?

if you have used the predefined action "Show / Hide Menubar Icons Left Of BTT Icon", it will also hide your BTT icon when executed (in the example preset above this is assigned to the a click on the notch

Yes. For now, as part of trying to figure out the Settings issue, I deleted BTT and all its files (I am only now starting again with BTT, so I had nothing to lose). So I have no predefined action. But I feel certain the BTT menubar icon is "hidden" behind the notch, FWIW.

Thanks, Andreas.

What did I do?

you helped discovering a bug in BTT :slight_smile: it's fixed 4.576

2 Likes

I kept the preset pretty simple and made screenshots as a tutorial for people to follow if they didn’t want to trust the pre-made file I shared. Sorry if one of the settings conflicted with something else you were doing with other settings.

Oh. Yay! LOL

There seems to be nothing in the preset you linked. Was it deleted?

Ah, thanks, maybe I copied the link to my logged-in view of it. Does this one work? toggleMenuBar

(trying to re-post to reply to the correct thread, oops)

Thanks, that works. But clicking the placeholder icon doesn't seem to do anything. The placeholder trigger has no actions associated with it. Should it?

No, the placeholder is only there to take up space. The variable is toggled by the button, and the placeholder renders itself based on the variable's setting.

If you wanted, you could give it the same action as the double-click on the menubar (have it run the action associated with the toggle button), then you'd be able to click on the empty space in the menubar in order to reveal the hidden icons. I didn't like how that behaved for reasons I don't quite recall (IIRC it selects the placeholder, and there is also "dead space" somewhere to the left of the notch) but YMMV. You could make the placeholder whitespace larger to increase its clickable area... unless OSX removes it completely when it's too large :thinking:

1 Like

Having an item that can be clicked to hide but stays visible itself will be possible with the next version.

The Ice developer Jordan Baird and I seem to have solved the last remaining issue, now both BTT and Ice should be able to gain the same functionality Bartender has.
([Feature Request] notch macbook support. · Issue #1 · jordanbaird/Ice · GitHub )

6 Likes

This is awesome, great work as always @Andreas_Hegenberg

P.S.

The double tap, how does that determine which menu bar icons to hide? Seems to be a set figure, can this be adjusted anywhere?