diff options
author | xengineering <me@xengineering.eu> | 2023-03-08 17:41:20 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-03-11 19:10:12 +0100 |
commit | 617ed79590ea350301be4037eea4864857e907fe (patch) | |
tree | 8faceee07955c2153498f9ec8d9056d74ef6c442 /wake.sh | |
parent | e195eba780cd187700943ceda441ea16b43de7de (diff) | |
download | scripts-617ed79590ea350301be4037eea4864857e907fe.tar scripts-617ed79590ea350301be4037eea4864857e907fe.tar.zst scripts-617ed79590ea350301be4037eea4864857e907fe.zip |
Add wake.sh
Diffstat (limited to 'wake.sh')
-rwxr-xr-x | wake.sh | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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 <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}" |