Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- introducir_en_orage ()
- {
- local fecha_inicio=$1
- local fecha_relleno=$2
- local actividad="$3"
- local fecha=$(date +'%Y%m%d%H%M%S')
- local fecha_dts=$(date --rfc-3339=ns | sed -e 's/ /T/' -e 's/[:-]//g' -e 's/\..*/Z/')
- categoria=$(sed -n 's/\[\(.*\)\]/\1/p' ~/.local/share/orage/orage_categories.txt |
- DISPLAY=:0 LANG=es_ES.UTF8 zenity --list --text "Categorias" --column categoria
- )
- sed -i '/^END:VCALENDAR/i \
- BEGIN:VJOURNAL \
- CLASS:PUBLIC \
- UID:zenity-'"$fecha"' \
- DTSTART:'"$fecha_dts"' \
- SUMMARY:'"$actividad"' \
- DESCRIPTION:Nota automática desde zenity \
- CATEGORIES:'"$categoria"' \
- END:VJOURNAL
- ' ~/.local/share/orage/zenity.ics
- }
- fecha=$(date --rfc-3339=ns | sed -e 's/ /T/' \
- -e 's/-\|://g' \
- -e 's/\(..\)\..*/\1Z/')
- (
- ([ -e ~/tmp/zenity.pid ] &&
- ps aux | awk '{print $2}' | grep -q $(cat ~/tmp/zenity.pid) &&
- kill $(cat ~/tmp/zenity.pid) &&
- sed -i '$d' ~/log/zenity.log ) || true) &&
- echo -n "$(date +"%Y%m%d %H:%M")" >> ~/log/zenity.log
- (
- actividad=$(DISPLAY=:0 LANG=es_ES.UTF8 timeout 1770 zenity --entry --text "¿Qué estás haciendo ahora $(date +\%H:\%M)?")
- if [[ "$actividad" = *.GOOGLE ]]
- then
- actividad=${actividad/.GOOGLE}
- password=$(DISPLAY=:0 LANG=es_ES.UTF8 zenity --entry --text "Introduce contrasena de google." --hide-text)
- ~/scripts/hh/put_event_args.sh -s $password -t "$actividad" -c "Desde zenity"
- fi
- fecha_relleno=$(date --rfc-3339=ns | sed -e 's/ /T/' \
- -e 's/-\|://g' \
- -e 's/\(..\)\..*/\1Z/')
- [ -z "$actividad" ] && exit 1
- introducir_en_orage $fecha $fecha_relleno "$actividad"
- echo " - "$(date +\%H:\%M)": ${actividad:-Cancelado}" ) >> ~/log/zenity.log &
- ****************************************************************************************************************************
- * FOR GOOGLE *
- ****************************************************************************************************************************
- $ cat ~/scripts/hh/put_event_args.sh
- email=yourmail@gmail.com
- # Esto habría que hacerlo con getopt ...
- if [ $# == 0 -o $# -lt 6 ]
- then
- echo "$0 -s \"SECRET\" -t "Titulo" -c \"CONTENIDO\" [ -fi \"2007-01-08T09:31:22.106190000+01:00\" -ff \"2007-01-08T09:31:22.106190000+01:00\" ] "
- exit 1
- fi
- # Password
- if [ "$1" == "-s" ]
- then
- passwd="$2"
- else
- echo "Introduce la contraseña: "
- stty -echo ; read passwd ; stty echo
- fi
- # Titulo
- if [ "$3" == "-t" ]
- then
- titulo="$4"
- else
- titulo="Evento de USER"
- fi
- # Contenido
- if [ "$5" == "-c" ]
- then
- contenido="$6"
- else
- contenido="Falta contenido, elimina esta entrada y revisa la orden desde la que se creó"
- fi
- # Fecha
- if [ "$7" == "-fi" ]
- then
- fecha_inicio="$8"
- else
- fecha_inicio=$(date --rfc-3339=ns -d '1 hour ago' | sed 's/ /T/')
- fi
- if [ "$9" == "-ff" ]
- then
- fecha_fin="$10"
- else
- fecha_fin=$(date --rfc-3339=ns | sed 's/ /T/')
- fi
- cat - << EOF > evento.tmp
- <entry xmlns='http://www.w3.org/2005/Atom'
- xmlns:gd='http://schemas.google.com/g/2005'>
- <category scheme='http://schemas.google.com/g/2005#kind'
- term='http://schemas.google.com/g/2005#event'></category>
- <title type='text'>$titulo</title>
- <content type='text'>$contenido</content>
- <author>
- <name>YOUR NAME </name>
- <email>yourname@gmail.com</email>
- </author>
- <gd:transparency
- value='http://schemas.google.com/g/2005#event.opaque'>
- </gd:transparency>
- <gd:eventStatus
- value='http://schemas.google.com/g/2005#event.confirmed'>
- </gd:eventStatus>
- <gd:where valueString='Example S.A.'></gd:where>
- <gd:when startTime='$fecha_inicio'
- endTime='$fecha_fin'></gd:when>
- </entry>
- EOF
- auth=$(wget --post-data='Email='$email'&Passwd='$passwd'&yourcalendar-1&service=cl' https://www.google.com/accounts/ClientLogin -O - | tail -1 | sed 's/Auth=//')
- sessionid=$(wget --header "Authorization: GoogleLogin auth=$auth" --header "Content-Type: application/atom+xml" --post-file="evento.tmp" http://www.google.com/calendar/feeds/default/private/full 2>&1 | tail -2 | grep -o "gsessionid=[^']*" | sed 's/gsessionid=//')
- wget --header "Authorization: GoogleLogin auth=$auth" --header "Content-Type: application/atom+xml" --post-file="evento.tmp" http://www.google.com/calendar/feeds/default/private/full?gsessionid=$sessionid &> /dev/null
- # Limpieza a lo cutre
- rm "full?gsessionid=$sessionid"*
- rm evento.tmp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement