I've noticed people using a product for Windows and Mac called iDisplay which lets you use your Android or iPad as a secondary display. This seems like a great idea, and something that could be done on Ubuntu. Unfortunately, I've got no idea how to get started.

How could you re-create this setup on Ubuntu?

  • 2
    Similar question currently under discussion on the forums: Use VNC as a second monitor
    – ændrük
    Commented Jun 21, 2013 at 4:40
  • 1
    Same question on Super User: Use VNC to create a second Screen
    – ændrük
    Commented Jun 21, 2013 at 4:59
  • 2
    Ok, the solutions presented here are network ones. But is there any chance to achieve this by simply faking a monitor through usb, to get the same experience as a monitor just like Duet does? Commented Dec 22, 2014 at 17:10
  • So Duet might be (essentially) emulating a DisplayLink chip in software -- I do not know but that's my guess. I wouldn't even try. What I would try (and it's not hard) is USB networking: tether (or reverse tether) your tablet and network away.
    – chx
    Commented Mar 10, 2015 at 8:10

15 Answers 15


Here's how to use Android as a second monitor, share the mouse, drag windows between tablet and computer screens.

The original source for the tutorial can be found here.

A. Tutorial

Step 1. Create a new virtual monitor

My tablet's resolution is 1280x1024. (You may change 1280 and 1024 everywhere in the commands if your tablet is in different resolution. You may also need to change LVDS1 if the default monitor's name is different).

Run in terminal:

  1. $ gtf 1280 1024 60.

    There is a line in the output similar to Modeline "1280x1024_60.00" 108.88 1280 1360 1496 1712 1024 1025 1028 1060 -HSync +Vsync. Copy everything after the word Modeline (exclude it) into the next command.

  2. xrandr --newmode "1280x1024_60.00" 108.88 1280 1360 1496 1712 1024 1025 1028 1060 -HSync +Vsync

    (Note, in the next step, you may also need to change VIRTUAL1 with what you find in xrandr output as an output with new mode)

  3. xrandr --addmode VIRTUAL1 1280x1024_60.00

  4. xrandr --output VIRTUAL1 --mode 1280x1024_60.00 --left-of LVDS1

Step 2. Enable remote desktop for the virtual monitor

Start VNC:

  1. x11vnc -clip 1280x1024+0+0

Step 3. Connect to the remote desktop

  1. Get the tablet on the same local network as the computer. Either by connecting to the same Wi-Fi or by creating a hotspot with one device and then connecting with another to it (USB Tethering).

  2. Find your computer's IP using ifconfig (when connecting from LAN).

  3. Download a VNC app to the tablet and then connect to the computer using computer's IP (and selecting port 5900) in the app.


  • Credits: kjans, contents edited.
  • WARNING: Data is unencrypted! (Relevant for Wi-Fi and not-LAN usage)
  • WARNING: Devices from all the networks you are connected might reach port 5900 and therefore connect to your monitor! Being behind a router usually would limit it to be accessible only within your local network (If you're using USB connection, you could block local network altogether with -listen <IP_ADDR> option to x11vnc (where <IP_ADDR> is the USB network interface)).
  • Running any of the 1 - 4 steps twice may output errors.
  • After successful use, 5. step must be repeated for another connection.

B. Script

The tutorial implemented as a script (Change the IP for use with the USB cable OR delete it and uncomment the line to use with Wi-Fi).

if [ "$1" == "create" ]; then
  gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | xargs xrandr --newmode
  # sed: get third line, delete 'Modeline', get first word, remove first and last characters
  gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --addmode $O
  gtf $W $H 60 | sed '3q;d' | sed 's/Modeline//g' | awk '{print $1;}' | sed 's/^.\(.*\).$/\1/' | xargs xrandr --output $O --left-of LVDS1 --mode
elif [ "$1" == "on" ]; then
  x11vnc -listen -clip ${W}x${H}+0+0
  # For use in Wi-Fi LAN.
  #x11vnc -clip ${W}x${H}+0+0 #**WARNING** Unencrypted stream. VNC accessible without password through port 5900 in all internet interfaces.
  echo "missing argument: [create | on]"
  • 13
    xrandr: cannot find output "VIRTUAL1" was returned when I type in number 3. Any ideas? Commented Dec 15, 2016 at 12:51
  • 3
    xrandr: cannot find output "VIRTUAL1" returned from xrandr --addmode VIRTUAL1 1280x800_60.00
    – Tooniis
    Commented Aug 1, 2017 at 15:57
  • 1
    @cprn Yes, you can share mouse cursor and drag windows. It's as if you had a second monitor connected Commented Sep 4, 2018 at 20:37
  • 2
    This should be accepted answer.
    – cprn
    Commented Sep 5, 2018 at 8:44
  • 1
    I got that error xrandr: cannot find output "VIRTUAL1". Replacing VIRTUAL1 by HDMI-1 worked! (xrandr --addmode HDMI-1 1280x1024_60.00 Commented Apr 25, 2020 at 11:20

Get a VNC client for Android, start up a new VNC server session on your computer (don't just share the current display - use vnc4server not x11vnc), connect to it from the Android VNC client, and (the clever bit) share the PC keyboard and mouse between the two sessions using synergy.

All necessary software to do this is available in the standard repos for the Ubuntu side, and there's a few free VNC clients available for Android in the market.

You won't be able to drag windows across the displays using this method. For that I think you would need to use Xdmx to bond the two sessions. This is a lot harder and would probably cause you to lose 3D acceleration.

Also be aware that synergy and vnc don't use encryption by default so you need to tunnel the connections if you are not on a trusted network.

  • 14
    can add a example please
    – rkmax
    Commented Sep 13, 2014 at 17:13
  • 35
    it'd be useful to have a step by step example that we can follow
    – OganM
    Commented Dec 22, 2014 at 20:16
  • 3
    How would this make a tablet a second screen - as in more screen space?
    – NoBugs
    Commented Sep 16, 2016 at 2:46
  • I had trouble with vncserver and Gnome 3. Every time I tried to launch vncserver the screen would go black. I ended up using tightvncserver (also in the Ubuntu repos) and it worked the first try with absolutely no configuration.
    – thirdender
    Commented Nov 24, 2016 at 20:18
  • This is more of a KVM switch-like or a remote control solution than a second display. Yes, it gives you another set of input but output is the same on both devices - you can't even switch the tablet to a different virtual desktop than your main screen, switching on one switches both. It doesn't answer the question. Question is about using mobile devices for extra output space, not about input at all.
    – cprn
    Commented Sep 4, 2018 at 16:27

tl; dr: xrandr --fb and x11vnc --clip together make a killer combo.
More X11vnc opts: -find, -clip, -display ... -opts

The thread linked by recognitium has a really interesting idea, not sure whether he meant this one because I couldn't find the author he indicated and also because I followed up on the forum post there, I will post this separately and not as an edit:

  1. First, let's assume: the primary machine does have a screen resolution of 1280x800, the secondary machine that you want to extend your desktop to over VNC has screen resolution of 1280x1024 and you want the extended screen to be right of your primary screen.
    The virtual screen needs to be 1280x800 + 1280x1024 = 2560x1024. (extend it horizontally and make the vertical resolution the bigger of the two) So run xrandr --fb 2560x1024.

  2. Now that the screen is bigger than your primary monitor, you have to make sure there is no panning or any other unwanted "feature" activated and also that the coordinates of your primary monitor's top left corner are 0x0.

  3. x11vnc -clip 1280x1024+1281+0 plus any other x11vnc options to taste :)

This should be it.

  • 2
    This seems like a way more seamless way to do it than the Synergy trick, nice! I'm curious how the extra virtual space will interact with my tiling window manager though. Will give this a shot in a little while and report back.
    – Ibrahim
    Commented Jan 23, 2013 at 23:49
  • 2
    Defeat snatched from the jaws of victory. The mouse pointer is not allowed to leave the primary screen. :( Commented Oct 25, 2013 at 6:18
  • 2
    Seems interesting. I actually manage to have a double screen there, but unfortunately, the command xrandr --fb 2560x1024 doesn't seem to have any effect. Which means I can't have a bigger screen than my primary monitor size ... :( Commented Feb 10, 2016 at 15:02
  • 1
    I read further about this. Got a X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 18 (RRAddOutputMode) Serial number of failed request: 29 Current serial number in output stream: 30 error. My guess is that my laptop doesn't support higher resolution than native 1600*900. Meaning this solution can't work. I'll have to find a double screen solution instead. Commented Feb 10, 2016 at 15:38
  • 3
    I finally made it work thanks to this post by running: sudo xrandr --fb 2732x768 --output LVDS1 --panning 2732x768+0+0/2732x768+0+0 (I was missing the --panning option) Commented Feb 10, 2016 at 19:39
  1. Install vnc4server and x2x.
  2. Then, set up a .vnc/xstartup config file. Mine looks like this

    # Uncomment the following two lines for normal desktop:
    # exec /etc/X11/xinit/xinitrc
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    #vncconfig -iconic &
    #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    #x-window-manager &
    exec gnome-session

    It launches gnome-fallback desktop (I don't know how to make gnome 3 launch in vnc).

  3. To launch vnc server, use vnc4server -geometry 800x480 command. Of course, instead of 800x480 you have to set your tablet's resolution.
  4. Launch x2x -east -to :1. That command says your computer to act as if display :1 had been to the right of the screen (use -west option if you want it to be on the left). You won't be able to move apps from one display to another, but you may use one mouse and one keyboard to control them both.
  5. Connect to the display created with vnc4server from your tablet (the port number is 5900 + display number (e.g. for display :1 port number will be 5901) (display number is shown in the vnc4server's output)).
  6. To exit from x2x, press Ctrl-C. Alternatively, you may launch it in the background (x2x -east -to :1 &). Then you will first need to move it to foreground (fg), or kill it with kill $! (be cautious, it kills last process launched in background).
  7. To remove the created display, call vnc4server -kill :1, where instead of :1 you may set your new display's number.
  • 1
    Thanks for x2x... Why no one else mentions it on the entire internet ??? Saved me big time. Synergy requires cyanogenmod or similar on your tablet. Also no one mentions it. Commented Sep 17, 2013 at 9:05
  • 2
    I already know x2x, find this post by searching for x2x android on google... But +1 for .vnc/xstartup, especialy for unset DBUS_SESSION_BUS_ADDRESS!! Small but rich and very usefull post, thanks! Commented Jun 20, 2014 at 6:56

Just wanted to add that if you want a better connection between your android device and your computer, you can use USB :

Be sure you have enabled USB debugging ( https://developer.android.com/studio/debug/dev-options )

Then install adb via sudo apt-get install android-tools-adb

Then if your VNC server is running on your computer on port 5900, use adb with :

adb reverse tcp:5900 tcp:5900

That way your computer 5900 port will also be accessible on your android device through localhost:5900 so configure your android VNC client to connect to localhost:5900 instead of your-computer-IP-addres:5900

  • Essential to making this work without external connection
    – JoeSchr
    Commented Nov 11, 2022 at 9:50

This is in principle possible using xdmx (distributed multihead X) which allows you to create a single desktop using two X-servers running on separate machines.

Three scenarios are possible in principle, but none are as seamless as iDisplay, because they all require restarting your X-session at least. I have not been able to get either to work perfectly, but I am running Ubuntu 10.10 and can't upgrade for various reasons.

The three are:

  1. Run an X-server on Android (there are two available now in the app store) and use xdmx to combine with your desktop or laptop display. - didn't work for me because xdmx crashed when the pointer moved to the tablet part of the desktop.

  2. Run a second X-server with vnc backend on your computer, use xdmx to combine that into one desktop with your computer screen, then look at the virtual part with a vnc viewer on the tablet - didn't work for me because xdmx requires all X-servers to have the same color visuals, which is not the case for the VNC server and the real display, and I wasn't able to convince vncserver to change.

  3. Run two VNC servers, one for each screen, then connect them with xdmx and look at each part with a VNC Viewer on the respective machine. - This came closest to working for me, unfortunately input was messed up. it was also quite slow in true-color over Wi-Fi. I used this script to start xdmx and the two instances of vncserver:

    vncserver :2 -geometry 1024x768 -depth 24 && \
    vncserver :3 -geometry 1920x1120 -depth 24 && \
    startx -- \
    /usr/bin/X11/Xdmx :1 \
    -input :2 \
    -display :2 \
    -display :3 \
    -ignorebadfontpaths \
    -norender \
    -noglxproxy \
    +xinerama \
    vncserver -kill :2 
    vncserver -kill :3



I made a simple bash script to make a tablet a second display. Copy ipad_monitor.sh (Don't worry. it also works with Android) in my blog post.

What's different from the other post is that you can set position of the second screen with additional argument very easily.

Edit: I included the original ipad_monitor.sh here. run this command like:

  • ./ipad_monitor.sh --right or ./ipad_monitor.sh --left
  • ./ipad_monitor.sh --right --portrait
  • ./ipad_monitor.sh --right --portrait --hidpi

The basic idea of this script is the same as others, running xrandr and x11vnc but I included options like which side you would like to attach the screen.

# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <[email protected]> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. - Bumsik Kim
# ----------------------------------------------------------------------------

# Configuration
WIDTH=1024  # 1368 for iPad Pro
HEIGHT=768  # 1024 for iPad Pro
MODE_NAME="mode_ipad"       # Set whatever name you like, you may need to change
                            # this when you change resolution, or just reboot.
DIS_NAME="VIRTUAL1"         # Don't change it unless you know what it is
RANDR_POS="--right-of"      # Default position setting for xrandr command

# Parse arguments
while [ "$#" -gt 0 ]; do
  case $1 in
    -l|--left)      RANDR_POS="--left-of"  ;;
    -r|--right)     RANDR_POS="--right-of" ;;
    -a|--above)     RANDR_POS="--above"    ;;
    -b|--below)     RANDR_POS="--below"    ;;
    -p|--portrait)  TMP=$WIDTH; WIDTH=$HEIGHT; HEIGHT=$TMP
                    MODE_NAME="$MODE_NAME""_port"  ;;
    -h|--hidpi)     WIDTH=$(($WIDTH * 2)); HEIGHT=$(($HEIGHT * 2))
                    MODE_NAME="$MODE_NAME""_hidpi" ;;
    *) echo "'$1' cannot be a monitor position"; exit 1 ;;

# Detect primary display
PRIMARY_DISPLAY=$(xrandr | perl -ne 'print "$1" if /(\w*)\s*connected\s*primary/')

# Add display mode
RANDR_MODE=$(cvt "$WIDTH" "$HEIGHT" 60 | sed '2s/^.*Modeline\s*\".*\"//;2q;d')
xrandr --addmode $DIS_NAME $MODE_NAME 2>/dev/null
# If the mode doesn't exist then make mode and retry
if ! [ $? -eq 0 ]; then
  xrandr --newmode $MODE_NAME $RANDR_MODE
  xrandr --addmode $DIS_NAME $MODE_NAME

# Show display first
xrandr --output $DIS_NAME --mode $MODE_NAME
# Then move display
sleep 5 # A short delay is needed. Otherwise sometimes the below command is ignored.

# Cleanup before exit
function finish {
  xrandr --output $DIS_NAME --off 
  xrandr --delmode $DIS_NAME $MODE_NAME
  echo "Second monitor disabled."

trap finish EXIT

# Get the display's position
CLIP_POS=$(xrandr | perl -ne 'print "$1" if /'$DIS_NAME'\s*connected\s*(\d*x\d*\+\d*\+\d*)/')
echo $CLIP_POS
# Share screen
x11vnc -multiptr -repeat -clip $CLIP_POS
# Possible alternative is x0vncserver but it does not show the mouse cursor.
#   x0vncserver -display :0 -geometry $DIS_NAME -overlaymode -passwordfile ~/.vnc/passwd
if ! [ $? -eq 0 ]; then
  echo x11vnc failed, did you \'apt-get install x11vnc\'?
  • 1
    Do you have a name for the script/app or any alternative link that you can post to help avoid link rot? Here we generally try to be as self contained as possible so as not to rely on other sites staying up, especially if those sites contain the bulk of the info that would be relevant to an answer where that info isn't actually put into the answer.
    – sbergeron
    Commented Apr 17, 2018 at 17:30
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – anonymous2
    Commented Apr 17, 2018 at 18:36
  • 2
    @sbergeron I see. I include the original code here.
    – Bumsik Kim
    Commented Apr 17, 2018 at 19:42
  • 1
    @anonymous2 You're right. I included the bash code here.
    – Bumsik Kim
    Commented Apr 17, 2018 at 19:43
  • Ah, much better. I think this should be able to stick around like this.
    – anonymous2
    Commented Apr 17, 2018 at 19:44


    $ sudo apt-get install x11vnc
    $ WINDOW_ID=$(xwininfo | awk '/Window.id/{print $4}') && x11vnc -viewonly -nopw -avahi -id $WINDOW_ID >/dev/null 2>&1 &

Now, just click at the window you want to share.


I have an iPad and Chromebook and I would like to use them as my monitors, to use some terminal commands htop, iptstate, nmon,etc . So, I'm lazy guy and made it using:

  1. Package instalation: sudo apt-get install x11vnc

  2. Open some terminal and put xwininfo | awk '/Window.id/{print $4}' and click in the window you want to share. The output will be something like:

     $ xwininfo | awk '/Window.id/{print $4}'
  3. Now you can start your x11vnc session:

     $ x11vnc -viewonly -nopw -avahi -id 0x4402f34 >/dev/null 2>&1 &
  4. Resize the window (0x4402f34) to have the best image as possible.

Mind the associated port of your session: 5900 -> :0, 5901 -> :1, 5902 -> :2...

Works fine with X11 apps: Firefox, OpenOffice, etc.


I use the xorg dummy driver and x11vnc -clip. The mouse point is not stuck on the edge.

sudo apt-get install xserver-xorg-video-dummy

There is the /etc/X11/xorg.conf for dummy driver on second screen:

Section "Device"
        Identifier      "Configured Video Device"
    Driver "radeon"         #CHANGE THIS

Section "Monitor"
        Identifier      "Configured Monitor"

Section "Screen"
        Identifier      "Default Screen"
        Monitor         "Configured Monitor"
        Device          "Configured Video Device"

Section "Device"
  Identifier "Videocard0"
  Driver "dummy"
  #VideoRam 4096000
  VideoRam 256000

Section "Monitor"
  Identifier "Monitor0"
#  HorizSync   10.0 - 300.0
#  VertRefresh 10.0 - 200.0
#  DisplaySize 4335 1084

Section "Screen"
  Identifier "Screen0"
  Device "Videocard0"
  Monitor "Monitor0"

Section "ServerLayout"
  Identifier   "dummy_layout"
  Screen       0 "Default Screen"
  Screen       1 "screen0" rightof "Default Screen"
    Option         "Xinerama" "1"

Then login to X session and run:

x11vnc -clip 1024x768+1280+0
  • Any way to do this without xorg.conf? If I create one on my computer then my graphics get completely messed up.
    – daboross
    Commented May 28, 2013 at 15:33
  • Is Xinerama still supported? How about xrandr? Commented Oct 25, 2013 at 6:26

These instructions are to create an "additional" screen for your linux machine using a tablet or any computer through a VNC client.

I made these steps in Mageia3 32Bit (have not tried 64bit) but should be similar for other distros as well (i.e. Ubuntu).

Make sure you have all the required packages with the following terminal command:

sudo apt-get install gcc autoconf automake x11-font-util libtool libxi-devel ibopenssl-devel libxfont1-devel libpam-devel x11-util-macros x11-xtrans-devel x11-server-xvfb x11-server-xdmx x11-server-devel x11-server-source

Once you have all the above packages, issue these commands:

cd /usr/share/x11-server-sources/
./configure --with-fontrootdir=/usr/share/fonts --with-xkb-path=/usr/share/X11/xkb --with-xkb-output=/usr/share/X11/xkb/compiled --enable-dmx

If you don't get any errors, patch Xdmx (simply put, it has been "broken" for some time):

open /usr/share/x11-server-sources/hw/dmx/input/dmxevents.c, and change line 730: change this:


to this:


IF line 730 is different use this section to find correct line: Orginal section - line to change marked with *

    case ButtonPress:
    case ButtonRelease:
        detail = dmxGetButtonMapping(dmxLocal, detail);
        QueuePointerEvents(p, type, detail,
 *                         POINTER_RELATIVE | POINTER_DESKTOP, &mask);

Check your version of Xdmx by running ./configure --version in /usr/share/x11-server-source/, for Xdmx 1.13 and older you also have to make these changes (for 1.14 and newer you can skip to the "make" step below):

open /usr/share/x11-server-sources/dix/getevents.c, line 1395: change this:

if (flags & POINTER_SCREEN ) {    /* valuators are in screen coords */

To this:

if (flags & ( POINTER_SCREEN | POINTER_DESKTOP) ) {    /* valuators are in screen coords */

(Original section - line to change marked with *)

    /* valuators are in driver-native format (rel or abs) */

    if (flags & POINTER_ABSOLUTE) {
*       if (flags & POINTER_SCREEN ) {    /* valuators are in screen coords */
            sx = valuator_mask_get(&mask, 0);
            sy = valuator_mask_get(&mask, 1);

open /usr/share/x11-server-sources/Xext/xtest.c, line 311: change this:


to this:


(original section - line to change marked with *)

       case MotionNotify:
            dev = PickPointer(client);
            valuators[0] = ev->u.keyButtonPointer.rootX;
            valuators[1] = ev->u.keyButtonPointer.rootY;
            numValuators = 2;
            firstValuator = 0;
            if (ev->u.u.detail == xFalse)
*               flags = POINTER_ABSOLUTE | POINTER_DESKTOP;

/usr/share/x11-server-sources/include/input.h, line 73: Add this line after the line starting with #define POINTER_EMULATED:

#define POINTER_DESKTOP         (1 << 7)

After making the above changes, re-execute (in /usr/share/x11-server-sources/):


You should have a new Xdmx file in /usr/share/x11-server-sources/hw/dmx/. We need to install that globally for ease, so I recommend renaming your existing one:

sudo mv /bin/Xdmx /bin/Xdmx-old

and copy the new one in place of it:

cp /usr/share/x11-server-sources/hw/dmx/Xdmx /bin

Now you're ready to do your first trial, the following commands allow you to keep your main/existing display (:0) running and open a new display with the multi-monitor support. I am using icewm with these commands to make it a little more lightweight (I use KDE on my main display :0 and open any large-multi-monitor application in the new multi-head display). You can most definitely script these commands for ease of use (it's what I did) -- Any of these commands can be executed on console and/or terminal window of any display, the only requirement is that they are executed in order.

This command creates your new display as a frame buffer for your VNC display :2 (adjust screen size as desired):

Xvfb :2 +xinerama -screen 0 1024x1280x24 -ac &

This starts a new lightweight X session on your physical display as display :1 (there are different ways to do this):

startx 'icewm' -- :1

This command starts the multi-display between your physical screen and the virtual screen and starts icewm for window manager:

Xdmx :3 +xinerama -display :1 -display :2 -norender -noglxproxy -ac & DISPLAY=:3 starticewm

Now open a terminal window and start the vnc server (change password as desired):

x11vnc -display :3 -passwd test -clip xinerama1 -noshm -forever -nowireframe &

The only thing left to do now is to fire up your VNC client and connect to your VNC -- you may need to disable or add an exception to your firewall to port 5900 so you can connect to it. Another thing to keep in mind is that some VNC clients don't display the remote cursor position, I certify that "Mocha VNC" for iOS works great if you turn off the option "local mouse".

Enjoy dragging windows between your main monitor and your new virtual second monitor (while also being able to use the tablet to click/type on things in the second monitor).

To close Xdmx press Ctrl+Alt+Backspace twice.


I use this bash script to start the whole process (also kills Xvfb on exit):

Xvfb :2 +xinerama -screen 0 1024x1280x24 -ac &
xinit dual -- :1
ps | grep Xvfb | awk '{print $1}' | xargs kill

Then I have a custom ~/.xinitrc file with this:

# ~/.xinitrc
# Executed by startx (run your window manager from here)

if [[ $1 == "" ]]
  exec startkde 
elif [[ $1 == "xterm" ]]
  exec xterm
elif [[ $1 == "dual" ]]
  exec Xdmx :3 +xinerama -display :1 -display :2 -norender -noglxproxy -ac & DISPLAY=:3 starticewm & x11vnc -display :3 -passwd test -clip xinerama1 -noshm -forever -nowireframe
  exec $1


  • When running Xdmx if you get an error saying sh: /usr/local/bin/xkbcomp: No such file or directory you may need to do execute: cd /usr/local/bin" and "ln -s /bin/xkbcomp, then try Xdmx again.

  • Ctrl+Alt+F1 through F7 is supposed to work in Xdmx to switch to other consoles/xsessions but for some reason it doesn't work, what I do is simply execute sudo chvt X (where X is a console/xsession number) to switch to my main display. Also when you switch back to Xdmx you may get some drawing issues on any open windows, I just click on the taskbar to hide/show the window again forcing a redraw.


For anyone still wondering on this topic: the xrandr and x11vnc clip does work; to enable the mouse to get over there you need to use the panning argument to set the mouse tracking area:

xrandr --fb 2560x1024 --output LVDS1 --panning 1280x1024+0+0/2560x1024+0+0

Then when running xvnc use:

x11vnc -clip 1280x1024+1281+0 -nocursorshape -nocursorpos

That stops VNC from attempting to use it's own cursor tracking and paints the cursor as part of the screen image.

I made notes here http://mikescodeoddities.blogspot.ae/2015/04/android-tablet-as-second-ubuntu-screen.html


Use vnc_virtual_display_linker

The tool sets up a second virtual monitor for connecting with VNC as described in many of the previous answers. It even supports connections from Android devices using a USB cable.


Since none of the solutions above worked for me on Ubuntu, I'll share the script and steps I use.

  1. Get a "Headless Display Adapter"; Xorg dummy package didn't work for me. Maybe because of NVIDIA, and there was no clear solution to be had after 3 hours. So, got myself one of these dummy HDMI devices online. Look up "dummy HDMI".

dummy hdmi

  1. Install a VNC app on android; I am using "bVNC Free" app, which works well and simple.

  2. Get the cables; If you have Type-C ports on both devices, get a cable to connect the ports.

  3. Enable developer mode in android device;

  4. Install x11 and adb packages needed on the Ubuntu device;

     sudo apt update
     sudo apt install android-tools-adb x11-xserver-utils x11vnc
  1. Setup VNC app on android; Use for VNC connection settings IP and port 5901. All else as default.

  2. Get the dummy HDMI's display name using xrandr; One display should be the main display and other the dummy. Mine was "HDMI-A-0";

xrandr | grep ' connected'
  1. Run the script below to start; It must be run on terminal. It can be saved in an executable .sh file to make it easy to start every time.
    #Set screen resolution and display name
    #Define mode and mode resolutions
    mode=$(cvt $resh $resv | grep "Modeline" | xargs | sed 's/Modeline //' | sed 's/\.00//');
    moderes=$(echo $mode | awk '{print $1;}');
    #Reset and kill all existing processes
    adb kill-server
    xrandr --output $dummy --off
    xrandr --delmode $dummy $moderes
    xrandr --rmmode $moderes
    killall -9 x11vnc
    #Start adb, set xrandr and start x11vnc
    adb reverse tcp:5901 tcp:5901 &
    sleep 5
    adb shell monkey -p com.iiordanov.freebVNC -c android.intent.category.LAUNCHER 1 &
    sleep 5
    xrandr --newmode $mode
    xrandr --addmode $dummy $moderes 
    xrandr --output $dummy --mode $moderes
    x11vnc -bg -clip "${resh}x${resv}+0+0" -rfbport 5901 2>/dev/null 1>&2

    #Notify and exit
    echo "VNC ready; Open VNC app to use. This window closes in 10 seconds.";
    notify-send "VNC ready";
    sleep 10
  1. Once ready, open the VNC app and open the saved connection. It should show the second display. Using Ubuntu's display manager, the position of the second display can be slightly altered. More room for experiments.

Updated script (Jan'24)

Here is my updated script to replace step 8 and 9, and run the script in background using root cronjob.

8.a. Save the following script in $HOME/startvnc.sh, or any other preferred location. Update the "Custom Definitions" section with your inputs.


#Custom Definitions (Screen resolutions, display names, modes, etc..)
user="username"; # Run whoami command on terminal to get username
origresh=1280; # Current PC display resolution horizontal
dummyresh=1280; # Dummy device resolution horizontal
dummyresv=800; # Dummy device resolution vertical
dummyname="HDMI-A-0"; # Run xrandr | grep ' connected' to get main display
defscreentout=15000; # ~15 seconds; Default screen timeout on phone;

#Standard Definitions
mode=$(cvt $dummyresh $dummyresv | grep "Modeline" | xargs | sed 's/Modeline //' | sed 's/\.00//');
moderes=$(echo $mode | awk '{print $1;}');

#Setup xrandr
if [[ $(xrandr -q | grep $moderes | wc -l) -eq 0 ]]; then
    xrandr --newmode $mode
    xrandr --addmode $dummyname $moderes 
    xrandr --output $dummyname --mode $moderes

#Function: To notify as root
function notify {
    if [[ -z "$1" || -z "$2" ]]; then
        echo "Valid format: notify user title comment(optional)";
        return -1;
    local userid=$(id -u $1);
    if [[ ! -z "$3" ]]; then
        sudo -u "$1" DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$userid/bus notify-send "$2" "$3";
        sudo -u "$1" DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$userid/bus notify-send "$2";
    adb shell cmd notification post --style bigtext --bigtext "$2" "1" "1";

#Function: To start adb and x11vnc
function startService {
    adb reverse tcp:5901 tcp:5901 &
    sleep 1
    adb shell monkey -p $vncappid -c android.intent.category.LAUNCHER 1 &
    sleep 1
    adb shell settings put system screen_off_timeout 2147483647
    x11vnc -noxdamage -nobell -wait 0 -defer 0 -ping 1 -nonap -sb 0 -speeds 6,100000,1 -repeat -bg -clip "${dummyresh}x${dummyresv}+${origresh}+0" -rfbport 5901 2>/dev/null 1>&2
    sleep 3;
    notify "$user" "VNC-client-ready" "Open VNC app on device to view";
    sleep 5;

#Function: To stop and exit
#Close the vnc app on phone before unplugging cable, so that the following commands can reset defaults.
function stopService {
    # Reset pref
    adb shell settings put system screen_off_timeout $defscreentout;
    # Reset and kill all existing processes
    adb kill-server
    killall -9 x11vnc
    # Notify and return
    sleep 2;
    notify "$user" "VNC-client-stopped" "Unplug the cable now";
    sleep 5;

#Loop and run
while /bin/true; do
    if [[ $(adb get-state) == "device" && $(adb shell "dumpsys activity | grep top-activity" | grep "$vncappid" | wc -l) -ne 0 && $(ps aux | grep -P 'x11vnc([\S\s\w]+)5901$' | wc -l) -eq 0 ]]; then
    if [[ ( $(adb get-state) != "device" || $(adb shell "dumpsys activity | grep top-activity" | grep "$vncappid" | wc -l) -eq 0 ) && $(ps aux | grep -P 'x11vnc([\S\s\w]+)5901$' | wc -l) -ne 0 ]]; then
    sleep 3;


8.b. Backup crontab and add a root cron job (reboot) for the above script. Reboot to activate script, or just run the command directly on terminal the first time. Replace "username" (whoami).

sudo cp "/etc/crontab" "/etc/crontab.bak"
sudo echo "@reboot username bash $HOME/startvnc.sh >/dev/null 2>/dev/null &" >> /etc/crontab 
  1. Insert the dummy HDMI plug, connect device with PC, unlock screen lock, and use the device like any other HDMI display. However, remember to close the app first before unplugging, to reset defaults (such as screen timeout delay..) on the device.

Thanks for the tutorial guys, i'll share what worked for me on Ubuntu 14.04

Get AndroidVNC here for your tablet

Get x11vnc for your Ubuntu pc by running

sudo apt-get install x11vnc

I had to use the Xorg dummy driver method. Here's what my /etc/X11/xorg.conf file look like :

Section "ServerLayout"
Identifier     "X.org Configured"
Screen      0  "Screen0" 0 0
**Screen        1  "Screen1" rightof "Screen0"**
InputDevice    "Mouse0" "CorePointer"
InputDevice    "Keyboard0" "CoreKeyboard"
**Option         "Xinerama" "1"**

Section "Files"
ModulePath   "/usr/lib/xorg/modules"
FontPath     "/usr/share/fonts/X11/misc"
FontPath     "/usr/share/fonts/X11/cyrillic"
FontPath     "/usr/share/fonts/X11/100dpi/:unscaled"
FontPath     "/usr/share/fonts/X11/75dpi/:unscaled"
FontPath     "/usr/share/fonts/X11/Type1"
FontPath     "/usr/share/fonts/X11/100dpi"
FontPath     "/usr/share/fonts/X11/75dpi"
FontPath     "built-ins"

Section "Module"
Load  "glx"

Section "InputDevice"
Identifier  "Keyboard0"
Driver      "kbd"

Section "InputDevice"
Identifier  "Mouse0"
Driver      "mouse"
Option      "Protocol" "auto"
Option      "Device" "/dev/input/mice"
Option      "ZAxisMapping" "4 5 6 7"

Section "Monitor"
Identifier   "Monitor0"
VendorName   "Monitor Vendor"
ModelName    "Monitor Model"
DisplaySize 1680 1050

**Section "Monitor"
Identifier "Monitor1"
VendorName "Dummy"
ModelName "Dummy"
DisplaySize 2704 1050

Section "Device"
    ### Available Driver options are:-
    ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
    ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
    ### <percent>: "<f>%"
    ### [arg]: arg optional
    #Option     "NoAccel"               # [<bool>]
    #Option     "SWcursor"              # [<bool>]
    #Option     "EnablePageFlip"        # [<bool>]
    #Option     "ColorTiling"           # [<bool>]
    #Option     "ColorTiling2D"         # [<bool>]
    #Option     "RenderAccel"           # [<bool>]
    #Option     "SubPixelOrder"         # [<str>]
    #Option     "AccelMethod"           # <str>
    #Option     "EXAVSync"              # [<bool>]
    #Option     "EXAPixmaps"            # [<bool>]
    #Option     "ZaphodHeads"           # <str>
    #Option     "EnablePageFlip"        # [<bool>]
    #Option     "SwapbuffersWait"       # [<bool>]
Identifier  "Card0"
Driver      "radeon"
BusID       "PCI:1:0:0"

**Section "Device"
  Identifier "Dummy"
  Driver "dummy"

Section "Screen"
Identifier "Screen0"
Device     "Card0"
Monitor    "Monitor0"
SubSection "Display"
    Viewport   0 0
    Depth     1
SubSection "Display"
    Viewport   0 0
    Depth     4
SubSection "Display"
    Viewport   0 0
    Depth     8
SubSection "Display"
    Viewport   0 0
    Depth     15
SubSection "Display"
    Viewport   0 0
    Depth     16
SubSection "Display"
    Viewport   0 0
    Depth     24

**Section "Screen"
Identifier "Screen1"
Device "Dummy"
Monitor "Monitor1

You probably wont need everything in there, just run X -configure to get your system autoconfig and add the dummy sections (stuff between the asterisks) to your file. Resolution for dummy screen in xorg.conf should be your main monitor width + your tablet resolution width, in my case 1680+1024=2704 keep your main monitor height, 1050 in my case.Restart X server/Reboot/Pull power plug, whatever suits you more :).

Run x11vnc by doing

x11vnc -rfbauth ~/.vnc/passwd -clip 1024x550+1680+0

Here the resolution should be your tablet width x tablet height + Main display width + 0

Connect to your Pc using the androidVNC client, make sure to enable localmouse option. That should be it, now feel the weirdness of having linux run over android :)


I had a lot of issues with the other techniques listed here. I wish I had a better solution, but my slow and simple solution is a good starting place.

For the VNC server, I tried the vncserver package but the screen would go black and I'd have to restart gdm to get anything working again. I switched to tightvncserver and it worked the first time with no configuration.

To share the mouse/keyboard between screens I used x2vnc. This could also be used with win2vnc to share the mouse/keyboard with a Windows PC next to your Linux PC.

Final commands:

sudo apt-get install tightvncserver
sudo apt-get install x2vnc
x2vnc -east localhost:1

At this point you should be able to open the second screen in a VNC program by connecting to YOUR_IP_ADDRESS:1. To start a program on the VNC screen, open a terminal, set DISPLAY, and then run the command. For example, to open xterm on the VNC "screen", run:

export DISPLAY=:1

Using this approach the second screen is pretty slow. Still, a lot of the other options I tried ran into dead ends, and this one worked with no configuration at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .