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?
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
and1024
everywhere in the commands if your tablet is in different resolution. You may also need to changeLVDS1
if the default monitor's name is different).Run in terminal:
$
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 wordModeline
(exclude it) into the next command.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)
xrandr --addmode VIRTUAL1 1280x1024_60.00
xrandr --output VIRTUAL1 --mode 1280x1024_60.00 --left-of LVDS1
Step 2. Enable remote desktop for the virtual monitor
Start VNC:
x11vnc -clip 1280x1024+0+0
Step 3. Connect to the remote desktop
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).
Find your computer's IP using
ifconfig
(when connecting from LAN).Download a VNC app to the tablet and then connect to the computer using computer's IP (and selecting port
5900
) in the app.Notices
-listen <IP_ADDR>
option tox11vnc
(where<IP_ADDR>
is the USB network interface)).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).
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.
tl; dr:
xrandr --fb
andx11vnc --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:
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 runxrandr --fb 2560x1024
.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.
x11vnc -clip 1280x1024+1281+0
plus any other x11vnc options to taste :)This should be it.
vnc4server
andx2x
.Then, set up a
.vnc/xstartup
config file. Mine looks like thisIt launches gnome-fallback desktop (I don't know how to make gnome 3 launch in vnc).
vnc4server -geometry 800x480
command. Of course, instead of 800x480 you have to set your tablet's resolution.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.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 thevnc4server
's output)).x2x
, pressCtrl-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 withkill $!
(be cautious, it kills last process launched in background).vnc4server -kill :1
, where instead of:1
you may set your new display's number.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:
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 becausexdmx
crashed when the pointer moved to the tablet part of the desktop.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 becausexdmx
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 convincevncserver
to change.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 startxdmx
and the two instances ofvncserver
:YMMV
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
andx11vnc
but I included options like which side you would like to attach the screen.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 :
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 tolocalhost:5900
instead ofyour-computer-IP-addres:5900
TL;DR:
Now, just click at the window you want to share.
FULL:
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:Package instalation:
sudo apt-get install x11vnc
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:Now you can start your
x11vnc
session: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.
There is the
/etc/X11/xorg.conf
for dummy driver on second screen:Then login to X session and run:
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:
Once you have all the above packages, issue these commands:
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 *
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:To this:
(Original section - line to change marked with *)
open
/usr/share/x11-server-sources/Xext/xtest.c
, line 311: change this:to this:
(original section - line to change marked with *)
/usr/share/x11-server-sources/include/input.h
, line 73: Add this line after the line starting with#define POINTER_EMULATED
: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:and copy the new one in place of it:
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):This starts a new lightweight X session on your physical display as display
:1
(there are different ways to do this):This command starts the multi-display between your physical screen and the virtual screen and starts icewm for window manager:
Now open a terminal window and start the vnc server (change password as desired):
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.
Automation:
I use this bash script to start the whole process (also kills Xvfb on exit):
Then I have a custom
~/.xinitrc
file with this:Troubleshooting:
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.