Skip to content

Bash Variable Not Updating #797

@kushvinth

Description

@kushvinth

A variable computed inside a SketchyBar item script updates correctly when logged, but the label does not reliably update in the bar when switching between a numeric value and a glyph.

Issue

The Variable Should Return 7 as in the label but all we get is 1

Code

#!/bin/bash
source "$HOME/.config/sketchybar/colors.sh"
BREW_COUNT=$(brew outdated | wc -l | tr -d ' ') #7
# echo "COUNT: $BREW_COUNT" > /tmp/sketchybar_debug.log

if [ "$BREW_COUNT" -ge 30 ]; then
    COLOR=$RED
elif [ "$BREW_COUNT" -ge 10 ]; then
    COLOR=$ORANGE
elif [ "$BREW_COUNT" -ge 1 ]; then
    COLOR=$YELLOW
else
    COLOR=$GREEN
    BREW_COUNT=􀆅
fi

sketchybar --set "$NAME" icon.color="$COLOR" label="$BREW_COUNT"

SS:

Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions