How to Use Your Android Tablet as a Second Monitor

Using an Android tablet as a second monitor

I spend a lot of time working remotely, and while I have a decently sized laptop, I often miss having a second monitor. I looked at USB monitors, but then I remembered my old 2014 Galaxy Tab. Could I use it as a second monitor? The answer is: yes!

This setup works via virtual output devices and VNC. It essentially creates a remote desktop session on your laptop, which you can view and even interact with from your tablet. It’ll technically work with any network-ready computing device for that matter, whether it’s a tablet, a phone, a Raspberry Pi, or even another laptop.

These instructions are for Linux. Any Linux distribution should work, but you must be using X.org, not Wayland. You’ll also need to install the Android Debug Bridge (adb) and x11vnc.

You can download the full script from GitHub. This post explains how the script works and provides setup instructions.

Step 1: Create a Virtual Output Device

First, we need to create a virtual output device by configuring Xorg. Create a file named /usr/share/X11/xorg.conf.d/20-virtual.conf and add the following contents:
Section "Device"
 Identifier "intelgpu0"
Driver "intel"
Option "VirtualHeads" "1"
EndSection

The Identifier and Driver options will be different if your GPU is AMD or Nvidia. You can add more virtual outputs by changing the VirtualHeads option, but for now let’s keep it at one. Save the file, then log out and log back in to apply the changes. To confirm, run the xrandr command. You should see a line starting with VIRTUAL1 disconnected.

Step 2: Configuring and Enabling the Virtual Display

Now, we need to configure the virtual display by setting its resolution and placement relative to the primary display (i.e. the laptop screen).

Open the create-android-display.sh file in a text editor and change the following lines to match your specific setup:

  • W=1920 and H=1080 set the width and height of the virtual display. Set this to your tablet screen’s resolution.
  • VIRTUAL1 should match the name of the virtual display as reported by xrandr.
  • eDP1 should match the name of your primary display. You can use xrandr to confirm this as well.

The line starting with PW uses xrandr to get the width of the primary display. We’ll use this later on when creating the VNC session.

The lines starting with gtf configure the display and set its position relative to the primary display. In the third line, you can change where the display is located by changing --right-of to --left-of, --above, or --below. These instructions assume you’re using --right-of, so if you decide to change the placement, note that you’ll need to change the crop options when running x11vnc.

Step 3: Create a VNC Session

For VNC, we’ll use x11vnc because it can expose an existing Xorg session without requiring root permissions. We’ll use the -clip option to restrict the visible area to the virtual monitor. We’ll also use -localhost to prevent x11vnc from exposing the session over the network for better security.

x11vnc -localhost -clip ${W}x${H}+${PW}+0

Some 3D applications and compositing window managers don’t work well over VNC, so if your screen isn’t updating, try adding -noxdamage to the command.

Step 4: Create an ADB Session

VNC software uses port 5900 by default. However, since we ran x11vnc with -localhost, only software running on the laptop itself can access the VNC session. Fortunately, we can use adb to forward port 5900 on our laptop to port 5900 on our tablet. With port forwarding enabled, our tablet can access x11vnc as if it was coming from localhost.

We’ll forward the port with the command:

adb reverse tcp:5900 tcp:5900

Step 5: Connect From Your Tablet

The final step is to use a VNC viewer app on your tablet to open the x11vnc session. I use bVNC, but any viewer app will work.

From the app, enter localhost as the target and click connect. In a moment, you should see your virtual monitor appear on screen. Move your cursor around, drag windows, and watch them appear on your tablet! Once you disconnect, the script automatically turns off the virtual display on your laptop so you don’t have “invisible windows” floating off-screen.

Using an Android tablet as a second monitor
Kate and Konsole on an Android tablet via VNC.

Final Thoughts

VNC isn’t a perfect protocol, and it can be slow even over USB. It’s alright for web browsing and Slack/Discord, but I wouldn’t use it to watch movies. You can use VNC over the network, but this comes with some severe security implications. Make sure you enable encryption and password protection before exposing your desktop to any network.

One problem I couldn’t completely resolve was black bars appearing on my tablet when the tablet resolution was different from the laptop resolution. The bars completely covered the desktop and any windows I had on the screen. My only solution was to use the same resolution for both the laptop and the tablet, but this was workable for me.

Have any issues, thoughts, or suggestions? Leave a comment!

Leave a Reply