Update .yabairc

This commit is contained in:
Kasper Juul Hermansen 2023-09-01 12:14:22 +02:00
parent 1f0835d5d9
commit ce76036080
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -53,32 +53,60 @@ yabai -m config \
#external_monitor=$(yabai -m query --displays | jq -r 'map(select(.external == 1)) | .[].index' | tr -d '\n') #external_monitor=$(yabai -m query --displays | jq -r 'map(select(.external == 1)) | .[].index' | tr -d '\n')
window_numbers=$(yabai -m query --spaces \ # window_numbers=$(yabai -m query --displays \
| jq '.[].index' \ # | jq -r 'map(select(.uuid == "37D8832A-2D66-02CA-B9F7-8F30A301B230")) | .[].spaces | .[]' \
| xargs -I{} yabai -m query --windows --space {} \ # | xargs -I{} yabai -m query --windows --space {} \
| jq -r 'map(select(."is-minimized" == false)) | length') # | jq -r 'map(select(."is-minimized" == false)) | length')
di=1 output=$(yabai -m query --displays \
for wn in $window_numbers; do | jq -r 'map(select(.uuid == "37D8832A-2D66-02CA-B9F7-8F30A301B230")) | .[].spaces | .[]' \
p=$((wn == 1 ? 200 : 20)) | xargs -I{} yabai -m query --windows --space {} \
| jq -r 'map(select(."is-minimized" == false))' \
| jq -c '[if length > 0 then {space: .[0].space, length: length} else empty end] | .[]')
echo "$output" | while read -r line; do
scale=40
space=$(echo "$line" | jq -r '.space')
length=$(echo "$line" | jq -r '.length')
p=$((length == 1 ? $scale : 20))
di="$space"
yabai -m config --space $di top_padding $p yabai -m config --space $di top_padding $p
yabai -m config --space $di bottom_padding $p yabai -m config --space $di bottom_padding $p
yabai -m config --space $di left_padding $p yabai -m config --space $di left_padding $p
yabai -m config --space $di right_padding $p yabai -m config --space $di right_padding $p
done
output=$(yabai -m query --displays \
| jq -r 'map(select(.uuid == "04D18502-16C9-45C6-8D4E-F6DAA26C5AB6")) | .[].spaces | .[]' \
| xargs -I{} yabai -m query --windows --space {} \
| jq -r 'map(select(."is-minimized" == false))' \
| jq -c '[if length > 0 then {space: .[0].space, length: length} else empty end] | .[]')
di=$((di+1)) echo "$output" | while read -r line; do
scale=200
space=$(echo "$line" | jq -r '.space')
length=$(echo "$line" | jq -r '.length')
p=$((length == 1 ? $scale : 20))
di="$space"
yabai -m config --space $di top_padding $p
yabai -m config --space $di bottom_padding $p
yabai -m config --space $di left_padding $p
yabai -m config --space $di right_padding $p
done done
# padding signals # padding signals
padding_refresh_command="p=\$((\$(yabai -m query --windows --space | jq 'map(select(.\"is-minimized\" == false)) | length') == 1 ? 200 : 20)) && \ #padding_refresh_command="p=\$((\$(yabai -m query --windows --space | jq 'map(select(.\"is-minimized\" == false)) | length') == 1 ? 200 : 20)) && \
yabai -m config --space mouse top_padding \$p && \ # yabai -m config --space mouse top_padding \$p && \
yabai -m config --space mouse bottom_padding \$p && \ # yabai -m config --space mouse bottom_padding \$p && \
yabai -m config --space mouse left_padding \$p && \ # yabai -m config --space mouse left_padding \$p && \
yabai -m config --space mouse right_padding \$p" # yabai -m config --space mouse right_padding \$p"
padding_refresh_command="~/bin/refresh-yabai-padding.sh"
yabai -m signal --add event=window_created action="$padding_refresh_command" yabai -m signal --add event=window_created action="$padding_refresh_command"
yabai -m signal --add event=window_destroyed action="$padding_refresh_command" yabai -m signal --add event=window_destroyed action="$padding_refresh_command"
yabai -m signal --add event=application_launched action="$padding_refresh_command" yabai -m signal --add event=application_launched action="$padding_refresh_command"