Skip to content

Commit 65912b5

Browse files
committed
fix(yabai): clear stale startup state
Run yabai through a launchd shell command that removes stale per-user lock and socket files before execing the stable TCC shim. Keep the shim itself as a copied yabai binary so Accessibility permissions remain attached to the stable filesystem path.
1 parent 78ad17e commit 65912b5

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

modules/darwin/desktop/wms/yabai/default.nix

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ let
2323
)
2424
+ lib.optionalString (yabaiExtraConfig != "") ("\n" + yabaiExtraConfig + "\n")
2525
);
26+
yabaiStablePath = "${userHome}/.local/bin/yabai-stable";
27+
yabaiStartupCommand = ''
28+
user_name="$USER"
29+
if [ -z "$user_name" ]; then
30+
user_name="$(id -un)"
31+
fi
32+
33+
if [ -n "$user_name" ]; then
34+
rm -f "/tmp/yabai_$user_name.lock" "/tmp/yabai_$user_name.socket"
35+
fi
36+
37+
exec ${
38+
lib.escapeShellArgs (
39+
[ yabaiStablePath ]
40+
++ lib.optionals (yabaiConfig != { } || yabaiExtraConfig != "") [
41+
"-c"
42+
yabaiConfigFile
43+
]
44+
)
45+
}
46+
'';
2647
in
2748
{
2849
options.khanelinix.desktop.wms.yabai = {
@@ -56,13 +77,11 @@ in
5677
launchd.user.agents.yabai.serviceConfig = {
5778
StandardErrorPath = cfg.logPaths.stderr;
5879
StandardOutPath = cfg.logPaths.stdout;
59-
ProgramArguments = lib.mkForce (
60-
[ "${userHome}/.local/bin/yabai-stable" ]
61-
++ lib.optionals (yabaiConfig != { } || yabaiExtraConfig != "") [
62-
"-c"
63-
"${yabaiConfigFile}"
64-
]
65-
);
80+
ProgramArguments = lib.mkForce [
81+
"/bin/sh"
82+
"-c"
83+
yabaiStartupCommand
84+
];
6685
KeepAlive = lib.mkForce {
6786
PathState = {
6887
"/run/current-system/sw/bin/yabai" = true;

0 commit comments

Comments
 (0)