Friday, April 24, 2015

Android tablet as a second Ubuntu screen with xrandr and x11vnc

Let's say you have a laptop, an Android tablet and you're working on debugging something.  Wouldn't it be nice to have some extra screen real estate?  The second answer here seemed to be going in the right direction... only one gets stuck moving the mouse into the extended screen area.

So here's a recipe that works (on Ubuntu 14.10 at least). Let's say the actual laptop screen is 1366x768 as in my case; and we want to create another screen of the same resolution:

$ sudo apt-get install x11vnc
$ sudo xrandr --fb 2732x768 --output LVDS1 --panning 2732x768+0+0/2732x768+0+0
$ sleep 3 # wait a moment
$ sudo xrandr --fb 2732x768 --output LVDS1 --panning 1366x768+0+0/2732x768+0+0

Explanation: xrandr (X Resize and Rotate) sets the screen size. To make it think the screen is bigger without doing strange things we first tell it to make a panning setup. With panning the section before the / is the area in which that screen can pan around, after the / is the very important tracking area in which the mouse can move.

Now we can use x11vnc with a clip

sudo x11vnc -clip 1366x768+1367+0 -nocursorshape -nocursorpos

We need to use -nocursorshape and -nocursorpos so the cursor is not dealt with by VNC; the cursor is directly painted on as part of the image.



Now you can take your pick of Android VNC apps and then point it at your laptop's IP address:

The new right half of the screen
Now there's only two and a bit problems left: VNC is not encrypted; so it should run over an SSH tunnel/VPN or something of the like.  Another problem can be lousy WiFi; I'm hoping to kill two bids with one stone by making this run using port forwarding on over the USB cable.

Thanks to this AskUbuntu post.

11 comments:

  1. thanks for sharing, this is really cool. Now my old tablet has a purpose again as secondary monitor.
    One question though, I'm using lubuntu and when I maximize windows after setting up the "bigger monitor" they maximize to the bigger monitor, not to the laptop monitor or the tablet monitor.
    Do you have any idea where can I look at to try and fix this?

    thanks again for sharing!

    ReplyDelete
    Replies
    1. a workaround in case it helps anybody, in my case the laptop and tablet use the same exact resolution, 1280x800 and I use them side by side, so the total display is 2560x800.
      Pressing super-left or super-right brings the current window to the left half or right half of the display, which in my case means laptop or tablet.
      Not the perfect solution but for me it does the trick.

      Delete
  2. Thanks for the information. It workd!

    Have you figured out how to do port forwarding over USB? I often need to work in places with weak/not secure wifi and ssh tunnel would not work...

    THANKS!

    ReplyDelete
  3. My pc went black screen after reboot and cant doanything. Anyhelp. I can accesos the recoveryof ubuntu

    ReplyDelete
  4. Thank you so much. How did you find about the `--panning` option? I still don't understand what it does, but it unblocked me!
    You should definitely add the port forwarding part in your tutorial. I'm trying it right now, to know how much it reduces the lag.

    ReplyDelete
  5. Very good.
    There are still a few things I don't understand but it worked.
    I'm using Lubuntu 14.04 and I tried with a Samsung Tab 2 phone.
    Thank you :)

    ReplyDelete
  6. my display is 1280x800. how can I create another screen using --panning

    ReplyDelete
  7. Mr Mikes
    Thanks it works
    so simple - 2 lines - and it works

    ReplyDelete
  8. Have a look here: http://pavatechpit.blogspot.co.uk/2017/04/android-tablet-as-second-monitor-on.html

    ReplyDelete
  9. Hi Mike, does this procedure work on Ubuntu 20.04?
    Best regards
    FSA

    ReplyDelete