|
#!/bin/bash
|
|
|
|
#pidof emacs && emacsclient -e '(org-caldav-sync)' # Sync emacs-caldav as well
|
|
eval "$(grep -h -- \
|
|
"^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\|XDG_DATA_HOME\|XDG_CONFIG_HOME\)=" \
|
|
"$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \
|
|
"$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" "$HOME/.pam_environment" 2>/dev/null)"
|
|
|
|
export CALCURSE_CALDAV_PASSWORD=$(pass show Server/drive.yigitcolakoglu.com/yigitcolakoglu)
|
|
lock=$(mktemp)
|
|
rm -f $lock
|
|
calcurse-caldav --lockfile $lock # Prevent lock file conflicts
|
|
|
|
|
|
tmpfile=$(mktemp)
|
|
destfile=$(mktemp)
|
|
|
|
wget -q 'https://drive.yigitcolakoglu.com/remote.php/dav/addressbooks/users/yigitcolakoglu/contacts/?export' \
|
|
--user yigitcolakoglu \
|
|
--password "$(pass show Server/drive.yigitcolakoglu.com/yigitcolakoglu)" \
|
|
-O $tmpfile
|
|
|
|
abook --convert \
|
|
--informat vcard \
|
|
--infile $tmpfile \
|
|
--outformat abook \
|
|
--outfile $destfile
|
|
|
|
vdirsyncer sync
|
|
|
|
rm $tmpfile
|
|
chmod 600 $destfile
|
|
sed -Ei 's/([0-9]) ([0-9])/\1\2/g' $destfile
|
|
sed -Ei 's/\+([0-9])/\1/g' $destfile
|
|
mv $destfile "$XDG_DATA_HOME"/abook/addressbook
|