Full Code of minoki/InputSourceSelector for AI

master bc5fd7261aa7 cached
4 files
6.9 KB
1.7k tokens
1 requests
Download .txt
Repository: minoki/InputSourceSelector
Branch: master
Commit: bc5fd7261aa7
Files: 4
Total size: 6.9 KB

Directory structure:
gitextract_z75ee504/

├── InputSourceSelector.m
├── LICENSE.txt
├── Makefile
└── README.md

================================================
FILE CONTENTS
================================================

================================================
FILE: InputSourceSelector.m
================================================
// An utility to manipulate Input Sources.
// Copyright (c) 2012 ARATA Mizuki
#include <stdio.h>
#include <stdlib.h>
#include <Carbon/Carbon.h>
#include <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
    id pool = [NSAutoreleasePool new];
    if (argc > 1 && (strcmp(argv[1],"list") == 0
                     || strcmp(argv[1],"list-enabled") == 0)) {
        Boolean listAll = strcmp(argv[1],"list") == 0;
        NSArray *inputSources = [(NSArray *)TISCreateInputSourceList(NULL,listAll) autorelease];
        for (NSObject *inputSource in inputSources) {
            NSString *inputSourceID = TISGetInputSourceProperty((TISInputSourceRef)inputSource, kTISPropertyInputSourceID);
            NSString *localizedName = TISGetInputSourceProperty((TISInputSourceRef)inputSource, kTISPropertyLocalizedName);
            printf("%s (%s)\n",[inputSourceID UTF8String],[localizedName UTF8String]);
        }
    } else if (argc > 1 && (strcmp(argv[1],"current") == 0
                            || strcmp(argv[1],"current-layout") == 0)) {
        TISInputSourceRef inputSource
            = strcmp(argv[1],"current-layout") == 0
                ? TISCopyCurrentKeyboardLayoutInputSource()
                : TISCopyCurrentKeyboardInputSource();
        NSString *inputSourceID = TISGetInputSourceProperty(inputSource, kTISPropertyInputSourceID);
        NSString *localizedName = TISGetInputSourceProperty(inputSource, kTISPropertyLocalizedName);
        printf("%s (%s)\n",[inputSourceID UTF8String],[localizedName UTF8String]);
        CFRelease(inputSource);
    } else if (argc > 2 && (strcmp(argv[1],"enable") == 0
                            || strcmp(argv[1],"disable") == 0
                            || strcmp(argv[1],"select") == 0
                            || strcmp(argv[1],"deselect") == 0)) {
        NSString *inputSourceID = [NSString stringWithUTF8String:argv[2]];
        NSDictionary *properties = [NSDictionary dictionaryWithObject:inputSourceID
                                                               forKey:(NSString *)kTISPropertyInputSourceID];
        NSArray *inputSources = [(NSArray *)TISCreateInputSourceList((CFDictionaryRef)properties, true) autorelease];
        if ([inputSources count] == 0) {
            fprintf(stderr,"Specified input source \"%s\" not found\n", argv[2]);
            [pool release];
            return 1;
        }
        TISInputSourceRef inputSource = (TISInputSourceRef)[inputSources objectAtIndex:0];
        if (strcmp(argv[1],"enable") == 0) {
            TISEnableInputSource(inputSource);
        } else if (strcmp(argv[1],"disable") == 0) {
            TISDisableInputSource(inputSource);
        } else if (strcmp(argv[1],"select") == 0) {
            TISSelectInputSource(inputSource);
        } else if (strcmp(argv[1],"deselect") == 0) {
            TISDeselectInputSource(inputSource);
        }
    } else {
        const char usage[]
          = "Usage:\n"
            "   %s [command]\n\n"
            "Available commands:\n"
            "   list                        Lists currently installed input sources.\n"
            "   list-enabled                Lists currently enabled input sources.\n"
            "   current                     Prints currently selected input source.\n"
            "   current-layout              Prints currently used keyboard layout.\n"
            "   enable [input source ID]    Enables specified input source.\n"
            "   disable [input source ID]   Disables specified input source.\n"
            "   select [input source ID]    Selects specified input source.\n"
            "   deselect [input source ID]  Deselects specified input source.\n";
        fprintf(stderr,usage,argv[0]);
    }
    [pool release];
    return 0;
}


================================================
FILE: LICENSE.txt
================================================
MIT License

Copyright (c) 2012-2025 ARATA Mizuki

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.


================================================
FILE: Makefile
================================================
all: InputSourceSelector

InputSourceSelector: InputSourceSelector.m
	$(CC) -o $@ -Wall $< -framework Carbon -framework Foundation


================================================
FILE: README.md
================================================
InputSourceSelector
===================

A utility program to manipulate Input Sources on Mac OS X.
This program is a thin wrapper for [Text Input Sources Services API](https://developer.apple.com/library/mac/documentation/TextFonts/Reference/TextInputSourcesReference/).

Install
=======

Typing
```
$ make
```
on the terminal should generate `InputSourceSelector` executable in the current directory.
Then copy it to somewhere on `$PATH`.

Usage
=====

```
$ InputSourceSelector [command]
```

`[command]` is described below.

Commands
========

* `list` Lists currently installed input sources.
* `list-enabled` Lists currently enabled input sources.
* `current` Prints currently selected input source.
* `current-layout` Prints currently used keyboard layout.
* `enable [input source ID]` Enables specified input source.
* `disable [input source ID]` Disables specified input source.
* `select [input source ID]` Selects specified input source.
* `deselect [input source ID]` Deselects specified input source.

`[input source ID]` is one of the input source IDs printed by `list`,`list-enabled`,`current`,`current-layout` commands,
such as `com.apple.keylayout.US` or `com.apple.inputmethod.Kotoeri.Japanese`.

Examples
========

* List all input sources installed on the system:
```
$ InputSourceSelector list
com.apple.keylayout.Czech-QWERTY (Czech - QWERTY)
com.apple.keylayout.Czech (Czech)
...
com.apple.inputmethod.VietnameseIM.VietnameseVIQR (VIQR)
com.apple.inputmethod.VietnameseIM.VietnameseTelex (Telex)
```

* List currently enabled input sources on the system:
```
$ InputSourceSelector list-enabled
com.apple.keylayout.Dvorak (Dvorak)
com.apple.keylayout.US (U.S.)
...
com.apple.KeyboardViewer (Keyboard Viewer)
com.apple.keylayout.UnicodeHexInput (Unicode Hex Input)
```

* Print the current input source:
```
$ InputSourceSelector current
com.apple.inputmethod.Kotoeri.Roman (Romaji)
```

* Print the current keyboard layout:
```
$ InputSourceSelector current-layout
com.apple.keylayout.Dvorak (Dvorak)
```

License
=======

[MIT License](LICENSE.txt)
Download .txt
gitextract_z75ee504/

├── InputSourceSelector.m
├── LICENSE.txt
├── Makefile
└── README.md
Condensed preview — 4 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (7K chars).
[
  {
    "path": "InputSourceSelector.m",
    "chars": 3766,
    "preview": "// An utility to manipulate Input Sources.\n// Copyright (c) 2012 ARATA Mizuki\n#include <stdio.h>\n#include <stdlib.h>\n#in"
  },
  {
    "path": "LICENSE.txt",
    "chars": 1074,
    "preview": "MIT License\n\nCopyright (c) 2012-2025 ARATA Mizuki\n\nPermission is hereby granted, free of charge, to any person obtaining"
  },
  {
    "path": "Makefile",
    "chars": 131,
    "preview": "all: InputSourceSelector\n\nInputSourceSelector: InputSourceSelector.m\n\t$(CC) -o $@ -Wall $< -framework Carbon -framework "
  },
  {
    "path": "README.md",
    "chars": 2072,
    "preview": "InputSourceSelector\n===================\n\nA utility program to manipulate Input Sources on Mac OS X.\nThis program is a th"
  }
]

About this extraction

This page contains the full source code of the minoki/InputSourceSelector GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 4 files (6.9 KB), approximately 1.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!