diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-08-24 14:02:11 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-08-24 14:02:11 +0900 |
| commit | 130e628ab35de45226fb5b88f103c1938dacfc63 (patch) | |
| tree | 22659cf6da6c8d03e9580c2a7b0aad04058a355f /mac/.config/sketchybar/plugins/cpu.sh | |
| parent | a311b30a10e90e3f878937bcf722daa8e75b68c1 (diff) | |
modified .gnupg/gpg-agent.conf, created sketchybar/
Diffstat (limited to 'mac/.config/sketchybar/plugins/cpu.sh')
| -rwxr-xr-x | mac/.config/sketchybar/plugins/cpu.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/mac/.config/sketchybar/plugins/cpu.sh b/mac/.config/sketchybar/plugins/cpu.sh new file mode 100755 index 0000000..dd55b0a --- /dev/null +++ b/mac/.config/sketchybar/plugins/cpu.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Source colors for consistent theming +source "$CONFIG_DIR/colors.sh" + +# Get CPU usage percentage +CPU_USAGE=$(top -l 1 -n 0 | grep "CPU usage" | awk '{print $3}' | sed 's/%//') + +# Handle empty CPU usage +if [[ -z "$CPU_USAGE" ]]; then + CPU_USAGE=0 +fi + +# Remove decimal point for comparison +CPU_INT=${CPU_USAGE%.*} + +# Set icon and color based on CPU usage +if [[ $CPU_INT -le 25 ]]; then + ICON="" # Low CPU + COLOR=$ACCENT_SECONDARY # Green +elif [[ $CPU_INT -le 50 ]]; then + ICON="" # Medium CPU + COLOR=$ACCENT_PRIMARY # Blue +elif [[ $CPU_INT -le 75 ]]; then + ICON="" # High CPU + COLOR=$ACCENT_TERTIARY # Orange +else + ICON="" # Very High CPU + COLOR=$RED # Red +fi + +# Update the CPU item +sketchybar --set "$NAME" icon="$ICON" \ + icon.color="$COLOR" \ + label="$CPU_USAGE%" \ + label.color=$WHITE \ + label.font="SF Pro:Medium:12.0" |
