Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know there is such a thing as a visual bell in Vim that makes the whole screen flash instead of beeping. Several terminal programs also have the same feature.

I'm looking for a similar type of visual bell that will flash all of my screens, on all of my virtual desktops, in X. I've only got headphones at work and my pc speaker is too quiet, so I need some other notification method that will definitely get my attention.

Does anyone know if it exists?

share|improve this question

6 Answers 6

up vote 2 down vote accepted

I don't of anything exactly like that, but you can use the command line tool notify-send to have pop-ups on the desktop. In Ubuntu the package is libnotify-bin. For example:

notify-send -u normal -t 10000 -i info 'hw' 'Hello world'
share|improve this answer
    
Since this works in any window manager, I'd say it's the best answer for now. –  Neil Jun 4 '09 at 16:55

You could use something like Zenity to show an alert dialog, or perhaps even a notification area item. You could also use dzen or xmsgd if you want something text-based. Note that none of these 'flash the screen' though.

share|improve this answer

You didn't specify GNOME or KDE, but KDE 4.2 has built-in support for this. If you look under System Settings > Accessibility, you can turn on the visual bell there. KDE also lets you customize actions for various system notifications that go beyond sounds. For example, you can show a popup, run a command, mark a taskbar entry, etc. This is under System Settings > System Notifications.

share|improve this answer
    
That's cool. I hope there's a Gnome equivalent. –  Neil Jun 4 '09 at 16:55

Depending on what you need, there is also xmessage—it's old, it's ugly, but it's included with X. It doesn't flash the screen, but it will pop up a message, and you can specify what buttons are on it (which one you press is returned in the exit status) if that's important.

share|improve this answer

Depending on the nature of the event and what desktop environment you are using, Specto might work for you.

share|improve this answer

Yes, this is possible!

The following is an implementation that dims your monitor's LCD backlight and then brings it back to where it was.

Step one: find a way to reliably alter your backlight [1][2]. I'll use the simplest one here but ymmv.

There are kernel(?)-level controls in /sys/class/backlight. The exact subdirectory name will vary based on your setup. I'm using this method in this example, but if you find another command that works, you can skip step two and alter the script in step three to have the get_brightness and set_brightness functions use your chosen method.

This will give you your current brightness level

cat /sys/class/backlight/intel_backlight/brightness

Now try changing it:

export BRIGHTNESS=/sys/class/backlight/intel_backlight/brightness
echo 50 |sudo tee $BRIGHTNESS; sleep 1; echo 80 |sudo tee $BRIGHTNESS

This should make your screen darker for one second and then bring it to level 80 (use the value you got earlier or else your display may be too dark). I've bundled them into the same command so you don't get stuck with a screen that is too dark. In this test, we're acting as root. We'll get access for your own account next. (Stop here if it doesn't work!)

Step two: get access for your own account:

sudo chmod g+w /sys/class/backlight/intel_backlight/brightness
sudo chgrp video /sys/class/backlight/intel_backlight/brightness
sudo usermod -a -G video my_username

(Note, this might not survive rebooting. I'll come back and revise this if that's the case, but I only reboot ~quarterly, so bear with me.)

Step three: write a script like the following:

#!/bin/sh
help() { cat <</help
Blink/flash the whole X display (on one LCD monitor)
Usage: visual-bell [BLINK_COUNT]
0.2+20140327 Copyright (c) 2010+ by Adam Katz <www.khopis.com/scripts>, LGPL 2+
/help
}

SLEEP_TIME=0.03
BRIGHTNESS=/sys/class/backlight/intel_backlight/brightness

get_brightness() {
  cat $BRIGHTNESS
}

set_brightness() {
  echo $1 > $BRIGHTNESS
}

COUNT=${1:-1}  # read count from first argument (default to one blink)
# if the argument wasn't a number greater than zero, show help and exit
if ! [ "$COUNT" -gt 0 ] 2>/dev/null; then
  help
  exit 1
fi

LEVEL=`get_brightness`

while [ $COUNT -gt 0 ]; do

  set_brightness 0        # blacken the screen
  sleep $SLEEP_TIME
  set_brightness $LEVEL   # revert the screen to previous brightness
  sleep $SLEEP_TIME

  COUNT=$((COUNT-1))      # decrement counter

done

You should be good to go. Save that as /usr/local/bin/visual-bell and make it executable (chmod +x visual-bell), then you can run it. This script will blink the given number of times (defaults to one), so you can run visual-bell 3 to blink three times.

You can theoretically blink multiple monitors if you use /sys/class/backlight/*/brightness but beware that different monitors may have different brightness scales. My Dell LCD (connected via a DisplayPort-VGA adapter) does not work here, though my laptop display does.

Further steps: Install as the "sound command" in programs like pidgin. I do not know how to do this in terminal emulators.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.