Skip to content

Instantly share code, notes, and snippets.

@sokolovvs
Last active March 5, 2021 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sokolovvs/ba8cc7e109434efd3d6911f8c7c3729e to your computer and use it in GitHub Desktop.
Save sokolovvs/ba8cc7e109434efd3d6911f8c7c3729e to your computer and use it in GitHub Desktop.
Simple timer (shell scripts, uses notify-send)
#!/usr/bin/env bash
function help() {
echo "Please, run this script with one argument."
echo "Examples:"
echo "1) $0 1h"
echo "2) $0 30m"
echo "3) $0 125s"
echo "4) $0 1h <your message>"
echo "5) $0 30m <your message>"
echo "6) $0 125s <your message>"
}
if [[ $# -gt 0 ]]
then
if [[ $1 =~ ^[1-9]*[0-9]*[h|m|s]$ ]]
then
sleep $1 &&
notify-send --urgency normal \
--expire-time=10000 \
-i /usr/share/icons/hicolor/48x48/apps/unity-datetime-panel.png \
"Timer" "$2"
else
help
fi
else
help
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment