/nuimode

A library for customizing Nuimo devices on OSX.

Primary LanguageScalaMIT LicenseMIT

Nuimode

A library for customizing the Nuimo device on OSX.

You can implement your own event handler for each particular application by extending NuimoHandler trait. The library provides some useful functions for handling Nuimo.

  • Reading battery information
  • Typing keystrokes
  • Executing applescripts
  • Handling events of a (multiple-) click, swipes, rotations, and fly actions (incl. height info.)
  • Displaying an LED image

The library also bundles some example handlers:

Setup

  1. Install
  2. Then, run npm install @abandonware/noble to install noble: A Node.js BLE (Bluetooth Low Energy) library.
  3. npm rebuild
  4. Clone this library.

Usage

On your console,

  1. cd /path/to/nuimode
  2. cp config/nuimo_config_example.txt config/nuimo_config.json
  3. Run sbt run
  4. Turn on your Nuimo.
  5. Confirm the UUID of your Nuimo on the console.
  6. Paste the UUID on config/nuimo_config.json
  7. Type Ctrl-C to stop Nuimode
  8. Run sbt run again.

Advanced Configuration

If you want to implement your own handler, see yuima.nuimo.handler.NuimoHandler and yuima.nuimo.handler.DeafaultHander for example.

In order to use your handler, you have to define a mapping between an application's name and the handler by modifying config/nuimo_config.json and yuima.nuimo.config.Config object.

For example, if you create a new object SafariHandler, you have to edit yuima.nuimo.config.Config.HandlerID as:

object HandlerID extends Enumeration {
  val Default, PowerPoint, Lightroom, GoogleChrome, Safari = Value
}

Then you modify yuima.nuimo.config.Config.id2handler as:

val id2handler = Map(
   HandlerID.Default -> yuima.nuimo.defaultHandler,
   HandlerID.PowerPoint -> PowerPointHandler,
   HandlerID.Lightroom -> LightroomHandler,
   HandlerID.GoogleChrome -> GoogleChromeHandler,
   HandlerID.Safari -> SafariHandler
)

Finally, you assign the application name to the handler on config/nuimo_config.json as:

[
  {
    "uuid": "123qweasdzxc456rtyfghvbn789uiojk",
    "name": "Left-hand Nuimo on MBA",
    "handlers": {
      "Microsoft PowerPoint.app": "PowerPoint",
      "Adobe Lightroom.app": "Lightroom",
      "Google Chrome.app": "GoogleChrome",
      "Safari.app": "Safari"
    }
  }
]

Acknowledgement

Some JS scripts used in the library are forked from the following projects.