$INFO output with hidden bar
PhrantiK opened this issue · comments
Trying to figure out the best way to hide a bar for a specific space. Noticed we can do it by display (#42) and also saw another issue with a bunch of yabai signals (#175 (comment)).
Is it possible to do it with an item & space_change event to keep things a bit faster & leaner?
ITEM:
sketchybar --add item hide2 right \
--set hide2 script="$PLUGIN_DIR/hide2.sh" \
--subscribe hide2 space_change
PLUGIN:
hide() {
# sketchybar --bar hidden=on
echo "turn it off"
}
unhide() {
# sketchybar --bar hidden=off
echo "turn it on"
}
case $(echo "$INFO" | jq '.[]') in
"2") hide
;;
*) unhide
;;
esac
It works great but when the bar is hidden, $INFO stops outputting so the bar stays hidden. Not sure if that's by design, a bug or feature request. Thanks!
This will work perfectly if you set sketchybar --set hide2 updates=on
because I presume it is currently set to when_shown
, hence it will not call its script when the item is not drawn to screen.
PEBKAC - Thanks Felix!
Edit: Leaving this here for posterity.
Been mucking about with the helper program to do this instead of adding an item and got it working:
add mach_helper=$HELPER
to the spaces config and add this to the helper:
else if (strcmp(sender, "space_change") == 0) {
// turn the bar off on D1S2
char *dos = strstr(info, "{\n\t\"display-1\": 2\n}");
char command[256];
char *hide;
hide = dos ? "on" : "off";
snprintf(command, 256, "--bar hidden=%s", hide);
sketchybar(command);
}
Makes it instant. Thanks again for the awesome software!