How to receive notifications at the end of the execution of a command in a terminal

The other day, reading the excellent blog WebUpd8, I discovered a tool to receive a notification at the end of the execution a command in the terminal, which can be useful in cases where this task can take several minutes. Honestly, I do not think it is the best solution. For that reason, here we propose other alternativesPlus traineeships and simple.

undistract-me

Andrew's recommended tool is Unidstract-me.

Installation in Ubuntu and derivatives:

sudo add-apt-repository ppa: undistract-me-packagers / daily sudo apt-get update sudo apt-get install undistract-me

To use it, you must enable the option "Run command as login terminal" in the terminal of your preference. In the one that comes with GNOME we can enable this option under Edit> Profile Preferences.

Once installed, any command that takes more than 10 seconds will display a message upon completion.

To install Undistract-me on other distros, you can find the instructions here.

other alternatives

The advantage of the methods shown below are several:

  • they run only when the user requests it
  • do not require the installation of additional programs (usually the necessary packages are already installed in almost all popular distros)
  • if laziness eats away at you, you can easily turn them into a script
  • they are super fast, do not consume resources and are easy to learn

notify-send

To display Ubuntu-style Notification messages, you must have notify-send installed. Ubuntu, Linux Mint, and derivatives come with this package installed by default. Arch users can install it from the AUR.

Then, just add && notify-send "Done!" at the end of the command we want to execute. Assuming that the command to execute was cat:

cat file && notify-send "Done!"

zenity

A more "complex" notification system is Zenity, with which we can display dialog boxes with buttons, etc.

As with notify-send, just add && zenity –info –text = »Finished!» at the end of the command we want to execute. Assuming, once again, that the command to execute was cat:

cat file && zenity --info --text = "Long command completed."
An interesting tip: it is possible to replace && with; to add elements to the command chain to be executed. For example, cat file && ls would stay cat file; ls.

Source: Webupd8


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Stephen Saracho said

    In theory this could also work: »cat file && echo -ea«, produces a beep at the end of the command (in chakra it does not work). About the Tip (if I did not misunderstand), "command1; command2" is not the same as "command1 && command2"; In the first case, command2 is executed regardless of whether command1 has finished correctly, in the second it is only executed if command1 finished correctly. Greetings and good post, I liked notify-send, very practical

  2.   pandacriss said

    very useful! testing…

  3.   Javi said

    Hello, I usually use this option better:
    cat file; zenity –info –text = »Long command completed.» &

    This allows me to put more than one notification and the terminal does not lock until I press.

    regards