improve default config

This commit is contained in:
Felix Kratz 2024-02-06 17:03:45 +01:00
parent 8c1971dc85
commit c6b8aa8288
6 changed files with 61 additions and 75 deletions

View file

@ -1,13 +1,13 @@
#!/bin/sh #!/bin/sh
PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) PERCENTAGE="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)"
CHARGING=$(pmset -g batt | grep 'AC Power') CHARGING="$(pmset -g batt | grep 'AC Power')"
if [ $PERCENTAGE = "" ]; then if [ "$PERCENTAGE" = "" ]; then
exit 0 exit 0
fi fi
case ${PERCENTAGE} in case "${PERCENTAGE}" in
9[0-9]|100) ICON="" 9[0-9]|100) ICON=""
;; ;;
[6-8][0-9]) ICON="" [6-8][0-9]) ICON=""
@ -19,10 +19,10 @@ case ${PERCENTAGE} in
*) ICON="" *) ICON=""
esac esac
if [[ $CHARGING != "" ]]; then if [[ "$CHARGING" != "" ]]; then
ICON="" ICON=""
fi fi
# The item invoking this script (name $NAME) will get its icon and label # The item invoking this script (name $NAME) will get its icon and label
# updated with the current battery status # updated with the current battery status
sketchybar --set $NAME icon="$ICON" label="${PERCENTAGE}%" sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%"

View file

@ -4,5 +4,5 @@
# the item invoking this script: # the item invoking this script:
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting # https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
sketchybar --set $NAME label="$(date '+%d/%m %H:%M')" sketchybar --set "$NAME" label="$(date '+%d/%m %H:%M')"

View file

@ -6,5 +6,5 @@
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting # https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
if [ "$SENDER" = "front_app_switched" ]; then if [ "$SENDER" = "front_app_switched" ]; then
sketchybar --set $NAME label="$INFO" sketchybar --set "$NAME" label="$INFO"
fi fi

View file

@ -4,4 +4,4 @@
# the space invoking this script (with name: $NAME) is currently selected: # 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 # https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
sketchybar --set $NAME background.drawing=$SELECTED sketchybar --set "$NAME" background.drawing="$SELECTED"

View file

@ -4,9 +4,9 @@
# percentage is passed to the script. # percentage is passed to the script.
if [ "$SENDER" = "volume_change" ]; then if [ "$SENDER" = "volume_change" ]; then
VOLUME=$INFO VOLUME="$INFO"
case $VOLUME in case "$VOLUME" in
[6-9][0-9]|100) ICON="󰕾" [6-9][0-9]|100) ICON="󰕾"
;; ;;
[3-5][0-9]) ICON="󰖀" [3-5][0-9]) ICON="󰖀"
@ -16,5 +16,5 @@ if [ "$SENDER" = "volume_change" ]; then
*) ICON="󰖁" *) ICON="󰖁"
esac esac
sketchybar --set $NAME icon="$ICON" label="$VOLUME%" sketchybar --set "$NAME" icon="$ICON" label="$VOLUME%"
fi fi

View file

@ -1,76 +1,70 @@
# This is a demo config to show some of the most important commands more easily. # This is a demo config to showcase some of the most important commands.
# This is meant to be changed and configured, as it is intentionally kept sparse. # It is meant to be changed and configured, as it is intentionally kept sparse.
# For a more advanced configuration example see my dotfiles: # For a (much) more advanced configuration example see my dotfiles:
# https://github.com/FelixKratz/dotfiles # https://github.com/FelixKratz/dotfiles
PLUGIN_DIR="$CONFIG_DIR/plugins" PLUGIN_DIR="$CONFIG_DIR/plugins"
##### Bar Appearance ##### ##### Bar Appearance #####
# Configuring the general appearance of the bar, these are only some of the # Configuring the general appearance of the bar.
# options available. For all options see: # These are only some of the options available. For all options see:
# https://felixkratz.github.io/SketchyBar/config/bar # https://felixkratz.github.io/SketchyBar/config/bar
# If you are looking for other colors, see the color picker: # If you are looking for other colors, see the color picker:
# https://felixkratz.github.io/SketchyBar/config/tricks#color-picker # https://felixkratz.github.io/SketchyBar/config/tricks#color-picker
sketchybar --bar height=32 \ sketchybar --bar position=top height=40 blur_radius=30 color=0x40000000
blur_radius=30 \
position=top \
sticky=off \
padding_left=10 \
padding_right=10 \
color=0x15ffffff
##### Changing Defaults ##### ##### Changing Defaults #####
# We now change some default values that are applied to all further items # We now change some default values, which are applied to all further items.
# For a full list of all available item properties see: # For a full list of all available item properties see:
# https://felixkratz.github.io/SketchyBar/config/items # https://felixkratz.github.io/SketchyBar/config/items
sketchybar --default icon.font="Hack Nerd Font:Bold:17.0" \ default=(
icon.color=0xffffffff \ padding_left=5
label.font="Hack Nerd Font:Bold:14.0" \ padding_right=5
label.color=0xffffffff \ icon.font="Hack Nerd Font:Bold:17.0"
padding_left=5 \ label.font="Hack Nerd Font:Bold:14.0"
padding_right=5 \ icon.color=0xffffffff
label.padding_left=4 \ label.color=0xffffffff
label.padding_right=4 \ icon.padding_left=4
icon.padding_left=4 \
icon.padding_right=4 icon.padding_right=4
label.padding_left=4
label.padding_right=4
)
sketchybar --default "${default[@]}"
##### Adding Mission Control Space Indicators ##### ##### Adding Mission Control Space Indicators #####
# Now we add some mission control spaces: # Let's add some mission control spaces:
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item # https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
# to indicate active and available mission control spaces # to indicate active and available mission control spaces.
SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10")
for i in "${!SPACE_ICONS[@]}" for i in "${!SPACE_ICONS[@]}"
do do
sid=$(($i+1)) sid="$(($i+1))"
sketchybar --add space space.$sid left \ space=(
--set space.$sid space=$sid \ space="$sid"
icon=${SPACE_ICONS[i]} \ icon="${SPACE_ICONS[i]}"
background.color=0x44ffffff \ icon.padding_left=7
background.corner_radius=5 \ icon.padding_right=7
background.height=20 \ background.color=0x40ffffff
background.drawing=off \ background.corner_radius=5
label.drawing=off \ background.height=25
script="$PLUGIN_DIR/space.sh" \ label.drawing=off
script="$PLUGIN_DIR/space.sh"
click_script="yabai -m space --focus $sid" click_script="yabai -m space --focus $sid"
)
sketchybar --add space space."$sid" left --set space."$sid" "${space[@]}"
done done
##### Adding Left Items ##### ##### Adding Left Items #####
# We add some regular items to the left side of the bar # 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 # only the properties deviating from the current defaults need to be set
sketchybar --add item space_separator left \ sketchybar --add item chevron left \
--set space_separator icon= \ --set chevron icon= label.drawing=off \
padding_left=10 \
padding_right=10 \
label.drawing=off \
\
--add item front_app left \ --add item front_app left \
--set front_app script="$PLUGIN_DIR/front_app.sh" \ --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \
icon.drawing=off \
--subscribe front_app front_app_switched --subscribe front_app front_app_switched
##### Adding Right Items ##### ##### Adding Right Items #####
@ -85,21 +79,13 @@ sketchybar --add item space_separator left \
# https://felixkratz.github.io/SketchyBar/config/events # https://felixkratz.github.io/SketchyBar/config/events
sketchybar --add item clock right \ sketchybar --add item clock right \
--set clock update_freq=10 \ --set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \
icon= \
script="$PLUGIN_DIR/clock.sh" \
\
--add item volume right \ --add item volume right \
--set volume script="$PLUGIN_DIR/volume.sh" \ --set volume script="$PLUGIN_DIR/volume.sh" \
--subscribe volume volume_change \ --subscribe volume volume_change \
\
--add item battery right \ --add item battery right \
--set battery script="$PLUGIN_DIR/battery.sh" \ --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \
update_freq=120 \
--subscribe battery system_woke power_source_change --subscribe battery system_woke power_source_change
##### Finalizing Setup ##### ##### Force all scripts to run the first time (never do this in a script) #####
# The below command is only needed at the end of the initial configuration to
# force all scripts to run the first time, it should never be run in an item script.
sketchybar --update sketchybar --update