mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
chezmoi: macOS
This commit is contained in:
parent
fff9275372
commit
c1a63e4658
39 changed files with 10 additions and 284 deletions
10
home/dot_config/sketchybar/plugins/executable_calendar.sh
Normal file
10
home/dot_config/sketchybar/plugins/executable_calendar.sh
Normal 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"
|
||||
4
home/dot_config/sketchybar/plugins/executable_clock.sh
Normal file
4
home/dot_config/sketchybar/plugins/executable_clock.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
LABEL=$(date '+%H:%M:%S')
|
||||
sketchybar --set "$NAME" label="$LABEL"
|
||||
3
home/dot_config/sketchybar/plugins/executable_cpu.sh
Normal file
3
home/dot_config/sketchybar/plugins/executable_cpu.sh
Normal 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}')"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
case "$SENDER" in
|
||||
"front_app_switched")
|
||||
sketchybar --set "$NAME" label="$INFO"
|
||||
;;
|
||||
esac
|
||||
16
home/dot_config/sketchybar/plugins/executable_memory.sh
Normal file
16
home/dot_config/sketchybar/plugins/executable_memory.sh
Normal 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%"
|
||||
30
home/dot_config/sketchybar/plugins/executable_power.sh
Normal file
30
home/dot_config/sketchybar/plugins/executable_power.sh
Normal 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
home/dot_config/sketchybar/plugins/executable_sound.sh
Normal file
20
home/dot_config/sketchybar/plugins/executable_sound.sh
Normal 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%"
|
||||
17
home/dot_config/sketchybar/plugins/executable_space.sh
Normal file
17
home/dot_config/sketchybar/plugins/executable_space.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source "$HOME/.config/sketchybar/variables.sh" # Loads all defined colors
|
||||
|
||||
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
home/dot_config/sketchybar/plugins/executable_spotify.sh
Normal file
11
home/dot_config/sketchybar/plugins/executable_spotify.sh
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue