summaryrefslogtreecommitdiff
path: root/bin/kindlenotes
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2014-12-08 19:18:39 +0900
committerSean Whitton <spwhitton@spwhitton.name>2014-12-08 19:18:39 +0900
commit5bf5a4d5b3c44316846368cd8abdfd4d02a1d473 (patch)
tree05268f1244474333da8a2b6b0d252b52ac3e11fd /bin/kindlenotes
parent750f946c43ba1988d148580da0a37c6894739295 (diff)
downloaddotfiles-5bf5a4d5b3c44316846368cd8abdfd4d02a1d473.tar.gz
script to copy Kindle clippings file to Dropbox
Diffstat (limited to 'bin/kindlenotes')
-rwxr-xr-xbin/kindlenotes25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/kindlenotes b/bin/kindlenotes
new file mode 100755
index 00000000..3a6ce5e9
--- /dev/null
+++ b/bin/kindlenotes
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+MNT=/mnt/kindle
+DEST="$HOME/lib/Dropbox/Kindle notes"
+
+kindle=$(blkid | awk -F: '/Kindle/ { print $1; exit; }')
+filename=$(date +kindle_%F_%R)
+group=$(groups | awk '{print $1}')
+sudo mkdir -p "$MNT"
+mkdir -p "$DEST"
+
+sudo umount $kindle
+sudo mount $kindle $MNT
+
+if [ -e "$DEST/$filename" ]; then
+ echo >&2 Won\'t clobber other Kindle notes
+elif sudo mv --no-clobber \
+ "$MNT/documents/My Clippings.txt" \
+ "$DEST/$filename"; then
+ sudo chown "$USER:$group" "$DEST/$filename"
+ # remove the supporting file only if the clippings were moved successfully
+ sudo rm -rf "$MNT/documents/My Clippings.sdr"
+fi
+
+sudo umount $kindle