Giter Site home page Giter Site logo

xkbswitch-macosx's Introduction

Xkbswitch-macosx

Console keyboard layout switcher for Mac OS X.

The utility for switching current layout in terminal. You can use it whenever you need that functionality (for example, for tmux statusline when one is running in fullscreen terminal). Also you can use it as auxilary utility for vim-xkbswitch plugin for changing the keyboard layout in Mac OS X. The utility should work on all versions of Mac OS X since 10.6.

Vim integration

For integration with vim-xkbswitch you need to install this library and follow instructions from there.

Installation

For installation put executable file from bin directory in any directory in your $PATH variable. For example you can put it into /usr/local/bin with this command (if source files of utility in your Download directory):

$ cp ~/Download/xkbswitch-macosx/bin/xkbswitch /usr/local/bin

Usage:

xkbswitch -g|s [-n|e] [value]
where:
-g - get number of layout
-s - set layout by number of list of layouts
-n - code mode (default mode)
-e - string mode (combine it with -g|s to get current layout name or set layouts by its name)
-l - list all available keyboard layouts (their names)

Examples:

set layout:

$ ./xkbswitch -se RussianWin
$ ./xkbswitch -se US
$ ./xkbswitch -s 2
$ ./xkbswitch -s 1

get current layout:

$ ./xkbswitch -ge
$ ./xkbswitch -g

License

The MIT License (MIT)

Copyright (c) 2015 Alexander Myshov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

xkbswitch-macosx's People

Contributors

cedricgatay avatar dmshvetsov avatar myshov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xkbswitch-macosx's Issues

Утечка памяти + хорошее README

Посмотри пожалуйста обсуждение lyokha/vim-xkbswitch#17

  • Исправить утекший интерфейс
  • Упоминуть в README про xcodebuild
  • Избавиться от бинарников в проекте
  • Поставить ссылку на библитеку для плагина vim-xkbswitch в README этого репозитария

Switching to Chinese/Korean IMEs produce Latin/QWERTY output until switching windows

I'm running into a strange problem where I can use xkbswitch to switch IMEs, but for certain non-Latin input methods, input to the current window comes out as US English until you switch to another window.

Specifically, I've tested on a handful of languages (Arabic, Spanish, English, Japanese-Hiragana, Japanese-Katakana, Korean, Simplified Chinese-Pinyin, Traditional Chinese-Zhuyin), and it only seems to be happening in Korean and Chinese (both Pinyin and Zhuyin) — both East Asian IMEs with alternate modes for English input.

Observations:

  • It's not limited to the GUI terminal.

    I thought it might just be limited to the terminal at first, but then tested by running

    sleep 3 && xkbswitch -s 1 
    

    switching over to Firefox, waiting for the IME to change, and then starting to type. The same thing happens.

  • It's always US English output, even if you're switching from a non-Latin language. (Possibly because US English is the default on my system.)

    If switching from Arabic to Chinese, US English characters still come out, not Arabic or Chinese. Usually, it's normal (single-width) characters, but sometimes (still haven't figured out why/when), it's double-width characters. Originally, this led me to believe that the unexpected US English input I was observing was a sub-mode of the IME that xkbswitch had switched to, but then I noticed the following:

    Both Korean and Chinese IMEs offer some mechanism for inputting US English characters without having to switch back to the English IME (in Zhuyin, caps lock will force all input to Latin/QWERTY; in Korean, holding down <Option> does the same). The behavior described in this issue is not a result of triggering these mechanisms: when this problem begins, <Option-a> outputs ‘å’, which is ordinarily not possible in Zhuyin.

  • xkbswitch appears to preserve some IME statefulness that is not preserved by the standard system keyboard shortcut for switching IMEs.

    This one's kind of hard to explain, so I'll format it as a series of shell commands with comments:

    $ xkbswitch -s 1     # switches to Chinese
    $ asdf               # at this point, input comes out in Latin/QWERTY
    
    # but if I switch to Firefox, the Chinese IME begins working correctly
    # and if I switch back to the terminal...
    
    $ ㄅㄆㄇㄈ            # Chinese continues to work
    $ xkbswitch -s 0     # at that point, I can switch back to English (pulling up this command via readline history)
    $ xkbswitch -s 1     # then back to Chinese
    $ ㄅㄆㄇㄈ            # and it works _without having to switch windows_
    
    # but then if I switch back to English with the system keyboard shortcut (CMD-Space)
    
    $ xkbswitch -s 1     # and switch back to Chinese again
    $ asdf               # then we're back where we started...
    

Thoughts?

Extremely slow on Big Sur

❯ 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?

Pinyin keyboard layout Bug!

image

As you see above. I found the Pinyin keyboard layout bug. the command xkbswitch -gn gets the number works well to use for xkbswitch -sn. but the -ge doesn't work!

Adding a new layout dynamically

This is a great and very useful tool, thank you for taking the time to create it! 👏😊

I was wondering if it would be useful/possible to allow adding a new layout dynamically, e.g.:

xkbswitch -se German

would then result in it being available and set.

screen shot 2018-09-04 at 12 33 57

Instead of getting this message (which totally makes sense, of course):

There is no active layout with name in the default prefix "German"
Trying with the org.unknown.keylayout prefix...
Unable to find an active layout with this name.

I think this would be a great addition since it’d really help with setting up preferred languages in dotfiles. I was/am trying to configure German/Serbian-Latin as my two only keyboard layouts by default and struggled finding a command-line-based solution that wasn’t too hacky. This tool is super clean but only allows for switching/reading, not adding.

Of course, it wouldn’t have to be via -se, it could also be done with its own flag, as long as it allows dynamically adding things. 🙂

I wonder if this feature hasn’t been implemented because of restrictions or something?

Would be a w e s o m e. 🤓

Thanks and let me know if I can help somehow. :)

The binary does not work for macOS with M1 cpu

The binary is compiled for intel processors, so it does not work for M1 cpu:

bad CPU type in executable: xkbswitch

How to compile it for M1 cpu? Please give some instructions to make it work M1 cpu, thanks!

Side question

Alex, this question may not fit your application, but I am new to mac and cannot find an answer. Any way to change the key on mac into key? Is there a text file in mac that I can edit that will change how the modifier keys will work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.