Xbar Script: Show count of hooked documents in menu bar

Hi, this is a simple script for xbar that shows the count of documents hooked to the currently active window/item in the menu bar.

Update: A few people pointed out that the script has conflicts with apps where Hook relys on UI-Scripting (e.g. Firefox).


This is fantastic - thank you so much!

Edit: I’ve had this installed for about ten hours now and my Hook usage has already skyrocketed. Thanks thanks for introducing me to xbar, too, can’t believe I’d not seen this before now!


Thank you very much @floflo for this contribution: as @thomasg says this script brings more usability to hook: I’m testing it and it changes the way I use hook too, but - unfortunately - I’ve detected a problem with Mozilla Firefox, with which I do a lot of linking via hook.

It turns out that when xbar with your hook.1s.sh plugin are active and “watching”, then the Firefox address window opens and closes intermittently, I suspect at the rate of 1second, I think, matching the 1-second “watch” rate that I think your script does. And therefore any possibility of using the browser is blocked. I have also found that with the Brave browser this interaction does not occur.

Have I explained myself well enough? Is there a possible hook-xbar-firefox triple interaction? Is it possible to find a solution?

Thank you very much for your attention.

One more fact:

Now I remember that Firefox’s behaviour of displaying the address bar always occurs when invoking hook to link, so I gather that the behaviour with xbar + hook.1s.sh suggests that at a rate of 1 second the address bar is displayed and closed as if it were a continuous invocation of hook.

Hey TBerni, interesting problem… i could reproduce it with Firefox.
The “Get Adress” command for Firefox uses UI-scripting-Applescript that seems to conflict with my Applescript. Not sure how/if i could resolve that, maybe the Hook developers have an idea?

Thanks for the feedback, glad it’s useful for you!

1 Like

Hello again @floflo:

I know from the developers that the level of compatibility between Firefox and Hook is not as high as that between Hook and Chromium-based browsers. In fact, I believe that the problem of the opening of the address bar - as I indicated - already exists between Firefox and Hook, what happens now with your script is that the problem becomes intractable due to the “surveillance” that hook.1s.sh exerts on Firefox and that determines the opening-closing-opening loop… in the address bar. (I don’t know how to express it in a more technical way).

I think your plugin is great, so I’m starting to think that I’ll have to use Brave as my first choice of browser instead of Firefox… Difficult dilemma!

Thanks again.

It’s not a Firefox specific issue. The problem is that some apps are not truly linkable (via an API), so for them Hook uses UI scripting, which involves automating interactions on the UI. (Hook Pro users can peer into Hook software integration scripts.)

Our solution will avoid this. It will only auto update the link count (in the separate window) if Hook can get the link info via automation.


Thank you very much for your explanation @LucB: I suspected some of this.

One question: do you already have a forecast of when you will be able to implement an internal solution to Hook to be able to see the links through the menu bar or by notification? In which version do you think you will introduce it?

1 Like

It tells me

Make your script executable: chmod +x hook. 1s.sh

no idea what I have to do. Thanks for any help

Found it in terminal … sorry for being dumb

I hesitate to commit specific dates. If I were a betting man, I’d say this 1/2 year.


Hi, This script isn’t usable for me. It keeps causing UI artifacts in many programs (FireFox, SideNote, etc). In a text editor, it is causing the cursor to move down the page one line at a time every second (NeoVim in a terminal). I suspect it’s due to UI scripting which often has this type of effect.

1 Like

yes, basically the script would need to check that Hook does not interact with the current app via UI scripting. I’d recommend checking whether the app is one of a set of apps, including Finder, DEVONthink, OmniFocus, Mail, etc.

Sorry to hear that… i tested it with the apps i use every day, but it seems that none of them are dependent on UI-Scripting. I’ll add a note up top.

1 Like

Great script @floflo - thanks for making this! Since I’m not using Firefox, only Brave and Safari, this is just perfect for my work. To improve the aesthetics and usability, I changed the IF-THEN-ELSE part slightly and moved the xbar item next to the Hook icon in the menubar so it looks like this (to the left):

Skärmavbild 2022-02-16 kl. 02.36.10

I find it a bit more intuitive and sleek this way.
It’s easy to change the script to whatever color you want on the figure - I prefer red because it has good contrast in both dark and light mode.

if (($count > 0)) 
	echo "$count | color=red | size=14"
	echo ""
1 Like