From 07d294425a98ee5d1e22d03e2b24ae2c76e487c0 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 23 Aug 2025 12:42:37 +0900 Subject: updates --- mac/.config/sketchybar.mon/plugins/battery.sh | 85 +++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 mac/.config/sketchybar.mon/plugins/battery.sh (limited to 'mac/.config/sketchybar.mon/plugins/battery.sh') diff --git a/mac/.config/sketchybar.mon/plugins/battery.sh b/mac/.config/sketchybar.mon/plugins/battery.sh new file mode 100755 index 0000000..60a8dc4 --- /dev/null +++ b/mac/.config/sketchybar.mon/plugins/battery.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +source "$CONFIG_DIR/colors.sh" + +render_item() { + + PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) + CHARGING=$(pmset -g batt | grep 'AC Power') + CHARGING_STATUS="Not charging" + + if [ $PERCENTAGE = "" ]; then + exit 0 + fi + + COLOR=$LABEL_COLOR + ICON="󰁹" + + case ${PERCENTAGE} in + 9[0-9]) + ICON="󰂂" + ;; + 8[0-9]) + ICON="󰂁" + ;; + 7[0-9]) + ICON="󰂀" + ;; + 6[0-9]) + ICON="󰁿" + ;; + 5[0-9]) + ICON="󰁾" + ;; + 4[0-9]) + ICON="󰁽" + ;; + 3[0-9]) + ICON="󰁼" + ;; + 2[0-9]) + ICON="󰁻" + ;; + 1[0-9]) + ICON="󰁺" + ;; + *) + ICON="󰂎" + COLOR=$RED + ;; + esac + + if [[ $CHARGING != "" ]]; then + ICON="󰂄" + CHARGING_STATUS="Charging" + COLOR=$LABEL_COLOR + fi + + sketchybar --set battery icon=$ICON + +} + +render_popup() { + sketchybar --set battery.details label="$PERCENTAGE% (${CHARGING_STATUS})" +} + +update() { + render_item + render_popup +} + +popup() { + sketchybar --set "$NAME" popup.drawing="$1" +} + +case "$SENDER" in +"routine" | "forced" | "power_source_change") + update + ;; +"mouse.entered") + popup on + ;; +"mouse.exited" | "mouse.exited.global") + popup off + ;; +esac -- cgit v1.2.3