-
Notifications
You must be signed in to change notification settings - Fork 1
/
tæller.sh
executable file
·58 lines (43 loc) · 1.04 KB
/
tæller.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/zsh
# shellcheck shell=bash
# define default filter file
filter="google.txt"
# allow user to specify an alternative filter file
# ./tæller.sh meta.txt
if [ -n "$1" ];
then
filter="$1"
fi
sniff() {
if [ ! -f "$filter" ];
then
echo "'$filter' filter file does not exist" >&2
exit 1
fi
sudo tcpdump --immediate-mode -nql -F "$filter" 2>&1
}
debounce() {
# limit to 10 beeps per second
last_line="none"
while read -r line;
do
if [ "$last_line" = "${line:0:10}" ];
then
continue;
fi
last_line="${line:0:10}"
echo "$last_line"
done
}
beep() {
while read -r;
do
# visual output
printf "[32;1m.[0m"
# the bell is too slow
# printf \\x07
# this works, thanks to https://osxdaily.com/2016/03/31/play-dtmf-tones-mac/
afplay --volume 0.05 /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/telephony/dtmf-pound.caf &
done
}
sniff | debounce | beep