Hi,
I've been lurking around on this forum for about a month now, trying out various hacks and having a good deal of fun pimping my Kindle 3. So I thought it was about time I developed some ideas of my own and posted them. Copy and Paste functionality is something that I often wish the Kindle had so I decided to have an initial stab at putting something together this afternoon. It can no doubt be improved but I think it's usable enough to be worthwhile sharing what I have so far.
Installation
Copy and paste the texts below into a text editor and save them somewhere on the Kindle. In my examples I'll assume that you put them somewhere on the system path and chmoded the two shell scripts to make them executable (if necessary). (I have /mnt/us/system on my path and put my shell scripts in there.)
Usage
Copying and Pasting One Piece of Text at a Time
To copy a single piece of text:
Use the Kindle's highlighting feature to highlight the text that you wish to copy. The last highlight or bookmark created is the text in the "clipboard".
To append the contents of the "clipboard" onto a file (pre-existing or not) called foo.txt in the Kindle's documents directory type the following in a terminal window:
paste2doc.sh foo
To paste just the highlighted text without the citation information:
paste2doc.sh -o foo
To paste the contents of the "clipboard" into a KindleNote document called foo:
paste2doc.sh -n foo
Batch Copying and Pasting
To begin copying a batch of items at once, run:
startcopy.sh
and then highlight all the pieces of text that you want to copy.
To paste all of the items in the batch at once:
paste2doc.sh -m foo
or,
paste2doc.sh -n -m foo
Practical Usage
Set up launchpad commands for pasting into your favourite documents (todo list, shopping list, whatever).
Source Code
paste2doc.sh (Unix line endings):
Code:
#!/bin/sh
if [ "$1" == '-n' ] ; then
PASTE_DIR=/mnt/us/developer/KindleNote/work
shift
else
PASTE_DIR=/mnt/us/documents
fi
if [ "$1" == '-m' ] ; then
BEGIN_LINE=`grep -n <'/mnt/us/documents/My Clippings.txt' '^___BEGIN_COPY_AND_PASTE___' | tail -n 1 | cut -d: -f1`
BEGIN_LINE=$((BEGIN_LINE+5))
shift
else
BEGIN_LINE=`grep -n <'/mnt/us/documents/My Clippings.txt' '^==========' | tail -n 2 | head -n 1 | cut -d: -f1`
BEGIN_LINE=$((BEGIN_LINE+1))
if [ "$1" == '-o' ] ; then
CITATION=no
shift
fi
fi
if [ "$1" == '-n' ] ; then
PASTE_DIR=/mnt/us/developer/KindleNote/work
shift
fi
if [ "$1" == '' ] ; then
echo >&2 "Usage $0 [-n] [-m|-o] memoname"
exit 1
fi
if [ "$PASTE_DIR" == '/mnt/us/documents' -a ! -e "/mnt/us/documents/$1.txt" ] ; then
REFRESH=yes
fi
if [ "$CITATION" == 'no' ] ; then
BEGIN_LINE=$((BEGIN_LINE+3))
tail '/mnt/us/documents/My Clippings.txt' -n +$BEGIN_LINE | grep -v '^==========' >>"$PASTE_DIR/$1.txt"
else
tail '/mnt/us/documents/My Clippings.txt' -n +$BEGIN_LINE >>"$PASTE_DIR/$1.txt"
fi
if [ "$REFRESH" == 'yes' ] ; then
dbus-send --system /default com.lab126.powerd.resuming int32:1
fi
startcopy.sh (Unix line endings):
Code:
#!/bin/sh
cat >>'/mnt/us/documents/My Clippings.txt' `dirname $0`/startcopy.txt
startcopy.txt (Windows line endings):
Code:
___BEGIN_COPY_AND_PASTE___
- Bookmark Loc. 1 | Added on Monday, November 19, 2007, 07:30 AM
==========
Possible Future Extensions - Ideas- Add an option to handle pasting into HTML files (including formatting URLS as links).
- Implement an alternative method of pasting by simulating keypresses? (I want to be able to paste into the Kindle's browser.)
- Write a Java program to enable "copying" from the browser's bookmarks file?