KindlePi - use your Kindle 4 as screen


10 posts
by Rasbimo » Sat Nov 30, 2013 10:35 am
I could mod my Kindle so I can now use it as screen for the RaspberryPi. KindleberryPi makes it possible to have a terminal only, but with my guide you can use it as a complete screen!

How-To for Kindle 4 NT:

1) jailbreak your Kindle: http://wiki.mobileread.com/wiki/Kindle4 ... #Jailbreak
2) install USBNetwork: http://wiki.mobileread.com/wiki/Kindle4NTHacking#SSH
3) install KindleVNC viewer: http://www.mobileread.com/forums/showth ... p?t=150434
4) now you can connect to your Kindle (the root password doesn't exist, you can type anything) by doing
Code: Select all
sudo ifconfig usb0 192.168.15.2
ssh root@192.168.15.244

5) start the vnc viewer with
Code: Select all
/mnt/us/kindlevncviewer/kvncviewer.sh 192.168.15.2:0 &


6) to autostart the Kindle's viewer once the Pi boots up, link to this script (you need to have sshpass and x11vnc installed!):
Code: Select all
sudo ifconfig usb0 192.168.15.2
sudo x11vnc -scale 800x600 -display :0 &
sleep 8
sshpass -p asdf ssh root@192.168.15.244 /mnt/us/kindlevncviewer/kvncviewer.sh 192.168.15.2:0 &

with
Code: Select all
[Desktop Entry]
Type=Application
Exec=/home/pi/kindlestart.sh

from ~/.config/autostart/kindlestart.desktop (create the folder if it doesn't exist).

Don't forget to enable USBNetworking, otherwise it won't work. You can do so with KUAL: http://www.mobileread.com/forums/showth ... p?t=203326

Happy hacking!
Last edited by Rasbimo on Mon Dec 23, 2013 10:27 am, edited 1 time in total.
Posts: 3
Joined: Sat Oct 26, 2013 10:19 am
by Rasbimo » Mon Dec 23, 2013 10:22 am
Here is how to do using WLAN.

0) use SSH to change your Kindle's password, for example to foobar123

1) enable "Allow SSH over WiFi" in your USBNetwork configuration
2) Now change the script to autoconnect with your password over WiFi if available. Don't forget to insert the correct IP addresses!

Code: Select all
sudo x11vnc -scale 800x600 -display :0 &
sleep 8
sudo ifconfig usb0 192.168.15.2
if [[ $? -eq 1 ]]
then
        sshpass -p foobar123 ssh root@192.168.15.244 /mnt/us/kindlevncviewer/kvncviewer.sh 192.168.15.2:0 &
else
        sshpass -p foobar123 ssh root@insert_kindle_ip_here /mnt/us/kindlevncviewer/kvncviewer.sh insert_rpi_ip_here:0 &
fi

3) If you want to show a terminal after boot, you can do so with "lxterminal"

Your WiFi status bar may show that you are disconnected once you activated USBNetworking, but that is not the case.
Posts: 3
Joined: Sat Oct 26, 2013 10:19 am
by Knlgdgl » Sun Feb 09, 2014 7:11 am
Hello Rasbimo,

The WLAN method isnt working for me. I enabled allow ssh over wifi from the config file in the kindle. I also changed the password to foobar123 and also changed the kindlestart.sh file. The normal usb method is working.

Am I doing it right? BTW its an awesome hack.
Posts: 8
Joined: Sun Feb 09, 2014 5:29 am
by twobob » Mon Jun 02, 2014 7:52 pm
addendum, with http://www.mobileread.com/forums/showpost.php?p=2525691&postcount=397 the right hack you can now push back screen clicks if using a touchscreen device (Kindle Touch, Kindle Paperwhite)

Just so you know.

simply editing config.lua in kvnc enables this.
Posts: 6
Joined: Mon Jun 02, 2014 2:30 pm
by twobob » Wed Jun 04, 2014 10:51 am
So I tried this last night. enabled the Paperwhite to click back through to the X virtual framebuffer implementation on the PI. I have never plugged this pi into a monitor so Xvfb was the best option IMHO.

More or less I did the following:

Code: Select all
#!/bin/bash

# CHANGE TO MATCH YOUR SETUP
raspberrypiIP="192.168.1.3"
kindleIP="192.168.1.4"

function kill_stuff {

# Lets demonstrate a few ways of killing processes...
   
   echo "CLEARING DOWN..."
   
    ssh root@$kindleIP "for process in $(ps -A -f | grep 'kvncviewerrefresh' | grep -v grep | awk '{print $2}') ;do kill -9 $process; done"
    >/dev/null 2>&1  kill -9 $(ps -A -f | grep "knvcviewerrefresh" | grep -v grep | awk '{print $2}')
    ssh root@$kindleIP "killall knvcviewerrefresh"
         # That should cover most cases for killing stuff, remotely. Obviously total overkill.
         # Let's remember to kill down our own local bits that we may have started.

    >/dev/null 2>&1  kill -9 $(ps -A -f | grep vncviewer | grep -v grep | awk '{print $2}')
    # OR
     >/dev/null 2>&1  killall vncviewer

          >/dev/null 2>&1  kill -9 $(ps -A -f | grep "x2vnc" | grep -v grep | awk '{print $2}')
     # OR
          >/dev/null 2>&1  killall Xvnc
   
          # etc...
     >/dev/null 2>&1 kill -9 $(ps -A -f | grep "xterm" | grep -v grep | awk '{print $2}')   
     >/dev/null 2>&1 killall dwm
     >/dev/null 2>&1  killall x2vnc
     >/dev/null 2>&1   killall Xvfb
         echo "Killed x2vnc, dwb, refresh loop, and other likely junk"
}


function clean_up {

   # Perform program exit housekeeping
   # This gets called if we send a signal before we make it into our final ssh session
   kill_stuff
   exit 0
}

trap clean_up SIGHUP SIGINT SIGTERM


         # I always assume something I don't want to run will be running...
    kill_stuff
     sleep 1

echo
echo "######### BOOTING KINDLE SCREEN TO PI X ######### "
echo

geometry=824x1200   # THATS A DX, A PAPERWHTE IS 1024, 768, TOUCH (et al) are 800x600

Xvfb :0 +extension RANDR +extension XTEST  +extension MIT-SHM +extension XFIXES -screen 0 "$geometry"x16 -dpi 160 &

/usr/bin/Xvnc -geometry $geometry -depth 16 -dpi 160  -alwaysshared :1 &
#-lazytight

sleep 1
echo "######### INITIALISING BASE WM + APPS ######### "
DISPLAY=:1 xterm &
DISPLAY=:1 dwm &

echo "######### INITIALISING KINDLE REMOTE REFRESHER ######### "
#vncviewer :1 &
#x2vnc -west 127.0.0.1:0 &
ssh root@$kindleIP /mnt/us/kindlevncviewer/kvncviewerrefresh.sh &

echo "######### INITIALISING KINDLE SCREEN ######### "

# prevents us seeing any extra "UPDATING SCREEN" junk to stderr (and click data stuff)
ssh root@$kindleIP /mnt/us/kindlevncviewer/kvncviewer.sh $raspberrypiIP:1 2>&1 | grep -v "event\|partially"

###### our trap wont be hit if we make it to the viewer , let's tidy up
   echo
   echo "CLEARING DOWN..."
   kill_stuff
   echo "Killed x2vnc refresh loop"



That enables a simple "one click" startup and tear-down for the process.

Worked okay in the main.

POSSIBLE TODOS: (for someone)
Figure out why clicks are repeated to OSK. (LUA probably)
I built a custom patched dwb that plays nicely with xvkbd. http://lists.suckless.org/dev/1012/6600.html (had to apply patch by hand, wasn't too bad)

Alter rotation to 1024, 768 rather than 768 1024.

but that was pretty usable.

Hope it helps.
Posts: 6
Joined: Mon Jun 02, 2014 2:30 pm
by twobob » Wed Jun 04, 2014 10:54 am
CONTENTS OF kvnviewerrefresh.sh (lives in /mnt/us/kindlevncviewer/ on kindle device)
(needed on kindle touch, paperwhite, PW2 to hack the screen to "refresh")

Kindle 2, DX, 3 and 4 dont need this workaround.

Code: Select all
#!/bin/sh

while :; do usleep 80000; /usr/sbin/eips '' ; done
Posts: 6
Joined: Mon Jun 02, 2014 2:30 pm
by slyr » Sun Aug 10, 2014 1:22 pm
Hey,

i have a problem starting the vnc viewer on my kindle. Its unable to connect to VNC server.
Would be nice if someone could help me with that. Thanks :)
Posts: 1
Joined: Sun Aug 10, 2014 1:17 pm
by sry9681 » Fri May 08, 2015 6:43 pm
I know it's been a while since anyone has replied but is there any way I can do this but connect the kindle directly to my android phone? would i just use the same commands (with different IP address of course) on a terminal app on a rooted device?
Posts: 1
Joined: Fri May 08, 2015 6:41 pm
by Rhett82 » Thu Jan 28, 2016 6:01 pm
I've just about got everything working how I want it, but I'm having trouble figuring out the Kindle debug mode. I need to run two commands at the same time (~disableScreensaver and ~usbNetwork), but whichever one I do first seems to get turned off when you enter the next.

So either I can have the Kindle properly display the Pi X enviroment for 10 minutes before I have to reboot because it goes to screensaver mode and I can't figure out how to exit that and refresh the vnc session without visual aid, or I can turn off the screensaver indefinitely without being able to connect to the Pi because the ~usbNetwork has apparently been disabled.

I've tried these combinations, but none of them seem to work

;debugOn ~disableScreensaver ~usbNetwork ;debugOff
;debugOn ~usbNetwork ~disableScreensaver ;debugOff
;debugOn ~disableScreensaver ;debugOff ;debugOn ~usbNetwork ;debugOff

I'm having trouble finding anything with google about running 2 debug commands simultaneously, so if anybody could help me out on this issue, I would really appreciate it.
Posts: 1
Joined: Thu Jan 28, 2016 5:47 pm
by Collin_Schupman » Wed Feb 03, 2016 9:52 pm
Hi,

I've been following this example and got to the point of running the script and am getting this error message:

Code: Select all
root@192.168.15.244's password:
#################################################
#  N O T I C E  *  N O T I C E  *  N O T I C E  #
#################################################
Rootfs is mounted read-only. Invoke mntroot rw to
switch back to a writable rootfs.
#################################################
[root@[192_168_15_244] root]# /mnt/us/kindlevncviewer/kvncviewer.sh 192.168.15.2
:0 &
[root@[192_168_15_244] root]# /mnt/us/kindlevncviewer/kvncviewer.sh: line 6: lipc-set-prop: not found
25/09/2015 03:56:06 ConnectToTcpAddr: connect
25/09/2015 03:56:06 Unable to connect to VNC server
/mnt/us/kindlevncviewer/kvncviewer.sh: line 8: lipc-set-prop: not found


It looks like this "lipc-set-prop" command is missing. What is it? Anyone know what's going on?
Posts: 1
Joined: Wed Feb 03, 2016 9:32 pm