Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yabai scripting additions are not reloaded after defaults are applied and Dock is restarted #1224

Open
veselyn opened this issue Dec 15, 2024 · 0 comments · May be fixed by #1225
Open

Yabai scripting additions are not reloaded after defaults are applied and Dock is restarted #1224

veselyn opened this issue Dec 15, 2024 · 0 comments · May be fixed by #1225

Comments

@veselyn
Copy link

veselyn commented Dec 15, 2024

I've been experiencing that after rebuild, I cannot use Yabai features that require scripting additions until I manually load them with sudo yabai --load-sa.

From my quick debug session I've noted that:

  • The scripting additions are loaded via a launchd daemon:
    launchd.daemons.yabai-sa = {
    script = "${cfg.package}/bin/yabai --load-sa";
    serviceConfig.RunAtLoad = true;
    serviceConfig.KeepAlive.SuccessfulExit = false;
    };
  • The Dock gets restarted when defaults are applied here:
    ${optionalString (length dock > 0) ''
    # Only restart Dock if current user is logged in
    if pgrep -xu $UID Dock >/dev/null; then
    echo >&2 "restarting Dock..."
    killall Dock || true
    fi
    ''}
  • The order of the activation scripts is correct (defaults are applied before launchd services are configured):
    ${cfg.activationScripts.defaults.text}
    ${cfg.activationScripts.launchd.text}
  • The launchd daemon is loaded only when it is different from the current applied one:
    launchdActivation = basedir: target: ''
    if ! diff '${cfg.build.launchd}/Library/${basedir}/${target}' '/Library/${basedir}/${target}' &> /dev/null; then
    if test -f '/Library/${basedir}/${target}'; then
    echo "reloading service $(basename ${target} .plist)" >&2
    launchctl unload '/Library/${basedir}/${target}' || true
    else
    echo "creating service $(basename ${target} .plist)" >&2
    fi
    if test -L '/Library/${basedir}/${target}'; then
    rm '/Library/${basedir}/${target}'
    fi
    cp -f '${cfg.build.launchd}/Library/${basedir}/${target}' '/Library/${basedir}/${target}'
    launchctl load -w '/Library/${basedir}/${target}'
    fi
    '';

Therefore, unless there are changes to the launchd daemon, it will not run again and inject the scripting additions in the newly started Dock process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant