How can I change ID of display and space? #1607
-
I have three monitors. If this is not possible |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The space numbering is handled by macOS and is not something we can override. You can assign labels to spaces in yabai upon startup, which you can refer to in Yabai-related commands that operate on spaces, which will allow for the sort of keybindings that you are trying to create. I have not looked into very much details with regards to the display situation. You can probably change the arrangement of your displays in the Display section of System Settings/Preferences, or use some external tool for display management. Yabai does not offer any feature to customize this. |
Beta Was this translation helpful? Give feedback.
-
I have 4 monitors (if you include my mac laptop). I wanted to refer to my displays consistently from left to right, with the display farthest on the left being display 1. My laptop is my primary monitor and happens to be in position 3 when ordered from left to right. I have 9 spaces configured for my primary display. This is how I made that happen. It's not the most elegant solution, but it works for me. I have a script called #!/usr/bin/env sh
case "${1}" in
display_added|display_removed|display_initialize)
yabai -m query --displays | jq -r 'sort_by(.frame.x) | .[].index' | xargs > ~/.config/yabai/env/displays.txt
;;
*)
echo "'${1}' not a recognized option."
esac In my ~/.yabairc, I have the following to call that script and use the output. ${HOME}/bin/yabai_ctl.sh display_initialize &> /dev/null
readarray -d ' ' -t screens < ${Y_ENV_DIR}/displays.txt
# When I have 4 displays, I know I want 3 to be my primary.
PRIMARY_DISPLAY=${screens[3]}
MAX_SPACES=9
yabai -m config external_bar all:32:0 \
layout bsp \
window_border on \
window_border_width $D_WINDOW_BORDER_WIDTH \
normal_window_border_color $D_NORMAL_BORDER_COLOR \
active_window_border_color $D_ACTIVE_BORDER_COLOR \
top_padding $D_WINDOW_PADDING \
bottom_padding $D_WINDOW_PADDING \
left_padding $D_WINDOW_PADDING \
right_padding $D_WINDOW_PADDING \
window_gap $D_WINDOW_PADDING \
auto_balance off \
split_ratio 0.5 \
window_shadow off \
window_animation_duration 0.0 \
window_opacity on \
active_window_opacity 1.0 \
normal_window_opacity 0.9 \
mouse_follows_focus on
# debug_output on
#
# setup spaces
#
for i in $(yabai -m query --spaces | jq ".[] | select((.display == ${PRIMARY_DISPLAY:=1}) and .index > $MAX_SPACES).index"); do
echo yabai -m space --destroy $i
done
function setup_space {
local idx="$1"
local name="$2"
local space=
echo "setup space $idx : $name"
space=$(yabai -m query --spaces --space "$idx")
if [ -z "$space" ]; then
yabai -m space --create
fi
yabai -m space "$idx" --label "$name"
}
setup_space 1 emacs
setup_space 2 web
setup_space 3 outlook
setup_space 4 chime
setup_space 5 firefox
setup_space 6 other
setup_space 7 slack
setup_space 8 kiwi
setup_space 9 term
# rules, etc....
yabai -m signal --add event=display_added action="${HOME}/bin/yabai_ctl.sh display_added &> /dev/null; skhd -r"
yabai -m signal --add event=display_removed action="${HOME}/bin/yabai_ctl.sh display_removed &> /dev/null; skhd -r" Sorry this is so long. I need to get my config files in Github and possibly write a blog post about this. |
Beta Was this translation helpful? Give feedback.
The space numbering is handled by macOS and is not something we can override. You can assign labels to spaces in yabai upon startup, which you can refer to in Yabai-related commands that operate on spaces, which will allow for the sort of keybindings that you are trying to create.
I have not looked into very much details with regards to the display situation. You can probably change the arrangement of your displays in the Display section of System Settings/Preferences, or use some external tool for display management. Yabai does not offer any feature to customize this.