Răsfoiți Sursa

feat(slack-client): trigger `slack_client.py` only when Slack is launched

Joe 1 an în urmă
părinte
comite
d4f3654a14
2 a modificat fișierele cu 21 adăugiri și 7 ștergeri
  1. 1 1
      .config/skhd/skhdrc
  2. 20 6
      .config/yabai/yabai.py

+ 1 - 1
.config/skhd/skhdrc

@@ -5,7 +5,7 @@ cmd - n : \
 		yabai -m window --focus next || yabai -m window --focus first; \
 	fi
 
-cmd + shift - n : /bin/zsh $XDG_CONFIG_HOME/yabai/yabairc && /usr/bin/env python3 ~/.scripts/slack_client.py
+cmd + shift - n : /bin/zsh $XDG_CONFIG_HOME/yabai/yabairc
 cmd + shift - d: /bin/zsh $HOME/.scripts/lightmode.zsh toggle
 
 cmd - 1 : /bin/zsh $HOME/.scripts/open_application.zsh terminal

+ 20 - 6
.config/yabai/yabai.py

@@ -130,16 +130,16 @@ class BetterDisplay(CLIWrapper):
     ]
 
     def __init__(self):
-        if exists(self._base_args[0]) and self.execute(self._base_args + ["help"], timeout=0.5):
+        if exists(self._base_args[0]) and self.execute(
+            self._base_args + ["help"], timeout=0.5
+        ):
             self._available = True
 
     @property
     def available(self) -> bool:
         return self._available
 
-    def set_brightness(
-        self, display: BetterDisplayDisplay, value: float
-    ):
+    def set_brightness(self, display: BetterDisplayDisplay, value: float):
         self.message(
             ["set", f"-uuid={display.uuid}", "-feature=brightness", f"-value={value}"]
         )
@@ -232,7 +232,6 @@ class Yabai(CLIWrapper):
                 if display:
                     better_display.set_brightness(display, 1)
 
-
     def manage_spaces(self):
         initial_window = self.get_focused_window()
         # Start by making sure that the expected number of spaces are present
@@ -405,6 +404,17 @@ class Yabai(CLIWrapper):
                 f"action=/bin/zsh {XDG_CONFIG_HOME}/surfingkeys/compile.sh",
             ]
         )
+        # Run Slack client script (populating cached values) when Slack is launched
+        self.message(
+            [
+                "signal",
+                "--add",
+                "event=application_launched",
+                "app=Slack",
+                "label=SlackRunSlackClientScript",
+                f"action=/usr/bin/env python3 {HOME}/.scripts/slack_client.py",
+            ]
+        )
         # Check if dark mode settings have been updated when focusing terminal
         self.message(
             [
@@ -419,7 +429,11 @@ class Yabai(CLIWrapper):
 
     def get_focused_window(self) -> Window | None:
         windows = [
-            window for window in [Window(window) for window in loads(self.message(["query", "--windows"]))] if window.has_focus
+            window
+            for window in [
+                Window(window) for window in loads(self.message(["query", "--windows"]))
+            ]
+            if window.has_focus
         ]
         if len(windows) > 0:
             return windows.pop()