From 022b94b85f2e8f25d8ced3a5b50994ff10bf63ea Mon Sep 17 00:00:00 2001 From: Abdulwahaab Ahmed Date: Sun, 9 Oct 2022 14:11:02 -0400 Subject: [PATCH 1/2] Add sketchybar --- sketchybar/colors.sh | 26 ++++++++++ sketchybar/icons.sh | 45 +++++++++++++++++ sketchybar/items/apple.sh | 32 ++++++++++++ sketchybar/items/calendar.sh | 17 +++++++ sketchybar/items/cpu.sh | 34 +++++++++++++ sketchybar/items/front_app.sh | 21 ++++++++ sketchybar/items/github.sh | 25 ++++++++++ sketchybar/items/mail.sh | 10 ++++ sketchybar/items/power.sh | 46 +++++++++++++++++ sketchybar/items/spaces.sh | 30 ++++++++++++ sketchybar/plugins/battery.sh | 31 ++++++++++++ sketchybar/plugins/cpu.sh | 29 +++++++++++ sketchybar/plugins/front_app.sh | 7 +++ sketchybar/plugins/github.sh | 87 +++++++++++++++++++++++++++++++++ sketchybar/plugins/mail.sh | 17 +++++++ sketchybar/plugins/time.sh | 4 ++ sketchybar/plugins/yabai.sh | 65 ++++++++++++++++++++++++ sketchybar/sketchybarrc | 67 +++++++++++++++++++++++++ 18 files changed, 593 insertions(+) create mode 100755 sketchybar/colors.sh create mode 100755 sketchybar/icons.sh create mode 100755 sketchybar/items/apple.sh create mode 100755 sketchybar/items/calendar.sh create mode 100755 sketchybar/items/cpu.sh create mode 100755 sketchybar/items/front_app.sh create mode 100755 sketchybar/items/github.sh create mode 100755 sketchybar/items/mail.sh create mode 100755 sketchybar/items/power.sh create mode 100755 sketchybar/items/spaces.sh create mode 100755 sketchybar/plugins/battery.sh create mode 100755 sketchybar/plugins/cpu.sh create mode 100755 sketchybar/plugins/front_app.sh create mode 100755 sketchybar/plugins/github.sh create mode 100755 sketchybar/plugins/mail.sh create mode 100755 sketchybar/plugins/time.sh create mode 100755 sketchybar/plugins/yabai.sh create mode 100755 sketchybar/sketchybarrc diff --git a/sketchybar/colors.sh b/sketchybar/colors.sh new file mode 100755 index 0000000..68fb215 --- /dev/null +++ b/sketchybar/colors.sh @@ -0,0 +1,26 @@ +#!/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 + +# General bar colors +BAR_COLOR=0xcc24273a #$GREY # Grey bar +ICON_COLOR=$WHITE # Color of all icons +LABEL_COLOR=$WHITE # Color of all labels + +POPUP_BACKGROUND_COLOR=$BLACK +POPUP_BORDER_COLOR=$GREEN + +SHADOW_COLOR=$BLACK + +# Item specific special colors +SPOTIFY_GREEN=0xff1db954 diff --git a/sketchybar/icons.sh b/sketchybar/icons.sh new file mode 100755 index 0000000..07924ca --- /dev/null +++ b/sketchybar/icons.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# General Icons +LOADING=􀖇 +APPLE=􀣺 +PREFERENCES=􀺽 +ACTIVITY=􀒓 +LOCK=􀒳 +MAIL=􀍜 +MAIL_OPEN=􀍜 +BELL=􀋚 +BELL_DOT=􀝗 + +BATTERY_100= +BATTERY_90= +BATTERY_80= +BATTERY_70= +BATTERY_60= +BATTERY_50= +BATTERY_40= +BATTERY_30= +BATTERY_20= +BATTERY_10= + + +# Git Icons +GIT_ISSUE=􀍷 +GIT_DISCUSSION=􀒤 +GIT_PULL_REQUEST=􀙡 +GIT_COMMIT=􀡚 +GIT_INDICATOR=􀂓 + +# Spotify Icons +SPOTIFY_BACK=􀊎 +SPOTIFY_PLAY_PAUSE=􀊈 +SPOTIFY_NEXT=􀊐 +SPOTIFY_SHUFFLE=􀊝 +SPOTIFY_REPEAT=􀊞 + +# Yabai Icons +YABAI_STACK=􀏭 +YABAI_FULLSCREEN_ZOOM=􀏜 +YABAI_PARENT_ZOOM=􀥃 +YABAI_FLOAT=􀢌 +YABAI_GRID=􀧍 diff --git a/sketchybar/items/apple.sh b/sketchybar/items/apple.sh new file mode 100755 index 0000000..3cbf17d --- /dev/null +++ b/sketchybar/items/apple.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +POPUP_OFF="sketchybar --set apple.logo popup.drawing=off" +POPUP_CLICK_SCRIPT="sketchybar --set \$NAME popup.drawing=toggle" + +sketchybar --add item apple.logo left \ + \ + --set apple.logo icon=$APPLE \ + icon.font="$FONT:Black:16.0" \ + icon.color=$GREEN \ + background.padding_left=5 \ + background.padding_right=25 \ + label.drawing=off \ + click_script="$POPUP_CLICK_SCRIPT" \ + \ + --add item apple.prefs popup.apple.logo \ + --set apple.prefs icon=$PREFERENCES \ + label="Preferences" \ + click_script="open -a 'System Preferences'; + $POPUP_OFF" \ + \ + --add item apple.activity popup.apple.logo \ + --set apple.activity icon=$ACTIVITY \ + label="Activity" \ + click_script="open -a 'Activity Monitor'; + $POPUP_OFF"\ + \ + --add item apple.lock popup.apple.logo \ + --set apple.lock icon=$LOCK \ + label="Lock Screen" \ + click_script="pmset displaysleepnow; + $POPUP_OFF" diff --git a/sketchybar/items/calendar.sh b/sketchybar/items/calendar.sh new file mode 100755 index 0000000..5e60d08 --- /dev/null +++ b/sketchybar/items/calendar.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +sketchybar --add item calendar right \ + --set calendar update_freq=15 \ + icon=cal \ + icon.color=$BLACK \ + icon.font="$FONT:Black:12.0" \ + icon.padding_left=15 \ + label.width=70 \ + label.align=right \ + label.color=$BLACK \ + label.padding_right=15 \ + align=center \ + script="$PLUGIN_DIR/time.sh" \ + background.color=0xffb8c0e0 \ + background.height=26 \ + background.corner_radius=11 diff --git a/sketchybar/items/cpu.sh b/sketchybar/items/cpu.sh new file mode 100755 index 0000000..98c85d5 --- /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:Semibold: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:Heavy: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/front_app.sh b/sketchybar/items/front_app.sh new file mode 100755 index 0000000..196a331 --- /dev/null +++ b/sketchybar/items/front_app.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh + +sketchybar --add event window_focus \ + --add item system.yabai left \ + --set system.yabai script="$PLUGIN_DIR/yabai.sh" \ + icon.font="$FONT:Bold:16.0" \ + label.drawing=off \ + icon.width=30 \ + icon=$YABAI_GRID \ + icon.color=$GREEN \ + updates=on \ + --subscribe system.yabai window_focus mouse.clicked \ + \ + --add item front_app left \ + --set front_app script="$PLUGIN_DIR/front_app.sh" \ + icon.drawing=off \ + background.padding_left=0 \ + label.color=$WHITE \ + label.font="$FONT:Black:12.0" \ + --subscribe front_app front_app_switched + diff --git a/sketchybar/items/github.sh b/sketchybar/items/github.sh new file mode 100755 index 0000000..fa2b17b --- /dev/null +++ b/sketchybar/items/github.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +sketchybar --add item github.bell right \ + --set github.bell update_freq=180 \ + icon.font="$FONT:Bold:15.0" \ + icon=$BELL \ + icon.color=$GREEN \ + label=$LOADING \ + label.highlight_color=$BLUE \ + popup.align=right \ + script="$PLUGIN_DIR/github.sh" \ + click_script="$POPUP_CLICK_SCRIPT" \ + --subscribe github.bell mouse.entered \ + mouse.exited \ + mouse.exited.global \ + \ + --add item github.template popup.github.bell \ + --set github.template drawing=off \ + background.corner_radius=12 \ + background.padding_left=7 \ + background.padding_right=7 \ + background.color=$BLACK \ + background.drawing=off \ + icon.background.height=2 \ + icon.background.y_offset=-12 diff --git a/sketchybar/items/mail.sh b/sketchybar/items/mail.sh new file mode 100755 index 0000000..725b337 --- /dev/null +++ b/sketchybar/items/mail.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +sketchybar --add item mail right \ + --set mail update_freq=120 \ + script="$PLUGIN_DIR/mail.sh" \ + background.padding_left=5 \ + icon.font="$FONT:Bold:16.0" \ + icon=$MAIL \ + icon.color=$BLUE \ + label=! diff --git a/sketchybar/items/power.sh b/sketchybar/items/power.sh new file mode 100755 index 0000000..3838dd8 --- /dev/null +++ b/sketchybar/items/power.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env sh + + +# BATT_PERCENT=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) +# CHARGING=$(pmset -g batt | grep 'AC Power') +# +# sketchybar -m --add item battery right +# +# if [[ ${CHARGING} != "" ]]; then +# # sketchybar -m --set battery icon="" +# # label="${BATT_PERCENT}%" +# sketchybar -m --set battery label="PWR: ${BATT_PERCENT}%" \ +# icon.color=0xff989898 \ +# update_freq=1 \ +# icon.font="$FONT:Black:16.0" +# exit 0 +# fi +# +# case ${BATT_PERCENT} in +# 100) ICON=$BATTERY_100 ;; +# 9[0-9]) ICON=$BATTERY_90 ;; +# 8[0-9]) ICON=$BATTERY_80 ;; +# 7[0-9]) ICON=$BATTERY_70 ;; +# 6[0-9]) ICON=$BATTERY_60 ;; +# 5[0-9]) ICON=$BATTERY_50 ;; +# 4[0-9]) ICON=$BATTERY_40 ;; +# 3[0-9]) ICON=$BATTERY_30 ;; +# 2[0-9]) ICON=$BATTERY_30 ;; +# 1[0-9]) ICON=$BATTERY_10 ;; +# *) ICON="" +# esac +# +# echo $ICON +# +# # sketchybar -m --set battery icon=$ICON \ +# # label="${BATT_PERCENT}%" +# sketchybar -m --set battery label="BATT: ${BATT_PERCENT}%" \ +# icon.color=0xff989898 \ +# update_freq=3 \ +# icon.font="$FONT:Black:16.0" + +sketchybar --add item battery right \ + --set battery script="$PLUGIN_DIR/battery.sh" \ + update_freq=10 \ + --subscribe battery system_woke + diff --git a/sketchybar/items/spaces.sh b/sketchybar/items/spaces.sh new file mode 100755 index 0000000..768438d --- /dev/null +++ b/sketchybar/items/spaces.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +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=22 \ + icon.padding_right=22 \ + icon.highlight_color=$RED \ + background.padding_left=-8 \ + background.padding_right=-8 \ + background.height=26 \ + background.corner_radius=9 \ + background.color=0xff3C3E4F \ + background.drawing=on \ + label.drawing=off \ + click_script="$SPACE_CLICK_SCRIPT" +done + +sketchybar --add item separator left \ + --set separator icon= \ + icon.font="Hack Nerd Font:Regular:16.0" \ + background.padding_left=26 \ + background.padding_right=15 \ + label.drawing=off \ + icon.color=$WHITE diff --git a/sketchybar/plugins/battery.sh b/sketchybar/plugins/battery.sh new file mode 100755 index 0000000..d068d95 --- /dev/null +++ b/sketchybar/plugins/battery.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env 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} != "" && ${PERCENTAGE} == 100 ]]; then + ICON="􀢋" +fi + +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 battery icon="$ICON" label="${PERCENTAGE}%" icon.font="$FONT:Black:16.0" 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/front_app.sh b/sketchybar/plugins/front_app.sh new file mode 100755 index 0000000..5427a28 --- /dev/null +++ b/sketchybar/plugins/front_app.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +case "$SENDER" in + "front_app_switched") sketchybar --set $NAME label="$INFO" + ;; +esac + diff --git a/sketchybar/plugins/github.sh b/sketchybar/plugins/github.sh new file mode 100755 index 0000000..013c6c0 --- /dev/null +++ b/sketchybar/plugins/github.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env sh + +update() { + source "$HOME/.config/sketchybar/colors.sh" + source "$HOME/.config/sketchybar/icons.sh" + + NOTIFICATIONS="$(gh api notifications)" + COUNT="$(echo "$NOTIFICATIONS" | jq 'length')" + args=() + if [ "$NOTIFICATIONS" = "[]" ]; then + args+=(--set $NAME icon=$BELL label="0") + else + args+=(--set $NAME icon=$BELL_DOT label="$COUNT") + fi + + PREV_COUNT=$(sketchybar --query github.bell | jq -r .label.value) + # For sound to play around with: + # afplay /System/Library/Sounds/Morse.aiff + + args+=(--remove '/github.notification\.*/') + + COUNTER=0 + COLOR=$WHITE + args+=(--set github.bell icon.color=$COLOR) + + while read -r repo url type title + do + COUNTER=$((COUNTER + 1)) + IMPORTANT="$(echo "$title" | egrep -i "(deprecat|break|broke)")" + COLOR=$BLUE + PADDING=0 + + if [ "${repo}" = "" ] && [ "${title}" = "" ]; then + repo="Note" + title="No new notifications" + fi + case "${type}" in + "'Issue'") COLOR=$GREEN; ICON=$GIT_ISSUE; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" + ;; + "'Discussion'") COLOR=$WHITE; ICON=$GIT_DISCUSSION; URL="https://www.github.com/notifications" + ;; + "'PullRequest'") COLOR=$MAGENTA; ICON=$GIT_PULL_REQUEST; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" + ;; + "'Commit'") COLOR=$WHITE; ICON=$GIT_COMMIT; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" + ;; + esac + + if [ "$IMPORTANT" != "" ]; then + COLOR=$RED + ICON=􀁞 + args+=(--set github.bell icon.color=$COLOR) + fi + + args+=(--clone github.notification.$COUNTER github.template \ + --set github.notification.$COUNTER label="$(echo "$title" | sed -e "s/^'//" -e "s/'$//")" \ + icon="$ICON $(echo "$repo" | sed -e "s/^'//" -e "s/'$//"):" \ + icon.padding_left="$PADDING" \ + label.padding_right="$PADDING" \ + icon.color=$COLOR \ + position=popup.github.bell \ + icon.background.color=$COLOR \ + drawing=on \ + click_script="open $URL; + sketchybar --set github.bell popup.drawing=off") + done <<< "$(echo "$NOTIFICATIONS" | jq -r '.[] | [.repository.name, .subject.latest_comment_url, .subject.type, .subject.title] | @sh')" + + sketchybar -m "${args[@]}" + + if [ $COUNT -gt $PREV_COUNT ] 2>/dev/null || [ "$SENDER" = "forced" ]; then + sketchybar --animate tanh 15 --set github.bell label.y_offset=5 label.y_offset=0 + fi +} + +popup() { + sketchybar --set $NAME popup.drawing=$1 +} + +case "$SENDER" in + "routine"|"forced") update + ;; + "mouse.entered") popup on + ;; + "mouse.exited"|"mouse.exited.global") popup off + ;; + "mouse.clicked") popup toggle + ;; +esac diff --git a/sketchybar/plugins/mail.sh b/sketchybar/plugins/mail.sh new file mode 100755 index 0000000..fc40617 --- /dev/null +++ b/sketchybar/plugins/mail.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +source "$HOME/.config/sketchybar/icons.sh" + +RUNNING=$(osascript -e 'if application "Mail" is running then return 0') +COUNT=0 + +if [ "$RUNNING" = "0" ]; then + COUNT=$(osascript -e 'tell application "Mail" to return the unread count of inbox') + if [ "$COUNT" -gt "0" ]; then + sketchybar --set $NAME label="$COUNT" icon=$MAIL + else + sketchybar --set $NAME label="$COUNT" icon=$MAIL_OPEN + fi +else + sketchybar --set $NAME label="!" icon=$MAIL +fi + diff --git a/sketchybar/plugins/time.sh b/sketchybar/plugins/time.sh new file mode 100755 index 0000000..fee55ae --- /dev/null +++ b/sketchybar/plugins/time.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +sketchybar --set $NAME icon="$(date '+%a %d. %b')" label="$(date '+%I:%M %p')" + diff --git a/sketchybar/plugins/yabai.sh b/sketchybar/plugins/yabai.sh new file mode 100755 index 0000000..2fac119 --- /dev/null +++ b/sketchybar/plugins/yabai.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env sh + +update() { + source "$HOME/.config/sketchybar/colors.sh" + source "$HOME/.config/sketchybar/icons.sh" + + WINDOW=$(yabai -m query --windows --window) + CURRENT=$(echo "$WINDOW" | jq '.["stack-index"]') + + args=() + if [[ $CURRENT -gt 0 ]]; then + LAST=$(yabai -m query --windows --window stack.last | jq '.["stack-index"]') + args+=(--set $NAME icon=$YABAI_STACK icon.color=$RED label.drawing=on label=$(printf "[%s/%s]" "$CURRENT" "$LAST")) + yabai -m config active_window_border_color $RED > /dev/null 2>&1 & + + else + args+=(--set $NAME label.drawing=off) + case "$(echo "$WINDOW" | jq '.["is-floating"]')" in + "false") + if [ "$(echo "$WINDOW" | jq '.["has-fullscreen-zoom"]')" = "true" ]; then + args+=(--set $NAME icon=$YABAI_FULLSCREEN_ZOOM icon.color=$GREEN) + yabai -m config active_window_border_color $GREEN > /dev/null 2>&1 & + elif [ "$(echo "$WINDOW" | jq '.["has-parent-zoom"]')" = "true" ]; then + args+=(--set $NAME icon=$YABAI_PARENT_ZOOM icon.color=$BLUE) + yabai -m config active_window_border_color $BLUE > /dev/null 2>&1 & + else + args+=(--set $NAME icon=$YABAI_GRID icon.color=0xfff0c6c6) + yabai -m config active_window_border_color $WHITE > /dev/null 2>&1 & + fi + ;; + "true") + args+=(--set $NAME icon=$YABAI_FLOAT icon.color=$MAGENTA) + yabai -m config active_window_border_color $MAGENTA > /dev/null 2>&1 & + ;; + esac + fi + + sketchybar -m "${args[@]}" +} + +mouse_clicked() { + yabai -m window --toggle float + update +} + +mouse_entered() { + sketchybar --set $NAME background.drawing=on +} + +mouse_exited() { + sketchybar --set $NAME background.drawing=off +} + +case "$SENDER" in + "mouse.entered") mouse_entered + ;; + "mouse.exited") mouse_exited + ;; + "mouse.clicked") mouse_clicked + ;; + "forced") exit 0 + ;; + *) update + ;; +esac diff --git a/sketchybar/sketchybarrc b/sketchybar/sketchybarrc new file mode 100755 index 0000000..c548ca6 --- /dev/null +++ b/sketchybar/sketchybarrc @@ -0,0 +1,67 @@ +#!/usr/bin/env sh + +source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors +source "$HOME/.config/sketchybar/icons.sh" # Loads all defined icons + +ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured +PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored + +FONT="PragmataPro Mono Liga" # Needs to have Regular, Bold, Semibold, Heavy and Black variants +SPACE_CLICK_SCRIPT="yabai -m space --focus \$SID 2>/dev/null" # The script that is run for clicking on space components + +PADDINGS=3 # All paddings use this value (icon, label, background and bar paddings) + +POPUP_BORDER_WIDTH=2 +POPUP_CORNER_RADIUS=11 + +SHADOW=on + +# Setting up the general bar appearance and default values +sketchybar --bar height=39 \ + corner_radius=0 \ + border_width=0 \ + margin=0 \ + blur_radius=50 \ + position=top \ + padding_left=10 \ + padding_right=10 \ + color=$BAR_COLOR \ + topmost=off \ + sticky=on \ + font_smoothing=off \ + y_offset=0 \ + shadow=$SHADOW \ + notch_width=200 \ + \ + --default drawing=on \ + updates=when_shown \ + label.font="$FONT:Semibold:13.0" \ + icon.font="$FONT:Bold:14.0" \ + icon.color=$ICON_COLOR \ + label.color=$LABEL_COLOR \ + icon.padding_left=$PADDINGS \ + icon.padding_right=$PADDINGS \ + label.padding_left=$PADDINGS \ + label.padding_right=$PADDINGS \ + background.padding_right=$PADDINGS \ + background.padding_left=$PADDINGS \ + popup.background.border_width=$POPUP_BORDER_WIDTH \ + popup.background.corner_radius=$POPUP_CORNER_RADIUS \ + popup.background.border_color=$POPUP_BORDER_COLOR \ + popup.background.color=$POPUP_BACKGROUND_COLOR \ + popup.background.shadow.drawing=$SHADOW + +# Left +source "$ITEM_DIR/apple.sh" +source "$ITEM_DIR/spaces.sh" +source "$ITEM_DIR/front_app.sh" + +# Right +source "$ITEM_DIR/power.sh" +source "$ITEM_DIR/calendar.sh" +source "$ITEM_DIR/cpu.sh" + +############## FINALIZING THE SETUP ############## +sketchybar --update + +echo "sketchybar configuation loaded.." From fa16249e7b9e9bf480bdd72da24c3605fa0ab799 Mon Sep 17 00:00:00 2001 From: Abdulwahaab Ahmed Date: Wed, 2 Nov 2022 14:04:55 -0400 Subject: [PATCH 2/2] Add sketchybar --- sketchybar/colors.sh | 13 --- sketchybar/icons.sh | 55 +++---------- sketchybar/items/apple.sh | 39 ++------- sketchybar/items/battery.sh | 4 + sketchybar/items/calendar.sh | 17 ---- sketchybar/items/clock.sh | 3 + sketchybar/items/cpu.sh | 4 +- sketchybar/items/darkside.sh | 4 + sketchybar/items/front_app.sh | 21 ----- sketchybar/items/github.sh | 25 ------ sketchybar/items/mail.sh | 10 --- sketchybar/items/power.sh | 46 ----------- sketchybar/items/spaces.sh | 41 ++++------ sketchybar/items/wifi.sh | 19 +++++ sketchybar/items/window_title.sh | 8 ++ sketchybar/items/yabai.sh | 5 ++ sketchybar/plugins/battery.sh | 23 +++--- sketchybar/plugins/clock.sh | 3 + sketchybar/plugins/darkmode.sh | 12 +++ sketchybar/plugins/darkmode_click.sh | 5 ++ sketchybar/plugins/front_app.sh | 7 -- sketchybar/plugins/github.sh | 87 -------------------- sketchybar/plugins/mail.sh | 17 ---- sketchybar/plugins/space.sh | 3 + sketchybar/plugins/time.sh | 4 - sketchybar/plugins/wifi.sh | 9 ++ sketchybar/plugins/wifi_click.sh | 7 ++ sketchybar/plugins/window_title.sh | 3 + sketchybar/plugins/yabai.sh | 65 --------------- sketchybar/plugins/yabai_mode.sh | 16 ++++ sketchybar/plugins/yabai_mode_click.sh | 16 ++++ sketchybar/sketchybarrc | 109 +++++++++++-------------- 32 files changed, 212 insertions(+), 488 deletions(-) create mode 100755 sketchybar/items/battery.sh delete mode 100755 sketchybar/items/calendar.sh create mode 100755 sketchybar/items/clock.sh create mode 100755 sketchybar/items/darkside.sh delete mode 100755 sketchybar/items/front_app.sh delete mode 100755 sketchybar/items/github.sh delete mode 100755 sketchybar/items/mail.sh delete mode 100755 sketchybar/items/power.sh create mode 100755 sketchybar/items/wifi.sh create mode 100755 sketchybar/items/window_title.sh create mode 100755 sketchybar/items/yabai.sh create mode 100755 sketchybar/plugins/clock.sh create mode 100755 sketchybar/plugins/darkmode.sh create mode 100755 sketchybar/plugins/darkmode_click.sh delete mode 100755 sketchybar/plugins/front_app.sh delete mode 100755 sketchybar/plugins/github.sh delete mode 100755 sketchybar/plugins/mail.sh create mode 100755 sketchybar/plugins/space.sh delete mode 100755 sketchybar/plugins/time.sh create mode 100755 sketchybar/plugins/wifi.sh create mode 100755 sketchybar/plugins/wifi_click.sh create mode 100755 sketchybar/plugins/window_title.sh delete mode 100755 sketchybar/plugins/yabai.sh create mode 100755 sketchybar/plugins/yabai_mode.sh create mode 100755 sketchybar/plugins/yabai_mode_click.sh diff --git a/sketchybar/colors.sh b/sketchybar/colors.sh index 68fb215..bf886f5 100755 --- a/sketchybar/colors.sh +++ b/sketchybar/colors.sh @@ -11,16 +11,3 @@ ORANGE=0xfff5a97f MAGENTA=0xffc6a0f6 GREY=0xff939ab7 TRANSPARENT=0x00000000 - -# General bar colors -BAR_COLOR=0xcc24273a #$GREY # Grey bar -ICON_COLOR=$WHITE # Color of all icons -LABEL_COLOR=$WHITE # Color of all labels - -POPUP_BACKGROUND_COLOR=$BLACK -POPUP_BORDER_COLOR=$GREEN - -SHADOW_COLOR=$BLACK - -# Item specific special colors -SPOTIFY_GREEN=0xff1db954 diff --git a/sketchybar/icons.sh b/sketchybar/icons.sh index 07924ca..fa81162 100755 --- a/sketchybar/icons.sh +++ b/sketchybar/icons.sh @@ -1,45 +1,16 @@ #!/usr/bin/env sh -# General Icons -LOADING=􀖇 -APPLE=􀣺 -PREFERENCES=􀺽 -ACTIVITY=􀒓 -LOCK=􀒳 -MAIL=􀍜 -MAIL_OPEN=􀍜 -BELL=􀋚 -BELL_DOT=􀝗 +# Uses SF Symbols. -BATTERY_100= -BATTERY_90= -BATTERY_80= -BATTERY_70= -BATTERY_60= -BATTERY_50= -BATTERY_40= -BATTERY_30= -BATTERY_20= -BATTERY_10= - - -# Git Icons -GIT_ISSUE=􀍷 -GIT_DISCUSSION=􀒤 -GIT_PULL_REQUEST=􀙡 -GIT_COMMIT=􀡚 -GIT_INDICATOR=􀂓 - -# Spotify Icons -SPOTIFY_BACK=􀊎 -SPOTIFY_PLAY_PAUSE=􀊈 -SPOTIFY_NEXT=􀊐 -SPOTIFY_SHUFFLE=􀊝 -SPOTIFY_REPEAT=􀊞 - -# Yabai Icons -YABAI_STACK=􀏭 -YABAI_FULLSCREEN_ZOOM=􀏜 -YABAI_PARENT_ZOOM=􀥃 -YABAI_FLOAT=􀢌 -YABAI_GRID=􀧍 +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 index 3cbf17d..b0bb5d9 100755 --- a/sketchybar/items/apple.sh +++ b/sketchybar/items/apple.sh @@ -1,32 +1,7 @@ -#!/usr/bin/env sh - -POPUP_OFF="sketchybar --set apple.logo popup.drawing=off" -POPUP_CLICK_SCRIPT="sketchybar --set \$NAME popup.drawing=toggle" - -sketchybar --add item apple.logo left \ - \ - --set apple.logo icon=$APPLE \ - icon.font="$FONT:Black:16.0" \ - icon.color=$GREEN \ - background.padding_left=5 \ - background.padding_right=25 \ - label.drawing=off \ - click_script="$POPUP_CLICK_SCRIPT" \ - \ - --add item apple.prefs popup.apple.logo \ - --set apple.prefs icon=$PREFERENCES \ - label="Preferences" \ - click_script="open -a 'System Preferences'; - $POPUP_OFF" \ - \ - --add item apple.activity popup.apple.logo \ - --set apple.activity icon=$ACTIVITY \ - label="Activity" \ - click_script="open -a 'Activity Monitor'; - $POPUP_OFF"\ - \ - --add item apple.lock popup.apple.logo \ - --set apple.lock icon=$LOCK \ - label="Lock Screen" \ - click_script="pmset displaysleepnow; - $POPUP_OFF" +#### 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/calendar.sh b/sketchybar/items/calendar.sh deleted file mode 100755 index 5e60d08..0000000 --- a/sketchybar/items/calendar.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env sh - -sketchybar --add item calendar right \ - --set calendar update_freq=15 \ - icon=cal \ - icon.color=$BLACK \ - icon.font="$FONT:Black:12.0" \ - icon.padding_left=15 \ - label.width=70 \ - label.align=right \ - label.color=$BLACK \ - label.padding_right=15 \ - align=center \ - script="$PLUGIN_DIR/time.sh" \ - background.color=0xffb8c0e0 \ - background.height=26 \ - background.corner_radius=11 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 index 98c85d5..badbd72 100755 --- a/sketchybar/items/cpu.sh +++ b/sketchybar/items/cpu.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh sketchybar --add item cpu.top right \ - --set cpu.top label.font="$FONT:Semibold:7" \ + --set cpu.top label.font="$FONT:Medium:7" \ label=CPU \ icon.drawing=off \ width=0 \ @@ -9,7 +9,7 @@ sketchybar --add item cpu.top right \ background.padding_right=10 \ \ --add item cpu.percent right \ - --set cpu.percent label.font="$FONT:Heavy:12" \ + --set cpu.percent label.font="$FONT:Bold:12" \ label=CPU \ y_offset=-4 \ width=40 \ 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/front_app.sh b/sketchybar/items/front_app.sh deleted file mode 100755 index 196a331..0000000 --- a/sketchybar/items/front_app.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env sh - -sketchybar --add event window_focus \ - --add item system.yabai left \ - --set system.yabai script="$PLUGIN_DIR/yabai.sh" \ - icon.font="$FONT:Bold:16.0" \ - label.drawing=off \ - icon.width=30 \ - icon=$YABAI_GRID \ - icon.color=$GREEN \ - updates=on \ - --subscribe system.yabai window_focus mouse.clicked \ - \ - --add item front_app left \ - --set front_app script="$PLUGIN_DIR/front_app.sh" \ - icon.drawing=off \ - background.padding_left=0 \ - label.color=$WHITE \ - label.font="$FONT:Black:12.0" \ - --subscribe front_app front_app_switched - diff --git a/sketchybar/items/github.sh b/sketchybar/items/github.sh deleted file mode 100755 index fa2b17b..0000000 --- a/sketchybar/items/github.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env sh - -sketchybar --add item github.bell right \ - --set github.bell update_freq=180 \ - icon.font="$FONT:Bold:15.0" \ - icon=$BELL \ - icon.color=$GREEN \ - label=$LOADING \ - label.highlight_color=$BLUE \ - popup.align=right \ - script="$PLUGIN_DIR/github.sh" \ - click_script="$POPUP_CLICK_SCRIPT" \ - --subscribe github.bell mouse.entered \ - mouse.exited \ - mouse.exited.global \ - \ - --add item github.template popup.github.bell \ - --set github.template drawing=off \ - background.corner_radius=12 \ - background.padding_left=7 \ - background.padding_right=7 \ - background.color=$BLACK \ - background.drawing=off \ - icon.background.height=2 \ - icon.background.y_offset=-12 diff --git a/sketchybar/items/mail.sh b/sketchybar/items/mail.sh deleted file mode 100755 index 725b337..0000000 --- a/sketchybar/items/mail.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env sh - -sketchybar --add item mail right \ - --set mail update_freq=120 \ - script="$PLUGIN_DIR/mail.sh" \ - background.padding_left=5 \ - icon.font="$FONT:Bold:16.0" \ - icon=$MAIL \ - icon.color=$BLUE \ - label=! diff --git a/sketchybar/items/power.sh b/sketchybar/items/power.sh deleted file mode 100755 index 3838dd8..0000000 --- a/sketchybar/items/power.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env sh - - -# BATT_PERCENT=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) -# CHARGING=$(pmset -g batt | grep 'AC Power') -# -# sketchybar -m --add item battery right -# -# if [[ ${CHARGING} != "" ]]; then -# # sketchybar -m --set battery icon="" -# # label="${BATT_PERCENT}%" -# sketchybar -m --set battery label="PWR: ${BATT_PERCENT}%" \ -# icon.color=0xff989898 \ -# update_freq=1 \ -# icon.font="$FONT:Black:16.0" -# exit 0 -# fi -# -# case ${BATT_PERCENT} in -# 100) ICON=$BATTERY_100 ;; -# 9[0-9]) ICON=$BATTERY_90 ;; -# 8[0-9]) ICON=$BATTERY_80 ;; -# 7[0-9]) ICON=$BATTERY_70 ;; -# 6[0-9]) ICON=$BATTERY_60 ;; -# 5[0-9]) ICON=$BATTERY_50 ;; -# 4[0-9]) ICON=$BATTERY_40 ;; -# 3[0-9]) ICON=$BATTERY_30 ;; -# 2[0-9]) ICON=$BATTERY_30 ;; -# 1[0-9]) ICON=$BATTERY_10 ;; -# *) ICON="" -# esac -# -# echo $ICON -# -# # sketchybar -m --set battery icon=$ICON \ -# # label="${BATT_PERCENT}%" -# sketchybar -m --set battery label="BATT: ${BATT_PERCENT}%" \ -# icon.color=0xff989898 \ -# update_freq=3 \ -# icon.font="$FONT:Black:16.0" - -sketchybar --add item battery right \ - --set battery script="$PLUGIN_DIR/battery.sh" \ - update_freq=10 \ - --subscribe battery system_woke - diff --git a/sketchybar/items/spaces.sh b/sketchybar/items/spaces.sh index 768438d..0f716f6 100755 --- a/sketchybar/items/spaces.sh +++ b/sketchybar/items/spaces.sh @@ -1,30 +1,21 @@ -#!/usr/bin/env sh - 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=22 \ - icon.padding_right=22 \ - icon.highlight_color=$RED \ - background.padding_left=-8 \ - background.padding_right=-8 \ - background.height=26 \ - background.corner_radius=9 \ - background.color=0xff3C3E4F \ - background.drawing=on \ - label.drawing=off \ - click_script="$SPACE_CLICK_SCRIPT" + 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 - -sketchybar --add item separator left \ - --set separator icon= \ - icon.font="Hack Nerd Font:Regular:16.0" \ - background.padding_left=26 \ - background.padding_right=15 \ - label.drawing=off \ - icon.color=$WHITE 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 index d068d95..61a78d9 100755 --- a/sketchybar/plugins/battery.sh +++ b/sketchybar/plugins/battery.sh @@ -1,4 +1,7 @@ #!/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') @@ -7,25 +10,19 @@ if [ $PERCENTAGE = "" ]; then fi case ${PERCENTAGE} in - 9[0-9]|100) ICON="􀛨" + 9[0-9]|100) ICON=$BATTERY_100 ;; - [6-8][0-9]) ICON="􀺸" + [6-8][0-9]) ICON=$BATTERY_75 ;; - [3-5][0-9]) ICON="􀛩" + [3-5][0-9]) ICON=$BATTERY_50 ;; - [1-2][0-9]) ICON="􀛩" + [1-2][0-9]) ICON=$BATTERY_25 ;; - *) ICON="􀛪" + *) ICON="$BATTERY_10" esac -if [[ ${CHARGING} != "" && ${PERCENTAGE} == 100 ]]; then - ICON="􀢋" -fi - if [[ $CHARGING != "" ]]; then - ICON="􀋦" + ICON=$BATTERY_CHARGING fi -# The item invoking this script (name $NAME) will get its icon and label -# updated with the current battery status -sketchybar --set battery icon="$ICON" label="${PERCENTAGE}%" icon.font="$FONT:Black:16.0" +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/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/front_app.sh b/sketchybar/plugins/front_app.sh deleted file mode 100755 index 5427a28..0000000 --- a/sketchybar/plugins/front_app.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env sh - -case "$SENDER" in - "front_app_switched") sketchybar --set $NAME label="$INFO" - ;; -esac - diff --git a/sketchybar/plugins/github.sh b/sketchybar/plugins/github.sh deleted file mode 100755 index 013c6c0..0000000 --- a/sketchybar/plugins/github.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env sh - -update() { - source "$HOME/.config/sketchybar/colors.sh" - source "$HOME/.config/sketchybar/icons.sh" - - NOTIFICATIONS="$(gh api notifications)" - COUNT="$(echo "$NOTIFICATIONS" | jq 'length')" - args=() - if [ "$NOTIFICATIONS" = "[]" ]; then - args+=(--set $NAME icon=$BELL label="0") - else - args+=(--set $NAME icon=$BELL_DOT label="$COUNT") - fi - - PREV_COUNT=$(sketchybar --query github.bell | jq -r .label.value) - # For sound to play around with: - # afplay /System/Library/Sounds/Morse.aiff - - args+=(--remove '/github.notification\.*/') - - COUNTER=0 - COLOR=$WHITE - args+=(--set github.bell icon.color=$COLOR) - - while read -r repo url type title - do - COUNTER=$((COUNTER + 1)) - IMPORTANT="$(echo "$title" | egrep -i "(deprecat|break|broke)")" - COLOR=$BLUE - PADDING=0 - - if [ "${repo}" = "" ] && [ "${title}" = "" ]; then - repo="Note" - title="No new notifications" - fi - case "${type}" in - "'Issue'") COLOR=$GREEN; ICON=$GIT_ISSUE; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" - ;; - "'Discussion'") COLOR=$WHITE; ICON=$GIT_DISCUSSION; URL="https://www.github.com/notifications" - ;; - "'PullRequest'") COLOR=$MAGENTA; ICON=$GIT_PULL_REQUEST; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" - ;; - "'Commit'") COLOR=$WHITE; ICON=$GIT_COMMIT; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" - ;; - esac - - if [ "$IMPORTANT" != "" ]; then - COLOR=$RED - ICON=􀁞 - args+=(--set github.bell icon.color=$COLOR) - fi - - args+=(--clone github.notification.$COUNTER github.template \ - --set github.notification.$COUNTER label="$(echo "$title" | sed -e "s/^'//" -e "s/'$//")" \ - icon="$ICON $(echo "$repo" | sed -e "s/^'//" -e "s/'$//"):" \ - icon.padding_left="$PADDING" \ - label.padding_right="$PADDING" \ - icon.color=$COLOR \ - position=popup.github.bell \ - icon.background.color=$COLOR \ - drawing=on \ - click_script="open $URL; - sketchybar --set github.bell popup.drawing=off") - done <<< "$(echo "$NOTIFICATIONS" | jq -r '.[] | [.repository.name, .subject.latest_comment_url, .subject.type, .subject.title] | @sh')" - - sketchybar -m "${args[@]}" - - if [ $COUNT -gt $PREV_COUNT ] 2>/dev/null || [ "$SENDER" = "forced" ]; then - sketchybar --animate tanh 15 --set github.bell label.y_offset=5 label.y_offset=0 - fi -} - -popup() { - sketchybar --set $NAME popup.drawing=$1 -} - -case "$SENDER" in - "routine"|"forced") update - ;; - "mouse.entered") popup on - ;; - "mouse.exited"|"mouse.exited.global") popup off - ;; - "mouse.clicked") popup toggle - ;; -esac diff --git a/sketchybar/plugins/mail.sh b/sketchybar/plugins/mail.sh deleted file mode 100755 index fc40617..0000000 --- a/sketchybar/plugins/mail.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env sh -source "$HOME/.config/sketchybar/icons.sh" - -RUNNING=$(osascript -e 'if application "Mail" is running then return 0') -COUNT=0 - -if [ "$RUNNING" = "0" ]; then - COUNT=$(osascript -e 'tell application "Mail" to return the unread count of inbox') - if [ "$COUNT" -gt "0" ]; then - sketchybar --set $NAME label="$COUNT" icon=$MAIL - else - sketchybar --set $NAME label="$COUNT" icon=$MAIL_OPEN - fi -else - sketchybar --set $NAME label="!" icon=$MAIL -fi - 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/time.sh b/sketchybar/plugins/time.sh deleted file mode 100755 index fee55ae..0000000 --- a/sketchybar/plugins/time.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh - -sketchybar --set $NAME icon="$(date '+%a %d. %b')" label="$(date '+%I:%M %p')" - 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.sh b/sketchybar/plugins/yabai.sh deleted file mode 100755 index 2fac119..0000000 --- a/sketchybar/plugins/yabai.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env sh - -update() { - source "$HOME/.config/sketchybar/colors.sh" - source "$HOME/.config/sketchybar/icons.sh" - - WINDOW=$(yabai -m query --windows --window) - CURRENT=$(echo "$WINDOW" | jq '.["stack-index"]') - - args=() - if [[ $CURRENT -gt 0 ]]; then - LAST=$(yabai -m query --windows --window stack.last | jq '.["stack-index"]') - args+=(--set $NAME icon=$YABAI_STACK icon.color=$RED label.drawing=on label=$(printf "[%s/%s]" "$CURRENT" "$LAST")) - yabai -m config active_window_border_color $RED > /dev/null 2>&1 & - - else - args+=(--set $NAME label.drawing=off) - case "$(echo "$WINDOW" | jq '.["is-floating"]')" in - "false") - if [ "$(echo "$WINDOW" | jq '.["has-fullscreen-zoom"]')" = "true" ]; then - args+=(--set $NAME icon=$YABAI_FULLSCREEN_ZOOM icon.color=$GREEN) - yabai -m config active_window_border_color $GREEN > /dev/null 2>&1 & - elif [ "$(echo "$WINDOW" | jq '.["has-parent-zoom"]')" = "true" ]; then - args+=(--set $NAME icon=$YABAI_PARENT_ZOOM icon.color=$BLUE) - yabai -m config active_window_border_color $BLUE > /dev/null 2>&1 & - else - args+=(--set $NAME icon=$YABAI_GRID icon.color=0xfff0c6c6) - yabai -m config active_window_border_color $WHITE > /dev/null 2>&1 & - fi - ;; - "true") - args+=(--set $NAME icon=$YABAI_FLOAT icon.color=$MAGENTA) - yabai -m config active_window_border_color $MAGENTA > /dev/null 2>&1 & - ;; - esac - fi - - sketchybar -m "${args[@]}" -} - -mouse_clicked() { - yabai -m window --toggle float - update -} - -mouse_entered() { - sketchybar --set $NAME background.drawing=on -} - -mouse_exited() { - sketchybar --set $NAME background.drawing=off -} - -case "$SENDER" in - "mouse.entered") mouse_entered - ;; - "mouse.exited") mouse_exited - ;; - "mouse.clicked") mouse_clicked - ;; - "forced") exit 0 - ;; - *) update - ;; -esac 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 index c548ca6..ff0cf0a 100755 --- a/sketchybar/sketchybarrc +++ b/sketchybar/sketchybarrc @@ -1,67 +1,52 @@ #!/usr/bin/env sh -source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors -source "$HOME/.config/sketchybar/icons.sh" # Loads all defined icons +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" -ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured -PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored - -FONT="PragmataPro Mono Liga" # Needs to have Regular, Bold, Semibold, Heavy and Black variants -SPACE_CLICK_SCRIPT="yabai -m space --focus \$SID 2>/dev/null" # The script that is run for clicking on space components - -PADDINGS=3 # All paddings use this value (icon, label, background and bar paddings) - -POPUP_BORDER_WIDTH=2 -POPUP_CORNER_RADIUS=11 - -SHADOW=on - -# Setting up the general bar appearance and default values -sketchybar --bar height=39 \ - corner_radius=0 \ - border_width=0 \ - margin=0 \ - blur_radius=50 \ - position=top \ - padding_left=10 \ - padding_right=10 \ - color=$BAR_COLOR \ - topmost=off \ - sticky=on \ - font_smoothing=off \ - y_offset=0 \ - shadow=$SHADOW \ - notch_width=200 \ - \ - --default drawing=on \ - updates=when_shown \ - label.font="$FONT:Semibold:13.0" \ - icon.font="$FONT:Bold:14.0" \ - icon.color=$ICON_COLOR \ - label.color=$LABEL_COLOR \ - icon.padding_left=$PADDINGS \ - icon.padding_right=$PADDINGS \ - label.padding_left=$PADDINGS \ - label.padding_right=$PADDINGS \ - background.padding_right=$PADDINGS \ - background.padding_left=$PADDINGS \ - popup.background.border_width=$POPUP_BORDER_WIDTH \ - popup.background.corner_radius=$POPUP_CORNER_RADIUS \ - popup.background.border_color=$POPUP_BORDER_COLOR \ - popup.background.color=$POPUP_BACKGROUND_COLOR \ - popup.background.shadow.drawing=$SHADOW - -# Left -source "$ITEM_DIR/apple.sh" -source "$ITEM_DIR/spaces.sh" -source "$ITEM_DIR/front_app.sh" - -# Right -source "$ITEM_DIR/power.sh" -source "$ITEM_DIR/calendar.sh" -source "$ITEM_DIR/cpu.sh" - -############## FINALIZING THE SETUP ############## sketchybar --update -echo "sketchybar configuation loaded.." +echo "sketchybar configuration loaded.."