Closed bobbyl140 closed 12 months ago
I think this is currently undocumented but I will share how to do it here (although it might be a good idea to document this at some point in the helper repo:
If you use a secondary bar (e.g. bottom_bar
) you need to do some extra work to get the helper to send the messages to the correct mach port. The mach port name of a bar is determined by its binary name:
git.felix.<binary_name>
So the initial sketchybar instance has the mach port name: git.felix.sketchybar
, which is where the sketchybar.h file from my dotfiles sends all of its messages. If you create a secondary bar you need to adapt the mach port name to e.g .
git.felix.bottom_bar
.
Second, the mach port of the helper should not be in use already i.e. you can not have both your helper register for git.felix.helper
but must choose a different name for every helper.
Sorry, that would be my fault, I didn't think to look at other repos. How is the bar's mach port named though? I have the second bar running from a symlink sketchybar2
, but when I added "2" to that port name in sketchybar.h
and recompiled the helper, it still doesn't seem to work.
Cam you share how you set up the helper for the second bar with an actual item?
I am trying to implement the same clock item, like this:
sketchybarrc
:
...
## Helper Script
HELPER=git.felix.helper2
~/.config/sketchybar2/scripts/helper2 $HELPER > /dev/null 2>&1 &
## Clock
sketchybar2 --add item clock left
sketchybar2 --set clock padding_right=5 background.drawing=1 icon.background.drawing=1 icon="" icon.color=0xff000000 icon.padding_left=4 icon.padding_right=5 background.border_width=1 label.padding_left=5 label.padding_right=5 background.color=0x77000000 label.font.size=12.5
~/.config/sketchybar2/scripts/clock &
...
Then in sketchybar.h
,
...
mach_port_t port;
if (bootstrap_look_up(bs_port,
"git.felix.sketchybar2",
&port ) != KERN_SUCCESS) {
return 0;
}
...
I get the feeling I'm missing something really obvious, if so, I'm sorry in advance.
Attached is a zip of my secondary bar config for experimenting called bottom_bar
.
It includes the clock helper bottom_bar.zip and works perfectly. I am wondering if the mach port name should possibly not contain any numbers... because everything else looks good.
Note that I have created a new makefile such that it compiles the clock
binary.
I changed every instance of sketchybar2
and helper2
to the same but with "two" spelled out, and still no luck. I will take a look at your files in that zip and see if I have something else wrong.
I might be missing something, actually. In your dotfiles repo you have a file with the literal name helper
in your sketchybarrc
. Is this required, or does the clock
binary in that zip do the same thing?
I recompiled the clock binary with the change to helper.c
because I realized it depended on that. The clock does in fact show up now. But still, do I need the separate helper binary, or is that merely a stub for other code?
You only need the clock
binary for the clock functionality, in my dotfiles the helper provides the data for the cpu graph and nothing more than that (as you can see from my bottom_bar
example I have provided where these files are absent).
I see now. I think I had confused helper.c
with sketchybar.h
. Thank you (again) for working through this with me!
No worries, using these C helper programs is a very advanced use of sketchybar already and combining it with multiple bars is even more complicated (also because I have not documented properly how to do that).
Hello again! I am working on extending my configuration after my last problem the other day (#454). I added a second bar, and tried to give it its own helper. But the helper seems to still target the original bar.
In your dotfiles, you have:
I appended "2" to the
HELPER=
line (and changed the config directory), but it didn't seem to change anything. I also noticed insketchybar.h
, there is an IDgit.felix.sketchybar
. I next appended "2" to this, also to no avail. Is there a way to do this, or is there something in the code of the actual sketchybar binary that sets the ID? Thank you!