Last active
December 7, 2018 06:55
-
-
Save John-Almardeny/04fb95eeb969aa46f031457c7815b07d to your computer and use it in GitHub Desktop.
Create a Notification With Sound with a Given Message and Time in Linux-Like OS
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
#!/bin/sh | |
# https://gist.github.com/John-Almardeny/04fb95eeb969aa46f031457c7815b07d | |
# Create a Notification With Sound with a Given Message and Time | |
# The Downloaded Sound is from Notification Sounds https://notificationsounds.com/ | |
MSSG="$1" | |
TIME="$2" | |
# install wget if not found | |
if ! [ -x "$(command -v wget)" ]; then | |
echo -e "INSTALLING WGET...\n\n" | |
sudo apt-get install wget | |
echo -e "\n\n" | |
fi | |
# install at package if not found | |
if ! [ -x "$(command -v at)" ]; then | |
echo -e "INSTALLING AT...\n\n" | |
sudo apt-get install at | |
echo -e "\n\n" | |
fi | |
# install sox if not found | |
if ! [ -x "$(command -v sox)" ]; then | |
echo -e "INSTALLING SOX...\n\n" | |
sudo apt-get install sox | |
sudo apt-get install sox libsox-fmt-all | |
echo -e "\n\n" | |
fi | |
# download the noti sound if this is first time | |
# add alias to the bashrc file | |
if ! [ -f ~/noti/sound.mp3 ]; then | |
echo -e "DOWNLOADING SOUND...\n\n" | |
touch ~/noti/sound.mp3 | wget -O ~/noti/sound.mp3 "https://notificationsounds.com/wake-up-tones/rise-and-shine-342/download/mp3" | |
sudo echo "alias noti=\"sh ~/noti/noti.sh\"" >> ~/.bashrc | |
source ~/.bashrc | |
echo -e "\n\n" | |
fi | |
# notify with the sound playing and particular given message and time | |
echo "notify-send \""$MSSG\"" && play ~/noti/sound.mp3" | at $TIME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How To Use?
First Run - Setting Up:
noti
mkdir ~/noti
noti
dir.noti
cd ~/noti
sudo chmod +x noti.sh
sh ~/noti/noti.sh "Test" "now"
Creating Notification Examples
For Notifying The Finish of Process (example)