This commit is contained in:
mr0xb 2026-06-03 14:36:50 -04:00
commit 715eb53860
No known key found for this signature in database
57 changed files with 7755 additions and 3 deletions

View file

@ -0,0 +1,23 @@
#!/bin/bash
# Handle left/right click on aerospace spaces
# Left click: focus workspace
# Right click: destroy workspace (if using yabai with SIP disabled)
WORKSPACE_NUMBER=$(echo "$NAME" | grep -o '[0-9]\+$')
case "$BUTTON" in
"left")
aerospace workspace "$WORKSPACE_NUMBER"
;;
"right")
# Destroy space (requires yabai with SIP disabled)
# For aerospace, we'll just move all windows from this space to space 1 and focus space 1
aerospace list-windows --workspace "$WORKSPACE_NUMBER" --format '%{window-id}' | while read -r window_id; do
if [ -n "$window_id" ]; then
aerospace move-node-to-workspace --window-id "$window_id" 1
fi
done
aerospace workspace 1
;;
esac

View file

@ -0,0 +1,26 @@
#!/bin/sh
source "$CONFIG_DIR/colors.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="󰂂 " ; COLOR="0xffa8ff60" ;;
[6-8][0-9]) ICON="󰁿 " ; COLOR="0xffa8ff60" ;;
[3-5][0-9]) ICON="󰁼 " ; COLOR="0xfffffeb7" ;;
[1-2][0-9]) ICON="󰁺 " ; COLOR="0xfffcb6b0" ;;
*) ICON="󰁹 " ; COLOR="0xfffa6c60" ;;
esac
if [ "$CHARGING" != "" ]; then
ICON=" "
#COLOR="0xffa8ff60"
COLOR=$GREEN
fi
sketchybar --set "$NAME" icon="$ICON" icon.color="$COLOR" label="${PERCENTAGE}%" label.drawing=on

View file

@ -0,0 +1,16 @@
#!/bin/bash
# Check Bluetooth status
BT_STATUS=$(system_profiler SPBluetoothDataType 2>/dev/null | grep "Bluetooth Power" | awk '{print $3}')
if [ "$BT_STATUS" = "On" ]; then
# Check if any devices are connected
CONNECTED=$(system_profiler SPBluetoothDataType 2>/dev/null | grep "Connected: Yes" | wc -l)
if [ $CONNECTED -gt 0 ]; then
sketchybar --set "$NAME" icon="󰂯" icon.color=0xfffacc15
else
sketchybar --set "$NAME" icon="󰂲" icon.color=0xffffffff
fi
else
sketchybar --set "$NAME" icon="󰂲" icon.color=0xff6272a4
fi

View file

@ -0,0 +1,14 @@
#!/bin/bash
# Calendar plugin with proper date formatting
# Get current date components
DAY=$(date '+%d')
MONTH_DAY=$(date '+%a %b %d')
TIME=$(date '+%H:%M')
# Remove leading zero from day for icon
ICON_DAY=$(date '+%-d')
# Format the display
sketchybar --set "$NAME" icon="$ICON_DAY" label="$MONTH_DAY $TIME"

View file

@ -0,0 +1,9 @@
#!/bin/bash
# Enhanced clock script with better date formatting
DATE=$(date '+%a %b %d')
TIME=$(date '+%H:%M')
sketchybar --set "$NAME" icon="$(date '+%d')" label="$DATE $TIME"

View file

@ -0,0 +1,21 @@
#!/bin/bash
# Dato integration with clean 12-hour format
# Simple, clean date and time display
# Get current date and time in 12-hour format
DAY=$(date '+%-d')
MONTH=$(date '+%B')
YEAR=$(date '+%Y')
TIME=$(date '+%-I:%M %p %Z')
# Add ordinal suffix to day
case $DAY in
1|21|31) SUFFIX="st";;
2|22) SUFFIX="nd";;
3|23) SUFFIX="rd";;
*) SUFFIX="th";;
esac
# Set clean label with full format
sketchybar --set "$NAME" label="$MONTH ${DAY}${SUFFIX}, $YEAR $TIME"

View file

@ -0,0 +1,18 @@
#!/bin/bash
# Check Focus/Do Not Disturb status
# This is a simplified version - macOS Focus status is complex to detect
# Try to detect if Focus is active
FOCUS_ACTIVE=0
# Check if Do Not Disturb is enabled (basic detection)
if plutil -extract dnd_prefs xml1 -o - ~/Library/Preferences/com.apple.ncprefs.plist 2>/dev/null | grep -q "userPref.*1"; then
FOCUS_ACTIVE=1
fi
if [ $FOCUS_ACTIVE -eq 1 ]; then
sketchybar --set "$NAME" icon="󰂞" icon.color=0xfffacc15
else
sketchybar --set "$NAME" icon="󰂞" icon.color=0xff6272a4
fi

View file

@ -0,0 +1,15 @@
#!/bin/bash
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config/sketchybar}"
source "$CONFIG_DIR/helpers/icon_map.sh"
if [ "$SENDER" = "front_app_switched" ]; then
__icon_map "$INFO"
# Use smooth animation for app switching - sin 6 for quick buttery transition
if [ -n "$icon_result" ] && [ "$icon_result" != ":default:" ]; then
sketchybar --animate sin 6 --set "$NAME" label="$INFO" icon="$icon_result"
else
sketchybar --animate sin 6 --set "$NAME" label="$INFO" icon=":default:"
fi
fi

View file

@ -0,0 +1,33 @@
#!/bin/bash
# Detect microphone usage from various apps
# Check for apps that commonly use microphone
MIC_USAGE=0
# Check for Zoom
if pgrep -f "zoom.us" > /dev/null; then
MIC_USAGE=1
fi
# Check for Teams
if pgrep -f "Microsoft Teams" > /dev/null; then
MIC_USAGE=1
fi
# Check for Discord
if pgrep -f "Discord" > /dev/null; then
MIC_USAGE=1
fi
# Check for QuickTime recording
if pgrep -f "QuickTime Player" > /dev/null && lsof | grep -q "AppleH13CamIn"; then
MIC_USAGE=1
fi
# Show/hide mic indicator based on usage
if [ $MIC_USAGE -eq 1 ]; then
sketchybar --set "$NAME" drawing=on background.drawing=on
else
sketchybar --set "$NAME" drawing=off background.drawing=off
fi

View file

@ -0,0 +1,35 @@
#!/bin/bash
# Filename: ~/github/dotfiles-latest/sketchybar/felixkratz/plugins/mic.sh
# https://github.com/FelixKratz/SketchyBar/discussions/12#discussioncomment-1216899
source "$CONFIG_DIR/colors.sh"
# Attempt to get the current input device name
MIC_NAME=$(SwitchAudioSource -t input -c)
# I just want the first word, in case it's too long
MIC_NAME=$(echo $MIC_NAME | awk '{print $1}')
# When no microphone is connected, SwitchAudioSource gives me back random
# characters and sketchybar shows "Warning: Malformed UTF-8 string"
# Validate MIC_NAME as UTF-8, replace invalid sequences with a '?', then compare with original
VALIDATED_MIC_NAME=$(echo "$MIC_NAME" | iconv -f UTF-8 -t UTF-8//IGNORE)
# Get the current microphone volume
MIC_VOLUME=$(osascript -e 'input volume of (get volume settings)')
# Check if MIC_NAME is not meaningful
if [[ "$MIC_NAME" != "$VALIDATED_MIC_NAME" || -z "$MIC_NAME" ]]; then
# If the mic name is not valid or empty
sketchybar -m --set mic label="" icon= icon.color=$YELLOW label.color=$YELLOW
else
# Update SketchyBar with the microphone's name and volume
if [[ $MIC_VOLUME -eq 0 ]]; then
sketchybar -m --set mic label="$MIC_NAME $MIC_VOLUME" icon= icon.color=$RED label.color=$RED
elif [[ $MIC_VOLUME -gt 0 && $MIC_VOLUME -lt 100 ]]; then
sketchybar -m --set mic label="$MIC_NAME $MIC_VOLUME" icon= icon.color=$ORANGE label.color=$ORANGE
elif [[ $MIC_VOLUME -eq 100 ]]; then
sketchybar -m --set mic label="$MIC_NAME $MIC_VOLUME" icon= icon.color=$GREEN label.color=$WHITE
fi
fi

View file

@ -0,0 +1,16 @@
#!/bin/bash
source "$CONFIG_DIR/colors.sh"
MIC_VOLUME=$(osascript -e 'input volume of (get volume settings)')
if [[ $MIC_VOLUME -eq 0 ]]; then
ICON=" "
COLOR=$RED
#sketchybar -m --set mic icon.color=$RED icon= icon.font="0xProto Nerd Font Mono:Bold:20"
elif [[ $MIC_VOLUME -gt 0 ]]; then
ICON=" "
COLOR=$GREEN
fi
#sketchybar -m --set mic icon= icon.color=$GREEN icon.font="0xProto Nerd Font Mono:Bold:25"
sketchybar -m --set mic icon="$ICON" icon.color="$COLOR" icon.font="0xProto Nerd Font Mono:Bold:30"

View file

@ -0,0 +1,64 @@
#!/bin/bash
# Filename: ~/github/dotfiles-latest/sketchybar/felixkratz/plugins/mic_click.sh
# https://github.com/FelixKratz/SketchyBar/discussions/12#discussioncomment-1216899
source "$CONFIG_DIR/colors.sh"
# This is basically the same as the `toggle_devices()` function in:
# ~/github/dotfiles-latest/sketchybar/felixkratz/plugins/volume_click.sh
toggle_mics() {
which SwitchAudioSource >/dev/null || exit 0
source "$CONFIG_DIR/colors.sh"
args=(--remove '/mic.device\.*/' --set "$NAME" popup.drawing=toggle popup.align=left popup.horizontal=on)
COUNTER=0
CURRENT="$(SwitchAudioSource -t input -c)"
while IFS= read -r device; do
COLOR=$GREY
if [ "${device}" = "$CURRENT" ]; then
COLOR=$WHITE
fi
args+=(--add item mic.device.$COUNTER popup."$NAME"
--set mic.device.$COUNTER label="${device}"
label.color="$COLOR"
click_script="SwitchAudioSource -t input -s \"${device}\" && sketchybar --set /mic.device\.*/ label.color=$GREY --set \$NAME label.color=$WHITE --set $NAME popup.drawing=off")
COUNTER=$((COUNTER + 1))
done <<<"$(SwitchAudioSource -a -t input)"
sketchybar -m "${args[@]}" >/dev/null
}
if [ "$BUTTON" = "left" ]; then
# Attempt to get the current input device name
MIC_NAME=$(SwitchAudioSource -t input -c)
# I just want the first word, in case it's too long
MIC_NAME=$(echo $MIC_NAME | awk '{print $1}')
# When no microphone is connected, SwitchAudioSource gives me back random
# characters and sketchybar shows "Warning: Malformed UTF-8 string"
# Validate MIC_NAME as UTF-8, replace invalid sequences with a '?', then compare with original
VALIDATED_MIC_NAME=$(echo "$MIC_NAME" | iconv -f UTF-8 -t UTF-8//IGNORE)
# Get the current microphone volume
MIC_VOLUME=$(osascript -e 'input volume of (get volume settings)')
# Check if MIC_NAME is not meaningful
if [[ "$MIC_NAME" != "$VALIDATED_MIC_NAME" || -z "$MIC_NAME" ]]; then
# If the mic name is not valid or empty
sketchybar -m --set mic label="" icon=
else
# Update SketchyBar with the microphone's name and volume
if [[ $MIC_VOLUME -lt 100 ]]; then
osascript -e 'set volume input volume 100'
sketchybar -m --set mic label="$MIC_NAME 100" icon= icon.color=$GREEN label.color=$WHITE
elif [[ $MIC_VOLUME -gt 0 ]]; then
osascript -e 'set volume input volume 0'
sketchybar -m --set mic label="$MIC_NAME 0" icon= icon.color=$RED label.color=$RED
fi
fi
# Check for right-click or shift modifier to show the microphone selection popup
elif [ "$BUTTON" = "right" ] || [ "$MODIFIER" = "shift" ]; then
toggle_mics
fi

View file

@ -0,0 +1,18 @@
#!/bin/bash
source "$CONFIG_DIR/colors.sh"
MIC_VOLUME=$(osascript -e 'input volume of (get volume settings)')
if [[ $MIC_VOLUME -eq 0 ]]; then
osascript -e 'set volume input volume 25'
ICON=""
COLOR=$GREEN
#sketchybar -m --set mic icon="" icon.color=$GREEN
elif [[ $MIC_VOLUME -gt 0 ]]; then
osascript -e 'set volume input volume 0'
ICON=""
COLOR=$RED
#sketchybar -m --set mic icon="" icon.color=$RED
fi
sketchybar -m --set mic icon="$ICON" icon.color=$COLOR

View file

@ -0,0 +1,19 @@
#!/bin/bash
SCREEN_RECORDING=0
# Check for active screencapture process (macOS screenshot/recording tool)
if pgrep -x screencapture > /dev/null 2>&1; then
SCREEN_RECORDING=1
fi
# Check for common recording applications
if pgrep -x OBS > /dev/null 2>&1 || pgrep -x Kap > /dev/null 2>&1 || pgrep -x "CleanShot X" > /dev/null 2>&1 || pgrep -x Camtasia > /dev/null 2>&1; then
SCREEN_RECORDING=1
fi
if [ $SCREEN_RECORDING -eq 1 ]; then
sketchybar --set "$NAME" drawing=on background.drawing=on
else
sketchybar --set "$NAME" drawing=off background.drawing=off
fi

View file

@ -0,0 +1,10 @@
#!/bin/bash
# Stop screen recording when clicked
# This simulates the macOS menu bar behavior
# Try to stop screen recording via keyboard shortcut
osascript -e 'tell application "System Events" to key code 28 using {shift down, command down}'
# Or try to quit QuickTime Player if it's recording
pkill -f "QuickTime Player"

View file

@ -0,0 +1,7 @@
#!/bin/sh
# 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
sketchybar --set "$NAME" background.drawing="$SELECTED"

View file

@ -0,0 +1,175 @@
#!/bin/bash
next ()
{
osascript -e 'tell application "Spotify" to play next track'
}
back ()
{
osascript -e 'tell application "Spotify" to play previous track'
}
play ()
{
osascript -e 'tell application "Spotify" to playpause'
}
repeat ()
{
REPEAT=$(osascript -e 'tell application "Spotify" to get repeating')
if [ "$REPEAT" = "false" ]; then
sketchybar -m --set spotify.repeat icon.highlight=on
osascript -e 'tell application "Spotify" to set repeating to true'
else
sketchybar -m --set spotify.repeat icon.highlight=off
osascript -e 'tell application "Spotify" to set repeating to false'
fi
}
shuffle ()
{
SHUFFLE=$(osascript -e 'tell application "Spotify" to get shuffling')
if [ "$SHUFFLE" = "false" ]; then
sketchybar -m --set spotify.shuffle icon.highlight=on
osascript -e 'tell application "Spotify" to set shuffling to true'
else
sketchybar -m --set spotify.shuffle icon.highlight=off
osascript -e 'tell application "Spotify" to set shuffling to false'
fi
}
update ()
{
PLAYING=1
if [ "$(echo "$INFO" | jq -r '.["Player State"]')" = "Playing" ]; then
PLAYING=0
TRACK="$(echo "$INFO" | jq -r .Name | sed 's/\(.\{20\}\).*/\1.../')"
ARTIST="$(echo "$INFO" | jq -r .Artist | sed 's/\(.\{20\}\).*/\1.../')"
ALBUM="$(echo "$INFO" | jq -r .Album | sed 's/\(.\{25\}\).*/\1.../')"
SHUFFLE=$(osascript -e 'tell application "Spotify" to get shuffling')
REPEAT=$(osascript -e 'tell application "Spotify" to get repeating')
COVER=$(osascript -e 'tell application "Spotify" to get artwork url of current track')
fi
args=()
if [ $PLAYING -eq 0 ]; then
curl -s --max-time 20 "$COVER" -o /tmp/cover.jpg
if [ "$ARTIST" == "" ]; then
args+=(--set spotify.title label="$TRACK"
--set spotify.album label="Podcast"
--set spotify.artist label="$ALBUM" )
else
args+=(--set spotify.title label="$TRACK"
--set spotify.album label="$ALBUM"
--set spotify.artist label="$ARTIST")
fi
args+=(--set spotify.play icon="􀊆"
--set spotify.shuffle icon.highlight=$SHUFFLE
--set spotify.repeat icon.highlight=$REPEAT
--set spotify.cover background.image="/tmp/cover.jpg"
background.color=0x00000000
--set spotify.anchor drawing=on
--set spotify.anchor icon.color=0xfffacc15 )
else
args+=(--set spotify.anchor drawing=on popup.drawing=off
--set spotify.anchor icon.color=0xfffacc15
--set spotify.play icon="􀊄" )
fi
sketchybar -m "${args[@]}"
}
scrubbing() {
DURATION_MS=$(osascript -e 'tell application "Spotify" to get duration of current track')
DURATION=$((DURATION_MS/1000))
TARGET=$((DURATION*PERCENTAGE/100))
osascript -e "tell application \"Spotify\" to set player position to $TARGET"
sketchybar --set spotify.state slider.percentage=$PERCENTAGE
}
scroll() {
DURATION_MS=$(osascript -e 'tell application "Spotify" to get duration of current track')
DURATION=$((DURATION_MS/1000))
FLOAT="$(osascript -e 'tell application "Spotify" to get player position')"
TIME=${FLOAT%.*}
sketchybar --animate linear 10 \
--set spotify.state slider.percentage="$((TIME*100/DURATION))" \
icon="$(date -r $TIME +'%M:%S')" \
label="$(date -r $DURATION +'%M:%S')"
}
mouse_clicked () {
case "$NAME" in
"spotify.next") next
;;
"spotify.back") back
;;
"spotify.play") play
;;
"spotify.shuffle") shuffle
;;
"spotify.repeat") repeat
;;
"spotify.state") scrubbing
;;
*) exit
;;
esac
}
popup () {
# Toggle popup instead of just on/off - stays open until clicked elsewhere
sketchybar --set spotify.anchor popup.drawing=toggle
}
routine() {
case "$NAME" in
"spotify.state") scroll
;;
*) update
;;
esac
}
case "$SENDER" in
"mouse.clicked")
if [ "$NAME" = "spotify.anchor" ]; then
sketchybar --set spotify.anchor popup.drawing=toggle
else
mouse_clicked
fi
;;
"mouse.entered")
if [ "$NAME" = "spotify.anchor" ]; then
sketchybar --set spotify.anchor popup.drawing=on
fi
;;
"mouse.exited")
# Close popup after a brief moment to avoid flickering
sleep 0.3
sketchybar --set spotify.anchor popup.drawing=off
;;
"mouse.exited.global")
sketchybar --set spotify.anchor popup.drawing=off
;;
"routine") routine
;;
"forced")
if pgrep -x Spotify > /dev/null 2>&1; then
STATE=$(osascript -e 'tell application "Spotify" to get player state as string' 2>/dev/null)
if [ "$STATE" = "playing" ]; then
TRACK=$(osascript -e 'tell application "Spotify" to get name of current track' 2>/dev/null)
ARTIST=$(osascript -e 'tell application "Spotify" to get artist of current track' 2>/dev/null)
ALBUM=$(osascript -e 'tell application "Spotify" to get album of current track' 2>/dev/null)
INFO=$(jq -n --arg t "$TRACK" --arg a "$ARTIST" --arg al "$ALBUM" \
'{"Player State":"Playing","Name":$t,"Artist":$a,"Album":$al}')
update
fi
fi
;;
*) update
;;
esac

View file

@ -0,0 +1,7 @@
#!/bin/bash
# Trigger the workspace update
/Users/zion/.config/sketchybar/plugins/aerospace_workspaces.sh
# Also trigger a sketchybar update
sketchybar --trigger aerospace_workspace_change

View file

@ -0,0 +1,20 @@
#!/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

View file

@ -0,0 +1,17 @@
#!/bin/bash
# Volume scroll script - allows changing volume with mouse scroll
VOLUME_STEP=5
case "$SCROLL_DIRECTION" in
"up")
osascript -e "set volume output volume (output volume of (get volume settings) + $VOLUME_STEP)"
;;
"down")
osascript -e "set volume output volume (output volume of (get volume settings) - $VOLUME_STEP)"
;;
esac
# Trigger volume update
sketchybar --trigger volume_change

View file

@ -0,0 +1,29 @@
#!/bin/bash
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config/sketchybar}"
source "$CONFIG_DIR/icons.sh"
# Check overall internet connection status
INTERNET_CONNECTED=0
# First check if we can reach the internet
if ping -c 1 8.8.8.8 >/dev/null 2>&1; then
INTERNET_CONNECTED=1
fi
if [ $INTERNET_CONNECTED -eq 1 ]; then
# Check if WiFi is on and connected
WIFI_STATUS=$(networksetup -getairportpower en0 2>/dev/null | awk '{print $4}')
SSID=$(networksetup -getairportnetwork en0 2>/dev/null | cut -d' ' -f4-)
if [ "$WIFI_STATUS" = "On" ] && [ "$SSID" != "You are not associated with an AirPort network." ] && [ "$SSID" != "" ]; then
# Connected via WiFi
sketchybar --set "$NAME" icon="📶" label="$SSID"
else
# Connected via Ethernet or other means
sketchybar --set "$NAME" icon="📶" label="Ethernet"
fi
else
# No internet connection at all
sketchybar --set "$NAME" icon="🚫" label="No Internet"
fi

View file

@ -0,0 +1,7 @@
#!/bin/bash
# Simple zen script - toggles between 12h and 24h format
# You can customize this to do whatever you want when clicking the clock
# For now, just open the Calendar app
open -a Calendar