From 57fa9ba298a45d1461ffc7c5be57228f0043d36b Mon Sep 17 00:00:00 2001 From: koekeishiya Date: Mon, 15 Jul 2019 12:46:27 +0200 Subject: [PATCH] #135 restart dock after installing scripting-addition, and tweak info messages --- CHANGELOG.md | 2 ++ src/osax/sa.m | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de7f5837..bbf84c31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Automatically restart Dock.app after installing the scripting-addition, and tweak messages shown when a payload is already loaded [#135](https://github.com/koekeishiya/yabai/issues/135) ## [1.1.2] - 2019-07-15 ### Changed diff --git a/src/osax/sa.m b/src/osax/sa.m index 8addc2fc..f51986da 100644 --- a/src/osax/sa.m +++ b/src/osax/sa.m @@ -220,10 +220,8 @@ static int scripting_addition_perform_validation(void) debug("yabai: osax version = %s, osax attrib = 0x%X\n", version, attrib); if (!string_equals(version, OSAX_VERSION)) { - notify("payload is outdated, please reinstall!", "scripting-addition"); return PAYLOAD_STATUS_OUTDATED; } else if ((attrib & OSAX_ATTRIB_ALL) != OSAX_ATTRIB_ALL) { - notify("payload could not resolve addresses in Dock.app!", "scripting-addition"); return PAYLOAD_STATUS_NO_ATTRIB; } else { char message[MAXLEN]; @@ -295,6 +293,7 @@ int scripting_addition_install(void) } scripting_addition_prepare_binaries(); + scripting_addition_maybe_restart_dock(PAYLOAD_STATUS_NO_ATTRIB); return 0; cleanup: @@ -368,11 +367,17 @@ int scripting_addition_load(void) if (result == OSAX_PAYLOAD_SUCCESS) { debug("yabai: scripting-addition successfully injected payload into Dock.app..\n"); - scripting_addition_perform_validation(); + switch (scripting_addition_perform_validation()) { + case PAYLOAD_STATUS_OUTDATED: notify("payload is outdated, please reinstall!", "scripting-addition"); break; + case PAYLOAD_STATUS_NO_ATTRIB: notify("payload could not resolve addresses in Dock.app!", "scripting-addition"); break; + } return 0; } else if (result == OSAX_PAYLOAD_ALREADY_LOADED) { warn("yabai: scripting-addition payload was already injected into Dock.app!\n"); - scripting_addition_maybe_restart_dock(scripting_addition_perform_validation()); + switch (scripting_addition_perform_validation()) { + case PAYLOAD_STATUS_OUTDATED: notify("an outdated payload is already loaded, please restart Dock.app!", "scripting-addition"); break; + case PAYLOAD_STATUS_NO_ATTRIB: notify("an invalid payload is already loaded, please restart Dock.app!", "scripting-addition"); break; + } return 0; } else if (result == OSAX_PAYLOAD_NOT_LOADED) { notify("failed to inject payload into Dock.app!", "scripting-addition");