11#! /bin/sh
22# Transfer PDF file(s) to a reMarkable
3- # Adrian Daerr 2017/2018 - public domain
3+ # Adrian Daerr and contributors, 2017 -- 2022 - public domain
44#
55# - The files will appear in reMarkable's top-level "My Files" directory,
66# - After finishing all transfers, you have to restart the xochitl
77# service on the tablet in order to force a scan of its document
88# directory ${xochitldir} (so that you see the newly transferred
99# files), e.g. by sending the tablet the following command:
1010# ssh remarkable systemctl restart xochitl
11+ # This script can do that for you at the end, either by default (set
12+ # environment variable RESTART_XOCHITL_DEFAULT to 1) or once when
13+ # given the command line parameter "-r".
14+ # - See more instructions and configuration options below
1115#
1216# Disclaimer and liability limitation:
1317# [see also all-caps text borrowed from GPL below]
@@ -93,15 +97,15 @@ for filename in "$@" ; do
9397 # so we generate one for the document at hand
9498 uuid=$( uuidgen)
9599
96- extension=" ${filename##* .} "
100+ extension=" ${filename##* .} "
97101
98102 # Copy the file itself
99103 cp -- " $filename " " ${tmpdir} /${uuid} .${extension} "
100104
101105 # Add metadata
102106 # The lastModified item appears to contain the date in milliseconds since Epoch
103107 cat << EOF >>${tmpdir} /${uuid} .metadata
104- {
108+ {
105109 "deleted": false,
106110 "lastModified": "$( date +%s) 000",
107111 "metadatamodified": false,
@@ -115,10 +119,10 @@ for filename in "$@" ; do
115119}
116120EOF
117121
118- if [ " $extension " = " pdf" ]; then
119- # Add content information
120- cat << EOF >${tmpdir} /${uuid} .content
121- {
122+ if [ " $extension " = " pdf" ]; then
123+ # Add content information
124+ cat << EOF >${tmpdir} /${uuid} .content
125+ {
122126 "extraMetadata": {
123127 },
124128 "fileType": "pdf",
@@ -141,28 +145,30 @@ EOF
141145 }
142146}
143147EOF
144- # Add cache directory
145- mkdir ${tmpdir} /${uuid} .cache
146148
147- # Add highlights directory
148- mkdir ${tmpdir} /${uuid} .highlights
149+ # Add cache directory
150+ mkdir ${tmpdir} /${uuid} .cache
149151
150- # Add thumbnails directory
151- mkdir ${tmpdir} /${uuid} .thumbnails
152+ # Add highlights directory
153+ mkdir ${tmpdir} /${uuid} .highlights
152154
153- elif [ " $extension " = " epub" ]; then
155+ # Add thumbnails directory
156+ mkdir ${tmpdir} /${uuid} .thumbnails
154157
155- # Add content information
156- cat << EOF >${tmpdir} /${uuid} .content
158+ elif [ " $extension " = " epub" ]; then
159+
160+ # Add content information
161+ cat << EOF >${tmpdir} /${uuid} .content
157162{
158163 "fileType": "epub"
159164}
160165EOF
161- else
162- echo " Unknown extension: $extension , skipping $filename "
163- rm -rf ${tmpdir} /*
164- continue
165- fi
166+
167+ else
168+ echo " Unknown extension: $extension , skipping $filename "
169+ rm -rf ${tmpdir} /*
170+ continue
171+ fi
166172
167173 # Transfer files
168174 echo " Transferring $filename as $uuid "
0 commit comments