diff --git a/man/remind.1.in b/man/remind.1.in index b7ee6662..5fcb9e5f 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -328,6 +328,18 @@ processes with the above technique. So be very careful. Because all shell and whitespace characters are escaped, the program you execute with the \fB\-k\fR option must be prepared to handle the entire message as a single argument. +.PP +If you follow the \fB\-k\fR option with a colon, then the command is applied +only to queued timed reminders. Normal reminders are handled as usual. +In the above example, if you want normal reminders to simply be displayed +as usual, but queued reminders to be sent to notify-send, you could use: +.PP +.nf + remind '\-k:notify-send %s &' ... +.fi +.PP +You use both \fB\-k\fR\fIcmd1\fR and \fB\-k:\fR\fIcmd2\fR to use different +commands for queued versus non-queued reminders. .RE .TP \fB\-z\fR[\fIn\fR] Runs \fBRemind\fR in the daemon mode. If \fIn\fR diff --git a/src/dorem.c b/src/dorem.c index 0cbbf044..afbf5e28 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -192,7 +192,7 @@ int DoRem(ParsePtr p) r = OK; if (ShouldTriggerReminder(&trig, &tim, dse, &err)) { - if ( (r=TriggerReminder(p, &trig, &tim, dse)) ) { + if ( (r=TriggerReminder(p, &trig, &tim, dse, 0)) ) { FreeTrig(&trig); return r; } @@ -898,7 +898,7 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type) /* Trigger the reminder if it's a RUN or MSG type. */ /* */ /***************************************************************/ -int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse) +int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse, int is_queued) { int r, y, m, d; char PrioExpr[VAR_NAME_LEN+25]; @@ -906,8 +906,16 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse) DynamicBuffer buf, calRow; DynamicBuffer pre_buf; char const *s; + char const *msg_command = NULL; Value v; + if (MsgCommand) { + msg_command = MsgCommand; + } + if (is_queued && QueuedMsgCommand) { + msg_command = QueuedMsgCommand; + } + int red = -1, green = -1, blue = -1; int is_color = 0; @@ -952,7 +960,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse) } /* If it's a MSG-type reminder, and no -k option was used, issue the banner. */ if ((t->typ == MSG_TYPE || t->typ == MSF_TYPE) - && !DidMsgReminder && !NextMode && !MsgCommand) { + && !DidMsgReminder && !NextMode && !msg_command) { DidMsgReminder = 1; if (!DoSubstFromString(DBufValue(&Banner), &buf, DSEToday, NO_TIME) && @@ -1096,7 +1104,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse) DBufPuts(&buf, Decolorize()); } - if ((!MsgCommand && t->typ == MSG_TYPE) || t->typ == MSF_TYPE) { + if ((!msg_command && t->typ == MSG_TYPE) || t->typ == MSF_TYPE) { if (DBufPutc(&buf, '\n') != OK) { DBufFree(&buf); return E_NO_MEM; @@ -1118,8 +1126,8 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse) switch(t->typ) { case MSG_TYPE: case PASSTHRU_TYPE: - if (MsgCommand) { - DoMsgCommand(MsgCommand, DBufValue(&buf)); + if (msg_command) { + DoMsgCommand(msg_command, DBufValue(&buf)); } else { printf("%s", DBufValue(&buf)); } diff --git a/src/globals.h b/src/globals.h index af59f4d2..b914c6e9 100644 --- a/src/globals.h +++ b/src/globals.h @@ -52,6 +52,7 @@ EXTERN uid_t TrustedUsers[MAX_TRUSTED_USERS]; EXTERN INIT( int NumTrustedUsers, 0); EXTERN INIT( char const *MsgCommand, NULL); +EXTERN INIT( char const *QueuedMsgCommand, NULL); EXTERN INIT( int ShowAllErrors, 0); EXTERN INIT( int DebugFlag, 0); EXTERN INIT( int DoCalendar, 0); diff --git a/src/init.c b/src/init.c index 48f6f311..69f51f16 100644 --- a/src/init.c +++ b/src/init.c @@ -600,7 +600,12 @@ void InitRemind(int argc, char const *argv[]) case 'k': case 'K': - MsgCommand = arg; + if (*arg == ':') { + arg++; + QueuedMsgCommand = arg; + } else { + MsgCommand = arg; + } while (*arg) arg++; /* Chew up remaining chars in this arg */ break; diff --git a/src/protos.h b/src/protos.h index ce3b697d..bc2f6bd3 100644 --- a/src/protos.h +++ b/src/protos.h @@ -35,7 +35,7 @@ int DoRem (ParsePtr p); int DoFlush (ParsePtr p); void DoExit (ParsePtr p); int ParseRem (ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals); -int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int dse); +int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int dse, int is_queued); int ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int dse, int *err); int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int mode); int DoSubstFromString (char const *source, DynamicBuffer *dbuf, int dse, int tim); diff --git a/src/queue.c b/src/queue.c index 43f84501..95954bc5 100644 --- a/src/queue.c +++ b/src/queue.c @@ -267,7 +267,7 @@ void HandleQueuedReminders(void) /* Set up global variables so some functions like trigdate() and trigtime() work correctly */ SaveAllTriggerInfo(&(q->t), &(q->tt), DSEToday, q->tt.ttime, 1); - (void) TriggerReminder(&p, &trig, &q->tt, DSEToday); + (void) TriggerReminder(&p, &trig, &q->tt, DSEToday, 1); if (Daemon < 0) { printf("NOTE endreminder\n"); }