feat(darwin): add sketchybar
to yabai
module
This commit is contained in:
parent
7df97750b7
commit
89d280b7af
10 changed files with 288 additions and 9 deletions
|
@ -29,10 +29,24 @@ in
|
||||||
skhdConfig = (builtins.readFile ./skhdrc);
|
skhdConfig = (builtins.readFile ./skhdrc);
|
||||||
};
|
};
|
||||||
|
|
||||||
# sketchybar = {
|
sketchybar = {
|
||||||
# enable = true;
|
enable = true;
|
||||||
# package = pkgs.sketchybar;
|
package = pkgs.sketchybar;
|
||||||
# };
|
extraPackages = with pkgs; [
|
||||||
|
jq
|
||||||
|
];
|
||||||
|
config = import ./sketchybar;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# For sketchybar
|
||||||
|
homebrew = {
|
||||||
|
taps = [
|
||||||
|
"shaunsingh/SFMono-Nerd-Font-Ligaturized"
|
||||||
|
];
|
||||||
|
casks = [
|
||||||
|
"font-sf-mono-nerd-font-ligaturized"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
164
modules/nix-darwin/yabai/sketchybar/default.nix
Executable file
164
modules/nix-darwin/yabai/sketchybar/default.nix
Executable file
|
@ -0,0 +1,164 @@
|
||||||
|
let
|
||||||
|
plugin_dir = ./plugins;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
PLUGIN_DIR="${plugin_dir}"
|
||||||
|
|
||||||
|
##### Bar Appearance #####
|
||||||
|
BACKGROUND_COLOR="0x502a2d3d"
|
||||||
|
|
||||||
|
appearance=''$''\(defaults read -g AppleInterfaceStyle''\)
|
||||||
|
|
||||||
|
if [[ ''$''\{appearance''\} != 'Dark' ]]; then
|
||||||
|
BACKGROUND_COLOR="0x50f5f0f5"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sketchybar --bar height="32" \
|
||||||
|
blur_radius="25" \
|
||||||
|
position="top" \
|
||||||
|
sticky="on" \
|
||||||
|
margin="10" \
|
||||||
|
color="0x002a2d3d" \
|
||||||
|
notch_offset="5" \
|
||||||
|
corner_radius="12" \
|
||||||
|
border_color="0x80c4a7e7" \
|
||||||
|
border_width="0"
|
||||||
|
|
||||||
|
##### Changing Defaults #####
|
||||||
|
# We now change some default values that are applied to all further items
|
||||||
|
# For a full list of all available item properties see:
|
||||||
|
# https://felixkratz.github.io/SketchyBar/config/items
|
||||||
|
|
||||||
|
sketchybar --default updates="when_shown" \
|
||||||
|
icon.font="SF Pro Rounded:Bold:14.0" \
|
||||||
|
icon.color="0xffc6ceef" \
|
||||||
|
label.font="SF Pro Rounded:Bold:14.0" \
|
||||||
|
label.color="0xffc6ceef" \
|
||||||
|
padding_left="3" \
|
||||||
|
padding_right="3" \
|
||||||
|
label.padding_left="4" \
|
||||||
|
label.padding_right="4" \
|
||||||
|
icon.padding_left="4" \
|
||||||
|
icon.padding_right="4"
|
||||||
|
|
||||||
|
##### Adding Mission Control Space Indicators #####
|
||||||
|
# Now we 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" "11" "12" "13" "14" "15" "16")
|
||||||
|
|
||||||
|
for i in "''$''\{!SPACE_ICONS[@]''\}"; do
|
||||||
|
sid=$(($i+1))
|
||||||
|
sketchybar --add space space.''$''\{sid''\} left \
|
||||||
|
--set space.''$''\{sid''\} associated_space="''$''\{sid''\}" \
|
||||||
|
icon="''$''\{SPACE_ICONS[i]''\}" \
|
||||||
|
background.color="0x44ffffff" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
background.height="20" \
|
||||||
|
background.drawing="on" \
|
||||||
|
background.border_color="0x952a2d3d" \
|
||||||
|
background.border_width="1" \
|
||||||
|
label.drawing="off" \
|
||||||
|
script="''$''\{PLUGIN_DIR''\}/space.sh" \
|
||||||
|
click_script="yabai -m space --focus ''$''\{sid''\}"
|
||||||
|
done
|
||||||
|
|
||||||
|
##### Adding Left Items #####
|
||||||
|
# We add some regular items to the left side of the bar
|
||||||
|
# only the properties deviating from the current defaults need to be set
|
||||||
|
|
||||||
|
sketchybar --add item space_separator left \
|
||||||
|
--set space_separator icon="λ" \
|
||||||
|
icon.color="0xffff946f" \
|
||||||
|
padding_left="10" \
|
||||||
|
padding_right="10" \
|
||||||
|
label.drawing="off" \
|
||||||
|
\
|
||||||
|
--add item front_app left \
|
||||||
|
--set front_app script="''$''\{PLUGIN_DIR''\}/front_app.sh" \
|
||||||
|
icon.drawing="off" \
|
||||||
|
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
blur_radius="30" \
|
||||||
|
background.border_color="0x80c4a7e7" \
|
||||||
|
background.border_width="1" \
|
||||||
|
--subscribe front_app front_app_switched
|
||||||
|
|
||||||
|
##### Adding Right Items #####
|
||||||
|
# In the same way as the left items we can add items to the right side.
|
||||||
|
# Additional position (e.g. center) are available, see:
|
||||||
|
# https://felixkratz.github.io/SketchyBar/config/items#adding-items-to-sketchybar
|
||||||
|
|
||||||
|
# Some items refresh on a fixed cycle, e.g. the clock runs its script once
|
||||||
|
# every 10s. Other items respond to events they subscribe to, e.g. the
|
||||||
|
# volume.sh script is only executed once an actual change in system audio
|
||||||
|
# volume is registered. More info about the event system can be found here:
|
||||||
|
# https://felixkratz.github.io/SketchyBar/config/events
|
||||||
|
|
||||||
|
sketchybar --add item test right \
|
||||||
|
--set test script="''$''\{PLUGIN_DIR''\}/theme.sh" \
|
||||||
|
icon="" \
|
||||||
|
background.height="30" \
|
||||||
|
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
icon.padding_left="10" \
|
||||||
|
icon.padding_right="13" \
|
||||||
|
blur_radius="30" \
|
||||||
|
background.border_color="0x80c4a7e7" \
|
||||||
|
background.border_width="1" \
|
||||||
|
label.drawing="off" \
|
||||||
|
click_script="~/.dotfiles/macos/wallpapers.zsh" \
|
||||||
|
--add item clock right i \
|
||||||
|
--set clock update_freq="10" \
|
||||||
|
icon="" \
|
||||||
|
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
icon.padding_left="10" \
|
||||||
|
label.padding_right="10" \
|
||||||
|
blur_radius="30" \
|
||||||
|
background.border_color="0x80c4a7e7" \
|
||||||
|
background.border_width="1" \
|
||||||
|
script="''$''\{PLUGIN_DIR''\}/clock.sh" \
|
||||||
|
\
|
||||||
|
--add item wifi right \
|
||||||
|
--set wifi script="''$''\{PLUGIN_DIR''\}/wifi.sh" \
|
||||||
|
icon="" \
|
||||||
|
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
icon.padding_left="10" \
|
||||||
|
label.padding_right="10" \
|
||||||
|
blur_radius="30" \
|
||||||
|
background.border_color="0x80c4a7e7" \
|
||||||
|
background.border_width="1" \
|
||||||
|
--subscribe wifi wifi_change \
|
||||||
|
\
|
||||||
|
--add item volume right \
|
||||||
|
--set volume script="''$''\{PLUGIN_DIR''\}/volume.sh" \
|
||||||
|
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
icon.padding_left="10" \
|
||||||
|
label.padding_right="10" \
|
||||||
|
blur_radius="30" \
|
||||||
|
background.border_color="0x80c4a7e7" \
|
||||||
|
background.border_width="1" \
|
||||||
|
--subscribe volume volume_change \
|
||||||
|
\
|
||||||
|
--add item battery right \
|
||||||
|
--set battery script="''$''\{PLUGIN_DIR''\}/battery.sh" \
|
||||||
|
update_freq="120" \
|
||||||
|
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||||
|
background.corner_radius="7" \
|
||||||
|
icon.padding_left="10" \
|
||||||
|
label.padding_right="10" \
|
||||||
|
blur_radius="30" \
|
||||||
|
background.border_color="0x80c4a7e7" \
|
||||||
|
background.border_width="1" \
|
||||||
|
--subscribe battery system_woke power_source_change \
|
||||||
|
|
||||||
|
##### Finalizing Setup #####
|
||||||
|
# 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
|
||||||
|
''
|
34
modules/nix-darwin/yabai/sketchybar/plugins/battery.sh
Executable file
34
modules/nix-darwin/yabai/sketchybar/plugins/battery.sh
Executable 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}%"
|
8
modules/nix-darwin/yabai/sketchybar/plugins/clock.sh
Executable file
8
modules/nix-darwin/yabai/sketchybar/plugins/clock.sh
Executable 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')"
|
||||||
|
|
8
modules/nix-darwin/yabai/sketchybar/plugins/front_app.sh
Executable file
8
modules/nix-darwin/yabai/sketchybar/plugins/front_app.sh
Executable 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}"
|
23
modules/nix-darwin/yabai/sketchybar/plugins/space.sh
Executable file
23
modules/nix-darwin/yabai/sketchybar/plugins/space.sh
Executable 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
|
1
modules/nix-darwin/yabai/sketchybar/plugins/theme.sh
Executable file
1
modules/nix-darwin/yabai/sketchybar/plugins/theme.sh
Executable file
|
@ -0,0 +1 @@
|
||||||
|
#!/bin/sh
|
18
modules/nix-darwin/yabai/sketchybar/plugins/volume.sh
Executable file
18
modules/nix-darwin/yabai/sketchybar/plugins/volume.sh
Executable 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}%"
|
8
modules/nix-darwin/yabai/sketchybar/plugins/wifi.sh
Executable file
8
modules/nix-darwin/yabai/sketchybar/plugins/wifi.sh
Executable 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}"
|
|
@ -6,8 +6,8 @@ launchctl unload -F /System/Library/LaunchAgents/com.apple.WindowManager.plist >
|
||||||
sudo yabai --load-sa
|
sudo yabai --load-sa
|
||||||
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
|
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
|
||||||
yabai -m signal --add event=window_focused action="sketchybar --trigger window_focus"
|
yabai -m signal --add event=window_focused action="sketchybar --trigger window_focus"
|
||||||
yabai -m signal --add event=display_added action="sleep 2 && ${HOME}/.config/yabai/create_spaces.sh"
|
# yabai -m signal --add event=display_added action="sleep 2 && ${HOME}/.config/yabai/create_spaces.sh"
|
||||||
yabai -m signal --add event=display_removed action="sleep 1 && ${HOME}/.config/yabai/create_spaces.sh"
|
# yabai -m signal --add event=display_removed action="sleep 1 && ${HOME}/.config/yabai/create_spaces.sh"
|
||||||
yabai -m signal --add event=window_created action="sketchybar --trigger windows_on_spaces"
|
yabai -m signal --add event=window_created action="sketchybar --trigger windows_on_spaces"
|
||||||
yabai -m signal --add event=window_destroyed action="sketchybar --trigger windows_on_spaces"
|
yabai -m signal --add event=window_destroyed action="sketchybar --trigger windows_on_spaces"
|
||||||
yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
|
yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
|
||||||
|
@ -53,6 +53,7 @@ yabai -m config "external_bar" "all:49:0" \
|
||||||
"window_opacity_duration" "0.15" \
|
"window_opacity_duration" "0.15" \
|
||||||
"active_window_opacity" "1.0" \
|
"active_window_opacity" "1.0" \
|
||||||
"normal_window_opacity" "0.95" \
|
"normal_window_opacity" "0.95" \
|
||||||
|
"window_border_blur" "off" \
|
||||||
"window_border_width" "2" \
|
"window_border_width" "2" \
|
||||||
"window_border_hidpi" "off" \
|
"window_border_hidpi" "off" \
|
||||||
"window_border_radius" "11" \
|
"window_border_radius" "11" \
|
||||||
|
@ -77,7 +78,7 @@ yabai -m config "external_bar" "all:49:0" \
|
||||||
yabai -m rule --add app="^(LuLu|Vimac|Calculator|Software Update|Dictionary|VLC|System Preferences|System Settings|zoom.us|Photo Booth|Archive Utility|Python|LibreOffice|App Store|Steam|Alfred|Activity Monitor)$" manage=off
|
yabai -m rule --add app="^(LuLu|Vimac|Calculator|Software Update|Dictionary|VLC|System Preferences|System Settings|zoom.us|Photo Booth|Archive Utility|Python|LibreOffice|App Store|Steam|Alfred|Activity Monitor)$" manage=off
|
||||||
yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off
|
yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off
|
||||||
yabai -m rule --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off
|
yabai -m rule --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off
|
||||||
yabai -m rule --add label="About This Mac" app="System Information" title="About This Mac" manage=off
|
yabai -m rule --add label="System Information" app="System Information" title="System Information" manage=off
|
||||||
yabai -m rule --add label="Select file to save to" app="^Inkscape$" title="Select file to save to" manage=off
|
yabai -m rule --add label="Select file to save to" app="^Inkscape$" title="Select file to save to" manage=off
|
||||||
|
|
||||||
yabai -m config layout bsp
|
yabai -m config layout bsp
|
||||||
|
|
Loading…
Reference in a new issue