Sfoglia il codice sorgente

monbell commands lets you trigger a command when it receives a bell character

master
mort 8 anni fa
parent
commit
5b42f83fe5
1 ha cambiato i file con 20 aggiunte e 0 eliminazioni
  1. 20
    0
      bin/monbell

+ 20
- 0
bin/monbell Vedi File

#!/bin/bash

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, run user's command
$1
done;

Loading…
Annulla
Salva