mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 16:53:00 +00:00
feat(sketchybar): rebuild sketchybar config
This commit is contained in:
parent
d93d153827
commit
0af876301c
27 changed files with 615 additions and 1059 deletions
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# make sure it's executable with:
|
||||
# chmod +x ~/.config/sketchybar/plugins/aerospace.sh
|
||||
|
||||
if [ "$1" = "$FOCUSED_WORKSPACE" ]; then
|
||||
sketchybar --set $NAME background.drawing=on
|
||||
else
|
||||
sketchybar --set $NAME background.drawing=off
|
||||
fi
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
PERCENTAGE="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)"
|
||||
CHARGING="$(pmset -g batt | grep 'AC Power')"
|
||||
|
||||
if [ "$PERCENTAGE" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "${PERCENTAGE}" in
|
||||
9[0-9] | 100)
|
||||
ICON=""
|
||||
;;
|
||||
[6-8][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[3-5][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[1-2][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
*) ICON="" ;;
|
||||
esac
|
||||
|
||||
if [[ "$CHARGING" != "" ]]; then
|
||||
ICON=""
|
||||
fi
|
||||
|
||||
# The item invoking this script (name $NAME) will get its icon and label
|
||||
# updated with the current battery status
|
||||
sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%"
|
||||
10
platforms/mac/sketchybar/plugins/calendar.sh
Executable file
10
platforms/mac/sketchybar/plugins/calendar.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
# vim:ft=bash
|
||||
|
||||
export LC_TIME=zh_CN.UTF-8
|
||||
|
||||
# 获取当前日期,并格式化为“3月3日 星期一”格式
|
||||
DATE=$(date "+%-m月%-d日 %A")
|
||||
|
||||
# 发送到 SketchyBar
|
||||
sketchybar --set $NAME label="$DATE"
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The $NAME variable is passed from sketchybar and holds the name of
|
||||
# the item invoking this script:
|
||||
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
|
||||
|
||||
sketchybar --set "$NAME" label="$(date '+%d日周%u %H:%M')"
|
||||
LABEL=$(date '+%H:%M:%S')
|
||||
sketchybar --set "$NAME" label="$LABEL"
|
||||
|
|
|
|||
3
platforms/mac/sketchybar/plugins/cpu.sh
Executable file
3
platforms/mac/sketchybar/plugins/cpu.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sketchybar --set "$NAME" icon="" label="$(ps -A -o %cpu | awk '{s+=$1} END {s /= 8} END {printf "%.1f%%\n", s}')"
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Some events send additional information specific to the event in the $INFO
|
||||
# variable. E.g. the front_app_switched event sends the name of the newly
|
||||
# focused application in the $INFO variable:
|
||||
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
|
||||
|
||||
if [ "$SENDER" = "front_app_switched" ]; then
|
||||
sketchybar --set "$NAME" label="$INFO"
|
||||
fi
|
||||
case "$SENDER" in
|
||||
"front_app_switched")
|
||||
sketchybar --set "$NAME" label="$INFO"
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
16
platforms/mac/sketchybar/plugins/memory.sh
Executable file
16
platforms/mac/sketchybar/plugins/memory.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
TOTAL_MEM=$(sysctl -n hw.memsize)
|
||||
TOTAL_MEM=$((TOTAL_MEM / 1024 / 1024)) # 转换为 MB
|
||||
|
||||
USED_MEM_RAW=$(top -l 1 | awk '/PhysMem/ {print $2}')
|
||||
|
||||
if [[ $USED_MEM_RAW == *G ]]; then
|
||||
USED_MEM=$(echo "$USED_MEM_RAW" | sed 's/G//' | awk '{print $1 * 1024}') # 转 MB
|
||||
else
|
||||
USED_MEM=$(echo "$USED_MEM_RAW" | sed 's/M//') # 直接取 MB
|
||||
fi
|
||||
|
||||
MEM_PERCENT=$(echo "scale=1; $USED_MEM / $TOTAL_MEM * 100" | bc)
|
||||
|
||||
sketchybar --set $NAME label=" $MEM_PERCENT%"
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
music_info=$(curlie GET http://localhost:10767/api/v1/playback/now-playing | jq -r '"\(.info.name) - \(.info.artistName)"')
|
||||
|
||||
ICON=""
|
||||
|
||||
sketchybar --set $NAME label="$music_info" icon="$ICON"
|
||||
30
platforms/mac/sketchybar/plugins/power.sh
Executable file
30
platforms/mac/sketchybar/plugins/power.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
|
||||
CHARGING=$(pmset -g batt | grep 'AC Power')
|
||||
|
||||
if [ "$PERCENTAGE" = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case ${PERCENTAGE} in
|
||||
9[0-9] | 100)
|
||||
ICON=""
|
||||
;;
|
||||
[6-8][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[3-5][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[1-2][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
*) ICON="" ;;
|
||||
esac
|
||||
|
||||
if [ "$CHARGING" != "" ]; then
|
||||
ICON=""
|
||||
fi
|
||||
|
||||
sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}% "
|
||||
20
platforms/mac/sketchybar/plugins/sound.sh
Executable file
20
platforms/mac/sketchybar/plugins/sound.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
VOLUME=$(osascript -e "output volume of (get volume settings)")
|
||||
MUTED=$(osascript -e "output muted of (get volume settings)")
|
||||
|
||||
if [ "$MUTED" != "false" ]; then
|
||||
ICON=""
|
||||
VOLUME=0
|
||||
else
|
||||
case ${VOLUME} in
|
||||
100) ICON="" ;;
|
||||
[5-9]*) ICON="" ;;
|
||||
[0-9]*) ICON="" ;;
|
||||
*) ICON="" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
sketchybar -m \
|
||||
--set "$NAME" icon=$ICON \
|
||||
--set "$NAME" label="$VOLUME%"
|
||||
|
|
@ -1,7 +1,17 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The $SELECTED variable is available for space components and indicates if
|
||||
# the space invoking this script (with name: $NAME) is currently selected:
|
||||
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
|
||||
source "$HOME/.config/sketchybar/variables.sh" # Loads all defined colors
|
||||
|
||||
sketchybar --set "$NAME" background.drawing="$SELECTED"
|
||||
SPACE_CLICK_SCRIPT="yabai -m space --focus $SID 2>/dev/null"
|
||||
|
||||
if [ "$SELECTED" = "true" ]; then
|
||||
sketchybar --animate tanh 5 --set "$NAME" \
|
||||
icon.color="$RED" \
|
||||
icon="${SPACE_ICONS[$SID - 1]}" \
|
||||
click_script="$SPACE_CLICK_SCRIPT"
|
||||
else
|
||||
sketchybar --animate tanh 5 --set "$NAME" \
|
||||
icon.color="$COMMENT" \
|
||||
icon="${SPACE_ICONS[$SID - 1]}" \
|
||||
click_script="$SPACE_CLICK_SCRIPT"
|
||||
fi
|
||||
|
|
|
|||
11
platforms/mac/sketchybar/plugins/spotify.sh
Executable file
11
platforms/mac/sketchybar/plugins/spotify.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
STATE="$(echo "$INFO" | jq -r '.state')"
|
||||
APP="$(echo "$INFO" | jq -r '.app')"
|
||||
|
||||
if [ "$STATE" = "playing" ] && [ "$APP" == "Spotify" ]; then
|
||||
MEDIA="$(echo "$INFO" | jq -r '.title + " - " + .artist')"
|
||||
sketchybar --set "$NAME" label="$MEDIA" drawing=on
|
||||
else
|
||||
sketchybar --set "$NAME" drawing=off
|
||||
fi
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# The volume_change event supplies a $INFO variable in which the current volume
|
||||
# percentage is passed to the script.
|
||||
|
||||
if [ "$SENDER" = "volume_change" ]; then
|
||||
VOLUME="$INFO"
|
||||
|
||||
case "$VOLUME" in
|
||||
[6-9][0-9] | 100)
|
||||
ICON=""
|
||||
;;
|
||||
[3-5][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
[1-9] | [1-2][0-9])
|
||||
ICON=""
|
||||
;;
|
||||
*) ICON="" ;;
|
||||
esac
|
||||
|
||||
sketchybar --set "$NAME" icon="$ICON" label="$VOLUME%"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue