feat(yabai): update
Add 10th workspace Add `get_menu_bar_height` objc program
This commit is contained in:
parent
22ccaedc94
commit
26cafb1599
7 changed files with 148 additions and 45 deletions
|
@ -35,7 +35,7 @@ in
|
|||
extraPackages = with pkgs; [
|
||||
jq
|
||||
];
|
||||
config = import ./sketchybar;
|
||||
config = import ./sketchybar pkgs;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,28 @@
|
|||
# TODO: AppleSelectedInputSourcesChangedNotification
|
||||
{ lib, darwin, ... }:
|
||||
|
||||
let
|
||||
plugin_dir = ./plugins;
|
||||
util_dir = ./utils;
|
||||
get_menu_bar_height = darwin.apple_sdk.stdenv.mkDerivation {
|
||||
name = "get_menu_bar_height";
|
||||
version = "0.0.1";
|
||||
src = lib.cleanSource ./get_menu_bar_height;
|
||||
buildInputs = with darwin.apple_sdk.frameworks; [
|
||||
Cocoa
|
||||
];
|
||||
buildPhase = ''
|
||||
clang -framework cocoa get_menu_bar_height.m -o get_menu_bar_height
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mv get_menu_bar_height $out/bin/get_menu_bar_height
|
||||
'';
|
||||
};
|
||||
in
|
||||
''
|
||||
PLUGIN_DIR="${plugin_dir}"
|
||||
export PLUGIN_DIR="${plugin_dir}"
|
||||
export UTIL_DIR="${util_dir}"
|
||||
|
||||
##### Bar Appearance #####
|
||||
BACKGROUND_COLOR="0x502a2d3d"
|
||||
|
@ -13,6 +33,8 @@ if [[ ''$''\{appearance''\} != 'Dark' ]]; then
|
|||
BACKGROUND_COLOR="0x50f5f0f5"
|
||||
fi
|
||||
|
||||
height=''$''\(${get_menu_bar_height}/bin/get_menu_bar_height''\)
|
||||
|
||||
sketchybar --bar height="32" \
|
||||
blur_radius="25" \
|
||||
position="top" \
|
||||
|
@ -96,20 +118,7 @@ sketchybar --add item space_separator left \
|
|||
# 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 \
|
||||
sketchybar --add item clock right i \
|
||||
--set clock update_freq="10" \
|
||||
icon="" \
|
||||
background.color="''$''\{BACKGROUND_COLOR''\}" \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main() {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSRect screenRect = [[NSScreen mainScreen] frame];
|
||||
NSRect visibleRect = [[NSScreen mainScreen] visibleFrame];
|
||||
|
||||
// Show the menu bar temporarily to get its height
|
||||
[NSMenu setMenuBarVisible:YES];
|
||||
|
||||
CGFloat menuBarHeight = screenRect.size.height - visibleRect.size.height;
|
||||
printf("%d\n", (int) menuBarHeight);
|
||||
|
||||
// Hide the menu bar again
|
||||
[NSMenu setMenuBarVisible:NO];
|
||||
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vim: ft=objc :
|
|
@ -1,34 +1,77 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
|
||||
source "${UTIL_DIR}/colors.sh"
|
||||
|
||||
BATT_PERCENT=$(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
|
||||
sketchybar --set "${NAME}" icon.color=0xff989898
|
||||
|
||||
if [ ${CHARGING} != "" ]; then
|
||||
ICON=""
|
||||
fi
|
||||
case ${BATT_PERCENT} in
|
||||
100)
|
||||
ICON=""
|
||||
COLOR="${GREEN}"
|
||||
;;
|
||||
9[0-9])
|
||||
ICON=""
|
||||
COLOR="${GREEN}"
|
||||
;;
|
||||
8[0-9])
|
||||
ICON=""
|
||||
COLOR="${GREEN}"
|
||||
;;
|
||||
7[0-9])
|
||||
ICON=""
|
||||
COLOR="${GREEN}"
|
||||
;;
|
||||
6[0-9])
|
||||
ICON=""
|
||||
COLOR="${YELLOW}"
|
||||
;;
|
||||
5[0-9])
|
||||
ICON=""
|
||||
COLOR="${YELLOW}"
|
||||
;;
|
||||
4[0-9])
|
||||
ICON=""
|
||||
COLOR="${ORANGE}"
|
||||
;;
|
||||
3[0-9])
|
||||
ICON=""
|
||||
COLOR="${ORANGE}"
|
||||
;;
|
||||
2[0-9])
|
||||
ICON=""
|
||||
COLOR="${RED}"
|
||||
;;
|
||||
1[0-9])
|
||||
ICON=""
|
||||
COLOR="${RED}"
|
||||
;;
|
||||
*)
|
||||
ICON=""
|
||||
COLOR="${RED}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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}%"
|
||||
sketchybar --set "${NAME}" icon="${ICON}" icon.color="${COLOR}"
|
||||
sketchybar --set "${NAME}" label="${BATT_PERCENT}%"
|
||||
else
|
||||
case ${BATT_PERCENT} in
|
||||
100) ICON="" COLOR="$GREEN" ;;
|
||||
9[0-9]) ICON="" COLOR="$GREEN" ;;
|
||||
8[0-9]) ICON="" COLOR="$GREEN" ;;
|
||||
7[0-9]) ICON="" COLOR="$GREEN" ;;
|
||||
6[0-9]) ICON="" COLOR="$YELLOW" ;;
|
||||
5[0-9]) ICON="" COLOR="$YELLOW" ;;
|
||||
4[0-9]) ICON="" COLOR="$ORANGE" ;;
|
||||
3[0-9]) ICON="" COLOR="$ORANGE" ;;
|
||||
2[0-9]) ICON="" COLOR="$RED" ;;
|
||||
1[0-9]) ICON="" COLOR="$RED" ;;
|
||||
*) ICON="" COLOR="$RED" ;;
|
||||
esac
|
||||
|
||||
sketchybar --set "${NAME}" icon="${ICON}" icon.color="${COLOR}"
|
||||
sketchybar --set "${NAME}" label="${BATT_PERCENT}%"
|
||||
fi
|
||||
|
|
26
modules/nix-darwin/yabai/sketchybar/utils/colors.sh
Normal file
26
modules/nix-darwin/yabai/sketchybar/utils/colors.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Color Palette
|
||||
export BLACK=0xff181926
|
||||
export WHITE=0xffcad3f5
|
||||
export RED=0xffed8796
|
||||
export GREEN=0xffa6da95
|
||||
export BLUE=0xff8aadf4
|
||||
export YELLOW=0xffeed49f
|
||||
export ORANGE=0xfff5a97f
|
||||
export MAGENTA=0xffc6a0f6
|
||||
export GREY=0xff939ab7
|
||||
export TRANSPARENT=0x00000000
|
||||
|
||||
# General bar colors
|
||||
export BAR_COLOR=0xff1e1e2e
|
||||
export BAR_BORDER_COLOR=0xff494d64 #0xa024273a
|
||||
export ICON_COLOR=$WHITE # Color of all icons
|
||||
export LABEL_COLOR=$WHITE # Color of all labels
|
||||
export BACKGROUND_1=0x603c3e4f
|
||||
export BACKGROUND_2=0x60494d64
|
||||
|
||||
export POPUP_BACKGROUND_COLOR=0xff1e1e2e
|
||||
export POPUP_BORDER_COLOR=$WHITE
|
||||
|
||||
export SHADOW_COLOR=$BLACK
|
|
@ -22,6 +22,7 @@ cmd - 6 : yabai -m space --focus 6
|
|||
cmd - 7 : yabai -m space --focus 7
|
||||
cmd - 8 : yabai -m space --focus 8
|
||||
cmd - 9 : yabai -m space --focus 9
|
||||
cmd - 0 : yabai -m space --focus 10
|
||||
cmd - tab : yabai -m space --focus recent
|
||||
# cmd - ; : yabai -m space --focus next
|
||||
|
||||
|
@ -44,6 +45,7 @@ shift + cmd - 6 : yabai -m window --space 6; sketchybar --trigger windows_on_spa
|
|||
shift + cmd - 7 : yabai -m window --space 7; sketchybar --trigger windows_on_spaces
|
||||
shift + cmd - 8 : yabai -m window --space 8; sketchybar --trigger windows_on_spaces
|
||||
shift + cmd - 9 : yabai -m window --space 9; sketchybar --trigger windows_on_spaces
|
||||
shift + cmd - 0 : yabai -m window --space 0; sketchybar --trigger windows_on_spaces
|
||||
|
||||
# Move focus container to workspace
|
||||
shift + alt - m : yabai -m window --space last; yabai -m space --focus last; sketchybar --trigger windows_on_spaces
|
||||
|
@ -58,6 +60,7 @@ shift + alt - 6 : yabai -m window --space 6; yabai -m space --focus 6; sketchyba
|
|||
shift + alt - 7 : yabai -m window --space 7; yabai -m space --focus 7; sketchybar --trigger windows_on_spaces
|
||||
shift + alt - 8 : yabai -m window --space 8; yabai -m space --focus 8; sketchybar --trigger windows_on_spaces
|
||||
shift + alt - 9 : yabai -m window --space 9; yabai -m space --focus 9; sketchybar --trigger windows_on_spaces
|
||||
shift + alt - 0 : yabai -m window --space 0; yabai -m space --focus 9; sketchybar --trigger windows_on_spaces
|
||||
|
||||
# Resize windows
|
||||
lctrl + alt - h : yabai -m window --resize left:-50:0; \
|
||||
|
|
|
@ -12,6 +12,7 @@ yabai -m signal --add event=window_created action="sketchybar --trigger windows_
|
|||
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=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
|
||||
yabai -m signal --add event=display_resized action="launchctl stop org.nixos.sketchybar && launchctl start org.nixos.sketchybar"
|
||||
|
||||
# {
|
||||
# DESIRED_SPACES_PER_DISPLAY=4
|
||||
|
@ -44,7 +45,7 @@ yabai -m signal --add event=application_terminated action="yabai -m query --wind
|
|||
yabai -m config "external_bar" "all:49:0" \
|
||||
"window_border" "on" \
|
||||
"mouse_follows_focus" "off" \
|
||||
"focus_follows_mouse" "autoraise" \
|
||||
"focus_follows_mouse" "off" \
|
||||
"window_zoom_persist" "off" \
|
||||
"window_placement" "second_child" \
|
||||
"window_topmost" "off" \
|
||||
|
|
Loading…
Reference in a new issue