Created
November 30, 2024 12:40
-
-
Save alsolovyev/83ec124eb0a1a25553c2c67f2173571d to your computer and use it in GitHub Desktop.
A Fish shell script for sending macOS notifications
This file contains hidden or 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
| # Notify Script | |
| # This Fish shell script sends macOS notifications with a customizable title, message, and sound. | |
| # Usage: notify [title] [message] [sound_name] | |
| function notify | |
| set -l title (string join " " $argv[1]) | |
| set -l message (string join " " $argv[2]) | |
| set -l sound_name (string join " " $argv[3]) | |
| if test -z "$title" | |
| set title "Title" | |
| end | |
| if test -z "$message" | |
| set message "Lorem ipsum dolor sit amet" | |
| end | |
| if test -z "$sound_name" | |
| set sound_name "Glass" | |
| end | |
| set -l valid_sounds (ls /System/Library/Sounds | string replace -r '\.aiff$' '') | |
| if not contains -- "$sound_name" $valid_sounds | |
| echo "Invalid sound name: $sound_name. Valid options are:" | |
| echo $valid_sounds | |
| return 1 | |
| end | |
| osascript -e "display notification \"$message\" with title \"$title\" sound name \"$sound_name\"" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment