summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorA Frederick Christensen2021-06-24 10:32:42 -0500
committerA Frederick Christensen2021-06-24 10:32:42 -0500
commit10f0484d09fb5326a768ff5ffdcb3e33a7ec9388 (patch)
tree59bbbd0b22b39acb8db7c95b78672193417c3b1c
downloadaur-phosh-contacts-importer.tar.gz
Initial PKGBUILD commit
-rw-r--r--.SRCINFO14
-rw-r--r--PKGBUILD20
-rw-r--r--contacts-importer.desktop6
-rw-r--r--contacts-importer.sh49
4 files changed, 89 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..84efab9b2f3d
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,14 @@
+pkgbase = phosh-contacts-importer
+ pkgdesc = VCF Contact Importer for Phosh Phone Shell Interface
+ pkgver = 1.0
+ pkgrel = 1
+ url = https://puri.sm/posts/easy-librem-5-app-development-contacts-importer/
+ arch = aarch64
+ license = CC-BY-SA
+ depends = syncevolution
+ source = contacts-importer.sh
+ source = contacts-importer.desktop
+ sha256sums = 9024536a5e7f0ba8aa9d2f4fdda6b73bc06374db4e3478c5d2f4a945236fff75
+ sha256sums = 257f30eee3b928f2916fc43c1d45fd9c0c340286f7f933069cce3fb1d52a6f7f
+
+pkgname = phosh-contacts-importer
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..6e857c83a76a
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,20 @@
+# Maintainer: A Frederick Christensen <aur@nosocomia.com>
+
+pkgname=phosh-contacts-importer
+_pkgname=contacts-importer
+pkgver=1.0
+pkgrel=1
+pkgdesc="VCF Contact Importer for Phosh Phone Shell Interface"
+arch=('aarch64')
+url="https://puri.sm/posts/easy-librem-5-app-development-contacts-importer/"
+license=('CC-BY-SA')
+depends=('syncevolution')
+source=("${_pkgname}.sh"
+ "${_pkgname}.desktop")
+sha256sums=('9024536a5e7f0ba8aa9d2f4fdda6b73bc06374db4e3478c5d2f4a945236fff75'
+ '257f30eee3b928f2916fc43c1d45fd9c0c340286f7f933069cce3fb1d52a6f7f')
+
+package() {
+ install -Dm755 "${_pkgname}.sh" "${pkgdir}/usr/bin/${_pkgname}.sh"
+ install -Dm755 "${_pkgname}.desktop" "${pkgdir}/usr/share/applications/${_pkgname}.desktop"
+}
diff --git a/contacts-importer.desktop b/contacts-importer.desktop
new file mode 100644
index 000000000000..4584808e1fbb
--- /dev/null
+++ b/contacts-importer.desktop
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Name=Contacts Importer
+Type=Application
+Icon=preferences-desktop-personal
+Exec=contacts-importer.sh
+Categories=Utility;
diff --git a/contacts-importer.sh b/contacts-importer.sh
new file mode 100644
index 000000000000..5b2b696fb154
--- /dev/null
+++ b/contacts-importer.sh
@@ -0,0 +1,49 @@
+#!/bin/bash -e
+
+# Original Script: https://www.isticktoit.net/?p=1536
+# Adapted for the L5 use case with gnome-contacts
+
+#Selecting a file
+
+FILE=`yad --title "Import Contacts" --text="Select a VCF file to import" --file=`
+
+if [ "$FILE" == "" ]; then
+ `yad --title "Import Contacts" --text="You did not selected any file"` exit 1
+fi
+
+notify-send -t 1000 "Import Contacts" "Importing Contacts from $FILE"
+
+#Name of the database where the contacts will be imported to.
+CONTACTDB=$(syncevolution --print-databases | grep "system-address-book"| sed 's#(.*##' | sed 's# ##g' )
+
+#Temp directory to mess with files:
+
+TEMP=$(mktemp -d -t contacts-importer-XXXXXXXXXXXXX-$(date +%Y-%m-%d-%H-%M-%S))
+
+#Some control info to make sure the file is a vcard
+
+MIMETYPE=$(file --mime-type -b $FILE)
+CONTROL="text/vcard"
+
+if [[ "$MIMETYPE" != "$CONTROL" ]]; then
+ notify-send -t 1000 "File is not a vcard! Bye!" && exit 1
+fi
+
+#Begin importing contacts
+
+cd $TEMP
+
+cat $FILE | awk ' /BEGIN:VCARD/ { ++a; fn=sprintf("card_import_L5_%02d.vcf", a); print "Writing: ", fn } { print $0 >> fn; } ' $1
+
+for f in $TEMP/card_import_L5*
+do syncevolution --import ${f%} backend=evolution-contacts database=${CONTACTDB}
+done
+
+if [ $? -eq 0 ]
+then
+ notify-send "Successful import";
+ exit 0
+else
+ notify-send "Error" >&2
+ exit 1
+fi