patchThe GNU Bourne-Again SHell - Patches: patch #10471, Notify when finished feature

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #10471: Notify when finished feature

Submitter:  Harkaitz Agirre <harkaitz>
Submitted:  Sun 25 Aug 2024 06:51:27 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open

Sat 08 Feb 2025 01:27:45 PM UTC, comment #2: 

You are right, this could be solved better with a simple function
added in "/etc/profile.d".

https://github.com/harkaitz/sh-alert-scripts/blob/master/etc/profile.d/fga.sh

Harkaitz Agirre <harkaitz>
Wed 29 Jan 2025 08:35:51 PM UTC, comment #1: 

Can't this be solved with pure bash scripting? Or maybe a custom loadable builtin? There are lots of inspiring examples in the bash source code. The public C programming interface of bash is also very versatile and powerful for most use cases.
For my systems I decided to focus on custom loadable built-ins (shared objects), because it also has the benefit to be loadable on every system without recompiling bash with additional build flags.
But probably you already evaluated these approaches, right?

Dominik Kummer <domson>
Sun 25 Aug 2024 06:51:27 PM UTC, original submission:  

This patch introduces the "notify me when finished" feature in bash.

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 Bash 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

Services like ntfy.sh etc can be used to notify the phone.

Do you like this feature? Any suggestions?

Harkaitz Agirre <harkaitz>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by domson (Posted a comment)
  • -email is unavailable- added by harkaitz (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-08-25 harkaitz Attached File- Added 0001-Notify-when-finished.patch, #56385

    Back to the top

    Powered by Savane 3.14-430a.
    Corresponding source code