Repository navigation
Command Line
Use ojd, the OpenJoystickDriver command line, to check status, start or stop the service, and manage controllers and controller records.
Note: This page applies to OpenJoystickDriver 0.6.0-alpha.1 and later. Version 0.5.0-beta.4 and earlier do not have all of the features on this page.
This page explains how to run ojd, which options apply to every command, how to read its output, and what its exit codes mean.
- Run a Command
- Shell Completion
- Global Options
- Environment Variables
- The Service
- Configuration
- Mod Packages
- Output
- Exit Codes
- Further Reading
The command-line tool is named ojd. It is the app's own executable: when it runs under the name ojd, it acts as the command line, and under any other name it opens the app.
To install ojd, open the app's Settings and click Install Command-Line Tool. The app links /usr/local/bin/ojd to its executable, and macOS asks for an administrator password when that folder needs it. Uninstall in the same place removes the link. The app never replaces a file at that path that is not a link.
To link it yourself instead, create the link in a folder on your PATH:
ln -s /Applications/OpenJoystickDriver.app/Contents/MacOS/OpenJoystickDriver /usr/local/bin/ojdWriting to /usr/local/bin can need sudo. To remove the tool, delete the link: rm /usr/local/bin/ojd.
Then run a command:
ojd statusThe command reference lists every command. ojd --help lists them too, and ojd COMMAND --help shows the options of one command.
To start, run ojd status to check the service, extension, and permissions, ojd diagnose to run every check, and ojd controller list to list connected controllers.
ojd --generate-completion-script SHELL prints a completion script for zsh, bash, or fish. For example, in zsh:
ojd --generate-completion-script zsh > ~/.zfunc/_ojdThe folder must be on your fpath.
These options work on every command, before or after the command name. ojd --json status and ojd status --json do the same thing. ojd --help lists them, and the help of each command points there instead of repeating them.
-
--json: Print JSON on standard output. -
--plain: Print one record per line on standard output, with tab-separated fields. -
-q,--quiet: Do not print success messages on standard error. -
--no-color: Do not use color. -
--no-input: Never ask a question. A command that needs a missing value fails and names the option that gives it. -
--timeout SECONDS: How long to wait for each request to the service. The default is 0.5 seconds. Forservice,virtual set, andvirtual resetcommands, it bounds the whole command, and the default is 5 seconds. Forpermission request, the default is 10 seconds. The value must be a number above 0. -
-h,--help: Show help on standard output. -
--version: Show the version alone, for example0.6.0-alpha.1.
--json and --plain cannot be used together.
These variables stand in for a global option that the command line leaves out. A flag beats its variable, and an empty variable counts as unset.
-
OJD_NO_INPUT:1,true, oryesacts as--no-input, and0,false, ornodoes not, in any letter case. -
OJD_TIMEOUT: Seconds, as for--timeout. -
OJD_COLOR:autofollows the rules under Output,alwaysuses color even off a terminal or withNO_COLORset, andneveracts as--no-color.
Any other OJD_NO_INPUT value, or an invalid OJD_TIMEOUT or OJD_COLOR value, is a usage error and exits with code 64.
For contributors: an ojd built from the repository hands each command to the installed app's ojd. Set OJD_RUN_REPOSITORY_CLI=1 to run the repository build itself instead.
Most commands send requests to the OpenJoystickDriver service, which runs inside the app. No command starts the service by itself. Start it with ojd service start, and stop it with ojd service stop.
A command that needs the service exits with code 69 when the service is not running. ojd status works without the service and reports it as stopped.
ojd config show prints each effective tuning value and the layer that set it: the driver default, the bundled record, a package, your all.patch.json, or your record. It reads the files directly, so it works without the service. With --controller and the service running, it also lists the active profile's stick deadzones in the profile layer. See Controller records.
ojd mod validates, installs, lists, and removes mod packages. It reads and writes files directly, so it works without the service. A running service applies a change to the installed packages without a restart. See Writing controller mods.
- Data goes to standard output. Progress messages, warnings, and errors go to standard error.
- Human-readable output is translated and can change between releases. Do not parse it in scripts.
-
--jsonoutput is one JSON object. A command that streams, such asojd controller watch, prints one object per line. Each object and each line hasapiVersion(openjoystickdriver/v1alpha1) andkind, the singular UpperCamelCase name of what the command prints, such asControllerforojd controller show. The lines ofojd controller watch --allare the exception: each has atype(ADDED,MODIFIED, orDELETED) and anobjectthat has its ownapiVersionandkind. A command that lists things, such asojd controller list, prints akindthat ends inList, with the entries initemsand an emptymetadata. A command that changes or removes something and has no object to print, such asojd profile delete, prints aStatus, withstatusSuccessand its data indetails. A command that fails prints no JSON: it exits with a non-zero code and writes the error on standard error. Values that OJD defines in output, such asnotFound, are lowerCamelCase. Keys and values are stable identifiers and are never translated.cli-output.schema.jsondescribes the output of each command. The schema is strict: it lists every key and value that its release prints, and rejects others. Within a major version, the output only gains keys and values: a later release never removes a key, a value, or a command's output, never makes an always-present key optional, and never gives a value a new type such asnull. Before 1.0, each minor version counts as a major version, so 0.6 can break the output of 0.5. A program that reads one release's output keeps working with later releases of the same major version. Because a later release can add keys and values, validate output against the schema from the same release. -
--plainoutput has one record per line, with tab-separated fields. The first field names the kind of record. Fields are stable identifiers and are never translated. - Errors use one format:
error[E2004]: WHAT FAILED. HOW TO FIX IT.The code in the brackets is stable, so a script can branch on it. An error that the service reports for remapping carries anE3xxxcode, and an error ofojd modcarries anE4xxxcode, orE5001when a package file has an unsupportedapiVersion.ojd explain E2004prints what a code means, and Error codes lists them all. - Color appears only on a terminal.
NO_COLOR,TERM=dumb,--no-color, andOJD_COLOR=neverturn it off.OJD_COLOR=alwaysturns it on anywhere, except under--no-color.
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | The command failed. |
| 64 | Usage error: an unknown command or option, or an invalid value. |
| 69 | The service is not running. Start it with ojd service start. |
| 77 | A macOS permission is missing. |
| 127 | An ojd built from the repository could not hand the command to the installed app. |
| 130 | Interrupted with Control-C. |
| 143 | Terminated with SIGTERM. |
- Home
- Start here
- Controllers
- Games
- Remapping
- Your Mac
- Command line
- Help
- Advanced