Page 1 of 1

gcalcli script (goocle calendar)

Posted: 2020-10-04 14:05
by bester69
Hi Pig, :o

Pig, I made this script to create events with everyday reminders.. It works pretty nice.

The script alerts you in advance around 20 days before event by sending you a mail alert and also a coventional alert .. first days it only alert you each two days, and last seven days It alerts you everyday at 11am.,, If alert is very near It truncates to create only reiterative alerts since the day you set the alert on..
The script set description to title if its empty and set add a code number to end title for deleting the loop of alerts for that coded event.

this way, you can delete easily all alerts associaded to event by using the code number description event:
gcalcli delete <<NumberCodedEvent>>

You can give it a try, Im using it to set reminders :o

reminder.sh

Code: Select all

#!/bin/bash
#
calen="--calendar=mymail@gmail.com"

read -p "Title: " title
if [ -z  "$title" ]
then
echo "título no puede ser null"
    exit
fi

read -p "Descripción: " description
if [ -z  "$description" ]
then
    description="$title"
fi

read -p "When: " choice
if [ -z  "$choice" ]
then
echo "fecha de entrada vacia"
    exit
fi
NEXT_DATE=$(date +%Y/%m/%d -d "$choice")
#############Codigo bara borrarlas
##>>>>>>>>> gcalcli delete $coddaydel
coddaydel=$(date +%j -d "$choice")
############
title="$title ($coddaydel)"
#description="($coddaydel) $description" 
if [  -z  "$NEXT_DATE" ]
then
echo "fecha de entrada incorrecta"
    exit
fi
#NEXT_DATE=$(date +%d/%m/%Y -d "$NEXT_DATE")


for i in {15..0}
do
NUMERO=$i
let RESTO=NUMERO%2
if [ $RESTO -eq 0 ]; then
echo “El número $NUMERO es par”
else
echo “El número $NUMERO es impar”
if [ $i -gt 6 ]; then
        continue 
        
  fi
fi

when=$(date +%Y-%m-%d -d "$NEXT_DATE -$i day")
   
fechahoy=$(date "+%s")
unix_cond=$(date -d "${when}" "+%s")
if [ ${fechahoy} -ge ${unix_cond} ]; then
   echo "over condition"
   continue
fi

   echo "es $when" 
 
 gcalcli $calen add --reminder "10m"  --reminder "12m email" --description="$description" \
--when="$when at 11am" \
--title="$title" --where="" --duration="600"
done

gcalcli  calm

And here the final resulting of setting an alert on 25 Nov.:
Image

Re: gcalcli script (goocle calendar)

Posted: 2020-10-04 19:42
by sickpig
Good on you and I am glad it meets your use case. For me a simple one liner to add an event does the job. I used to use google keep to set reminders to notes but now gcalcli has completely replaced that.

Re: gcalcli script (goocle calendar)

Posted: 2020-10-04 20:23
by bester69
sickpig wrote:Good on you and I am glad it meets your use case. For me a simple one liner to add an event does the job. I used to use google keep to set reminders to notes but now gcalcli has completely replaced that.
I used INBOX, but they shutted down.. then Google OK (Android).. and gcalcli cant set reminders, these ones are events with notifiers...

Ive three tools for reminders..:
Google OK (Android), Kalarm and To Do Reminder (android)... I usually use kalarm, but when is something important I use all or two of tree just in case I get mislead

If you dont know you should try Kalarm, its wondefull this app.

Re: gcalcli script (goocle calendar)

Posted: 2020-10-04 21:10
by sickpig
bester69 wrote:If you dont know you should try Kalarm, its wondefull this app.
Thanks but won't it pull 2 tonnes of KDE dependencies? Also, I try to avoid resource hungry gui apps as far as possible except browsers.
I use systemd transient timers for reminders. Provides all the functionalities minus the bloat.