-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalarm
More file actions
executable file
·66 lines (56 loc) · 1.42 KB
/
alarm
File metadata and controls
executable file
·66 lines (56 loc) · 1.42 KB
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
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
declare loud=0
declare urgent
declare old_volume
declare old_volume
cleanup() {
set_volume "$old_volume"
}
trap cleanup exit SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT
bground() {
("$@" &> /dev/null &)
}
get_volume() {
pactl list sinks | awk '/Volume:/{print $5; exit}'
}
set_volume() {
pactl set-sink-volume 0 "$1"
}
export -f set_volume
sounds() {
local xt ll
if (( loud )); then
set_volume '110%'
else
set_volume '50%'
fi
xterm -name dialog -class dialog -geometry 220x60 -display :0 -e "figlet -t '$1' && mpv ${urgent:+--loop=inf} '$sound' ${urgent:+--loop=inf}" &
xt=$!
if (( urgent )); then
while :; do
sleep 10
set_volume '+2%'
pactl set-sink-mute 0 false
done &
ll=$!
wait -f $xt
kill $ll
fi
}
old_volume=$(get_volume)
sound=~/Downloads/Store_Door_Chime-Mike_Koenig-570742973.mp3 # http://soundbible.com/1599-Store-Door-Chime.html
OPTERR=0
while getopts ':utL' opt; do
case "$opt" in
u) sound=~/'Downloads/Sunday\ Church\ Ambiance-SoundBible.com-974744686.wav' # http://soundbible.com/1264-Sunday-Church-Ambiance.html
urgent=1 ;;
L) loud=1 ;;
t) sound=~/'Downloads/Loud_Alarm_Clock_Buzzer-Muk1984-493547174.mp3' # http://soundbible.com/2061-Loud-Alarm-Clock-Buzzer.html
urgent=1 ;;
*) break ;;
esac
done
shift $(( OPTIND - 1 ))
unset opt OPTARG OPTIND
(( $# > 0 )) && notify-send ${urgent:+-u critical} "$@"
sounds "$2"