From d7749a064a28c3c7a11a8791a8b7bc0036fe617a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 7 May 2025 17:18:36 +0200 Subject: checkpoint --- bin/extra/alarm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/extra/alarm (limited to 'bin/extra/alarm') diff --git a/bin/extra/alarm b/bin/extra/alarm new file mode 100755 index 0000000..f7a417f --- /dev/null +++ b/bin/extra/alarm @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ "$1" ] +then + AlarmTime="$1" +else + >&2 printf 'time: ' + AlarmTime="$(head -n 1)" +fi +[ "$AlarmTime" ] || exit 1 + +AlarmTimeSeconds="$(date -d "$AlarmTime" '+%s')" +[ "$AlarmTimeSeconds" ] || exit 1 + +TimeNowSeconds="$(date '+%s')" +SecondsToSleep="$((AlarmTimeSeconds - TimeNowSeconds))" +>&2 printf 'now: %s\n' "$(date '+%T')" + + +if [ "$SecondsToSleep" -gt 0 ] +then + >&2 printf 'Sleeping %s seconds...\n' "$SecondsToSleep" + sleep "$SecondsToSleep" >/dev/null 2>&1 +else + >&2 printf 'Not sleeping\n' +fi + +>&2 printf 'press [q] to quit ' +mpv --loop --volume=100 --msg-level=all=no --resume-playback=no ~/sync/share/sounds/pomo.aac 2>/dev/null +>&2 printf '\n' -- cgit v1.2.3-70-g09d2