Using Android/PC as a Second Monitor in Linux

Using second monitor is a cool thing that eliminates the burden of changing windows. Windows 10 have already this feature builtin and it is wireless. There are also bunch of apps available to do these things. But with Linux it seems little hard if you don’t know how to do. So here is the few commands that makes it possible to use any Android devices or Windows or Linux PC as a wireless secondary monitor. However Android can be also connected using a data cable.

And the result will look like above. Image Source

Before starting make sure you have VNC server (x11vnc) installed. To check you can try simply running x11vnc.

x11vnc

You can install tightvnc if VNC server is not already installed.

First of all you need to find the resolution of the device you want to use as secondary display. For example let’s use an Android device of 1280×720 resolution and the PC has 1366×768 resolution.

Then we need to know available displays and outputs ports.

xrandr

The output was;

Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
eDP-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1366x768      60.00*+  48.01
   1280x720      60.00    59.99    59.86    59.74
   1024x768      60.04    60.00
   960x720       60.00
   928x696       60.05
   896x672       60.01
   1024x576      59.95    59.96    59.90    59.82
   960x600       59.93    60.00
   960x540       59.96    59.99    59.63    59.82
   800x600       60.00    60.32    56.25
   840x525       60.01    59.88
   864x486       59.92    59.57
   700x525       59.98
   800x450       59.95    59.82
   640x512       60.02
   700x450       59.96    59.88
   640x480       60.00    59.94
   720x405       59.51    58.99
   684x384       59.88    59.85
   640x400       59.88    59.98
   640x360       59.86    59.83    59.84    59.32
   512x384       60.00
   512x288       60.00    59.92
   480x270       59.63    59.82
   400x300       60.32    56.34
   432x243       59.92    59.57
   320x240       60.05
   360x202       59.51    59.13
   320x180       59.84    59.32
HDMI-1 disconnected (normal left inverted right x axis y axis)

Here my current display is eDP-1 and unused output port is HDMI-1.

First of all we need to create a new mode for the secondary monitor. For this we need some extra information which can be found using;

gtf 1280 720 60

Which gives VESA GTF mode lines for 1280×720 @ 60 fps. This results;

# 1280x720 @ 60.00 Hz (GTF) hsync: 44.76 kHz; pclk: 74.48 MHz
  Modeline "1280x720_60.00"  74.48  1280 1336 1472 1664  720 721 724 746  -HSync +Vsync

Now let’s add a new mode for our Android device.

xrandr --newmode "1280x720_60.00"  74.48  1280 1336 1472 1664  720 721 724 746  -HSync +Vsync

Now let’s add this new mode to the unused display. HDMI-1 for this case.

xrandr --addmode HDMI-1 1280x720_60.00

Now let’s enable HDMI-1 and move it to the right of the default display (eDP-1). After this mouse cursor can be moved to right side more than your default display allows. It is because we are adding 1280×720 to the right side of eDP-1.

xrandr --output HDMI-1 --mode 1280x720_60.00 --right-of eDP-1

The final step is to start VNC server and only allow to show the right portion of the screen which can’t be seen in default display.

x11vnc -clip 1280x720+1366+0

It clips the 1366 pixels (width) of your total screen (1366+1280) and shows the only remaining (which we can not see now) screen of the right side.

Now you need to connect your Android or PC using VNC viewer. To do so you need an IP and port. To find IP run;

ip a

In my case it is 192.168.1.67. The default port in VNC is 5900 unless you changed it.

For Android you can use MultiVNC or for Windows you can use RealVNC. RealVNC is also available for Mac, Linux or other distro.

To exit xrandr,

xrandr --output HDMI-1 --off 

You can get more information from here – https://bbs.archlinux.org/viewtopic.php?id=191555

20 thoughts on “Using Android/PC as a Second Monitor in Linux”

  1. HI Aran, did you get it to work? Mine works perfectly up to the same point… then is shows a blank screen on my Samsung Tablet

  2. I have done it and it works, but my (KDE plasma) display does not show anything but a blank screen (Normall VNC connectins with the same software works)

    1. I don’t know the original source since I din’t copy pasted from this wiki. But one of my friend showed me this and I googled a little bit and made this article. But anyway if that is the original source there is no harm of crediting for their effort. Thank you for your suggestion.

  3. xrandr –output HDMI-1 –mode 1280x720_60.00 –right-of eDP-1
    at this point i am getting an error saying
    xrandr: Configure crtc 1 failed
    and when i started x11vnc server ignoring the above error , i am just able to mirror my primary screen
    is it possible to extend ?

  4. When I arrived to
    “xrandr –output Virtual2 –mode 2560x1600_60.00 –right-of Virtual1”
    I got:
    “X Error of failed request: BadMatch (invalid parameter attributes)
    Major opcode of failed request: 141 (RANDR)
    Minor opcode of failed request: 7 (RRSetScreenSize)
    Serial number of failed request: 56
    Current serial number in output stream: 57”
    Thanks!

  5. Hi. At the end, for connecting the linux PC and the Android tablet using VNC, do we need them to be in a local network necessarily? Is it possible to connect them via USB?

  6. How to revert back to original setting?? There is a lot of empty space in Right side which is extended. My cursor goes away when moved in right side.

  7. everything worked up to : xrandr –addmode DP-3 1920x1200_60.00
    i got :
    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: 43
    Current serial number in output stream: 44

      1. Screen 0: minimum 8 x 8, current 2560 x 1440, maximum 32767 x 32767
        DP-0 disconnected (normal left inverted right x axis y axis)
        DP-1 disconnected (normal left inverted right x axis y axis)
        HDMI-0 disconnected (normal left inverted right x axis y axis)
        DP-2 connected primary 2560×1440+0+0 (normal left inverted right x axis y axis) 697mm x 392mm
        2560×1440 99.95*+ 59.95
        1920×1080 60.00 59.94 50.00
        1680×1050 59.95
        1600×900 60.00
        1440×900 59.89
        1280×1024 75.02 60.02
        1280×800 59.81
        1280×720 60.00 59.94 50.00
        1152×864 75.00
        1024×768 75.03 70.07 60.00
        800×600 75.00 72.19 60.32 56.25
        720×576 50.00
        720×480 59.94
        640×480 75.00 72.81 59.94
        DP-3 disconnected (normal left inverted right x axis y axis)
        DP-4 disconnected (normal left inverted right x axis y axis)
        DP-5 disconnected (normal left inverted right x axis y axis)
        USB-C-0 disconnected (normal left inverted right x axis y axis)
        —————————————————————————
        gtf 1920 1200 60
        # 1920×1200 @ 60.00 Hz (GTF) hsync: 74.52 kHz; pclk: 193.16 MHz
        Modeline “1920x1200_60.00” 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync
        ————————————————————————————
        xrandr –newmode “1920x1200_60.00” 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync
        ————————————————————————————
        xrandr –addmode DP-3 “1920x1200_60.00”
        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: 43
        Current serial number in output stream: 44

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top