first draft
This commit is contained in:
40
remind.sh
Executable file
40
remind.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function remind() {
|
||||
local COUNT="$#"
|
||||
local COMMAND="$1"
|
||||
local MESSAGE="$1"
|
||||
local OP="$2"
|
||||
shift 2
|
||||
local WHEN="$@"
|
||||
|
||||
# Display help if no parameters or help command
|
||||
if [[ $COUNT -eq 0 || "$COMMAND" == "help" || "$COMMAND" == "--help" || "$COMMAND" == "-h" ]]; then
|
||||
echo "Usage: remind <message> <time>"
|
||||
echo "Examples:"
|
||||
echo ' remind "Hi there" now'
|
||||
echo ' remind "Time to wake up" in 5 minutes'
|
||||
echo ' remind "Dinner" in 1 hour'
|
||||
echo ' remind "Take a break" at noon'
|
||||
echo ' remind "Are you ready?" at 13:00'
|
||||
return
|
||||
fi
|
||||
|
||||
# Determine time of notification
|
||||
if [[ "$OP" == "in" ]]; then
|
||||
local TIME="now + $WHEN"
|
||||
elif [[ "$OP" == "at" ]]; then
|
||||
local TIME="$WHEN"
|
||||
elif [[ "$OP" == "now" ]]; then
|
||||
local TIME="now"
|
||||
else
|
||||
echo "Invalid time operator $OP"
|
||||
return
|
||||
fi
|
||||
|
||||
# Schedule the notification
|
||||
echo "notify-send '$MESSAGE' 'Reminder' -u critical" | at $TIME 2>/dev/null
|
||||
echo "Notification scheduled at $TIME"
|
||||
}
|
||||
|
||||
remind "$@"
|
||||
Reference in New Issue
Block a user