summaryrefslogtreecommitdiff
path: root/wake.sh
blob: a682ad3c7a1a6f91a5c33b341e4233634eb7df4c (plain)
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
#/bin/sh


# wake.sh [time]
#
# A script to play $SOUNDFILE (see below) at a time given as shell argument.
# The format of this timestamp corresponds to whatever `date -d <format>`
# accepts.
#
# See these examples:
#
# - ./wake.sh "tomorrow 6:15"    # wake up tomorrow
# - ./wake.sh "5 minutes"        # 5 minute timer
# - ./wake.sh "2059-03-08 9:30"  # reminder on a specific date and time
#
# See `man 1 date` for details.


SOUNDFILE="${HOME}/wakeup-sound"


time_str="$1"
time_parsed="$(date -d "${time_str}")"
time_unix="$(date -d "${time_str}" +%s)"
now_unix="$(date +%s)"
delta="$(((${time_unix}) - (${now_unix})))"

echo "Alarm set to: ${time_parsed}"
sleep "${delta}"
mpv --no-video --no-resume-playback --really-quiet "${SOUNDFILE}"