D
D
dmitry_hidden2014-06-09 19:04:31
linux
dmitry_hidden, 2014-06-09 19:04:31

linux. Shell. Sound notification about the end of the execution of a long command

Sometimes you run commands in the terminal that take a long time (minutes). While you wait, you move on to reading all sorts of sites or even leave the computer. I would like to receive sound notifications at the end of such a process.
Moreover, a sound notification is needed if the process is quite lengthy (let's say it takes more than 20 seconds).
As I see it:
Some of my commands are launched in the console, if the execution took more than 20 seconds, then a beep occurs at the end. If it's done quickly, don't run anything. (To avoid the case when you run a lot of small commands and get constantly beep, beep, beep)
Tell me which way to dig? Are there ready-made solutions or at least blanks?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
Dmitry, 2014-06-14
@dmitry_hidden

there is such a cool thing mumak.net/undistract-me + article on Habré habrahabr.ru/post/174449

V
Vadim Yakovlev, 2014-06-09
@FrimInc

long command && echo -en "\007"

S
seniorivn, 2014-06-09
@seniorivn

welinux.ru/post/963
and switch to zsh

I
Igor, 2014-06-10
@merryjane

As for the sound, I don’t think that this is a good option, and the speakers are connected in few places now, here is a pop-up message for yourself:
You can also connect via &&, for example:

gzip very_big_dump_file.sql && notify-send --expire-time=10000 "Dump" "gzip have done"

D
dmitry_hidden, 2014-06-10
@dmitry_hidden

I don’t see a ready-made beautiful solution (
Can I create my own bike?
There was an idea to override the bash_rc function prompt_command, which will send the called commands to a separate python daemon, in which all the logic will be implemented.
Send messages via dbus-send
How do you like the idea?

X
xandox, 2014-06-10
@xandox

Add something like this to .bashrc

function notify_if_long() { 
    start=$(date +%s); 
    eval "[email protected]"; 
    end=$(date +%s); 
    elaps=$(( $end - $start )); 
    if ; # или сколько там секунд тебе надо 
    then 
           echo -en "\007"; #тут любой из предложенных способов натификации
    fi;
}

use like this
notify_if_long sleep 11
notify_if_long cat somefile \| grep something

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question