Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 07-21-2009, 11:24 AM   #1
Gearhead
Enthusiast
Gearhead began at the beginning.
 
Posts: 32
Karma: 45
Join Date: Dec 2007
Device: Kindle DX, PRS505
Restore KindleDX's font dialog justification toggle

Selectable text justification is one the issues that I've been keen to have Amazon address. They actually built this feature into all Kindles but left it disabled. I've not seen any issues when using the built in left justification but maybe there is a reason Amazon left it disabled. Maybe it is buggy? Maybe some publishers are forcing Amazon to keep the feature off the Kindle? This is the third generation of the Kindle hardware without an official left justification toggle and it doesn't seem likely that Amazon will enable this so I'll go over the steps I took to enable the built in justification toggle (full, left) on the DX.

First, a bit of background. Out of the box, the Kindle uses full text justification. This means that the left and right margins are even. This looks good to most folks. It is how most printed books look and works well enough. I find that full justification is distracting and prefer a single space between words with a ragged right margin. This is a more agreeable to me when you have the ability to change font sizes, it keeps the white space uniform between the words no matter what font size. (see attached images)

I've been following ebs lead on the screen saver fix and poked around the DX until I found the settings that need to be changed to enable the justification toggle. Once these settings are added to your DX, you will see the toggle show up automatically on the font (aA button) screen.

The settings to allow the toggle reside in this file:

system/com.amazon.ebook.booklet.reader/reader.pref.default

Here is how mine looks now:

Code:
#Reader Booklet
#Tue Jul 21 09:31:16 GMT 2009
FONT_SIZE=36
JUSTIFICATION=left
LAST_BOOK_READ=/mnt/us/documents/UR-asin_B001RF3U9K-type_EBOK-v_0.azw
ALLOW_JUSTIFICATION_CHANGE=true
You can view this file in any text editor. It is in the user mountable section at the same level as the documents folder. Unfortunately, you can't just add ALLOW_JUSTIFICATION_CHANGE=true because the Kindle framework rewrites this file when shutting down. The settings need to be injected after boot but before the java framework is started. Since I already implemented ebs usbnetworking auto start script, I decided to hijack it to see what happened. It worked. My changes are in bold

Code:
#!/bin/sh

    _FUNCTIONS=/etc/rc.d/functions
    [ -f ${_FUNCTIONS} ] && . ${_FUNCTIONS}

    US_ENABLE=/mnt/us/usbnet/AUTO

    case "$1" in

            start)
                    if [ -f ${US_ENABLE} ]; then
                            /mnt/us/usbnet/usbnetwork
                            
                            echo "JUSTIFICATION = left" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref                                       
                            echo "ALLOW_JUSTIFICATION_CHANGE = true" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref
                            
                    else
                            msg "not usbnet" I
                    fi
            ;;

            stop)
                    ;;
            *)
                    msg "Usage: $0 {start|stop}" W >&2
                    exit 1
                    ;;
    esac

    exit 0
With these changes, I rebooted once into auto usbnetworking. That injected the changes. Another reboot is needed to get back to normal mode. Although this works, the echo lines should be moved to separate script and there needs to be some shell logic written to prevent injecting the justification lines into the reader.pref file if they already exist. If there is enough interest, these changes could be packaged up into a binary file to make updating easier. Also, there needs to be a way to reverse this change.

-robert
Attached Thumbnails
Click image for larger version

Name:	screen_shot-4589.gif
Views:	452
Size:	16.2 KB
ID:	32735   Click image for larger version

Name:	screen_shot-4590.gif
Views:	457
Size:	15.5 KB
ID:	32736  
Gearhead is offline   Reply With Quote
Old 07-21-2009, 01:35 PM   #2
rfog
Evangelist
rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.rfog ought to be getting tired of karma fortunes by now.
 
Posts: 404
Karma: 238214
Join Date: Aug 2007
Location: Elda - Alicante (Spain)
Device: PB903, K2, K3, K2i, KDX, iPad, Q1U, X51v, TM2
WOW!

Yesterday I was messing with some similar: interline. In Kindle 2 you can press Shift+Alt+<number>, but in DX cannot.

Then I searched about that but I couldn't find where K2 stores those justification.

How do you search for the strings. I tried to decompile java programs stored in /opt/amazon/ebook/booklet but the result was not usable...
rfog is offline   Reply With Quote
Old 07-21-2009, 01:43 PM   #3
ebs
Zealot
ebs will become famous soon enoughebs will become famous soon enoughebs will become famous soon enoughebs will become famous soon enoughebs will become famous soon enoughebs will become famous soon enough
 
Posts: 100
Karma: 629
Join Date: Jun 2009
Location: California, USA
Device: Kindle DX
Quote:
Originally Posted by rfog View Post
WOW!
How do you search for the strings. I tried to decompile java programs stored in /opt/amazon/ebook/booklet but the result was not usable...
I use "jad -f -nolvt" to decompile extracted class files. Output is almost always unusable for re-compilation, but it will show all strings.

If you really want to change some the logic - use something like IDA to produce java assembly and jasmin to compile it back or just re-write the whole file and use normal java tools to compile it.
ebs is offline   Reply With Quote
Old 08-22-2009, 02:08 PM   #4
ectoplasm
Addict
ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.
 
Posts: 228
Karma: 1151364
Join Date: Aug 2009
Device: Aura HD and H2O
Quote:
Originally Posted by Gearhead View Post
..Unfortunately, you can't just add ALLOW_JUSTIFICATION_CHANGE=true because the Kindle framework rewrites this file when shutting down.
Quote:
Originally Posted by Gearhead View Post
..Although this works, the echo lines should be moved to separate script and there needs to be some shell logic written to prevent injecting the justification lines into the reader.pref file if they already exist.
If the reader.pref file is rewritten when shutting down, why do you have to worry about injecting the lines more than once?
ectoplasm is offline   Reply With Quote
Old 08-25-2009, 01:28 PM   #5
Gearhead
Enthusiast
Gearhead began at the beginning.
 
Posts: 32
Karma: 45
Join Date: Dec 2007
Device: Kindle DX, PRS505
Quote:
Originally Posted by ectoplasm View Post
If the reader.pref file is rewritten when shutting down, why do you have to worry about injecting the lines more than once?
You have a point there. It shouldn't matter. But...it is possible there are conditions when the file is not rewritten. The obfuscated code makes it difficult to tell for sure.

-robert
Gearhead is offline   Reply With Quote
Old 08-28-2009, 07:27 PM   #6
ectoplasm
Addict
ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.ectoplasm ought to be getting tired of karma fortunes by now.
 
Posts: 228
Karma: 1151364
Join Date: Aug 2009
Device: Aura HD and H2O
Thanks to Gearhead for figuring this out.

When I first got this working, I thought something was wrong, until I realized this only works on some books. In fact, less than half of the books on my Kindle DX will react to this switch. However, in my view, if I can "fix" any books with this switch, it is a good thing.

Code:
I    don't    care   to    have   extra   space   between   words   in   sentences   just   to   have   an   aligned   right   margin.
I do have an alternative procedure that works on any book. I'll post a thread about that soon.

Here is a script I made that is separate from the usbnetwork script:
Code:
#!/bin/bash

grep_output=`grep ALLOW_JUSTIFICATION_CHANGE "/mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref"`
if [ "$grep_output" == "" ]; then
    echo "Not found - adding"
    echo "JUSTIFICATION = left" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref                     
    echo "ALLOW_JUSTIFICATION_CHANGE = true" >> /mnt/us/system/com.amazon.ebook.booklet.reader/reader.pref
else
    echo "Justification option already exists in pref file."
fi
1) Create file named justify_option (with above contents) in /etc/init.d using vi editor, or however you can get it in there.
2) Make it executable (I forgot the exact chmod command)
3) Make a link using command:
ln -s /etc/init.d/justify_option /etc/rcS.d/S73justify_option
4) Reboot

Last edited by ectoplasm; 09-08-2009 at 10:52 AM.
ectoplasm is offline   Reply With Quote
Old 11-29-2009, 12:18 AM   #7
dundundun
Junior Member
dundundun began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2009
Device: Kindle 2i
Could some generous person wrap this up into a .bin file?

The rivers inside some text are driving me nuts and I spent the last hour trying to figure out this SSH stuff but failed.
dundundun is offline   Reply With Quote
Old 11-29-2009, 01:39 AM   #8
edge777
Kindle Enthusiastic
edge777 will become famous soon enoughedge777 will become famous soon enoughedge777 will become famous soon enoughedge777 will become famous soon enoughedge777 will become famous soon enoughedge777 will become famous soon enough
 
Posts: 67
Karma: 582
Join Date: Nov 2009
Device: Kindle 2 International
A BIN for the Kindle 2 and Kindle International would also be greatly appreciated!
edge777 is offline   Reply With Quote
Old 11-30-2009, 05:03 AM   #9
dundundun
Junior Member
dundundun began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2009
Device: Kindle 2i
Alright I'm starting to get some of this stuff and wrote this basic install script. I bundled it with the justify_option script above and updated my kindle. Unfortunately, no-go. Any ideas where I went astray?

Code:
#!/bin/sh

# Result codes
OK=0
ERR=$OK

# Move the justify script into place
cp justify_option /usr/bin

# Make it executable
chmod +x /usr/bin/justify_option

ln -s /usr/bin/justify_option /etc/rcS.d/S73justify_option

# Yay we're done
update_progressbar 100
exit $OK
dundundun is offline   Reply With Quote
Old 11-30-2009, 07:31 PM   #10
stevenmoy
Zealot
stevenmoy has a complete set of Star Wars action figures.stevenmoy has a complete set of Star Wars action figures.stevenmoy has a complete set of Star Wars action figures.stevenmoy has a complete set of Star Wars action figures.
 
Posts: 133
Karma: 348
Join Date: Jan 2008
Device: Kindle 2
When a writer writes an ebook, they can use HTML to dictate what justification the paragraph should be in. That makes the toggle very confusing because if I write a book and have justification to full justification in the entire book, no user intervention can make it not fully justified. =(
stevenmoy is offline   Reply With Quote
Old 11-30-2009, 08:41 PM   #11
dundundun
Junior Member
dundundun began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2009
Device: Kindle 2i
^ I get that, but I'm reading many gutenberg books that don't specify the justification, thus relying on the kindle's default.
dundundun is offline   Reply With Quote
Old 12-04-2009, 01:37 AM   #12
dundundun
Junior Member
dundundun began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2009
Device: Kindle 2i
Any help? I am considering returning the kindle if I can't figure this out.
dundundun is offline   Reply With Quote
Old 12-19-2009, 06:07 PM   #13
dundundun
Junior Member
dundundun began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2009
Device: Kindle 2i
One last pity bump and then I'll leave it alone.
dundundun is offline   Reply With Quote
Old 09-08-2010, 04:43 PM   #14
EldRick
Addict
EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Posts: 385
Karma: 91339
Join Date: Aug 2010
Device: Kobo Mini, Kobo Glo (Sony PRS-950, Nook STR, Kobo Touch, K-DX, K-3)
Another bump - any way to get Left Justification packaged as an update file for v3?

Last edited by EldRick; 09-10-2010 at 10:55 AM.
EldRick is offline   Reply With Quote
Old 09-14-2010, 03:43 AM   #15
EldRick
Addict
EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.EldRick is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Posts: 385
Karma: 91339
Join Date: Aug 2010
Device: Kobo Mini, Kobo Glo (Sony PRS-950, Nook STR, Kobo Touch, K-DX, K-3)
Well, it won't restore the Justification dialog, but if you edit the reader.pref file to change Justification=full to =left, and then do a soft restart from the Settings menu, it will set left justification until you either change Words per Line, or do a hard reset.

You can also reduce the margin (in pixels) to get another character or two per line (20 works well) by the same technique.

I was thrilled to find this in a Tips thread on kindleboards.com - I find that ragged-right and a smaller margins makes it appreciably easier to speed-read on a Kindle.

BIG THANKS to w5jck !!!

Last edited by EldRick; 09-15-2010 at 01:49 PM.
EldRick is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacks Restore the text justification menu toggle without a hack Gearhead Amazon Kindle 67 09-11-2014 01:09 AM
PRS-650 Can the 650 change font and justification? AlexBell Sony Reader 21 09-17-2010 05:58 AM
New preferences dialog kovidgoyal Calibre 22 09-07-2010 02:04 PM
which command does uds send to toggle fullscreen? Iñigo iRex Developer's Corner 16 08-06-2010 10:51 AM
Problem with Volume Toggle? moxy789 Amazon Kindle 2 03-04-2009 04:37 PM


All times are GMT -4. The time now is 02:22 PM.


MobileRead.com is a privately owned, operated and funded community.