diff --git a/README.md b/README.md index 3747b0b..b1f2f8c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ ## Installation -If you don't have yabai, install yabai (version 4.0.0 required) first: [Official installation guide](https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)) +If you don't have yabai, install yabai (version 4.0.2 required) first: [Official installation guide](https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)) Just download and unzip the latest release of YabaiIndicator from [Releases](https://github.com/xiamaz/YabaiIndicator/releases) and run. Now you should be able to see empty spaces for each desktop and clicking spaces should work. @@ -48,14 +48,6 @@ yabai -m signal --add event=window_minimized action='echo "refresh windows" | nc yabai -m signal --add event=window_deminimized action='echo "refresh windows" | nc -U /tmp/yabai-indicator.socket' ``` -## How it works - -Information on spaces and displays is directly taken from SkyLight API and space and display switches are handled through the NotificationCenter. Unfortunately that is not enough to ensure that the information on the space indicator is correct, as MissionControl can be used to Add/Delete/Reorder spaces. Fortunately MissionControl invocation can be caught via the Accessibility API, as is done by Yabai. - -IPC with easy shell scripting is realized through a UNIX Domain Socket Server, that listens at `/tmp/yabai-indicator.socket`. Currently only a `refresh` message is implemented, which is used to allow yabai signals to modify our UI. - -The Menubar Indicator uses SwiftUI and is integrated into the StatusBarItem as a Subview of the default button. While replacing the StatusBarItem view is being deprecated, this approach should be future-proof for now. - If certain keybinds modify the spaces arrangement the following commands needs to be added to keep the indicator in sync: ``` diff --git a/YabaiIndicator.xcodeproj/project.pbxproj b/YabaiIndicator.xcodeproj/project.pbxproj index bfbc146..0688c77 100644 --- a/YabaiIndicator.xcodeproj/project.pbxproj +++ b/YabaiIndicator.xcodeproj/project.pbxproj @@ -532,7 +532,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 0.3.1; + MARKETING_VERSION = 0.3.2; PRODUCT_BUNDLE_IDENTIFIER = de.arsbrevis.YabaiIndicator; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -567,7 +567,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 0.3.1; + MARKETING_VERSION = 0.3.2; PRODUCT_BUNDLE_IDENTIFIER = de.arsbrevis.YabaiIndicator; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/YabaiIndicator/SocketClient.c b/YabaiIndicator/SocketClient.c index 9abf5d0..28ce3e8 100644 --- a/YabaiIndicator/SocketClient.c +++ b/YabaiIndicator/SocketClient.c @@ -13,7 +13,7 @@ #include #include -#define MAXLEN 256 +#define MAXLEN 512 #define SOCKET_PATH_FMT "/tmp/yabai_%s.socket" #define FAILURE_MESSAGE "\x07" @@ -60,8 +60,10 @@ int send_message(int argc, char** argv, char** response) { message_length += argl[i]; } - char *message = malloc(message_length); - char *temp = message; + char *message = malloc(sizeof(int)+message_length); + char *temp = sizeof(int)+message; + + memcpy(message, &message_length, sizeof(int)); for (int i = 1; i < argc; ++i) { memcpy(temp, argv[i], argl[i]); @@ -71,6 +73,12 @@ int send_message(int argc, char** argv, char** response) { *temp++ = '\0'; int sockfd; + sockfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (sockfd == -1) { + snprintf(*response, BUFSIZ, "yabai-msg: failed to open socket..\n"); + return EXIT_FAILURE; + } + char socket_file[MAXLEN]; snprintf(socket_file, sizeof(socket_file), SOCKET_PATH_FMT, user); @@ -79,7 +87,7 @@ int send_message(int argc, char** argv, char** response) { return EXIT_FAILURE; } - if (send(sockfd, message, message_length, 0) == -1) { + if (send(sockfd, message, sizeof(int)+message_length, 0) == -1) { snprintf(*response, BUFSIZ, "yabai-msg: failed to send data..\n"); return EXIT_FAILURE; }