feat(darwin): add sketchybar to yabai module

This commit is contained in:
reo101 2023-07-29 17:45:58 +03:00
parent 7df97750b7
commit 89d280b7af
Signed by: reo101
GPG key ID: 675AA7EF13964ACB
10 changed files with 288 additions and 9 deletions
modules/nix-darwin/yabai/sketchybar/plugins

View file

@ -0,0 +1,34 @@
#!/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,8 @@
#!/bin/sh
# 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
sketchybar --set ${NAME} label="$(date '+%d/%m %H:%M')"

View file

@ -0,0 +1,8 @@
#!/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
sketchybar --set ${NAME} label="${INFO}"

View file

@ -0,0 +1,23 @@
#!/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
BACKGROUND_COLOR=0x502a2d3d
HIGHLIGHT_COLOR=0x90faafa6
appearance=$(defaults read -g AppleInterfaceStyle)
if [[ ${appearance} != 'Dark' ]]; then
BACKGROUND_COLOR=0x50f5f0f5
fi
if [ "${SELECTED}" == "true" ]; then
sketchybar --set ${NAME} background.color=${HIGHLIGHT_COLOR}
else
sketchybar --set ${NAME} background.color=${BACKGROUND_COLOR} \
blur_radius=30
fi

View file

@ -0,0 +1 @@
#!/bin/sh

View file

@ -0,0 +1,18 @@
#!/bin/sh
# The volume_change event supplies a ${INFO} variable in which the current volume
# percentage is passed to the script.
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}%"

View file

@ -0,0 +1,8 @@
#!/bin/sh
# The wifi_change event supplies a ${INFO} variable in which the current SSID
# is passed to the script.
WIFI=${INFO:-"Not Connected"}
sketchybar --set ${NAME} label="${WIFI}"