Comments (2)
Ok, I remove label from bad space, and add to created.
But windows from old web
moved to first space on main display. how I can reassign windows to spaces? Only remove and create rules again?
from yabai.
Script for display_added
, display_removed
events, and in yabairc
:
#!/bin/bash
function find_free_space() {
yabai -m query --spaces | jq -e '[.[] | select (.label == "" and ."is-native-fullscreen" == false)][0].index'
}
function has_space() {
yabai -m query --spaces | jq -e --arg label "$1" '.[] | select(.label == $label)' > /dev/null 2>&1
}
function has_bad_space() {
# # https://github.com/koekeishiya/yabai/issues/1853
yabai -m query --spaces --space "$1" > /dev/null 2>&1
}
function setup_space() {
has_space $1
if [ $? -eq 0 ]; then
echo "space $1 already exists"
return
fi
# unlabel bad space
has_bad_space $1
if [ $? -eq 0 ]; then
echo "space $1 is bad, remove label"
yabai -m space $1 --label
fi
# find free space or create a new one
idx=$(find_free_space)
if [ $? -ne 0 ]; then
echo "create new space for $1"
yabai -m space --create
idx=$(find_free_space)
else
echo "use existing space $idx for $1"
fi
yabai -m space "$idx" --label "$1"
}
echo "Setup spaces"
setup_space media
setup_space support
setup_space chats
setup_space web
setup_space work
setup_space tmp
echo "Normalizing spaces"
# when there are more than one display
if [ "$(yabai -m query --displays | jq -r '. | length')" -gt 1 ]; then
IFS=' ' read -r -a indexes <<< $(yabai -m query --displays | jq -r 'sort_by(.frame.y) | "\(.[0].index) \(.[1].index)"')
# 'web' and 'chats' spaces are on the top display
yabai -m space web --display "${indexes[0]}"
yabai -m space chats --display "${indexes[0]}"
yabai -m space media --display "${indexes[1]}"
yabai -m space support --display "${indexes[1]}"
yabai -m space work --display "${indexes[1]}"
yabai -m space tmp --display "${indexes[1]}"
# all fullscreen windows are on the main display
IFS=' ' read -r -a fullscreen <<< $(yabai -m query --spaces | jq -r '[.[] | select (."is-native-fullscreen" == true) | .index] | join(" ")')
for i in "${fullscreen[@]}"; do
yabai -m space "$i" --display "${indexes[1]}"
done
fi
# Destroy not used spaces
IFS=' ' read -r -a not_used <<< $(yabai -m query --spaces | jq -r '[.[] | select (.label == "" and ."is-native-fullscreen" == false) | .index] | join(" ")')
for i in "${not_used[@]}"; do
echo "Destroying not used space $i"
yabai -m space "$i" --destroy
done
# TODO: need remove and add rules for spaces
from yabai.
Related Issues (20)
- Is there a way to detect the toggle status of a scratchpad?
- yabai is not working after updating macos HOT 4
- Yabai manage=off is not working. HOT 5
- Yabai unable to manage Windows apps installed using whiskey
- When moving an unmanaged/floating window to next display, it disappears HOT 8
- Extend stack window sel to support indices
- `query --windows` take a very long time HOT 2
- Create n space on display 1 with 2 displays connected results in n-1 on main and 1 on the other display
- Emacs (emacs-mac) on macos goes haywire HOT 2
- Incorrect stack window is focused
- gtk apps are broken visually
- Struggling to get windows focused correctly
- Release windows when dragging another one
- Consistently failed to load scripting addition HOT 2
- Prevent scripting addition from loading when Yabai starts HOT 2
- ffm only on space change?
- Focus lost if you try to move bewteen workspaces after moving between displays
- How to move yabai into the future? ideas / visions / cross OS / nested layouts / new JS like action/selection language HOT 2
- How to make the app unmanaged by yabai invisible when the app lost focus HOT 1
- manage=off not working for WhatsApp HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yabai.