@@ -65,7 +65,7 @@ TARGET_DIR="${REMARKABLE_HOST}:${REMARKABLE_XOCHITL_DIR}"
65
65
66
66
# Check if we have something to do
67
67
if [ $# -lt 1 ]; then
68
- echo " Transfer PDF document to a reMarkable tablet"
68
+ echo " Transfer PDF or Epub document to a reMarkable tablet"
69
69
echo " usage: $( basename $0 ) [ -r ] path-to-pdf-file [path-to-pdf-file]..."
70
70
exit 1
71
71
fi
@@ -87,14 +87,16 @@ tmpdir=$(mktemp -d)
87
87
88
88
# Loop over the command line arguments,
89
89
# which we expect are paths to the PDF files to be transferred
90
- for pdfname in " $@ " ; do
90
+ for filename in " $@ " ; do
91
91
92
92
# reMarkable documents appear to be identified by universally unique IDs (UUID),
93
93
# so we generate one for the document at hand
94
94
uuid=$( uuidgen)
95
95
96
- # Copy the PDF file itself
97
- cp -- " $pdfname " ${tmpdir} /${uuid} .pdf
96
+ extension=" ${filename##* .} "
97
+
98
+ # Copy the file itself
99
+ cp -- " $filename " " ${tmpdir} /${uuid} .${extension} "
98
100
99
101
# Add metadata
100
102
# The lastModified item appears to contain the date in milliseconds since Epoch
@@ -109,12 +111,13 @@ for pdfname in "$@" ; do
109
111
"synced": false,
110
112
"type": "DocumentType",
111
113
"version": 1,
112
- "visibleName": "$( basename -- " $pdfname " .pdf ) "
114
+ "visibleName": "$( basename -- " $filename " " . $extension " ) "
113
115
}
114
116
EOF
115
117
116
- # Add content information
117
- cat << EOF >${tmpdir} /${uuid} .content
118
+ if [ " $extension " = " pdf" ]; then
119
+ # Add content information
120
+ cat << EOF >${tmpdir} /${uuid} .content
118
121
{
119
122
"extraMetadata": {
120
123
},
@@ -138,18 +141,31 @@ EOF
138
141
}
139
142
}
140
143
EOF
144
+ # Add cache directory
145
+ mkdir ${tmpdir} /${uuid} .cache
146
+
147
+ # Add highlights directory
148
+ mkdir ${tmpdir} /${uuid} .highlights
141
149
142
- # Add cache directory
143
- mkdir ${tmpdir} /${uuid} .cache
150
+ # Add thumbnails directory
151
+ mkdir ${tmpdir} /${uuid} .thumbnails
144
152
145
- # Add highlights directory
146
- mkdir ${tmpdir} /${uuid} .highlights
153
+ elif [ " $extension " == " epub" ]; then
147
154
148
- # Add thumbnails directory
149
- mkdir ${tmpdir} /${uuid} .thumbnails
155
+ # Add content information
156
+ cat << EOF >${tmpdir} /${uuid} .content
157
+ {
158
+ "fileType": "epub"
159
+ }
160
+ EOF
161
+ else
162
+ echo " Unknown extension: $extension , skipping $filename "
163
+ rm -rf ${tmpdir} /*
164
+ continue
165
+ fi
150
166
151
167
# Transfer files
152
- echo " Transferring $pdfname as $uuid "
168
+ echo " Transferring $filename as $uuid "
153
169
scp -r ${tmpdir} /* " ${TARGET_DIR} "
154
170
rm -rf ${tmpdir} /*
155
171
done
0 commit comments