Aj-snapshot is a small program that can be used to make snapshots of the connections made between JACK and/or ALSA clients. Because JACK can provide both audio and MIDI support to programs, aj-snapshot can store both types of connections for JACK. ALSA, on the other hand, only provides routing facilities for MIDI clients.

Aj-snapshot is meant to be used from the command line. To make a new snapshot, just type

aj-snapshot filename

in a terminal window, where filename can be any name you choose for your snapshot file.

If the name of this file is the name of an existing file, aj-snapshot will ask if you want to overwrite that file. You can force aj-snapshot to overwrite existing files with the '-f,--force' option

When you make a snapshot, all the currently active connections are saved in an XML file with your chosen name. Once you have made a snapshot file, you can restore it at any later time with the '-r, --restore' option:

aj-snapshot -r filename

The default behaviour of aj-snapshot is to store/restore both ALSA and JACK connections. When you want aj-snapshot to store/restore only JACK or ALSA connections, you can do this with the '-a,--alsa' or '-j,--jack' options. EXAMPLES:

aj-snapshot -a filename (store ALSA connections to file)
aj-snapshot -ra filename (restore ALSA connections from file)
aj-snapshot -j filename (store JACK connections to file)
aj-snapshot -rj filename (restore JACK connections from file)

When you restore connections with aj-snapshot, the default behaviour is to leave all existing connections untouched, and to add the connections from the snapshot file 'on top of' those. Connections from the snapshot file that are already active are simply left as they are.
If you want to restore the exact state of the system, you have to tell aj-snapshot to remove all existing connections before doing the restore. This can be done with the '-x,--remove' option. In combination with the -a or -j options, aj-snapshot will only remove the existing ALSA or JACK connections respectively. EXAMPLES:

aj-snapshot -rx filename (remove all existing ALSA and JACK connections before restoring ALSA and JACK connections from filename)
aj-snapshot -rax filename (remove all existing ALSA connections before restoring ALSA connections from filename)
aj-snapshot -rjx filename (remove all existing JACK connections before restoring JACK connections from filename)

When specify the '-x' option, without supplying a filename argument, aj-snapshot will just remove all existing ALSA and/or JACK connections without any further action. EXAMPLES:

aj-snapshot -x (remove all existing ALSA and JACK connections).
aj-snapshot -ax (remove all existing ALSA connections).
aj-snapshot -jx (remove all existing JACK connections).

When you specify the '-d, --daemon' option, aj-snapshot will keep on running until it is stopped, restoring connections while clients and ports appear. EXAMPLE:

aj-snapshot -d filename

The daemon restores connections every 200 ms. (defined by POLLING_INTERVAL_MS in aj-snapshot.c) For JACK connections, restoring is only done when the connections did actually change.

You can ask the daemon to reload the XML file by sending it the HUP signal. This makes it possible to add new connections while the daemon is running, store the connection state by overwriting the existing XML file with another instance of aj-snapshot, and reload the file by sending the HUP signal to the daemon. When combining '-d' and '-x' options, all connections are removed before the daemon reloads the XML file. EXAMPLE:

aj-snapshot -dx filename
...add more connections...
aj-snapshot -f filename
kill -HUP $(pidof aj-snapshot)

NOTE: aj-snapshot will try to survive a JACK server shutdown.

With the '-i, --ignore' option, you can ask aj-snapshot to ignore certain clients. You can repeat this option (upto 50 times). When the client name contains spaces, or any other special characters, these have to be quoted from the shell. You can ignore clients when you store, or when you restore connections. Ignoring clients when restoring will keep the snapshot file intact. EXAMPLES:

aj-snapshot -i 'Midi Through' -i Ardour2 filename
aj-snapshot -ar -i fluidsynth filename

The '-X, --remove-except-ignored' option does the same as the --remove option, except that it will not remove connections to or from clients that were specified with the '--ignore' option.

With the '-q, --quiet' option, you can ask aj-snapshot to not print any information about what happens when storing/restoring connections. This includes the information about failed connections, which are not considered real errors in this context.