Search code examples
linuxterminallinux-kernelgnome-terminal

Pop up or sound after completion of any running process in terminal (Linux)


I want to write a program for having a pop up or sound after completion of any running process in terminals of any Linux distributions. Many times I run some command in the terminal and leave it to complete the process but then I have to keep checking that whether it has been completed or not. Any suggestions on how to get started with this?


Solution

  • Here's a solution using notify-send, which is available on most linux desktop environments:

    yourCommand; notify-send "Completed !:0" "Exit status: $?"
    

    Another tool for such things is zenity:

    yourCommand; zenity --info --text "Command !:0 completed with exit code $?"
    

    Both tools are either already installed on your system or easily installable with the package manager. You might want to wrap the above snippets into an alias or into a custom script that you place somewhere in your $PATH.