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:

~/Library/Application Support/Namjai/settings.env

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
Terminal
# 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.

SettingMeaningAccepted values and defaultNeeded byWhen it is wrong
NAMJAI_WHATSAPP_STOREThe place of WhatsApp's chat file on this Maca file path; setup saves ~/Library/Group Containers/group.net.whatsapp.WhatsApp.shared/ChatStorage.sqlite or --store; no defaultevery wp commandEmpty: 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_ZONEThe time zone for every date and timea 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 zoneevery wp commandNAMJAI_TIME_ZONE must be an IANA time zone name such as Asia/Bangkok, got "Local", with the value it got
NAMJAI_OUTPUT_FORMATThe format of the wp lists when no format option is giventext, table, csv or json, capitals ignored; empty means textthe wp listsA 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_COMMANDThe program nj wp send and nj wp send-setup run Apple's Shortcuts withA program's path; empty means /usr/bin/shortcutsnj wp send, nj wp send-setup, the sending line of nj wp doctorSending says the shortcut is missing or Shortcuts did not answer. Tests point it at a fake that sends nothing
NAMJAI_OPEN_COMMANDThe program nj setup and nj wp send-setup open the signed shortcut with, and nj remove opens the Shortcuts app withA program's path; empty means /usr/bin/opennj setup, nj wp send-setup, nj removenj 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_ADDRESSWhere nj update reads release.json and downloads the installerAn 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.envnj updateEmpty 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_DEFAULTSThe file the installer left the download address in; only NAMJAI_DOWNLOAD_ADDRESS is read from itA file path; empty means /usr/local/share/namjai/installer-defaults.envnj updateA missing file is no address. Tests point it at a made-up file
NAMJAI_INSTALL_COMMANDThe program nj update runs Apple's installer withA program's path; empty means /usr/bin/sudonj updatenj update says the installer did not finish and exits with 1. Tests point it at a fake that installs nothing
NAMJAI_REMOVE_COMMANDThe program nj remove deletes the installed program withA program's path; empty means /usr/bin/sudonj removenj 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_ENVWhich environment this runs inlocal, ci, dev, uat or prod; setup saves prodwp sync, demo sendNAMJAI_ENV must be one of local, ci, dev, uat, prod, got ""
NAMJAI_SERVERThe Namjai server's addressan 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 itwp sync, demo send; wp doctor checks the sending lines only when it is setNAMJAI_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_KEYThe secret key that seals the outbox32 random bytes in base64; setup makes onewp sync, demo sendNAMJAI_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_DIRThe outbox foldera folder; empty means the outbox folder inside NAMJAI_STATE_DIR for wp sync, and a new temporary folder for demo sendwp sync, demo sendNot checked; a folder that cannot be used fails the send, exit code 1
NAMJAI_STATE_DIRWhere Namjai remembers how far it has sent, and its device IDa folder; setup saves ~/Library/Application Support/Namjai/statewp syncNAMJAI_STATE_DIR is not set: give it a directory the desktop app may keep its state in
NAMJAI_WHATSAPP_ACCOUNTYour own WhatsApp number+, the country code and the number, 7 to 15 digits, no spaces (the form the message calls E.164); no defaultwp syncNAMJAI_WHATSAPP_ACCOUNT must be the salesperson's own WhatsApp number in E.164, such as +999812345678
NAMJAI_WHATSAPP_CLIENT_CHATSThe chats marked client, the only ones wp sync reads and sendsnumbers 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 nonewp syncNAMJAI_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.:

Terminal: NAMJAI_TIME_ZONE=Local nj wp labels
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.