12345678910111213141516171819202122232425262728 |
- #!/bin/bash
-
- # Written by Francis Wharf, https://github.com/xeom
-
- # Default
- name="<unknown>"
-
- # If there is an argument, use it as program name
- [[ $1 ]] && name=$1
-
- while true; do
- # Read, ignoring escapes, until the first bell char if
- # no bell is received in 10 seconds, the script loops
- read -r -d $(printf "\007") -t 10;
- code=$?
-
- # If the code is a timeout error, continue
- if [[ $code > 128 ]]; then
- continue
-
- # If read returned eof, suicide
- elif [[ $code != 0 ]]; then
- exit 0
- fi
-
- # If read returned success, notify user of bell
- mnotify "$name" "Bell received"
- done;
|