• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Example evolution synchronization script by Nicolas Tetreault,
4# modified by Linus Walleij.
5
6# Define target files
7SYNC_HOME=$HOME/MTP_device_sync
8
9# Define tool locations
10SENDFILE=`which mtp-sendfile`
11# SENDFILE="$HOME/comp-apps/bin/sendfile"
12#EADDEXP=`which evolution-addressbook-export`
13# This is the location in Fedora Core 5:
14EADDEXP="/usr/libexec/evolution/2.6/evolution-addressbook-export"
15
16# You need to change the name of the files
17# that contains the calendar and contacts on your device.
18# You can find out by  starting Gnomad2, choose the data transfer
19# tab, sort by size (it should be small files, extension .ics and .vcf)
20# On my Zen Microphoto, the calendar and contacts files are called
21# 6651416 with the ics and vcf extensions, respectively.
22CALENDAR_FILE="6651416.ics"
23CONTACTS_FILE="6651416.vcf"
24
25# The evolution address book. To list your addressbooks, type:
26# evolution-addressbook-export -l
27# the output for me:
28# "file:///home/nt271/.evolution/addressbook/local/system
29# ","Personal",26
30# "file:///home/nt271/.evolution/addressbook/local/1158600180.5386.0@sierra"
31# ,"MicroPhoto",24
32# I only want the Microphoto addressbook and the output will be
33# $SYNC_HOME/contacts/Evolution_contacts.vcf
34EVOLUTION_CONTACTS="file:///home/linus/.evolution/addressbook/local/system"
35
36# Check for sync dir, create it if needed
37
38if test -d $SYNC_HOME ; then
39    echo "$SYNC_HOME exists, OK."
40else
41    echo "$SYNC_HOME must first be created..."
42    mkdir $SYNC_HOME
43    # This is a working dir for contact merging, you can put
44    # in some extra .vcf files here as well if you like.
45    mkdir $SYNC_HOME/contacts
46    # Here you can place some extra calendars to be sync:ed, you
47    # can put in some extra .ics files of any kind here.
48    mkdir $SYNC_HOME/calendars
49fi
50
51# Check for prerequisites
52
53if test -f $EADDEXP ; then
54    echo "evolution-addressbook-export present in $EADDEXP, OK."
55else
56    echo "Cannot locate evolution-addressbook-export!!"
57    exit 0
58fi
59
60
61# Next line merges all of your tasklist, your personal calendar,
62# and then any saved to disk calendar you have placed in
63# $SYNC_HOME/calendars
64
65cat $HOME/.evolution/tasks/local/system/tasks.ics \
66    $HOME/.evolution/calendar/local/system/calendar.ics \
67    $SYNC_HOME/calendars/*.ics > $SYNC_HOME/$CALENDAR_FILE
68
69# Use evolution-addressbook-export (installed with Evolution) to
70# export your contacts to vcard.
71
72$EADDEXP --format=vcard \
73    --output=$SYNC_HOME/contacts/Evolution_contacts.vcf \
74    $EVOLUTION_CONTACTS
75
76# Repeat for each addressbook you want to upload.
77
78# The next command will then merge all the contact lists
79
80cat $SYNC_HOME/contacts/*.vcf > $SYNC_HOME/$CONTACTS_FILE
81
82# The calendar and contacts files now need to be converted from unix
83# to DOS linefeeds (CR+LF instead of just LF)
84
85unix2dos $SYNC_HOME/$CALENDAR_FILE $SYNC_HOME/$CONTACTS_FILE
86
87# You can now upload the ics and vcf files to you My Organizer folder
88# on your device. Change the path to your sendfile command.
89# Sending the vcf file is only supported in CVS version at this time
90
91$SENDFILE -f "My Organizer" -t ics $SYNC_HOME/$CALENDAR_FILE
92$SENDFILE -f "My Organizer" -t vcf $SYNC_HOME/$CONTACTS_FILE
93
94