summaryrefslogtreecommitdiff
path: root/mac/.config/sketchybar.mon/sketchybar/plugins/cpu.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mac/.config/sketchybar.mon/sketchybar/plugins/cpu.sh')
-rwxr-xr-xmac/.config/sketchybar.mon/sketchybar/plugins/cpu.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.mon/sketchybar/plugins/cpu.sh b/mac/.config/sketchybar.mon/sketchybar/plugins/cpu.sh
new file mode 100755
index 0000000..dd55b0a
--- /dev/null
+++ b/mac/.config/sketchybar.mon/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"