|
|
@@ -123,19 +123,18 @@ class Yabai(CLIWrapper):
|
|
|
def __init__(self):
|
|
|
self._dual_display = len(self.get_displays()) > 1
|
|
|
self.spaces.append(
|
|
|
- (
|
|
|
- "Communication",
|
|
|
- False,
|
|
|
- ["Slack", "Signal", "Spotify"],
|
|
|
- False,
|
|
|
- )
|
|
|
+ (
|
|
|
+ "Communication",
|
|
|
+ False,
|
|
|
+ ["Slack", "Signal", "Spotify"],
|
|
|
+ False,
|
|
|
)
|
|
|
+ )
|
|
|
+ self.spaces.append(("Notetaking", True, ["Obsidian", "Asana", "Notion"], True))
|
|
|
+ self.spaces.append(("Admin", True, ["Notion Calendar", "Notion Mail"], True))
|
|
|
if self._dual_display:
|
|
|
for application in [
|
|
|
"Google Meet",
|
|
|
- "Obsidian",
|
|
|
- "Asana",
|
|
|
- "Notion",
|
|
|
"Netflix",
|
|
|
"YouTube",
|
|
|
]:
|
|
|
@@ -147,12 +146,12 @@ class Yabai(CLIWrapper):
|
|
|
False,
|
|
|
)
|
|
|
)
|
|
|
- else:
|
|
|
- self.spaces.append(("Notetaking", True, ["Obsidian", "Asana", "Notion"], False))
|
|
|
|
|
|
def __enter__(self):
|
|
|
self._initial_window = self.get_focused_window()
|
|
|
- self._initial_spaces = [s for s in self.get_spaces() if s.is_visible and len(s.label)]
|
|
|
+ self._initial_spaces = [
|
|
|
+ s for s in self.get_spaces() if s.is_visible and len(s.label)
|
|
|
+ ]
|
|
|
return self
|
|
|
|
|
|
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any):
|
|
|
@@ -188,7 +187,9 @@ class Yabai(CLIWrapper):
|
|
|
def get_main_display(
|
|
|
self, displays: set[YabaiDisplay] | None = None
|
|
|
) -> YabaiDisplay:
|
|
|
- return sorted(list(displays if displays is not None else self.get_displays()))[-1]
|
|
|
+ return sorted(list(displays if displays is not None else self.get_displays()))[
|
|
|
+ -1
|
|
|
+ ]
|
|
|
|
|
|
def is_blank_space(self, space: Space) -> bool:
|
|
|
return (
|
|
|
@@ -276,16 +277,28 @@ class Yabai(CLIWrapper):
|
|
|
if self._dual_display:
|
|
|
display_by_space_label = {s[0]: 1 if s[-1] else 2 for s in self.spaces}
|
|
|
spaces = self.get_spaces()
|
|
|
- wrong_spaces = [s for s in spaces
|
|
|
- if s.label in display_by_space_label and
|
|
|
- s.display != display_by_space_label[s.label]]
|
|
|
+ wrong_spaces = [
|
|
|
+ s
|
|
|
+ for s in spaces
|
|
|
+ if s.label in display_by_space_label
|
|
|
+ and s.display != display_by_space_label[s.label]
|
|
|
+ ]
|
|
|
wrong_main_spaces = [s for s in wrong_spaces if s.display != 1]
|
|
|
wrong_secondary_spaces = [s for s in wrong_spaces if s.display != 2]
|
|
|
- while len(wrong_main_spaces) and len (wrong_secondary_spaces):
|
|
|
- self.message([ "space", wrong_main_spaces.pop().label, "--swap", wrong_secondary_spaces.pop().label ])
|
|
|
+ while len(wrong_main_spaces) and len(wrong_secondary_spaces):
|
|
|
+ self.message(
|
|
|
+ [
|
|
|
+ "space",
|
|
|
+ wrong_main_spaces.pop().label,
|
|
|
+ "--swap",
|
|
|
+ wrong_secondary_spaces.pop().label,
|
|
|
+ ]
|
|
|
+ )
|
|
|
wrong_spaces = wrong_main_spaces + wrong_secondary_spaces
|
|
|
while len(wrong_spaces) and (space := wrong_spaces.pop().label):
|
|
|
- self.message([ "space", space, "--display", display_by_space_label[space]])
|
|
|
+ self.message(
|
|
|
+ ["space", space, "--display", display_by_space_label[space]]
|
|
|
+ )
|
|
|
info(f"Spaces configured: {sorted(self.get_spaces())}")
|
|
|
|
|
|
def set_space_background(self, space: SpaceSel):
|
|
|
@@ -302,7 +315,9 @@ class Yabai(CLIWrapper):
|
|
|
]
|
|
|
)
|
|
|
|
|
|
- def set_global_config( self,):
|
|
|
+ def set_global_config(
|
|
|
+ self,
|
|
|
+ ):
|
|
|
self.message(["config", "auto_balance", "on"])
|
|
|
self.message(["config", "mouse_follows_focus", "on"])
|
|
|
|
|
|
@@ -411,15 +426,6 @@ class Yabai(CLIWrapper):
|
|
|
]
|
|
|
)
|
|
|
|
|
|
- self.message(
|
|
|
- [
|
|
|
- "signal",
|
|
|
- "--add",
|
|
|
- "event=display_added",
|
|
|
- "label=DisplayBrightnessManager",
|
|
|
- "action=/bin/zsh $DOTFILES_DIR/.scripts/display_brightness.zsh",
|
|
|
- ]
|
|
|
- )
|
|
|
if self._dual_display:
|
|
|
self.message(
|
|
|
[
|
|
|
@@ -442,10 +448,19 @@ class Yabai(CLIWrapper):
|
|
|
"signal",
|
|
|
"--add",
|
|
|
f"event={trigger}",
|
|
|
- f"label=DisplayChange{trigger}",
|
|
|
+ f"label=DisplayChangeYabai{trigger}",
|
|
|
f"action=/usr/bin/env python3 {HOME}/.config/yabai.py manage",
|
|
|
]
|
|
|
)
|
|
|
+ self.message(
|
|
|
+ [
|
|
|
+ "signal",
|
|
|
+ "--add",
|
|
|
+ f"event={trigger}",
|
|
|
+ f"label=DisplayChangeDisplay{trigger}",
|
|
|
+ "action=/bin/zsh $DOTFILES_DIR/.scripts/display_brightness.zsh",
|
|
|
+ ]
|
|
|
+ )
|
|
|
|
|
|
# Rules that differ for one or multiple displays
|
|
|
if not self._dual_display:
|
|
|
@@ -475,6 +490,17 @@ class Yabai(CLIWrapper):
|
|
|
"manage=on",
|
|
|
]
|
|
|
)
|
|
|
+ else:
|
|
|
+ self.message(
|
|
|
+ [
|
|
|
+ "rule",
|
|
|
+ "--add",
|
|
|
+ "label=SlackVideoCallFloatingWindowRule",
|
|
|
+ "app=Slack",
|
|
|
+ "title=Huddle.*",
|
|
|
+ "space=Google Meet",
|
|
|
+ ]
|
|
|
+ )
|
|
|
|
|
|
def move_spaces_to_displays(self):
|
|
|
if not self._dual_display:
|
|
|
@@ -588,10 +614,6 @@ if __name__ == "__main__":
|
|
|
yabai.manage_spaces()
|
|
|
if argv[1] == "initialize":
|
|
|
yabai.set_rules_and_signals()
|
|
|
- if (
|
|
|
- argv[1] == "move"
|
|
|
- or argv[1] == "manage"
|
|
|
- or argv[1] == "initialize"
|
|
|
- ):
|
|
|
+ if argv[1] == "move" or argv[1] == "manage" or argv[1] == "initialize":
|
|
|
yabai.enable_exit_with_refocus()
|
|
|
yabai.move_spaces_to_displays()
|