Fw: [PATCH] Notify when finished
Harkaitz Agirre
harkaitz.aguirre at gmail.com
Tue Aug 27 08:42:16 UTC 2024
Begin forwarded message:
Date: Tue, 27 Aug 2024 10:40:32 +0200
From: Harkaitz Agirre <harkaitz.aguirre at gmail.com>
To: Kang-Che Sung <explorer09 at gmail.com>
Subject: Re: [PATCH] Notify when finished
On Tue, 27 Aug 2024 01:41:27 +0800
Kang-Che Sung <explorer09 at gmail.com> wrote:
> Harkaitz Agirre <harkaitz.aguirre at gmail.com> 於 2024年8月26日
> 星期一寫道:
> > This patch introduces the "notify me when finished" feature in
> > Busybox
> Shell.
> >
> > When executing long-running commands (such as compiling code or
> > performing backups), it can be useful to receive notifications when
> > these tasks
> finish.
> >
> > This allows the user to step away from the terminal, perhaps to
> > grab a
> coffee.
> >
> > The need for a notification is usually an afterthought, so it is not
> > practical to add a prefix to the commands in order to being
> > notified when finished. Instead, it is more convenient to have a
> > mechanism that
> automatically
> > alerts the user when a command takes longer than expected.
> >
> > This change makes ash read two variables, TIMED_ALERT and
> TIMED_ALERT_SECS.
> >
> > If a command execution exceeds the time specified in
> > $TIMED_ALERT_SECS (by default 60 seconds) executes the command in
> > $TIMED_ALERT (if set).
> >
> > The command in $TIMED_ALERT can consult
> $TIMED_COMMAND,$TIMED_COMMAND_DURATION
> > and $? to prepare the message to send.
> >
> > One example:
> >
> > $ export TIMED_ALERT='notify-send "Command finished" "Command
> $TIMED_COMMAND finished in $TIMED_COMMAND_DURATION seconds with exit
> status $?"'
> > $ export TIMED_ALERT_SECS=10
> >
>
> My personal comments on this:
>
> 1. Does any other core utility or shell ever implement this feature?
> If not, it's unlikely that busybox should be the first to support
> this feature either.
>
> 2. My concern is on the future interoperability with other Unix
> shells, as you would now reserve `TIMED_ALERT*` and `TIMED_COMMAND*`
> environment variables for this BusyBox-exclusive feature. Better not
> do this unless there is no other option available.
>
> 3. As other people have suggested: this feature can be implemented as
> a separate wrapper script. Making the `TIMED_ALERT` built-in can
> sometimes be annoying when user has to run a command that lasts a
> long duration simply because it is interactive (e.g. `top(1)`) or it
> is meant to monitor something in the back . And your `TIMED_ALERT`
> feature doesn't seem to exempt these commands from alerting.
Thank you for the response Kang-Che,
I think the best solution is the one given by Laurent, a solution around
"fg", or I in my opinion something around job control. That would solve
the point 3 you pointed out (long duration interactive programs).
To have the duration and the command in the notification I guess the
best would be to be able to access some variables from job control.
Point 1 and 2, I think this is a feature all shells should have, it is
more useful than MAIL (at least for me), I have to agree with you that
ideally it should be implemented outside the shell in a separate script.
Harkaitz
More information about the busybox
mailing list