# Customizing GNUmed client startup and shutdown

There are several hooks for customization of the startup/shutdown process built in. One can, of course, always write custom shell scripts/batch files to launch the client and/or hack the Python source code itself to achieve any needed behaviour.

- Startup
  - shell command line
  - (/usr/bin/)gnumed launcher shell script
  - gnumed.py launcher Python script
  - Plugin configuration
    - Default startup plugin
    - Workplace plugin configuration
- Shutdown

## Startup

### shell command line

The GNUmed client accepts a few command line options. They are documented in the man page. The options are passed to the `/usr/bin/gnumed` launcher shell script and eventually to the `gnumed.py` Python launcher script.

In particular, it may be convenient to use `--conf-file` to tell the GNUmed client to use a certain configuration file.

### `(/usr/bin/)gnumed` launcher shell script

The client is usually launched with the `/usr/bin/gnumed` shell script which is included in the release tarball. This script looks for

- `/etc/gnumed/gnumed-startup-local.sh`
  - can be used for site-wide "local" customization

- `~/.gnumed/scripts/gnumed-startup-local.sh`
  - can be used for user-specific customization

and executes them (in that order) if they exist. Both scripts can do anything the user launching `/usr/bin/gnumed` can do (unless they are setuid-root). GNUmed as a project will never overwrite those files (but your package manager may decide to provide an updated `/etc/gnumed/gnumed-startup-local.sh` from time to time).

### `gnumed.py` launcher Python script

When this script has been called the client as such is running. During startup two hooks provide for customization:

- hook `startup-before-GUI`
  - this is called before the wxPython GUI is initialized

- hook `startup-post-GUI-init`
  - this is called after the wxPython GUI has been initialized but before flow control is handed to user input

Among other things connecting to the backend (which can be customized as well) happens between those two hooks.

### Plugin configuration

At startup a configurable list of plugins is loaded depending on which workplace the client is started as. The workplace to use is set in the configuration file.

#### Default startup plugin

The first (ending up leftmost) plugin in the workplace plugin list will be the one displayed right after startup so it better be one not requiring a patient to be active. As per default configuration this is set to Provider Inbox. You can influence which plugin is displayed either by editing the plugin load order or by hooking into `startup-post-GUI-init`.

#### Workplace plugin configuration

To configure which plugins are loaded in which order for any given workplace go to the menu item GNUmed > Options ... > User Interface > Workplaces. This will allow you to create customized workplaces for different purposes, such as rooms or machines. You can have different workplaces for, say "ultrasound room 2", "front desk", "exam room", or "X-ray lab". Note that this configuration is per workplace, independant of the logged on user.

## Shutdown

During shutdown the hook `shutdown-post-GUI` is called when the wxPython GUI has been closed.