File: sync-evolution.sh

package info (click to toggle)
gtkpod 2.1.5-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 19,412 kB
  • ctags: 6,307
  • sloc: ansic: 51,604; xml: 16,135; sh: 11,916; cpp: 7,545; perl: 1,449; makefile: 1,378; lex: 638; awk: 73; python: 35
file content (102 lines) | stat: -rwxr-xr-x 3,257 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# Script for syncing evolution addressbook data with iPod
# (c) 2004 Clinton Gormley <clint at traveljury dot com>
#

# Usage:
# 
# sync-addressbooks.sh [-i <ipod mountpoint>] [-e <encoding>]
#                      [-d <path to evolution-addressbook-export>]
#
# (specify '-d' if evolution-addressbook-export is not in your default
# path)
#
# with the following defaults: 

IPOD_MOUNT=/media/ipod         # mountpoint of ipod
ENCODING=ISO-8859-15         # encoding used by ipod

# try to find the path to evolution-addressbook-export
for i in {/opt/gnome,/usr,/usr/local}/{bin,lib*}/{,evolution/*/}evolution-addressbook-export; do
    if [ -x "$i" ]; then
        EVOPATH=`dirname "$i"`
        break
    fi
done

# Unless called with "-e=none" this script requires "iconv" available
# from http://www.gnu.org/software/libiconv/

# About the encoding used by the iPod (by Jorg Schuler):
#
# For some reason the encoding used for the contact files and
# calender files depends on the language you have set your iPod
# to. If you set your iPod to German, iso-8859-15 (or -1?) is
# expected. If you set it to Japanese, SHIFT-JIS is expected. You need
# to reboot the iPod to have the change take effect, however. (I'm
# using firmware version 1.3.)
#
# If you know of more encodings, please let me know, so they can be
# added here:
#
# iPod language      encoding expected
# ----------------------------------------
# German             ISO-8859-15
# Japanese           SHIFT-JIS


# Changelog:
#
# 2004/12/07 (Clinton Gormley <clint at traveljury dot com>):
# adapted sync-kaddressbook to work with evolution.
#
# 2004/12/15 (Jorg Schuler <jcsjcs at users dot sourceforge dot net>):
# Split evolution support into a new file.
#
# 2007/04/02 (Jorg Schuler <jcsjcs at users dot sourceforge dot net>):
# Allow syncing of contacts containing pictures. Thanks to Lars Friedrichs.


# overwrite default settings with optional command line arguments
while getopts i:d:e: option; do
    case $option in
        i) IPOD_MOUNT=$OPTARG;;
        d) EVOPATH=$OPTARG;;
        e) ENCODING=$OPTARG;;
        
        \?) echo "Usage: `basename $0 ` [-i <ipod mountpoint>] [-e <encoding>] [-d <path to evolution-addressbook-export>]"
	    exit 1;;
    esac
done


# set the RECODE command
if [ $ENCODING = "none" ] || [ $ENCODING = "NONE" ]; then
    RECODE="cat"    # no conversion
else
    RECODE="iconv -f UTF-8 -t $ENCODING"
fi


echo "Trying to export from evolution:"

# adjust path to find evolution-addressbook-export
PATH=$EVOPATH:$PATH

# check if evolution-addressbook-export is in PATH
evolution-addressbook-export --help  >/dev/null 2>&1

if [ ! $? == 0 ]; then
    echo "** Error: Couldn't find evolution-addressbook-export in your PATH:"
    echo $PATH
    echo ""
    echo "Please specify \"-d <path to evolution-addressbook-export>\" when you call this script"
    exit 1
fi


# remove all empty lines and recode if necessary
echo -n "Syncing iPod ... [Contacts] "
# Redirect STDERR to avoid the "FIXME : wait for completion unimplemented" warning
evolution-addressbook-export 2>&1 | grep -v '^[[:space:]]$\|^$' | $RECODE | sed -e "s/PHOTO;ENCODING=b;TYPE=\"X-EVOLUTION-UNKNOWN\"/PHOTO;BASE64/g" > $IPOD_MOUNT/Contacts/evolution
echo "done!"