Question

I would like to find a way to get my terminal to give audio feedback whenever new input is delivered to the terminal.

Here's the scenario. At my desk, I have a monitoring machine set up that has various Munin and NewRelic dashboards. I'm also tailing a few logs in Terminal, some with specific greps. I would like to find a way to have the terminal play a sound when one of these tail'd logs is updated.

For example:

tail -f /var/log/myservice.log | grep "CRITICAL" | beep
Était-ce utile?

La solution

Most terminals (can be configured) to beep when a ^G character is displayed; that is the ASCII BEL character.

You can generate the BEL character with an echo -e '\a' command or something similar. With a slight change of your script, you ought to be able to do this easily:

tail -f /var/log/myservice.log | sed 's/CRITICAL/CRITICAL\a/'

Most terminals will also set the Urgent flag on the window in question, which should make it easy to discover the specific terminal that requires attention even when on another desktop.

Autres conseils

in konsole you can tell it to monitor a terminal for activity, and you can configure what notifications to use (sound, popup, run command...).

This is how to play sound every time that some file changes:

while true; do inotifywait /var/log/myservice.log && mplayer /usr/share/sounds/ubuntu/stereo/bell.ogg; done

Press Ctrl+C to interrupt. You need to install package inotify-tools and mplayer (can be replaced with any other console player).

If you still want to see tail output, run tail in another tab.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top