FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.2k stars 82 forks source link

sketchybar --reload extremely slow #570

Closed realhackcraft closed 1 week ago

realhackcraft commented 1 week ago

I'm not sure if my config is wrong or something, but today, the first time I'm using sketchybar (that is to say I don't have a frame of reference), the loading of the items are extremely slow.

https://github.com/FelixKratz/SketchyBar/assets/65378120/328262ab-8e21-41c7-a7b2-5b41ec75969b

FelixKratz commented 1 week ago

Could you share a few more informations?

realhackcraft commented 1 week ago

sure!

MacOS version: 15

sketchybarrc:

#! /bin/bash

PLUGIN_DIR="$CONFIG_DIR/plugins"
ITEM_DIR="$CONFIG_DIR/items"

# -- Bar Appearance --
sketchybar --bar position=top height=40 blur_radius=30 color=0x40000000

# -- Changing Defaults --
default=(
  padding_left=5
  padding_right=5
  icon.font="SF Pro:Semi Bold:15.0"
  label.font="SF Pro:Semi Bold:15.0"
  icon.color=0xffffffff
  label.color=0xffffffff
  background.corner_radius=5
  background.height=24 
  icon.padding_left=10
  icon.padding_right=4
  label.padding_left=4
  label.padding_right=10
)
sketchybar --default "${default[@]}"

# -- Left Side Items --
source $ITEM_DIR/spaces.sh
source $ITEM_DIR/front_app.sh

# -- Center Items --
source $ITEM_DIR/media.sh

# --- Right Side Items ---
source $ITEM_DIR/calendar.sh
source $ITEM_DIR/volume.sh
source $ITEM_DIR/battery.sh
source $ITEM_DIR/cpu.sh
# -- Force all scripts to run the first time (never do this in a script) --
sketchybar --update

items/spaces.sh: (the others are similar, but this one can be observed the clearest)

#!/bin/bash

SPACE_SIDS=(1 2 3 4 5 6 7 8 9 10)

for sid in "${SPACE_SIDS[@]}"
do
  sketchybar --add space space.$sid left                                 \
             --set space.$sid space=$sid                                 \
                              icon=$sid                                  \
                              label.font="sketchybar-app-font:Regular:16.0" \
                              label.padding_right=20                     \
                              label.y_offset=-1                          \
                              script="$PLUGIN_DIR/space.sh"
done

sketchybar --add item space_separator left                             \
           --set space_separator icon="􀆊"                                \
                                 icon.color=$ACCENT_COLOR \
                                 icon.padding_left=4                   \
                                 label.drawing=off                     \
                                 background.drawing=off                \
                                 script="$PLUGIN_DIR/space_windows.sh" \
           --subscribe space_separator space_windows_change

The following two scripts takes less time. I think it's the sketchybar --add that takes the longest.

plugins/spaces.sh

#!/bin/sh

# The $SELECTED variable is available for space components and indicates if
# the space invoking this script (with name: $NAME) is currently selected:
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item

if [ $SELECTED = true ]; then
  sketchybar --set $NAME background.drawing=on \
                         background.color=0x40ffffff \
                         label.color=0xffffffff \
                         icon.color=0xffffffff
else
  sketchybar --set $NAME background.drawing=off \
                         label.color=0xffffffff \
                         icon.color=0xffffffff
fi

plugins/spaces_window.sh

#!/bin/bash

if [ "$SENDER" = "space_windows_change" ]; then
  space="$(echo "$INFO" | jq -r '.space')"
  apps="$(echo "$INFO" | jq -r '.apps | keys[]')"

  icon_strip=" "
  if [ "${apps}" != "" ]; then
    while read -r app
    do
      icon_strip+=" $($CONFIG_DIR/plugins/icon_map_fn.sh "$app")"
    done <<< "${apps}"
  else
    icon_strip=" —"
  fi

  sketchybar --set space.$space label="$icon_strip"
fi
FelixKratz commented 1 week ago

It may have something to do with macOS 15, will have to give it a closer look once it is released in fall. It does look as though some api call is blocking for too long. Will be hard to figure out without doing the proper debugging.

realhackcraft commented 1 week ago

👍🏼

realhackcraft commented 1 week ago

The problem is now fix (??) when I restarted to upgrade to 15 beta 2. Probably the restart fixed, it, but could also be the update.

realhackcraft commented 1 week ago

This could be only affecting me

realhackcraft commented 1 week ago

https://github.com/FelixKratz/SketchyBar/assets/65378120/b03c1de2-cc90-4fb0-864d-3be911a76c20

FelixKratz commented 1 week ago

I think it must have been the update. Good to hear that its fixed.