diff --git a/sketchybar/colors.sh b/sketchybar/colors.sh new file mode 100755 index 0000000..bf886f5 --- /dev/null +++ b/sketchybar/colors.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +# Color Palette +BLACK=0xff181926 +WHITE=0xffcad3f5 +RED=0xffed8796 +GREEN=0xffa6da95 +BLUE=0xff8aadf4 +YELLOW=0xffeed49f +ORANGE=0xfff5a97f +MAGENTA=0xffc6a0f6 +GREY=0xff939ab7 +TRANSPARENT=0x00000000 diff --git a/sketchybar/icons.sh b/sketchybar/icons.sh new file mode 100755 index 0000000..fa81162 --- /dev/null +++ b/sketchybar/icons.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +# Uses SF Symbols. + +APPLE_ICN=􀣺 +SUN_ICN=􀆮 +MOON_ICN=􀆺 +WIFI_ICN=􀙇 +NETWORK_ICN=􀤆 +SPEED_ICN=􀍾 +BATTERY_100=􀛨 +BATTERY_75=􀺸 +BATTERY_50=􀺶 +BATTERY_25=􀛩 +BATTERY_0=􀛪 +BATTERY_CHARGING=􀢋 diff --git a/sketchybar/items/apple.sh b/sketchybar/items/apple.sh new file mode 100755 index 0000000..b0bb5d9 --- /dev/null +++ b/sketchybar/items/apple.sh @@ -0,0 +1,7 @@ +#### Apple Logo #### +sketchybar -m \ + --add item apple.logo left \ + --set apple.logo icon=$APPLE_ICN \ + icon.font="$FONT:Heavy:16.0" \ + label.drawing=off \ + icon.padding_right=17 \ \ No newline at end of file diff --git a/sketchybar/items/battery.sh b/sketchybar/items/battery.sh new file mode 100755 index 0000000..bc3af02 --- /dev/null +++ b/sketchybar/items/battery.sh @@ -0,0 +1,4 @@ +sketchybar --add item battery right \ + --set battery script="$PLUGIN_DIR/battery.sh" \ + update_freq=10 \ + --subscribe battery system_woke diff --git a/sketchybar/items/clock.sh b/sketchybar/items/clock.sh new file mode 100755 index 0000000..920862a --- /dev/null +++ b/sketchybar/items/clock.sh @@ -0,0 +1,3 @@ +sketchybar --add item clock right \ +--set clock update_freq=1 \ +script="$PLUGIN_DIR/clock.sh" \ diff --git a/sketchybar/items/cpu.sh b/sketchybar/items/cpu.sh new file mode 100755 index 0000000..badbd72 --- /dev/null +++ b/sketchybar/items/cpu.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +sketchybar --add item cpu.top right \ + --set cpu.top label.font="$FONT:Medium:7" \ + label=CPU \ + icon.drawing=off \ + width=0 \ + y_offset=6 \ + background.padding_right=10 \ + \ + --add item cpu.percent right \ + --set cpu.percent label.font="$FONT:Bold:12" \ + label=CPU \ + y_offset=-4 \ + width=40 \ + icon.drawing=off \ + update_freq=2 \ + background.padding_right=10 \ + \ + --add graph cpu.sys right 100 \ + --set cpu.sys width=0 \ + graph.color=$RED \ + graph.fill_color=$RED \ + label.drawing=off \ + icon.drawing=off \ + background.padding_right=10 \ + \ + --add graph cpu.user right 100 \ + --set cpu.user graph.color=$BLUE \ + update_freq=2 \ + label.drawing=off \ + icon.drawing=off \ + background.padding_right=10 \ + script="$PLUGIN_DIR/cpu.sh" diff --git a/sketchybar/items/darkside.sh b/sketchybar/items/darkside.sh new file mode 100755 index 0000000..3567dc4 --- /dev/null +++ b/sketchybar/items/darkside.sh @@ -0,0 +1,4 @@ +sketchybar --add item appearance right \ + --set appearance script="$PLUGIN_DIR/darkmode.sh" \ + click_script="$PLUGIN_DIR/darkmode_click.sh" \ + update_freq=1 \ No newline at end of file diff --git a/sketchybar/items/spaces.sh b/sketchybar/items/spaces.sh new file mode 100755 index 0000000..0f716f6 --- /dev/null +++ b/sketchybar/items/spaces.sh @@ -0,0 +1,21 @@ +SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") + +for i in "${!SPACE_ICONS[@]}" +do + sid=$(($i+1)) + sketchybar --add space space.$sid left \ + --set space.$sid associated_space=$sid \ + icon=${SPACE_ICONS[i]} \ + icon.padding_left=8 \ + icon.padding_right=8 \ + background.padding_left=5 \ + background.padding_right=5 \ + background.color=0x44ffffff \ + background.corner_radius=5 \ + background.height=22 \ + background.drawing=off \ + label.drawing=off \ + script="$PLUGIN_DIR/space.sh" \ + click_script="yabai -m space --focus $sid" \ + icon.font="$FONT:Medium:15.0" +done diff --git a/sketchybar/items/wifi.sh b/sketchybar/items/wifi.sh new file mode 100755 index 0000000..7f5cf3a --- /dev/null +++ b/sketchybar/items/wifi.sh @@ -0,0 +1,19 @@ +source "$PLUGIN_DIR/wifi.sh" + +sketchybar --add item wifi.control right \ + \ + --set wifi.control icon=$WIFI_ICN \ + label="${SSID}" \ + click_script="$POPUP_CLICK_SCRIPT" \ + popup.background.color=0x70000000 \ + popup.blur_radius=50 \ + popup.background.corner_radius=5 \ + \ + --add item wifi.ssid popup.wifi.control \ + --set wifi.ssid icon=$NETWORK_ICN \ + label="${SSID}" \ + \ + --add item wifi.speed popup.wifi.control \ + --set wifi.speed icon=$SPEED_ICN \ + script="$PLUGIN_DIR/wifi_click.sh" \ + update_freq=10 \ diff --git a/sketchybar/items/window_title.sh b/sketchybar/items/window_title.sh new file mode 100755 index 0000000..0164066 --- /dev/null +++ b/sketchybar/items/window_title.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +sketchybar --add item space_separator left \ +--add item window_title left \ +--set window_title script="$PLUGIN_DIR/window_title.sh" \ +icon.drawing=off \ +label.font="$FONT:Semibold:15.0" \ +--subscribe window_title front_app_switched \ No newline at end of file diff --git a/sketchybar/items/yabai.sh b/sketchybar/items/yabai.sh new file mode 100755 index 0000000..1647f8c --- /dev/null +++ b/sketchybar/items/yabai.sh @@ -0,0 +1,5 @@ +sketchybar -m --add item yabai_mode left \ + --set yabai_mode update_freq=3 \ + --set yabai_mode script="$PLUGIN_DIR/yabai_mode.sh" \ + --set yabai_mode click_script="$PLUGIN_DIR/yabai_mode_click.sh" \ + --subscribe yabai_mode space_change diff --git a/sketchybar/plugins/battery.sh b/sketchybar/plugins/battery.sh new file mode 100755 index 0000000..61a78d9 --- /dev/null +++ b/sketchybar/plugins/battery.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +source $HOME/.config/sketchybar/icons.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=$BATTERY_100 + ;; + [6-8][0-9]) ICON=$BATTERY_75 + ;; + [3-5][0-9]) ICON=$BATTERY_50 + ;; + [1-2][0-9]) ICON=$BATTERY_25 + ;; + *) ICON="$BATTERY_10" +esac + +if [[ $CHARGING != "" ]]; then + ICON=$BATTERY_CHARGING +fi + +sketchybar --set $NAME icon="$ICON" label="${PERCENTAGE}%" diff --git a/sketchybar/plugins/clock.sh b/sketchybar/plugins/clock.sh new file mode 100755 index 0000000..4a74222 --- /dev/null +++ b/sketchybar/plugins/clock.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +sketchybar --set $NAME label="$(date '+%h %d - %H:%M:%S')" diff --git a/sketchybar/plugins/cpu.sh b/sketchybar/plugins/cpu.sh new file mode 100755 index 0000000..f8b88dc --- /dev/null +++ b/sketchybar/plugins/cpu.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +source "$HOME/.config/sketchybar/colors.sh" + +CORE_COUNT=$(sysctl -n machdep.cpu.thread_count) +CPU_INFO=$(ps -eo pcpu,user) +CPU_SYS=$(echo "$CPU_INFO" | grep -v $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}") +CPU_USER=$(echo "$CPU_INFO" | grep $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}") + +TOPPROC=$(ps axo "%cpu,ucomm" | sort -nr | tail +1 | head -n1 | awk '{printf "%.0f%% %s\n", $1, $2}' | sed -e 's/com.apple.//g') +CPUP=$(echo $TOPPROC | sed -nr 's/([^\%]+).*/\1/p') + +CPU_PERCENT="$(echo "$CPU_SYS $CPU_USER" | awk '{printf "%.0f\n", ($1 + $2)*100}')" + +COLOR=$WHITE +case "$CPU_PERCENT" in + [1-2][0-9]) COLOR=$YELLOW + ;; + [3-6][0-9]) COLOR=$ORANGE + ;; + [7-9][0-9]|100) COLOR=$RED + ;; +esac + +sketchybar --set cpu.percent label=$CPU_PERCENT% \ + label.color=$COLOR \ + --set cpu.top label="$TOPPROC" \ + --push cpu.sys $CPU_SYS \ + --push cpu.user $CPU_USER diff --git a/sketchybar/plugins/darkmode.sh b/sketchybar/plugins/darkmode.sh new file mode 100755 index 0000000..e29bf53 --- /dev/null +++ b/sketchybar/plugins/darkmode.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +source $HOME/.config/sketchybar/icons.sh + +if [[ $(defaults read -g AppleInterfaceStyle 2>/dev/null) == "Dark" ]] +then + sketchybar -m --set appearance icon="$SUN_ICN" + +else + sketchybar -m --set appearance icon="$MOON_ICN" +fi + diff --git a/sketchybar/plugins/darkmode_click.sh b/sketchybar/plugins/darkmode_click.sh new file mode 100755 index 0000000..a87d27f --- /dev/null +++ b/sketchybar/plugins/darkmode_click.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode' + +./darkmode.sh diff --git a/sketchybar/plugins/space.sh b/sketchybar/plugins/space.sh new file mode 100755 index 0000000..fa9f127 --- /dev/null +++ b/sketchybar/plugins/space.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +sketchybar --set $NAME background.drawing=$SELECTED \ No newline at end of file diff --git a/sketchybar/plugins/wifi.sh b/sketchybar/plugins/wifi.sh new file mode 100755 index 0000000..1815f4d --- /dev/null +++ b/sketchybar/plugins/wifi.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +CURRENT_WIFI="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I)" +SSID="$(echo "$CURRENT_WIFI" | grep -o "SSID: .*" | sed 's/^SSID: //')" +CURR_TX="$(echo "$CURRENT_WIFI" | grep -o "lastTxRate: .*" | sed 's/^lastTxRate: //')" + +POPUP_OFF="sketchybar --set wifi.control popup.drawing=off" +POPUP_CLICK_SCRIPT="sketchybar --set \$NAME popup.drawing=toggle" + diff --git a/sketchybar/plugins/wifi_click.sh b/sketchybar/plugins/wifi_click.sh new file mode 100755 index 0000000..0f836a5 --- /dev/null +++ b/sketchybar/plugins/wifi_click.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +export CURRENT_WIFI="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I)" +export SSID="$(echo "$CURRENT_WIFI" | grep -o "SSID: .*" | sed 's/^SSID: //')" +export CURR_TX="$(echo "$CURRENT_WIFI" | grep -o "lastTxRate: .*" | sed 's/^lastTxRate: //')" + +sketchybar --set $NAME label="${CURR_TX}Mbps" diff --git a/sketchybar/plugins/window_title.sh b/sketchybar/plugins/window_title.sh new file mode 100755 index 0000000..90a2e35 --- /dev/null +++ b/sketchybar/plugins/window_title.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +sketchybar --set $NAME label="$INFO" diff --git a/sketchybar/plugins/yabai_mode.sh b/sketchybar/plugins/yabai_mode.sh new file mode 100755 index 0000000..718291c --- /dev/null +++ b/sketchybar/plugins/yabai_mode.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +space_number=$(yabai -m query --spaces --space | jq -r .index) +yabai_mode=$(yabai -m query --spaces --space | jq -r .type) + +case "$yabai_mode" in + bsp) + sketchybar -m --set yabai_mode label="􀏝" + ;; + stack) + sketchybar -m --set yabai_mode label="􀏭" + ;; + float) + sketchybar -m --set yabai_mode label="􀢌" + ;; +esac diff --git a/sketchybar/plugins/yabai_mode_click.sh b/sketchybar/plugins/yabai_mode_click.sh new file mode 100755 index 0000000..b7a693d --- /dev/null +++ b/sketchybar/plugins/yabai_mode_click.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +space_number=$(yabai -m query --spaces --space | jq -r .index) +yabai_mode=$(yabai -m query --spaces --space | jq -r .type) + +case "$yabai_mode" in + bsp) + yabai -m space --layout stack && sketchybar -m --set yabai_mode label="􀢌" + ;; + stack) + yabai -m space --layout float && sketchybar -m --set yabai_mode label="􀏭" + ;; + float) + yabai -m space --layout bsp && sketchybar -m --set yabai_mode label="􀏝" + ;; +esac diff --git a/sketchybar/sketchybarrc b/sketchybar/sketchybarrc new file mode 100755 index 0000000..ff0cf0a --- /dev/null +++ b/sketchybar/sketchybarrc @@ -0,0 +1,52 @@ +#!/usr/bin/env sh + +PLUGIN_DIR="$HOME/.config/sketchybar/plugins" +ITEM_DIR="$HOME/.config/sketchybar/items" + +# run helper program +# TODO: UNCOMMENT WHEN DYNAMIC ISLAND HAS BEEN FIXED +# ISLANDHELPER=git.crissnb.islandhelper +# killall islandhelper +# $HOME/.config/sketchybar/plugins/Dynamic-Island-Sketchybar/helper/islandhelper $ISLANDHELPER & + + +source $HOME/.config/sketchybar/colors.sh +source $HOME/.config/sketchybar/icons.sh +# TODO: UNCOMMENT WHEN DYNAMIC ISLAND HAS BEEN FIXED +# source "$PLUGIN_DIR/Dynamic-Island-Sketchybar/config.sh" + +export FONT="IBM Plex Mono" +export NERD_FONT="JetBrainsMono Nerd Font" + +sketchybar --bar height=30 \ + blur_radius=100 \ + position=top \ + padding_left=10 \ + padding_right=10 \ + color=0x15000000 \ + shadow=on + +sketchybar --default updates=when_shown \ + drawing=on \ + icon.font="$NERD_FONT:Regular:14.0" \ + icon.color=0xffffffff \ + label.font="$FONT:Medium:14.0" \ + label.color=0xffffffff \ + label.padding_left=4 \ + label.padding_right=4 \ + icon.padding_left=4 \ + icon.padding_right=4 + +source $ITEM_DIR/apple.sh +source $ITEM_DIR/spaces.sh +source $ITEM_DIR/window_title.sh +source $ITEM_DIR/clock.sh +source $ITEM_DIR/battery.sh +source $ITEM_DIR/cpu.sh +source $ITEM_DIR/wifi.sh +# TODO: UNCOMMENT WHEN DYNAMIC ISLAND HAS BEEN FIXED +# source "$PLUGIN_DIR/Dynamic-Island-Sketchybar/item.sh" + +sketchybar --update + +echo "sketchybar configuration loaded.."