summaryrefslogtreecommitdiff
path: root/wake.sh
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-03-08 17:41:20 +0100
committerxengineering <me@xengineering.eu>2023-03-11 19:10:12 +0100
commit617ed79590ea350301be4037eea4864857e907fe (patch)
tree8faceee07955c2153498f9ec8d9056d74ef6c442 /wake.sh
parente195eba780cd187700943ceda441ea16b43de7de (diff)
downloadscripts-617ed79590ea350301be4037eea4864857e907fe.tar
scripts-617ed79590ea350301be4037eea4864857e907fe.tar.zst
scripts-617ed79590ea350301be4037eea4864857e907fe.zip
Add wake.sh
Diffstat (limited to 'wake.sh')
-rwxr-xr-xwake.sh30
1 files changed, 30 insertions, 0 deletions
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 <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}"