#/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}"