Skip to content

Instantly share code, notes, and snippets.

@cGuille
Created July 5, 2016 15:27
Show Gist options
  • Select an option

  • Save cGuille/f7f50de9b7e20e8527bca649ca9582d5 to your computer and use it in GitHub Desktop.

Select an option

Save cGuille/f7f50de9b7e20e8527bca649ca9582d5 to your computer and use it in GitHub Desktop.
A bash script that schedules a desktop notification sometime later.
#!/usr/bin/env bash
# USAGE:
# remindme {WHEN} {REMINDER MESSAGE}
# - The first argument must be compliant with DATE(1) and defines when to remind you.
# - The following arguments are a message to be delivered in a desktop notification.
#
# Examples:
# remindme tomorrow Write an e-mail to John Doe
# remindme '20160705 17:25' Call Jane Doe
# Display the notification during this amount of milliseconds:
NOTIFICATION_DURATION=20000
set -e
delay=$1
shift
message=$*
if [[ $delay == ?(-)+([0-9]) ]]; then
delay="$delay minutes"
fi
reminder_delay=$(( $(date -d "$delay" +'%s') - $(date +'%s') ))
echo "You will be reminded of this on $(date -d "$delay") unless you shutdown your computer in the meantime."
(
sleep "$reminder_delay"
notify-send -t "$NOTIFICATION_DURATION" "$message"
) &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment