Settings
Where Namjai keeps its settings, which wins when two disagree, and every setting it reads.
The settings file
Namjai keeps its settings in one file in your home folder:
nj setup writes it, and nj set format changes one line of it. Nothing else writes it. Each line is a name, =, and a value in quotes, under one line saying what the file is. If you edit it by hand, a value may also be in single quotes or in none, a line may start with export, and a # after a space starts a note to the end of the line. A value cannot hold a line break: setup and set refuse one, naming the setting. Only your Mac account can open it: the folder is closed to other accounts and the file can be read and written by you alone. It holds the names below and nothing about your chats. To see which names it holds, without their values:
cut -d= -f1 ~/Library/Application\ Support/Namjai/settings.env# Namjai's settings, written by `namjai setup` and `namjai set`. NAMJAI_ENV NAMJAI_OUTBOX_KEY NAMJAI_STATE_DIR NAMJAI_TIME_ZONE NAMJAI_WHATSAPP_STORE
nj setup saves the WhatsApp file's place, the time zone, NAMJAI_ENV as prod, the state folder ~/Library/Application Support/Namjai/state, and a new random outbox key the first time. nj set format adds a line to that list, NAMJAI_OUTPUT_FORMAT, and nj set download another, NAMJAI_DOWNLOAD_ADDRESS.
The environment wins
Every command reads a setting from the environment first, and from the file only when the environment does not set it. A developer can so try another value for one command without changing the file, for example NAMJAI_OUTPUT_FORMAT=json nj wp labels. A setting that is set but empty in the environment does not count: the file's value is used. One setting has a third, last place: when neither the environment nor the file gives NAMJAI_DOWNLOAD_ADDRESS, nj update takes the address the installer left in /usr/local/share/namjai/installer-defaults.env, the site the installer was downloaded from. Every other name in that file is ignored, so an installer cannot change any other setting.
Every setting
The desktop program reads these 16. You need none of them by hand: nj setup saves the ones reading WhatsApp needs, and the rest are for a Namjai server or for tests. Values are checked when a command needs them; the message names the setting and never prints a secret. A missing or wrong setting stops the command with nj: configuration:, one line per problem, and exit code 2 (the number a command hands back when it ends: 0 means it worked, any other number means it did not). The WhatsApp commands add If you have not yet, run: nj setup.
| Setting | Meaning | Accepted values and default | Needed by | When it is wrong |
|---|---|---|---|---|
NAMJAI_WHATSAPP_STORE | The place of WhatsApp's chat file on this Mac | a file path; setup saves ~/Library/Group Containers/group.net.whatsapp.WhatsApp.shared/ChatStorage.sqlite or --store; no default | every wp command | Empty: NAMJAI_WHATSAPP_STORE is not set: give it the path of WhatsApp's ChatStorage.sqlite on this computer. A place with no file: nj: whatsapp store: stat and the place, exit code 1 |
NAMJAI_TIME_ZONE | The time zone for every date and time | a zone name such as Asia/Bangkok, from the IANA list (the world's shared list of time zone names); not Local; setup saves the Mac's zone | every wp command | NAMJAI_TIME_ZONE must be an IANA time zone name such as Asia/Bangkok, got "Local", with the value it got |
NAMJAI_OUTPUT_FORMAT | The format of the wp lists when no format option is given | text, table, csv or json, capitals ignored; empty means text | the wp lists | A wp list prints nj: NAMJAI_OUTPUT_FORMAT is "xml", which is not text, table, csv or json. Fix it with: nj set format text (with the wrong value) and exits with 2; a format option on the command still works |
NAMJAI_SHORTCUTS_COMMAND | The program nj wp send and nj wp send-setup run Apple's Shortcuts with | A program's path; empty means /usr/bin/shortcuts | nj wp send, nj wp send-setup, the sending line of nj wp doctor | Sending says the shortcut is missing or Shortcuts did not answer. Tests point it at a fake that sends nothing |
NAMJAI_OPEN_COMMAND | The program nj setup and nj wp send-setup open the signed shortcut with, and nj remove opens the Shortcuts app with | A program's path; empty means /usr/bin/open | nj setup, nj wp send-setup, nj remove | nj wp send-setup prints the reason and exits with 1. nj setup says Shortcuts did not open the shortcut and that reading still works. nj remove tells you to open the Shortcuts app yourself. Tests point it at a fake that opens nothing |
NAMJAI_DOWNLOAD_ADDRESS | Where nj update reads release.json and downloads the installer | An https:// address (plain http:// only for this computer, such as http://localhost:8080), with no user name or password and no ?... or #... part; empty means the address the installer carries in /usr/local/share/namjai/installer-defaults.env | nj update | Empty here and in the installer's file: nj update says to install the newest installer or run nj set download ADDRESS, and exits with 1. Not an address: it says so and exits with 1 |
NAMJAI_INSTALLER_DEFAULTS | The file the installer left the download address in; only NAMJAI_DOWNLOAD_ADDRESS is read from it | A file path; empty means /usr/local/share/namjai/installer-defaults.env | nj update | A missing file is no address. Tests point it at a made-up file |
NAMJAI_INSTALL_COMMAND | The program nj update runs Apple's installer with | A program's path; empty means /usr/bin/sudo | nj update | nj update says the installer did not finish and exits with 1. Tests point it at a fake that installs nothing |
NAMJAI_REMOVE_COMMAND | The program nj remove deletes the installed program with | A program's path; empty means /usr/bin/sudo | nj remove | nj remove says macOS did not finish removing the program and exits with 1. Tests point it at a fake that deletes only in a made-up folder |
NAMJAI_ENV | Which environment this runs in | local, ci, dev, uat or prod; setup saves prod | wp sync, demo send | NAMJAI_ENV must be one of local, ci, dev, uat, prod, got "" |
NAMJAI_SERVER | The Namjai server's address | an http or https address; when NAMJAI_ENV is dev, uat or prod it must be https unless the server is on this computer (localhost, 127.0.0.1); no default; --server wins over it | wp sync, demo send; wp doctor checks the sending lines only when it is set | NAMJAI_SERVER is not set and no --server was given, or NAMJAI_SERVER (or --server) must be an http or https URL, got "...", or NAMJAI_SERVER (or --server) must be an https address when NAMJAI_ENV is prod, unless the server is on this computer; got "..." |
NAMJAI_OUTBOX_KEY | The secret key that seals the outbox | 32 random bytes in base64; setup makes one | wp sync, demo send | NAMJAI_OUTBOX_KEY is not set: give it 32 random bytes in base64 (openssl rand -base64 32), or NAMJAI_OUTBOX_KEY must be 32 bytes in standard base64 |
NAMJAI_OUTBOX_DIR | The outbox folder | a folder; empty means the outbox folder inside NAMJAI_STATE_DIR for wp sync, and a new temporary folder for demo send | wp sync, demo send | Not checked; a folder that cannot be used fails the send, exit code 1 |
NAMJAI_STATE_DIR | Where Namjai remembers how far it has sent, and its device ID | a folder; setup saves ~/Library/Application Support/Namjai/state | wp sync | NAMJAI_STATE_DIR is not set: give it a directory the desktop app may keep its state in |
NAMJAI_WHATSAPP_ACCOUNT | Your own WhatsApp number | +, the country code and the number, 7 to 15 digits, no spaces (the form the message calls E.164); no default | wp sync | NAMJAI_WHATSAPP_ACCOUNT must be the salesperson's own WhatsApp number in E.164, such as +999812345678 |
NAMJAI_WHATSAPP_CLIENT_CHATS | The chats marked client, the only ones wp sync reads and sends | numbers with +, or WhatsApp chat IDs (the name WhatsApp gives a chat inside its files, such as 999812345678@s.whatsapp.net for a person or one ending in @g.us for a group), separated by commas; empty means none | wp sync | NAMJAI_WHATSAPP_CLIENT_CHATS holds an entry that is neither a number in E.164 nor a WhatsApp chat ID |
For example, with a wrong time zone in the environment, here typed in front of the command so that it holds for that one command. The environment is the list of settings Terminal hands to every command it runs.:
nj: configuration: NAMJAI_TIME_ZONE must be an IANA time zone name such as Asia/Bangkok, got "Local" If you have not yet, run: nj setup
nj help settings prints the same list in short; see help settings.