sketchybar: init

This commit is contained in:
Nico 2025-10-04 13:45:49 +10:00
parent ded82a8f8b
commit ae71080920
Signed by: nico
SSH key fingerprint: SHA256:XuacYOrGqRxC3jVFjfLROn1CSvLz85Dec6N7O9Gwu/0
10 changed files with 182 additions and 96 deletions

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# make sure it's executable with:
# chmod +x ~/.config/sketchybar/plugins/aerospace.sh
#
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/../colours.sh
if [ "$1" = "$FOCUSED_WORKSPACE" ]; then
# If workspace is focused
sketchybar --set $NAME background.color=$PRIMARY_COLOUR label.color=$BACKGROUND_COLOUR
else
sketchybar --set $NAME background.color=$BACKGROUND_COLOUR label.color=$PRIMARY_COLOUR
fi

View file

@ -12,4 +12,4 @@ else
sketchybar --set "$NAME" label.padding_right=20
fi
sketchybar --set "$NAME" label="$(date +'%a %d %b')$(date +'%I:%M %p')"
sketchybar --set "$NAME" label="$(date +'%l:%M %p')"

View file

@ -0,0 +1,29 @@
#!/bin/sh
# from: https://apple.stackexchange.com/questions/251666/how-to-get-current-input-language-of-the-input-source
#!/usr/local/bin/bash
# Checks current keyboard input source (aka language)
#These are the strings that MacOS uses to identify the current input source
ENGLISH="Australian"
HIRIGANA="com.apple.inputmethod.Japanese"
KATANA="com.apple.inputmethod.Japanese.Katakana"
WESTERN_LANGUAGE=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep 'KeyboardLayout Name' | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/')
# If the current language is not western one, then check a different variable
EASTERN_LANGUAGE=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep -w 'Input Mode' | head -1 | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/')
if [ "$WESTERN_LANGUAGE" = "$ENGLISH" ]; then
LABEL="English"
ICON="🇬🇧"
elif [ "$EASTERN_LANGUAGE" = "$HIRIGANA" ]; then
LABEL="Japanese"
ICON="🇯🇵"
elif [ "$EASTERN_LANGUAGE" = "$KATANA" ]; then
LABEL="Katakana"
ICON="🈴"
fi
sketchybar --set "$NAME" label="$LABEL" icon="$ICON"

View file

@ -0,0 +1,10 @@
#!/bin/sh
# sketchybar doesn't like it when the line doesn't end with a carriage return
SONG="$(osascript -e 'tell application "Music" to if player state is playing then artist of current track & " - " & name of current track' | head -c 65 && echo '\r')"
if [[ "$(echo $SONG | wc -w | sed 's/ //g')" != "0" ]]; then
sketchybar --set "$NAME" label="${SONG}" background.drawing=true icon.drawing=true
else
sketchybar --set "$NAME" label="" background.drawing=false icon.drawing=false
fi

View file

@ -0,0 +1,8 @@
#!/bin/sh
ping -c 1 1.1.1.1 &> /dev/null
if [ "$?" = "0" ]; then
sketchybar --set $NAME icon=󰖩
else
sketchybar --set $NAME icon=󰖪
fi