1
1
#! /bin/sh
2
2
# Transfer PDF file(s) to a reMarkable
3
- # Adrian Daerr 2017/2018 - public domain
3
+ # Adrian Daerr and contributors, 2017 -- 2022 - public domain
4
4
#
5
5
# - The files will appear in reMarkable's top-level "My Files" directory,
6
6
# - After finishing all transfers, you have to restart the xochitl
7
7
# service on the tablet in order to force a scan of its document
8
8
# directory ${xochitldir} (so that you see the newly transferred
9
9
# files), e.g. by sending the tablet the following command:
10
10
# 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
11
15
#
12
16
# Disclaimer and liability limitation:
13
17
# [see also all-caps text borrowed from GPL below]
@@ -93,15 +97,15 @@ for filename in "$@" ; do
93
97
# so we generate one for the document at hand
94
98
uuid=$( uuidgen)
95
99
96
- extension=" ${filename##* .} "
100
+ extension=" ${filename##* .} "
97
101
98
102
# Copy the file itself
99
103
cp -- " $filename " " ${tmpdir} /${uuid} .${extension} "
100
104
101
105
# Add metadata
102
106
# The lastModified item appears to contain the date in milliseconds since Epoch
103
107
cat << EOF >>${tmpdir} /${uuid} .metadata
104
- {
108
+ {
105
109
"deleted": false,
106
110
"lastModified": "$( date +%s) 000",
107
111
"metadatamodified": false,
@@ -115,10 +119,10 @@ for filename in "$@" ; do
115
119
}
116
120
EOF
117
121
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
+ {
122
126
"extraMetadata": {
123
127
},
124
128
"fileType": "pdf",
@@ -141,28 +145,30 @@ EOF
141
145
}
142
146
}
143
147
EOF
144
- # Add cache directory
145
- mkdir ${tmpdir} /${uuid} .cache
146
148
147
- # Add highlights directory
148
- mkdir ${tmpdir} /${uuid} .highlights
149
+ # Add cache directory
150
+ mkdir ${tmpdir} /${uuid} .cache
149
151
150
- # Add thumbnails directory
151
- mkdir ${tmpdir} /${uuid} .thumbnails
152
+ # Add highlights directory
153
+ mkdir ${tmpdir} /${uuid} .highlights
152
154
153
- elif [ " $extension " = " epub" ]; then
155
+ # Add thumbnails directory
156
+ mkdir ${tmpdir} /${uuid} .thumbnails
154
157
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
157
162
{
158
163
"fileType": "epub"
159
164
}
160
165
EOF
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
166
172
167
173
# Transfer files
168
174
echo " Transferring $filename as $uuid "
0 commit comments