From 617ed79590ea350301be4037eea4864857e907fe Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 8 Mar 2023 17:41:20 +0100 Subject: Add wake.sh --- wake.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 wake.sh diff --git a/wake.sh b/wake.sh new file mode 100755 index 0000000..a682ad3 --- /dev/null +++ b/wake.sh @@ -0,0 +1,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 ` +# 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}" -- cgit v1.2.3-70-g09d2