• Stars
    star
    197
  • Rank 196,523 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A funny helper tool for HHKB professional keyboard on mac. Its main job is that it can auto detect the HHKB professional keyboard plugged in and out, and do some actions you want.

HHKB Assistant for mac

A funny helper tool for HHKB professional keyboard on mac. Its main job is that it can auto detect the HHKB professional keyboard plugged in and out, and do some actions you want. For example, disable mac build-in keyboard.

HHKB Assistant Version History

VERSION 1.1 - 2014/05/17

VERSION 1.0 - 2014/05/08

  • First release upon the world

Why

I bought HHKB Professional keyboard last week, and I often use it like this:

alt text

The reason is simple, everytime I need to execute some magic shell commands to disable mac build-in keyboard before I put HHKB on macbook, or else HHKB will press keys in build-in keyboard to interrupt you work. And then do the command again when I plugged out HHKB to enable build-in keyboard.

So this app is to help me do the repetitive job, and I also add one funny feature to make a voice message when HHKB is in and out. You can download and try it.

Demo

Here I use console output to demo it. Message is simple, use a forever loop to detect HHKB plugged in and out, and do the disable/enable build-in keyboard action at the same time.

You maybe notice message [disable build-in keyboard is error], because I use unload keyboard driver to do the disable action, and you will always get a error message when you want to unload build-in keyboard driver dynamically, but it still works.

alt text

Usage

HHKBAssistant is also just a status bar app like MuteIt, just an icon in the system menu bar.

alt text
β€»The first menu is to let you can disable/enable keyboard anytime manually.

I also provide a Preference window to create your personal settings.
alt text

You can input your favorite messages into text fields to speak when HHKB is in and out. The device name will be always spoken, when your check this voice message feature on.

Implementation

I use command:

sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

to disable/enable mac build-in keyboard manually. It seems to unload/load driver for build-in keyboard and works fine.

So how to do it in the code. In my opinion, I needed to do three tasks.

  1. detect usb device
  2. unload/load the driver
  3. run sudo command

The first task, you can reference USB Device Detect, use some multi-thread implementations and need to wrap obj-c code to c static function if you want to mix c and obj-c code.

The second task is simple, just use KextManager API will do me favor.

The third one, is a little complicated. I found Apple documents say when you want to run sudo authentication task, with the security consideration, you should use something like:

  1. launchd
  2. SMJobBless
  3. XPC service
  4. codesign
  5. etc...

to abstract the high rights task to a sub helper tool run as a launchd process, and use XPC service to communication between main application and this helper tool.

When finish the main three tasks, the whole thing is almost done.

Install

Download app from here, and install like other mac apps.

The installer UI will be like this:
![alt text][installer]

β€»It will ask you to input root password to install the helper tool. Because disable keyboard needs sudo authentication.
[installer]: https://raw.githubusercontent.com/hanks/HHKBAssistant_for_mac/master/Demo/installer.png "installer"

Uninstall

I also create a simple uninstall script here, just contains three lines of sudo rm commands, you can check it and use it to remove all the related files.

Bugs

  1. Now I can not find a correct way to detect build-in keyboard is disabled or not, because I want to use detect keyboard driver is loaded or not, but the driver is always loaded whether keyboard is disabled or not..., the first menu item will not be displayed correctly.

Contribution

Waiting for your pull requests

Lisence

MIT Lisence

More Repositories

1

Natural-Language-Processing

Open Course of Stanford University
Java
39
star
2

Bookmark-plugin-for-eclipse

A simple treeview version bookmark plugin for eclipse, And use github to host my bookmark plugin for online eclipse marketplace
Java
18
star
3

Refresh_this_project_plugin_for_eclipse

Use opened file in editor or selected in package explorer to find project root , and refresh the whole project. And use github to host my refresh-this-project plugin for eclipse marketplace
Java
5
star
4

MuteIt_for_mac

Make macbook muted when headphone unplugged, just like user experience of iPhone.
Objective-C
3
star
5

Supervisord_Notifier

Use classic Observer Pattern to implement a simple supervisord PROCESS_LOG listener, and send message to HipChat or Mail or else place.
Python
3
star
6

another-super-tiny-compiler

Python version of the super tiny compiler project
Python
2
star
7

MIT-OCW-Introduction-to-Computer-Science-and-Programming-6.00

the assignment of 6.00 of MIT OCW (Finish)
Python
2
star
8

csv2esjson

A tiny tool to transfer csv content to elasticsearch json format content
Go
2
star
9

Software-Engineering-for-Software-as-a-Service

Open Course of UC Berkeley
Ruby
1
star
10

awsudo-go

A handy AWS credential helper, based on Okta Single Sign-On
Go
1
star
11

Design-and-Analysis-Algorithm

open course of Stanford University
Python
1
star
12

python-challenge

solve the quiz on the python challenge website
Python
1
star
13

tetris

tetris by cocos2d-x lua
C++
1
star
14

ribbon

A simple color print library for console.
Python
1
star
15

Scratch_for_mac

A draw panel to do some simple scratch using tracepad of macbook
Objective-C
1
star
16

First_Hackson_Demo

A demo with iBeacon device for my first hackson event in company
Objective-C
1
star
17

pystructure

A tiny tool to help reading source code with showing structure of python source code
Python
1
star