# The &kalarm; Handbook

## Introduction

&kalarm; is a personal alarm message and command scheduler. It lets you set up personal alarm/reminder messages which pop up on the screen at the time you specify, or you can set up commands to be executed.

In its default graphical mode, &kalarm; displays a list of pending alarms, showing their times and details. You can create new alarms, or you can select existing alarms for modification or deletion.

When setting up or modifying an alarm, you may either type in the alarm message text, specify a text file to display, or specify a command to execute. You can also choose the colour of the alarm message, whether it should repeat, whether to play a sound, and whether the alarm should be cancelled if it can't be triggered at its scheduled time.

Alarms may also be scheduled on the command line, or via &DCOP; calls from programs.

When an alarm message is due, it is displayed on each &kde; desktop to ensure that you don't miss it. The message window shows the time for which the alarm was scheduled. It usually has a defer option to ask for the alarm to be displayed again later. An example of an alarm message:

Screenshot of the &kalarm; message window Alarm message

When the alarm specifies a command to execute, &kalarm; displays nothing.

&kalarm; can run in either of two modes: continuous (the default) where it runs from the &kde; system tray, or on-demand where it runs as and when required (with the option of displaying an independent system tray icon).

This document makes various references to the alarm daemon. This is an application which runs in the background, checking pending alarms and telling &kalarm; to display them when they become due.

## Using &kalarm;

### Graphical mode

When it is run with no command line parameters, &kalarm; starts in graphical mode. It displays the current list of outstanding alarms, showing their times, repetition intervals, colours, and message texts, names of files to display or commands to execute. (For a recurring alarm, the time shown is its next scheduled trigger time.) An icon at the left of each alarm text/file/command indicates the type of alarm.

Screenshot of the &kalarm; main window Main window

For a repeated alarm, the list shows its next scheduled trigger time and the number of times which it is due to repeat after that.

The alarms may be ordered by date/time, repeat interval, colour or text by clicking on the title bar for the appropriate column. To reverse the sort order, click the column title bar again.

When &kalarm; starts in graphical mode, it checks whether the alarm daemon is running. If it is not already running, &kalarm; starts it.

#### Adding a new alarm

To add a new alarm, select Actions New. This displays the alarm edit dialog as described below.

#### Modifying an existing alarm

To modify an existing alarm, do one of the following:

- Double click on its entry in the alarm list.

- Select it by clicking on its entry in the alarm list. Then choose Actions Modify.

- Right click on its entry in the alarm list and choose Modify from the context menu.

This displays the alarm edit dialog:

Screenshot of the alarm edit dialog Alarm edit dialog

In the Action group box, select either Text in order to enter the message text (which may include newlines) in the edit box, File to enter the name or &URL; of a text file whose contents are to be displayed in the alarm message, or Command to enter a shell command to execute. When File is selected, the button to the right of the edit box may be used to display a file selection dialog.

If the alarm is a recurring alarm and it was deferred after it was last displayed, the Deferred Alarm group box shows the time the alarm was deferred to. Change... displays a dialog which allows you to change the deferred time or to cancel the deferral.

In the Time group box, select either

- At date/time to enter the date and time when the alarm is to be triggered. Check the Any time checkbox if you want to specify only a date for the alarm: in this case the alarm will be displayed at the first opportunity on or after the configured start-of-day time, on the specified date. (Configuring default options describes how to set the start-of-day time.)

- Time from now to enter how long after now (in hours and minutes) the alarm should be triggered.

Specify whether or how the alarm should be repeated in the Repetition group box.

- To trigger the alarm once only, select No repetition.

- Select Repeat at login to trigger the alarm whenever you log in, until its scheduled time. (Note that an alarm repeated at login will also be triggered any time you enable alarms, or restart or reset the alarm daemon.)

- Select Recur to trigger the alarm at regular intervals. You must then specify the recurrence parameters in the Recurrence tab.

  In the Recurrence Rule group box, set the recurrence time period by selecting one of the time period types and entering in the Recur every box how many time periods should elapse between recurrences. For example, to repeat every fortnight, you could select Daily and enter a value of 14, or select Weekly and enter a value of 2. Depending on the time period type selected, you may have further options:

  - For a weekly recurrence, check each day in the week on which you wish to trigger the alarm.

  - For a monthly recurrence, you may select either a fixed date, or a position (⪚ the second Tuesday).

  - For a yearly recurrence, you may select either a fixed date in the year, or a position in a month (⪚ the last Saturday in May).

  In the Recurrence End group box, set the overall recurrence time span as follows:

  - Select No end to continue the repetitions indefinitely.

  - Select End after to specify the total number of occurrences of the alarm.

  - Select End by to specify the date/time until which the alarm will be repeated.

The Cancel if late checkbox determines what happens if the alarm can't be triggered at its scheduled time. Check this box to cancel the alarm if it can't be triggered within one minute after the right time. Leave the box unchecked to trigger the alarm at the first opportunity starting at the scheduled time. Date-only alarms, &ie; ones for which the Any time option is selected, will be cancelled if they cannot be displayed within 24 hours of the start-of-day time on the date scheduled.

An alarm can only be triggered while you are logged in, and while both X and the alarm daemon are running.

The Confirm acknowledgement checkbox lets you specify whether you will be prompted for confirmation when you close the alarm message window. This may be used as a safeguard against accidental acknowledgement of alarms.

Check the Sound checkbox if you want an audible alarm to sound when the alarm message is displayed. By default a beep is sounded; use the button on the right to select an audio file to play. To revert to a beep, click the button again. To see what your current sound selection is, hover the mouse above the button until a tooltip appears.

Select the background colour for the alarm message window.

Press the OK button when all details are correct, to add the alarm to the scheduled list.

#### Deleting an existing alarm

To delete an existing alarm, do one of the following:

- Select it by clicking on its entry in the alarm list. Then choose Actions Delete .

- Right click on its entry in the alarm list and choose Delete from the context menu.

#### Acknowledging an alarm

See Alarm message window for how to acknowledge alarms.

#### Displaying &kalarm; in the system tray

You must be running the &kde; desktop in order to display &kalarm; in the system tray. If &kalarm; is running in continuous mode, the system tray icon is always displayed. These instructions apply only to on-demand mode. (See Configuring default options for a description of run modes.)

To display &kalarm; in the &kde; system tray, select View Show in System Tray .

To remove &kalarm; from the &kde; system tray, do one of the following:

- Select View Hide from System Tray.

- Right click on the system tray icon and choose Quit from the context menu.

Use of the system tray icon is described below.

#### Enabling/disabling alarm monitoring

##### Enabling alarm monitoring

First, if &kalarm;'s run mode is continuous and you have selected Disable alarms while not running in the Preferences dialog, you must ensure that &kalarm; is running in order for alarm monitoring to take place.

Then if alarm monitoring is currently disabled, do one of the following:

- Select Actions Enable Alarms.

- Right click on the system tray icon and choose Enable Alarms from the context menu.

The alarm daemon is started if necessary and alarms will be monitored for when they become due.

Starting the alarm daemon will affect any other applications which use the alarm daemon.

##### Disabling alarm monitoring

There are several ways to disable alarm monitoring, which prevents &kalarm; from displaying any further alarms either until you re-enable alarms, or - assuming that the alarm daemon is configured to start at login - until the next time you log in.

To disable alarms without stopping the alarm daemon (and therefore without affecting any other applications which use the alarm daemon), do one of the following:

- Select Actions Alarms Enabled.

- Right click on the system tray icon and choose Alarms Enabled from the context menu.

- If &kalarm;'s run mode is continuous and you have selected Disable alarms while not running in the Preferences dialog, quit &kalarm;.

To disable alarms by stopping the alarm daemon:

- Select Settings Control Alarm Daemon.... This displays the Service Manager dialog which enables you to stop the alarm daemon.

This will affect any other applications which use the alarm daemon.

#### Refreshing alarms

If in the unlikely event that any alarm was not triggered when it should have been, you can refresh the alarm list and trigger any missed alarms by selecting Actions Refresh Alarms .

&kalarm; retriggers missed alarms by resetting the alarm daemon, which is discussed in the Alarm daemon section.

#### Controlling the alarm daemon

To control the alarm daemon, select Settings Control Alarm Daemon.... This displays the Service Manager dialog which allows you to stop or start the alarm daemon and configure whether it runs automatically at login. See Controlling the alarm daemon with the Service Manager for details.

#### Quitting the program

Quit &kalarm; by closing all its windows and the system tray icon, or if it is running in continuous mode, by closing any message windows and selecting Quit in the system tray icon context menu.

File Quit closes only the window concerned. The effect of the system tray icon context menu item Quit depends on the run mode: in on-demand mode it hides the system tray icon, while in continuous mode it quits the program.

Quitting &kalarm; has no effect on the alarm daemon, which if already active will continue to monitor scheduled alarms and request their display when they become due (unless you have selected Disable alarms while not running in the Preferences dialog).

### Alarm message window

When an alarm message is due, it is displayed on each &kde; desktop and cannot be covered by ordinary windows, to ensure that you see it. The message window shows the time for which the alarm was scheduled, so that you can see when it popped up if you were away from the computer at the time.

In the case of a repeated alarm, if an unacknowledged message window remains from a previous occurrence of the alarm, the existing window is simply popped up when the alarm recurs. This avoids having to acknowledge multiple copies of the same message should you not wish, or be unable, to acknowledge a message at the time it appears.

When an alarm message window is displayed, do one of the following:

- Acknowledge it by clicking the Close button. This closes the window (after a prompt for confirmation, if you selected Confirm acknowledgement).

- Display options to defer the alarm by clicking the Defer... button. Then select Defer to date/time to enter the date and time when the message is to be redisplayed, or select Defer for time interval to enter how long after now (in hours and minutes) the message should be redisplayed. Then click Defer to defer the alarm message.

  If the alarm recurs regularly, the time it is deferred to must be earlier than its next scheduled repetition.

  The Defer... button is not available for alarms which are displayed at login due to the Repeat at login option having been selected.

The button showing the &kalarm; icon provides a convenient way to activate &kalarm;. Clicking it has no effect on the alarm message window.

### System tray icon

&kalarm; may be run as an icon in the &kde; system tray. This icon allows one-click activation of &kalarm;, and provides both control and status indication of alarm monitoring. A normal &kalarm; icon indicates that alarms are being monitored, while a red cross through the icon indicates that alarms are not being monitored.

Left click on the system tray icon to toggle between displaying and hiding the &kalarm; main window.

Right click on the system tray icon to display its context menu:

Enable Alarms

- Enables monitoring of alarms.

  See Enabling/disabling alarm monitoring for details.

Alarms Enabled

- Disables monitoring of alarms.

  See Enabling/disabling alarm monitoring for details.

Configure &kalarm;...

- Displays the &kalarm; preferences dialog.

  The preferences dialog is described in Configuring default options. It includes options relating to the &kalarm; system tray icon.

Control Alarm Daemon...

- Displays the Service Manager dialog which allows you to control the alarm daemon.

  See Controlling the alarm daemon with the Service Manager for details.

Restore / Minimise

- Restores or minimises the main &kalarm; window.

  This option is only available if the run mode is continuous. (See Configuring default options for a description of run modes.)

Quit

- Closes the &kalarm; system tray icon.

  In continuous run mode only, it also closes all &kalarm; main windows. It has no effect on the monitoring of alarms by the alarm daemon (unless you have selected Disable alarms while not running in the Preferences dialog).

### Configuring default options

To set default options for &kalarm;, select Settings Configure &kalarm;.... This displays the configuration dialog. The General section lets you control &kalarm;'s overall behaviour:

- Specify &kalarm;'s run mode. You can choose either to run it continuously in the &kde; system tray, or to run it only on demand. This selection does not affect the display of alarms when they become due, since it is the alarm daemon and not &kalarm; which monitors the alarm list. Running &kalarm; in the system tray makes the application more accessible and displays an alarm-enabled indication, but running an application continuously does consume some system resources. So if system performance is of concern, the on-demand option may be preferable.

  When running in on-demand mode, the system tray icon can still be displayed. The main difference in operation between the two modes is the effect of closing the system tray icon: in on-demand mode, closing it has no effect on any &kalarm; windows, while in continuous mode, closing it also closes all &kalarm; main windows.

- If you specified that &kalarm; should run in continuous mode, you can disable all alarms due for display while &kalarm; is not running.

- Specify that the &kalarm; system tray icon should be displayed at &kde; session login.

- Set the frequency at which the &kalarm; system tray icon is updated to reflect whether alarms are currently being monitored. This involves checking whether the alarm daemon is running.

- Set the start-of-day time for the purposes of triggering date-only alarms, &ie; ones for which the Any time option was selected. On the date when they are due, such alarms will be output at the earliest opportunity during the 24 hours starting from the start-of-day time.

- Specify whether you should be prompted for confirmation each time you delete an alarm.

The Alarm Defaults and Appearance sections let you choose default values for the options in the alarm edit dialog:

- Set the default font and background colour to use for alarm message display.

- Set the default states for the Cancel if late and Confirm acknowledgement checkboxes.

- Set beep as the default for the Sound option.

- Set the default recurrence period for recurring alarms.

### Command line operation

When command line parameters are supplied, &kalarm; does not display the list of scheduled alarms as described in Graphical mode above. Command line options specific to &kalarm; may be used to perform the following operations:

- schedule a new alarm

- control the alarm daemon

- control &kalarm;'s display mode

- obtain help

Additional command line options are provided primarily to enable other programs to interface to &kalarm;. They are described in the chapter Developer's Guide to &kalarm;.

The command line must only contain options applicable to one &kalarm; operation. If you want to perform multiple operations, you must invoke &kalarm; multiple times with a single set of options each time.

#### Schedule a new alarm

The following options are used to schedule a new alarm:

Option | Description
`-a`, `--ack-confirm` | Prompt for confirmation when the alarm message is acknowledged.
`-b`, `--beep` | Make an audible beep when the message is displayed. `--sound` must not be present if this option is specified.
`-c`, `--color`, `--colour `colour`` | Set the message background colour to the specified &Qt; colour name or hex code 0xRRGGBB.
`-e`, `--exec `commandline`` | Specify a shell command to execute. If specified, this option must be the last &kalarm; option in &kalarm;'s command line. All subsequent command parameters and options are interpreted as forming the command line to execute. `--file` cannot be specified with this option. `--ack-confirm`, `--beep` and `--color` are ignored with this option.
`-f`, `--file `URL`` | Specify the name or &URL; of a text file whose contents are to form the alarm message. `message` must not be present if this option is specified.
`-i`, `--interval `period`` | Set the interval between repetitions of the alarm. Hours/minutes are specified in the format `nHnM`, where `n` is a number, ⪚ 3H30M. Other time periods are specified in the format `nX`, where `n` is a number and `X` is one of the following letters: Y (years), M (months), W (weeks), D (days). Mandatory if `--repeat` or `--until` is specified.
`-l`, `--late-cancel` | Cancel the alarm if it cannot be triggered at the correct time.
`-L`, `--login` | Trigger the alarm every time you log in. `--interval`, `--repeat` and `--until` cannot be specified with this option.
`-r`, `--repeat `count`` | The number of times the alarm should be triggered. Specify -1 to repeat the alarm indefinitely. `--interval` must be, and`--until` cannot be, specified with this option.
`-s`, `--sound `URL`` | Specify the name or &URL; of an audio file to be played when the alarm message is displayed. `--beep` must not be present if this option is specified.
`-t`, `--time `date/time`` | Trigger alarm on the date or at the date/time specified. Specify a date without a time in the format `yyyy-mm-dd`; specify a date and time by `[[[yyyy-]mm-]dd-]hh:mm` (where omitted, date fields default to the values for today).
`-u`, `--until `date/time`` | Repeat the alarm until the date or date/time specified. Specify a date without a time in the same format as for `--time`. `--interval` must be, and `--repeat` cannot be, specified with this option.
`message` | Message text to display.

Either a message text, `--file` or `--exec` must be specified; except as noted above, all the options are optional.

Two alternative examples which display a multi-line message with a red background at 10 p.m. on the 27th of this month are:

    % kalarm -c red -t 27-22:00 "Remember to\nSTOP"
    % kalarm -c 0xFF0000 -t 27-22:00 "Remember to\nSTOP"

#### Other options

The following options are used to reset or halt the alarm daemon, or to control &kalarm;'s display mode.

See the Alarm daemon section for a discussion about resetting and stopping the alarm daemon.

Option | Description
`--reset` | Reset the alarm daemon.
`--stop` | Stop the alarm daemon.
`--tray` | Display &kalarm; as an icon in the &kde; system tray.

For example, to reset the alarm daemon:

    % kalarm --reset

#### Help options

The following help options are common to all &kde; programs:

Option | Description
`--help` | Shows a brief options help text.
`--help-qt` | Shows numerous generic &Qt;-specific options.
`--help-kde` | Shows numerous generic &kde;-specific options.
`--help-all` | Shows all options.
`--author` | Shows the names and email addresses of &kalarm; authors.
`-v`, `--version` | Shows the running versions of the &Qt; library , &kde; and &kalarm;.
`--license` | Show licence information.

### Alarm daemon

The alarm daemon, &kalarmd;, monitors &kalarm;'s calendar file for alarms becoming due. When it determines that an alarm is due, it tells &kalarm; to display or execute it, or to cancel it if it is late and late trigger was not selected for that alarm.

Under &kde;3, the alarm daemon may also be used by other applications, including KOrganizer.

The alarm daemon runs in the background, with no user interface. It may be controlled as described below.

#### Starting, resetting and stopping the alarm daemon

The alarm daemon is normally started at &kde; session login (unless you use the Service Manager dialog to disable auto start), and runs continuously until logout. If for any reason it is not running, alarm monitoring will not occur and &kalarm; will not display or execute any alarms.

##### Starting the alarm daemon

To start the alarm daemon, you can either run &kalarm; in its default graphical mode (&ie; without any command line parameters), enable alarms using &kalarm;'s system tray icon menu, reset the daemon as described below, start it using the Service Manager dialog (see Controlling the alarm daemon with the Service Manager) or you can run the alarm daemon directly from the command line:

    % kalarmd

##### Resetting the alarm daemon

It is also possible to reset the alarm daemon without stopping it. Resetting causes the alarm daemon to re-read the list of scheduled messages from the calendar file and re-initialise its &kalarm;-related data.

Why might you want to reset the alarm daemon? It isn't a very likely occurrence, but if for any reason &kalarm; was not able to run when the alarm daemon told it to trigger an alarm, that alarm will never be displayed or executed until the alarm daemon is either reset or restarted. Resetting is preferable to stopping the alarm daemon and restarting it, since resetting the daemon will not affect any other applications which use the alarm daemon.

Resetting starts the alarm daemon if it is not currently running.

To reset the alarm daemon, either use the menu command Actions Refresh Alarms or type the following command:

    % kalarm --reset

##### Stopping the alarm daemon

Stopping the alarm daemon will prevent any further monitoring of scheduled alarm messages until the daemon is restarted.

Stopping it will affect the functioning of any other applications which also use the alarm daemon. Consider resetting the daemon instead.

To stop the alarm daemon, either use the Service Manager dialog (see Controlling the alarm daemon with the Service Manager), or type the following command:

    % kalarm --stop

#### Controlling the alarm daemon with the Service Manager

The Service Manager dialog allows you to configure and control the alarm daemon. You can:

- Configure whether it runs automatically at login.

  If neither the alarm daemon nor &kalarm; is configured to run at login, alarm monitoring will not occur and &kalarm; will not display or execute any alarms.

- Stop and start the alarm daemon.

  Starting or stopping the alarm daemon will affect any other applications which use the alarm daemon.

The Service Manager dialog can be accessed either via the menu option Settings Control Alarm Daemon..., or via the &kde; Control Centre.

## Developer's Guide to &kalarm;

&kalarm; provides an interface to allow other applications to request the following functions:

- schedule a new alarm

- trigger or cancel an already scheduled alarm

- cancel an already scheduled alarm

- trigger an already scheduled alarm

Each of the above functions is implemented both by a &DCOP; call and by the command line. &DCOP; calls should be used in preference if &kalarm; is already running.

### &DCOP; interface

cancelEvent

cancelEvent

cancel an already scheduled alarm.

    void cancelEvent(const QString& calendarFile, const QString& eventID)

##### Parameters

`calendarFile`

- Specifies the &URL; of the calendar file containing the event to be cancelled.

`eventID`

- Specifies the unique ID of the event to be cancelled, as stored in `calendarFile`.

##### Description

`cancelEvent()` is a &DCOP; call to cancel the specified alarm. &kalarm; deletes the alarm from the calendar file without displaying or executing it.

The `calendarFile` parameter is only used for integrity checking: if the &URL; does not specify &kalarm;'s current default calendar file, the request will be ignored.

The old name for this function, `cancelMessage`, has been retained for compatibility, but all new applications should use `cancelEvent`.

triggerEvent

triggerEvent

trigger an already scheduled alarm.

    void triggerEvent(const QString& calendarFile, const QString& eventID)

##### Parameters

`calendarFile`

- Specifies the &URL; of the calendar file containing the event to be triggered.

`eventID`

- Specifies the unique ID of the event to be triggered, as stored in `calendarFile`.

##### Description

`triggerEvent()` is a &DCOP; call to trigger the immediate display or execution of the specified alarm (regardless of what time it is scheduled for). &kalarm; retrieves the alarm from the calendar file and then displays or executes it.

If the alarm is already due, &kalarm; then deletes all scheduled occurrences of the alarm up to the current time, and if no repetitions of the alarm still remain, the alarm is deleted from the calendar file. If the alarm is not due yet, its scheduled occurrences are left unchanged.

The `calendarFile` parameter is only used for integrity checking: if the &URL; does not specify &kalarm;'s current default calendar file, the request will be ignored.

The old name for this function, `displayMessage`, has been retained for compatibility, but all new applications should use `triggerEvent`.

handleEvent

handleEvent

trigger or cancel an already scheduled alarm.

    void handleEvent(const QString& calendarFile, const QString& eventID)

##### Parameters

`calendarFile`

- Specifies the &URL; of the calendar file containing the event to be displayed/executed or cancelled.

`eventID`

- Specifies the unique ID of the event to be displayed/executed or cancelled, as stored in `calendarFile`.

##### Description

`handleEvent()` is a &DCOP; call to display/execute or cancel the specified alarm. &kalarm; retrieves the alarm from the calendar file and then determines what action to take depending on when the alarm is due.

- If the alarm is not yet due, nothing happens.

- If the alarm is due, it acts as follows. If the late-cancel flag is set and the alarm is late, &ie; the scheduled trigger time was longer then one minute ago, &kalarm; does not display or execute the alarm; otherwise, &kalarm; displays or executes the alarm. If no repetitions of the alarm are still scheduled, &kalarm; then deletes the alarm from the calendar file.

The `calendarFile` parameter is only used for integrity checking: if the &URL; does not specify &kalarm;'s current default calendar file, the request will be ignored.

scheduleMessage

scheduleMessage

schedule a new alarm message.

    bool scheduleMessage(const QString& message, const QDateTime& dateTime, const QColor& bg, int flags, const QString& audioURL)

    bool scheduleMessage(const QString& message, const QDateTime& dateTime, const QColor& bg, int flags, const QString& audioURL, int simpleRepeatType, int interval, int repeatCount)

    bool scheduleMessage(const QString& message, const QDateTime& dateTime, const QColor& bg, int flags, const QString& audioURL, int simpleRepeatType, int interval, const QDateTime& endTime)

##### Parameters

`message`

- Specifies the text of the message to be scheduled.

`dateTime`

- Specifies the scheduled date and time at which the message should be displayed.

`bg`

- Specifies the background colour for displaying the message.

`flags`

- Specifies the logical OR of the desired alarm message flags. The flag bits are those defined in class KAlarmEvent in `msgevent.h`

`audioURL`

- Specifies the name or &URL; of an audio file which is to be played when the message is displayed.

`simpleRepeatType`

- Specifies the recurrence type for the alarm. The permissible values are MINUTELY, DAILY, WEEKLY, MONTHLY_DAY, ANNUAL_DATE. These are defined in class KAlarmEvent in `msgevent.h`.

`interval`

- Specifies the number of periods (minutes/days/weeks/months/years) between repetitions of the alarm message.

`repeatCount`

- Specifies the number of times that the alarm message should be displayed. Specify -1 to repeat the alarm indefinitely.

##### Description

`scheduleMessage()` is a &DCOP; call to schedule the specified alarm message for display at the specified date and time. It has three forms: one for a non-repeating alarm, one for a repeating alarm with a repetition count, and one for a repeating alarm with an end time.

If the scheduled time (including any repetitions) has already passed, &kalarm; immediately displays the message or, if the LATE_CANCEL flag bit is set, ignores the request. If the scheduled time (or a repetition) is in the future, &kalarm; adds the alarm message to the calendar file for later display.

Use a code sequence similar to the following to set up the parameter data for the &DCOP; call to `scheduleMessage()` for a non-repeating alarm:

    QString message, audioFile;
    QDateTime dateTime;
    QColor bgColour;
    Q_UINT32 flags;
    . . .
    QByteArray data;
    QDataStream arg(data, IO_WriteOnly);
    arg << message;
    arg.writeRawBytes((char*)&dateTime, sizeof(QDateTime));
    arg.writeRawBytes((char*)&bgColour, sizeof(QColor));
    arg << flags << audioFile;

Use a code sequence similar to the following to set up the parameter data for the &DCOP; call to `scheduleMessage()` for a repeating alarm:

    QString message, audioFile;
    QDateTime dateTime;
    QColor bgColour;
    Q_UINT32 flags;
    Q_INT32 repeatType, repeatCount, repeatInterval;
    . . .
    QByteArray data;
    QDataStream arg(data, IO_WriteOnly);
    arg << message;
    arg.writeRawBytes((char*)&dateTime, sizeof(QDateTime));
    arg.writeRawBytes((char*)&bgColour, sizeof(QColor));
    arg << flags << audioFile << repeatType << repeatCount << repeatInterval;

scheduleFile

scheduleFile

schedule a new alarm which displays the contents of a text file.

    bool scheduleFile(const QString& URL, const QDateTime& dateTime, const QColor& bg, int flags, const QString& audioURL)

    bool scheduleFile(const QString& URL, const QDateTime& dateTime, const QColor& bg, int flags, const QString& audioURL, int simpleRepeatType, int interval, int repeatCount)

    bool scheduleFile(const QString& URL, const QDateTime& dateTime, const QColor& bg, int flags, const QString& audioURL, int simpleRepeatType, int interval, const QDateTime& endTime)

##### Parameters

`URL`

- Specifies the name or &URL; of a text file whose contents are to be displayed in the message to be scheduled.

`dateTime`

- Specifies the scheduled date and time at which the file should be displayed.

`bg`

- Specifies the background colour for displaying the file.

`flags`

- Specifies the logical OR of the desired alarm flags. The flag bits are those defined in class KAlarmEvent in `msgevent.h`

`audioURL`

- Specifies the name or &URL; of an audio file which is to be played when the message is displayed.

`simpleRepeatType`

- Specifies the recurrence type for the alarm. The permissible values are MINUTELY, DAILY, WEEKLY, MONTHLY_DAY, ANNUAL_DATE. These are defined in class KAlarmEvent in `msgevent.h`.

`interval`

- Specifies the number of periods (minutes/days/weeks/months/years) between repetitions of the alarm.

`repeatCount`

- Specifies the number of times that the file should be displayed. Specify -1 to repeat the alarm indefinitely.

##### Description

`scheduleFile()` is a &DCOP; call to schedule the specified text file for display at the specified date and time. Apart from specifying a file name or &URL;, its usage is identical to `scheduleMessage` - see the description of that function for further details.

scheduleCommand

scheduleCommand

schedule a new alarm which executes a shell command.

    bool scheduleCommand(const QString& commandLine, const QDateTime& dateTime, int flags)

    bool scheduleCommand(const QString& commandLine, const QDateTime& dateTime, int flags, int simpleRepeatType, int interval, int repeatCount)

    bool scheduleCommand(const QString& commandLine, const QDateTime& dateTime, int flags, int simpleRepeatType, int interval, const QDateTime& endTime)

##### Parameters

`commandLine`

- Specifies the shell command line whose execution is to be scheduled.

`dateTime`

- Specifies the scheduled date and time at which the command should be executed.

`flags`

- Specifies the logical OR of the desired alarm flags. The flag bits are those defined in class KAlarmEvent in `msgevent.h` except that the BEEP flag bit is ignored.

`simpleRepeatType`

- Specifies the recurrence type for the alarm. The permissible values are MINUTELY, DAILY, WEEKLY, MONTHLY_DAY, ANNUAL_DATE. These are defined in class KAlarmEvent in `msgevent.h`.

`interval`

- Specifies the number of periods (minutes/days/weeks/months/years) between repetitions of the alarm.

`repeatCount`

- Specifies the number of times that the alarm should be repeated. Specify -1 to repeat the alarm indefinitely.

##### Description

`scheduleCommand()` is a &DCOP; call to schedule the specified shell command line for execution at the specified date and time. Apart from specifying a command line and omitting the message colour and audio file parameters, its usage is identical to `scheduleMessage` - see the description of that function for further details.

### Command line interface

Command line options are provided to enable other programs (such as the alarm daemon) to start up &kalarm; if it is not already running, in order to trigger or cancel scheduled alarms, or schedule new alarms. The reason for using command line options for this purpose is that if &kalarm; were started without any command line parameters and then sent &DCOP; requests, it would start in its default graphical mode, which is clearly undesirable for an inter-program request.

Programs should first check whether &kalarm; is already running; if it is, they should instead use &DCOP; calls to request these operations.

The command line options for scheduling a new alarm are as described in the chapter Using &kalarm;. The options for triggering and cancelling scheduled alarms are as follows:

Normal users may also if they wish use these command line options (assuming that they can supply the necessary parameter information).

Option | Description
`--calendarURL `url`` | Use the calendar file with the specified &URL;. This option is only used for integrity checking: if the &URL; doesn't specify &kalarm;'s current default calendar file, the request will be ignored.
`--cancelEvent `eventID`` | Cancel the event with the specified event ID.
`--triggerEvent `eventID`` | Trigger the event with the specified event ID. The action taken is the same as for the triggerEvent() &DCOP; call.
`--handleEvent `eventID`` | Trigger or cancel the event with the specified event ID. &kalarm; determines which action to take in the same way as for the handleEvent() &DCOP; call.

`--cancelEvent`, `--triggerEvent` and `--handleEvent` are mutually exclusive. `--calendarURL` is optional, but can only be used with one of the other three options.

Examples are:

    % kalarm --triggerEvent &kalarm;-387486299.702 --calendarURL file:/home/zaphod/hydra.ics
    % kalarm --cancelEvent &kalarm;-388886299.793

## Questions and Answers

&reporting.bugs; &updating.documentation;

What configuration files does &kalarm; use?

The file `$KDEHOME/share/config/kalarmrc` holds your &kalarm; preferences.

The calendar file which stores your scheduled alarms is `$KDEHOME/share/apps/kalarm/calendar.ics`, unless a different calendar file is specified in the preferences file.

If you change the calendar file in the preferences file, you should also edit the alarm daemon's `clients` configuration file to remove the old calendar file reference. This should be done while the alarm daemon is not running to avoid it overwriting your change.

What configuration files does the alarm daemon use?

The file `$KDEHOME/share/config/kalarmdrc` holds your alarm daemon preferences.

The file `$KDEHOME/share/apps/kalarmd/clients` holds details of client applications which have previously been registered with the alarm daemon, and their calendar files.

What are the application names of &kalarm; and the alarm daemon?

&kalarm;'s application name is kalarm, and the alarm daemon's application name is kalarmd. In addition, in &kde; versions previous to 3.1, there is a small application kalarmautostart whose function is to start &kalarm;'s system tray icon at login.

## Credits and Licence

&kalarm;

Program copyright 2001, 2002 David Jarvie software@astrojar.org.uk

Alarm daemon authors:

- Preston Brown pbrown@kde.org

- David Jarvie software@astrojar.org.uk

- Cornelius Schumacher schumacher@kde.org

Documentation copyright 2001, 2002 David Jarvie software@astrojar.org.uk

Thanks go to the author of the &kde;1 KAlarm application, Stefan Nikolaus stefan.nikolaus@stuco.uni-oldenburg.de, who kindly agreed to allow the name &kalarm; to be used by this &kde;2/&kde;3 application.

&underFDL; &underGPL;

## Installation

### How to obtain &kalarm;

&install.intro.documentation;

&kalarm; is available for &kde;2 and as a standalone package for &kde;3 from http://www.astrojar.org.uk/linux

### Requirements

&kalarm; requires the standard &kde; libraries to be installed (the `kdelibs` package). To compile from source, you also need the &Qt; and `kdelibs` development packages.

&kalarm; uses about 12 Mb and the alarm daemon uses about 2.5 Mb of memory to run, but this may vary depending on your platform and configuration.

You can find a list of changes in the `ChangeLog` file, or at http://www.astrojar.org.uk/linux/kalarm.html.

### Compilation and installation

If you cannot obtain a suitable precompiled binary package, you need to compile &kalarm; yourself from source files. Get the source package file `kdepim-x.x.tar.bz2` or `kalarm-x.x.tar.bz2` (or similar), depending on whether you want to install &package; or just &kalarm;. Unpack it in a new directory using a command similar to ``tar` `xvfj `package.tar.bz2```, and change to the directory which has been created.

&install.compile.documentation;

If you have more than one version of &kde; installed (e.g. &kde;2 and &kde;3), this may possibly install &kalarm; into the wrong &kde; directory. If necessary, you can give the &kde; directory as a parameter to ``./configure`` . For example, if your &kde; is installed in `/opt/kde2`:

``./configure` --prefix=`/opt/kde2``

### Configuration

No special configuration is required to set up &kalarm; to run on the &kde; desktop. Once you have run &kalarm; for the first time, the alarm daemon will start every time you log in, in order to monitor scheduled alarms.

To run &kalarm; on a non-&kde; desktop, the main requirement is to ensure that the alarm daemon is run automatically whenever you log in. More detailed instructions are contained in the `INSTALL` file which is distributed with &kalarm;.

&documentation.index;