sketchybar: init

This commit is contained in:
Nico 2025-05-03 16:16:03 +10:00
parent cc92b9c72c
commit 37f5757b2c
8 changed files with 257 additions and 0 deletions

View file

@ -0,0 +1,32 @@
#!/bin/sh
# The brightness_change event supplies a $INFO variable in which the current backlight brightness
# percentage is passed to the script.
if [ "$SENDER" = "brightness_change" ]; then
BRIGHTNESS="$INFO"
case "$BRIGHTNESS" in
[9][0-9]|100) ICON=""
;;
[8][0-9]) ICON=""
;;
[7][0-9]) ICON=""
;;
[6][0-9]) ICON=""
;;
[5][0-9]) ICON=""
;;
[4][0-9]) ICON=""
;;
[3][0-9]) ICON=""
;;
[2][0-9]) ICON=""
;;
[1][0-9]) ICON=""
;;
*) ICON=""
esac
sketchybar --set "$NAME" icon="$ICON" label="$BRIGHTNESS%"
fi

View file

@ -0,0 +1,28 @@
#!/bin/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" != "" ]]; then
ICON=""
fi
# The item invoking this script (name $NAME) will get its icon and label
# updated with the current battery status
sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%"

View file

@ -0,0 +1,15 @@
#!/bin/bash
# The $NAME variable is passed from sketchybar and holds the name of
# the item invoking this script:
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
HOUR=$(date +%l)
if (( $HOUR >= 10 )); then
sketchybar --set "$NAME" label.padding_right=10
else
sketchybar --set "$NAME" label.padding_right=20
fi
sketchybar --set "$NAME" label="$(date +'%a %d %b')$(date +'%I:%M %p')"

View file

@ -0,0 +1,10 @@
#!/bin/sh
# Some events send additional information specific to the event in the $INFO
# variable. E.g. the front_app_switched event sends the name of the newly
# focused application in the $INFO variable:
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
if [ "$SENDER" = "front_app_switched" ]; then
sketchybar --set "$NAME" label="$INFO"
fi

View file

@ -0,0 +1,13 @@
#!/usr/local/bin/bash
# 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"
if [ $SELECTED = 'true' ]; then
sketchybar --set "$NAME" background.color=0xfff48fb1
else
sketchybar --set "$NAME" background.color=0xffffffff
fi

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,132 @@
# vim: set filetype=sh :
# This is a demo config to showcase some of the most important commands.
# It is meant to be changed and configured, as it is intentionally kept sparse.
# For a (much) more advanced configuration example see my dotfiles:
# https://github.com/FelixKratz/dotfiles
PLUGIN_DIR="$HOME/.config/sketchybar/plugins"
##### Bar Appearance #####
# Configuring the general appearance of the bar.
# These are only some of the options available. For all options see:
# https://felixkratz.github.io/SketchyBar/config/bar
# If you are looking for other colors, see the color picker:
# https://felixkratz.github.io/SketchyBar/config/tricks#color-picker
sketchybar --bar position=top \
height=32 \
blur_radius=30 \
color=0x00000000 \
padding_right=10 \
padding_left=10 \
y_offset=3
default=(
icon.font="ComicShannsMono Nerd Font:Regular:11.0"
label.font="ComicShannsMono Nerd Font:Bold:11.0"
padding_left=1
padding_right=1
icon.color=$PRIMARY_COLOUR
label.color=$PRIMARY_COLOUR
icon.padding_left=10
icon.padding_right=1
label.padding_left=5
label.padding_right=10
background.padding_left=2
background.padding_right=2
background.corner_radius=10
)
sketchybar --default "${default[@]}"
##### Adding Mission Control Space Indicators #####
# Let's add some mission control spaces:
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
# to indicate active and available mission control spaces.
SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10")
for i in "${!SPACE_ICONS[@]}"
do
sid="$(($i+1))"
space=(
icon.color=$PRIMARY_COLOUR
background.color=$BACKGROUND_COLOUR
space="$sid"
icon="${SPACE_ICONS[i]}"
icon.padding_left=12
icon.padding_right=12
background.height=32
background.padding_left=0
background.padding_right=0
label.drawing=off
script="$PLUGIN_DIR/space.sh"
click_script="yabai -m space --focus $sid"
)
sketchybar --add space space."$sid" left --set space."$sid" "${space[@]}"
done
##### Adding Left Items #####
# We add some regular items to the left side of the bar, where
# only the properties deviating from the current defaults need to be set
#sketchybar --add item chevron left \
# --set chevron icon= label.drawing=off \
# --add item front_app left \
# --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \
# --subscribe front_app front_app_switched
sketchybar --add item front_app left \
--set front_app icon.drawing=off \
label.color=$PRIMARY_COLOUR \
padding_left=10 \
label.padding_left=10 \
background.color=$BACKGROUND_COLOUR \
background.height=32 \
script="$PLUGIN_DIR/front_app.sh" \
--subscribe front_app front_app_switched \
##### Adding Right Items #####
sketchybar --add item clock right \
--set clock \
update_freq=10 \
icon.color=$PRIMARY_COLOUR \
label.color=$PRIMARY_COLOUR \
background.color=$BACKGROUND_COLOUR \
background.height=32 \
label.padding_right=20 \
script="$PLUGIN_DIR/clock.sh"
sketchybar --add item battery right \
--set battery update_freq=10 \
script="$PLUGIN_DIR/battery.sh" \
icon.color=$SECONDARY_COLOUR \
label.color=$SECONDARY_COLOUR \
background.color=$BACKGROUND_COLOUR \
background.height=32 \
sketchybar --add item backlight right \
--set backlight icon="" \
icon.color=$TERTIARY_COLOUR \
label.color=$TERTIARY_COLOUR \
background.color=$BACKGROUND_COLOUR \
background.height=32 \
script="$PLUGIN_DIR/backlight.sh" \
--subscribe backlight brightness_change \
sketchybar --add item audio right \
--set audio icon = "" \
icon.color=$TERTIARY_COLOUR \
label.color=$TERTIARY_COLOUR \
background.color=$BACKGROUND_COLOUR \
background.height=32 \
script="$PLUGIN_DIR/volume.sh" \
--subscribe audio volume_change \
##### Force all scripts to run the first time (never do this in a script) #####
sketchybar --update