Technology enthusiast, photographer and die-hard programmer
which at
to see if it's present. If not, install it with your package manager of choice, for examplesudo apt install notify-send
notify-send "Dinner ready!"
notify-send "Tip of the Day" "How about a nap?"
man notify-send
. You can use a small set of HTML tags in the notification body, to give your notifications nice touch. On top of that, URLs are rendered as clickable, for example:notify-send -u critical \
"Build failed!" \
"There were <b>123</b> errors. Click to see the results: http://buildserver/latest"
at 12:00
at
accepts parameters from standard input, so we can use it this way:echo "npm run build" | at now + 1 minute
echo "backup-db" | at 13:00
10:00
through relative time such as now + 2 hours
to special times such as noon
or midnight
. We can combine it with notify-send
to show ourselves reminders at some time in future, for example:echo "notify-send 'Stop it and go home now' 'Enough for today.' -u critical" | at now
remind "I'm still here" now
remind "Time to wake up!" in 5 minutes
remind "Dinner" in 1 hour
remind "Take a break" at noon
remind "It's Friday pints time!" at 17:00
remind
which supports the above syntax. The actual work is done in the last two lines. The rest is responsible for help, parameter validation etc. which rougly matches the proportion of useful code vs necessary white-noise in any large application 😉 Save the code somewhere, for example in ~/bin/remind
file and load the function in your .bashrc
profile:source ~/bin/remind
remind
to see the syntax. Enjoy!#!/usr/bin/env bash
function remind () {
local COUNT="$#"
local COMMAND="$1"
local MESSAGE="$1"
local OP="$2"
shift 2
local WHEN="[email protected]"
# Display help if no parameters or help command
if [[ $COUNT -eq 0 || "$COMMAND" == "help" || "$COMMAND" == "--help" || "$COMMAND" == "-h" ]]; then
echo "COMMAND"
echo " remind <message> <time>"
echo " remind <command>"
echo
echo "DESCRIPTION"
echo " Displays notification at specified time"
echo
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'
echo ' remind list'
echo ' remind clear'
echo ' remind help'
echo
return
fi
# Check presence of AT command
if ! which at >/dev/null; then
echo "remind: AT utility is required but not installed on your system. Install it with your package manager of choice, for example 'sudo apt install at'."
return
fi
# Run commands: list, clear
if [[ $COUNT -eq 1 ]]; then
if [[ "$COMMAND" == "list" ]]; then
at -l
elif [[ "$COMMAND" == "clear" ]]; then
at -r $(atq | cut -f1)
else
echo "remind: unknown command $COMMAND. Type 'remind' without any parameters to see syntax."
fi
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 "remind: 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"
}
notify-send
on MacOS, notifications can be sent with ActionScript. For example:osascript -e 'display notification "Wake up!" with title "Reminder"'
at
available, so things should be easy? Well, not so. Sadly, MacOS is makes it increasingly difficult for power users to use their powers ...at
is disabled by default. Even if you run it, nothing will happen at scheduled time, because atrun
daemon is disabled, and no user account is allowed to use it by default./var/at/at.allow
file and add your user name.sudo open -a textedit /var/at/at.allow
atrun
daemon:sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
osascript -e 'display notification "Wake up!" with title "Reminder"' | at now
atrun
to the list. The file is found at /usr/libexec/atrun
path. You want to see this:# Install reattach-to-user-namespace utility
brew install reattach-to-user-namespace
# Run notification command as follows
reattach-to-user-namespace osascript -e 'display notification "Wake up!" with title "Reminder"' | at now
remind
script on your Mac as well! Happy weekend!