Created
June 10, 2024 03:07
-
-
Save lowk3v/dc429ef86a7bb7eca7760381d0f210d9 to your computer and use it in GitHub Desktop.
Random words to reminder on mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!env bash | |
mac_notify() { | |
# Usage: mac_notify "title" "subtitle" "message" "sound" | |
sound="Glass" | |
if [ "$#" -ge 4 ]; then | |
# mac_notify "title" "subtitle" "message" "sound" | |
title="with title \"$1\"" | |
subtitle="subtitle \"$2\"" | |
message="$3" | |
sound="$4" | |
elif [ "$#" -eq 3 ]; then | |
# mac_notify "title" "subtitle" "message" | |
title="with title \"$1\"" | |
subtitle="subtitle \"$2\"" | |
message="$3" | |
elif [ "$#" -eq 2 ]; then | |
# mac_notify "title" "message" | |
title="with title \"$1\"" | |
subtitle="" | |
message="$2" | |
elif [ "$#" -eq 1 ]; then | |
# mac_notify "message" | |
title="with title \"$1\"" | |
subtitle="" | |
message="-" | |
else | |
echo "Usage: mac_notify <title> <subtitle> <message> <sound>" | |
return | |
fi | |
cmd="display notification \"$message\" $title $subtitle sound name \"$sound\"" | |
/usr/bin/osascript -e "$cmd" | |
} | |
function random_sentence() { | |
# 0 8-23 * * * source $HOME/mac-words-reminder.sh && random_sentence words.txt | |
vocabulary=${1:-"$HOME/vocabulary.txt"} | |
sentence=$(/opt/homebrew/bin/shuf -n 1 $vocabulary) | |
eng=$(echo $sentence | awk -F: '{print $1}') | |
vn=$(echo $sentence | awk -F: '{print $2}') | |
if [ -z "$vn" ]; then | |
mac_notify "$eng" "." | |
else | |
mac_notify "$eng" "$vn" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment