Today I Learned: Using an Android device as a second display using Ubuntu

in #hobo8 years ago (edited)

M

y laptop screen is broken, as you would know from my previous post about this, and I have been meaning to work out some way to use my phone to extend it or so. Well, it's pretty simple... Note that this method also the android device can send input control back to the machine it is connected to, depending on the VNC client, I can do double touch to scroll, I can select by touch, and I can zoom in and out from the display with two fingers as people would be familiar with.

First, you need to install vnc4server and x2x:

sudo apt install vnc4server x2x

Then as for the example of mine, where the right hand side is broken, I can plug in my android phone, turn on USB tethering to the laptop, and it can sit on the right hand side of my screen where I can see it and nothing on the laptop screen is really useful on that part anyway.

Next, create a file in ~/.vnc/xstartup like so:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] xrdb $HOME/.Xresources
xsetroot -solid grey

Now we can start up the x server thusly:

vnc4server -geometry 960x540

This is the resolution of my Sony Xperia M2 Aqua. This runs and disappears into the background. Next, we link the two displays together using x2x:

x2x -east -to :1

where :1 is the x display ID. Then you need to have a VNC client on the mobile device, there is several, and vnc4server uses the port 590x where the x is the number of the X display ID. The command above makes the mouse jump between the two screens when you roll the mouse over the right hand edge of the laptop display, and then you are inside the VNC display that you can see on your android device.

Well, I am still working on this. I run gnome which does not play nice with non-accelerated video, so I can't start a gnome-session or link it easily, so I just start my web browser, for example, like this:

DISPLAY=:1 chromium-browser

I am going to work on getting it set up so it automatically binds the VNC to the inbuilt display and launches the gnome session... well, that presents a fairly big puzzle because gnome-session bombs when you try to run it on a virtual VNC x server, because there is no acceleration.

So, it's just something for now that lets me use my laptop keyboard and laptop's CPU to run my browser on a secondary display. For now this is enough though it doesn't make anything else very easy. I really need to have a window manager running on the phone display as well, so I can have multiple windows for doing development, to switch between and the like. But this for now gives me a more readable display - the laptop does not have as many working pixels as this display has.

image

By installing metacity, I can have multiple windows and when the mouse is on the vnc display I can switch using alt-tab. To run metacity, or your window manager of choice (mutter, the default gnome 3 window manager refuses to run without gpu acceleration, still yawn) just prefix a command in a shell with:

DISPLAY=:1 &

...and it will appear on the Android device.

Yes, in theory this could be done with any two computers even, so long as there is a vnc client available.

More notes

It probably is better for a small display like the one I am using, to use a virtual touchpad mode for the mouse control. The direct touch interface is a bit clunky, and with touchpad mode two fingers lets you scroll up and down - my laptop's touchpad for some reason isn't letting me use its internal scrolling, so I am sorta getting the benefit of using my laptop with a touchscreen :)

Also, depending on your VNC client, you can use the inbuilt keyboard on the android device as well.


We can't stop here! This is Whale country!

Loki was born in Australia, now is wandering Amsterdam again after 9 months in Sofia, Bulgaria. IT generalist, physics theorist, futurist and cyber-agorist. Loki's life mission is to establish a secure, distributed layer atop the internet, and enable space migration, preferably while living in a beautiful mountain house somewhere with a good woman, and lots of farm animals and gardens, where he can also go hunting and camping.

I'm a thoughtocaster, a conundrummer in a band called Life Puzzler. I've flipped more lids than a monkey in a soup kitchen, of the mind. - Xavier, Renegade Angel

*

All images in the above post are either original from me, or taken from Google Image Search, filtered for the right of reuse and modification, and either hotlinked directly, or altered by me

Sort:  

@l0k1 Followed and upvoted!
I'm new to Steemit visit my post, upvoted and follow me @Sandra16

This post has been ranked within the top 50 most undervalued posts in the second half of Nov 18. We estimate that this post is undervalued by $9.85 as compared to a scenario in which every voter had an equal say.

See the full rankings and details in The Daily Tribune: Nov 18 - Part II. You can also read about some of our methodology, data analysis and technical details in our initial post.

If you are the author and would prefer not to receive these comments, simply reply "Stop" to this comment.

Have you tried other servers like the tightvncserver used here, https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-14-04, any pros/cons?

They are much the same on usb or wifi - no acceleration :(

Coin Marketplace

STEEM 0.13
TRX 0.12
JST 0.024
BTC 51367.14
ETH 2266.57
USDT 1.00
SBD 2.01