SketchyBar
SketchyBar copied to clipboard
front_app_switched event firing multiple times
Recently noticed some strange flickering issues with one of my items, traced it back to the front_app_switched
event firing multiple times when it shouldn't. Unsure if this is a personal config issue or an issue with SketchyBar, but wanted to open an issue anyways. If you need any additional information, please let me know. Thanks again!
System Information
- SketchyBar v2.21.0
- yabai v7.1.0
Config
sketchybarrc
#!/usr/bin/env bash
# import colors
source "$CONFIG_DIR/colors.sh"
# setting global variables
ITEMS_DIR="$CONFIG_DIR/items"
FONT_FAMILY="JetBrains Mono"
FONT_WEIGHT="Regular"
FONT_SIZE="12.0"
export FONT="${FONT_FAMILY}:${FONT_WEIGHT}:${FONT_SIZE}"
BAR_PADDING=3
ITEM_PADDING=5
INTERNAL_PADDING=8
bar=(
color="$BAR_COLOR"
position=bottom
height=34
margin=0
padding_left="$BAR_PADDING"
padding_right="$BAR_PADDING"
topmost=window
sticky=off
shadow=off
)
sketchybar --bar "${bar[@]}"
# default options
defaults=(
# geometry
padding_left="$ITEM_PADDING"
padding_right="$ITEM_PADDING"
# background
background.color="$ITEM_COLOR"
background.border_color="0x00FFFFFF"
background.border_width=2
background.height=28
background.corner_radius=5
# icon
icon.padding_left="$INTERNAL_PADDING"
icon.padding_right="$INTERNAL_PADDING"
icon.color="$ICON_COLOR"
icon.highlight_color="$ICON_HIGHLIGHT"
icon.font="$FONT"
# label
label.padding_left="$INTERNAL_PADDING"
label.padding_right="$INTERNAL_PADDING"
label.color="$LABEL_COLOR"
label.highlight_color="$LABEL_HIGHLIGHT"
label.font="$FONT"
)
sketchybar --default "${defaults[@]}"
# add left side items
# these have been commented out for debugging
# source "$ITEMS_DIR/spaces.sh"
# source "$ITEMS_DIR/layout.sh"
source "$ITEMS_DIR/apps.sh"
# final steps
sketchybar --hotload on
sketchybar --update
apps.sh
#!/usr/bin/env bash
source "$CONFIG_DIR/colors.sh"
PLUGIN_DIR="$CONFIG_DIR/plugins"
# item properties
app=(
background.color="$ITEM_HIGHLIGHT"
padding_left=0
label.max_chars=25
icon.padding_right=0
label.color="$LABEL_HIGHLIGHT"
icon.color="$LABEL_HIGHLIGHT"
script="$PLUGIN_DIR/apps_plugin.sh"
)
sketchybar --add item app left \
--set app "${app[@]}" \
--add event app_update \
--subscribe app front_app_switched \
mouse.entered \
mouse.exited \
app_update
apps_plugin.sh
#!/usr/bin/env bash
source "$CONFIG_DIR/plugins/icon_map.sh"
source "$CONFIG_DIR/colors.sh"
mouse() {
if [[ "$SENDER" == "mouse.entered" ]]; then
sketchybar --set app scroll_texts=on
else
sketchybar --set app scroll_texts=off
fi
}
update() {
# this is for debugging
echo ran update from $SENDER at $(date "+%H:%M:%S")
APP=$(yabai -m query --windows --window)
if [ ! -z "$APP" ]; then
APP_NAME=$(jq '.app' <<< "$APP" | tr -d '"')
APP_TITLE=$(jq '.title' <<< "$APP" | tr -d '"' | xargs echo)
__icon_map "${APP_NAME}"
ICON="${icon_result}"
app=(
drawing=on
icon.font="sketchybar-app-font:Regular:12"
icon="$ICON"
)
if [ "$APP_NAME" == "$APP_TITLE" ]; then
app+=(label="$APP_NAME")
else
app+=(label="$APP_NAME / $APP_TITLE")
fi
if $(jq '."is-floating"' <<< "$APP"); then
app+=(background.border_color="$SPACE_NATIVE_FULLSCREEN")
else
app+=(background.border_color="0x00ffffff")
fi
else
app=(
drawing=off
)
fi
sketchybar --set app "${app[@]}"
}
case "$SENDER" in
"mouse.entered" | "mouse.exited") mouse ;;
*) update ;;
esac
Screen Recording
https://github.com/FelixKratz/SketchyBar/assets/22670587/5cb643c2-cfbb-4ca6-a4ca-b4666e51c384
Explanation:
- Run sketchybar from the command line
- Open new window (issue first appeared when using Arc/Little Arc so unsure if it's an issue with how Little Arc windows are handled)
- Switch spaces around (using skhd/yabai)
- App item switches between Arc/Alacritty quickly, even when not switching windows