Code Monkey home page Code Monkey logo

paddington's Introduction

Paddington

Control your Mac from MIDI devices! The Novation Launchpad (and Launchpad Mini) are supported at the moment, but thanks to Elixir's behaviours, it's easy to add new devices!

Usage

Paddington requires a .paddington.yml file in your home folder to work. This file defines a device name, and a list of applications you want to control with paddington. Something like this:

device: Launchpad Mini
applications:
- mpc
- iTerm
- Chrome
- iTunes

The device name has to be among one of the connected MIDI devices, or the app will fail with an :invalid_device_id error. Launch mix portmidi.devices from the main folder to discover the available devices.

The applications are Elixir script files (exs) defined in the ~/.paddington folder, and must follow the naming found in the .paddington.yml file. Check out the paddington-example repo for a quick start.

As an example, this is my ~/.paddington/mpc.exs:

app "MPC", :line
osx "iTerm2"

command "Activate" do
  osascript "activate"

  if tmux.current_session == "music" do
    tmux.switch
  else
    tmux.switch "music"
  end
end

command "Previous track" do
  mpc.previous
end

command "Play/Pause" do
  mpc.playpause

  if mpc.playing? do
    led.green
  end
end

command "Next track" do
  mpc.next
end

command "Open in browser" do
  open "http://localhost:6680/spotmop"
end

As you can see, different helpers are available in the application files. app defines the name of the application, osx sets the app to use in osascript (aka Applescript), and every command block defines what series of commands to fire when a MIDI note is received from the external device.

The commands are collected as the interpreter goes through the file(s). In the case of this configuration, that means that if your device has a grid (like a Launchpad), the pad in the upper left corner will focus on iTerm2 and switch to the tmux session named music (or switch back to the previous session, if already on music).

You can find all the available helpers in the helpers folder (they are not that many at the moment, bear with me!).

Installation

At the moment, the installation is pretty rudimentary:

$ git clone https://github.com/lucidstack/paddington.git
$ cd paddington
$ make
$ make install
...
$ paddington

Contributing

Any contribution is welcome! If you have a device you'd like to implement (or see implemented), take a look at the Launchpad transducer and feel free to ping me for help here, on twitter, or on the Elixir Slack organisation (lucidstack).

As usual, the process is pretty simple: fork, write tests, write code, tests pass, submit a PR! I'll try to get back as soon as possible.

License

See LICENSE

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.