Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Feel free to redistribute!
- Version=1.1.5b
- cd "${0%/*}"
- ScriptName=$(basename $0)
- source $ScriptName.cfg
- CronCheck=$(crontab -l | grep -wo $ScriptName)
- if [ "$CronCheck" != "$ScriptName" ]; then
- (crontab -l 2>/dev/null; echo "30 4 * * * $PWD/$ScriptName") | crontab -
- fi
- if [ ! -e $ScriptName.cfg ]; then
- wget https://pastebin.com/raw/6rx1EMiB --output-document $PWD/$ScriptName.cfg.new
- sleep 1s && tr -d '\r' < $ScriptName.cfg.new > $ScriptName.cfg
- sleep 1s && rm $ScriptName.cfg.new
- fi
- #Customization from config file
- Text1P=$Text1 ##Phone Friendly conversion
- Text2P=$Text2 ##Phone Friendly conversion
- Text1="<big><b>$Text1</b></big>" ##Mon, Tues, etc
- Text2="<big><b>$Text2</b></big>" ##DD/MM/YY
- GetDate1=$(date +$DateFormat1) ##Mon, Tues, etc
- GetDate2=$(date +$DateFormat2) ##DD/MM/YY
- DateCheck1=$(grep $GetDate1 $DataFile1 | awk '!seen[$1]++' | awk -F ' -' '{print $1}') ##Is today Mon, Tues, etc?
- DateCheck2=$(grep $GetDate2 $DataFile2 | awk '!seen[$1]++' | awk -F ' -' '{print $1}') ##Is today DD/MM/YY?
- DataRaw1=$(grep $GetDate1 $DataFile1 | awk -v text=$GetDate1 'BEGIN{RS="'"$GetDate1 - "'";ORS=""} {print}' | sed 's/*/$asterisk/g') ##Mon, Tues, etc
- DataRaw2=$(grep $GetDate2 $DataFile2 | awk -v text=$GetDate2 'BEGIN{RS="'"$GetDate2 - "'";ORS=""} {print}' | sed 's/*/$asterisk/g') ##DD/MM/YY
- ########## SYMBOL FIXES ##########
- PhoneSymbols() { # Fixes: & * ; % +
- Data1=$(echo $DataRaw1 | sed 's/&/and/g;s/$asterisk/*/g;s/;/□/g;s/%/□/g;s/+/□/g')
- Data2=$(echo $DataRaw2 | sed 's/&/and/g;s/$asterisk/*/g;s/;/□/g;s/%/□/g;s/+/□/g')
- }
- DesktopSymbols() { # Fixes: & < > *
- Data1=$(echo -e "$DataRaw1\n" | sed 's/&/&/g;s/</\</g;s/>/\>/g;s/$asterisk/*/g')
- Data2=$(echo -e "$DataRaw2\n" | sed 's/&/&/g;s/</\</g;s/>/\>/g;s/$asterisk/*/g')
- }
- ########## API PUSHES ##########
- PhonePush1() {
- curl --header "Authorization: Bearer $AccessToken" -X POST https://api.pushbullet.com/v2/pushes -d type=note -d title="$Text1P" -d body="$Data1" > /dev/null
- }
- PhonePush2() {
- curl --header "Authorization: Bearer $AccessToken" -X POST https://api.pushbullet.com/v2/pushes -d type=note -d title="$Text2P" -d body="$Data2" > /dev/null
- }
- ########## NOTIFICATOR MESSAGE BOX ##########
- MsgBox=('zenity --info --text="$Text2\n$Data2\n\n$Text1\n$Data1" --title="$Title" --ok-label="Delay Reminders..." --extra-button=Ok $Icons --display=:0.0 2> /dev/null')
- DelayReminders() {
- DelayReminders=$(zenity --calendar --text "Pick which day you want todays reminders to show on." --title "Delay Reminders" --date-format=$DateFormat2)
- if [ $DelayReminders ]; then sed -i -e "s|$GetDate2|$DelayReminders|g" $DataFile2; fi
- }
- OnTop() {
- if [ $AlwaysOnTop == 1 ]; then
- Above="wmctrl -F -a $Title -b add,above"
- fi
- (sleep 1 && eval "$Above")
- }
- if [ "$GetDate1" == "$DateCheck1" ]; then
- ########## DD/MM/YY AND PROGRAMME REMINDERS ##########
- if [ "$GetDate2" == "$DateCheck2" ]; then
- if [ $Phone == 1 ]; then
- PhoneSymbols
- PhonePush1
- PhonePush2
- fi
- if [ $Desktop == 1 ]; then
- DesktopSymbols
- OnTop & (eval ${MsgBox[@]})
- if [ $? == 0 ]; then
- DelayReminders
- fi
- fi
- else
- ########## PROGRAMME REMINDERS ##########
- if [ $Phone == 1 ]; then
- PhoneSymbols
- PhonePush1
- fi
- if [ $Desktop == 1 ]; then
- DesktopSymbols
- OnTop & (eval ${MsgBox[0]:0:22}${MsgBox[0]:40:33}${MsgBox[0]:123:34})
- fi
- fi
- ########## DD/MM/YY REMINDERS ##########
- elif [ "$GetDate2" == "$DateCheck2" ]; then
- if [ $Phone == 1 ]; then
- PhoneSymbols
- PhonePush2
- fi
- if [ $Desktop == 1 ]; then
- DesktopSymbols
- OnTop & (eval ${MsgBox[0]:0:22}${MsgBox[0]:22:14}${MsgBox[0]:54:103})
- if [ $? == 0 ]; then
- DelayReminders
- fi
- fi
- fi
- ########## REMOVE OLD REMINDERS ##########
- if [ $PurgeOldReminders == 1 ]; then
- PrevDay=$(date +$DateFormat2 -d "$DATE - 1 day")
- sed -i -e "\|$PrevDay.*$|d" $DataFile2
- fi
- ########## UPDATER ##########
- CurrentDay=$(date +%u)
- if [ $CurrentDay == 7 ]; then
- NewVersion=$(curl -s https://pastebin.com/raw/vKCSNwca)
- if [ $AutoUpdate == "1" ]; then
- if [ "$Version" != "$NewVersion" ]; then
- if [ "$ConfigVersion" != "$Version" ]; then
- sed -i -e "s|$ConfigVersion|$Version|g" $ScriptName.cfg
- fi
- wget https://pastebin.com/raw/9AuQDjtc --output-document $PWD/$ScriptName.new
- sleep 1s && tr -d '\r' < $ScriptName.new > $ScriptName
- sleep 1s && rm $ScriptName.new
- fi
- else
- if [ $Desktop == 1 ]; then
- zenity --warning --title="Notificator Update" --text="<b>An update is available! \n\nYour version:</b> $Version \n<b>New version:</b> $NewVersion"
- fi
- if [ $Phone == 1 ]; then
- curl --header "Authorization: Bearer $AccessToken" -X POST https://api.pushbullet.com/v2/pushes -d type=note -d title="Notificator Update" -d body="Your version: $Version
- New version: $NewVersion"
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement