sleep-until: now is a script
This commit is contained in:
parent
fb83f01978
commit
c942f340ab
2 changed files with 15 additions and 17 deletions
15
.config/shell/bin/sleep-until
Executable file
15
.config/shell/bin/sleep-until
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
# Usage: sleep_until <time>
|
||||
# Ex: sleep-until 3:00 pm
|
||||
|
||||
if [ -n "$1" ] && date --date="$*" > /dev/null 2>&1; then
|
||||
SLEEP_TIME="$(( $(date -f - +%s- <<< "$*"$'\nnow') 0 ))"
|
||||
if [ "$SLEEP_TIME" -gt 0 ]; then
|
||||
echo "Sleeping until: $(date --date="$*") (${SLEEP_TIME}s)"
|
||||
sleep "$SLEEP_TIME"
|
||||
else
|
||||
echo "Sadly, you cannot sleep to a time in the past"
|
||||
fi
|
||||
else
|
||||
echo "Please input a valid date"
|
||||
fi
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Usage: sleep_until <time>
|
||||
# Ex: sleep_until 3:00 pm
|
||||
|
||||
sleep_until() {
|
||||
if [ -n "$1" ] && date --date="$*" > /dev/null 2>&1; then
|
||||
SLEEP_TIME="$(( $(date -f - +%s- <<< "$*"$'\nnow') 0 ))"
|
||||
if [ "$SLEEP_TIME" -gt 0 ]; then
|
||||
echo "Sleeping until: $(date --date="$*") (${SLEEP_TIME}s)"
|
||||
sleep "$SLEEP_TIME"
|
||||
else
|
||||
echo "Sadly, you cannot sleep to a time in the past"
|
||||
fi
|
||||
else
|
||||
echo "Please input a date"
|
||||
fi
|
||||
}
|
Loading…
Add table
Reference in a new issue