-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchime.linux
More file actions
executable file
·39 lines (30 loc) · 813 Bytes
/
chime.linux
File metadata and controls
executable file
·39 lines (30 loc) · 813 Bytes
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
#!/usr/bin/env bash
# Required to get sound from cron
export XDG_RUNTIME_DIR="/run/user/$UID"
# Directory to find chime sound files
export DIR=~/chime-time/
function active_sound {
pactl list sink-inputs | while read -r line ; do
echo $line | grep -oP 'Corked: \K[^$]'
echo $line | grep -oP 'application.process.binary = "\K[^"]+'
done | while read corked
do
read proc
echo $corked $proc
done
}
echo "chime"
any=$(active_sound | grep -v "^y" | grep -v "mumble")
if [[ -z "${any//[:space]}" ]]; then
echo "no other sound playing"
hour12=$(date +%I)
hour24=$(date +%-H)
if (( ${hour24} > 6 )) ; then
if (( ${hour24} < 22 )) ; then
echo "within chime hours, playing"
#mplayer $DIR/chime-${hour12}.aiff
/usr/bin/play $DIR/chime-${hour12}.aiff
echo "return code $?"
fi
fi
fi