myshov / xkbswitch-macosx

Console keyboard layout switcher for MacOS
218 stars 26 forks source link

Extremely slow on Big Sur #13

Closed NightMachinery closed 3 years ago

NightMachinery commented 3 years ago
❯ time2 xkbswitch -ge
Persian-ISIRI2901

Took 6.962615966796875

This happens with my own objective-c script, as well:

// #!/usr/bin/env scriptisto

#import <Foundation/Foundation.h>
#include <Carbon/Carbon.h>

// scriptisto-begin
// script_src: main.m
// build_cmd: clang -framework Carbon -framework Foundation main.m -o ./script
// scriptisto-end

int main (int argc, const char * argv[]) {
  TISInputSourceRef current_source = TISCopyCurrentKeyboardInputSource();
  NSString *s = (__bridge NSString *)(TISGetInputSourceProperty(current_source, kTISPropertyInputSourceID));
  // get last part of string (without com.apple.keylayout.)
  NSUInteger last_dot_num = [s rangeOfString:@"." options:NSBackwardsSearch].location;
  NSString *substring = [s substringFromIndex:last_dot_num + 1];
  printf("%s", [substring UTF8String]);

  return 0;
}

I guess the API is now broken?

myshov commented 3 years ago

@NightMachinary hi! Unfortunatelly I don't have an access to a mac with Big Sur. Did you try to reproduce the problem on the different machine running on Big Sur?

NightMachinery commented 3 years ago

@myshov commented on Mar 8, 2021, 5:31 PM GMT+3:30:

@NightMachinary hi!
Unfortunatelly I don't have an access to a mac with Big Sur. Did you try to reproduce the problem on the different machine running on Big Sur?

Hi! Hmm ... I'll ask a friend to check it as well. Sth worth noting is that hammerspoon can still get the input language without delay, but I don't know what API they use:

hammerspoon -A -c 'hs.keycodes.currentSourceID()'
NightMachinery commented 3 years ago

It is no longer slow for me now. I guess the bug is really complicated. :(

myshov commented 3 years ago

@NightMachinary I think this bug was not related to the utility, so I close this issue. Feel free to reopen the issue if you will be able to reproduce it