Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
agentdr8
Old
(Last edited by agentdr8; 17th March 2011 at 07:30 PM.)
#1  
agentdr8's Avatar
Senior Member - OP
Thanks Meter 136
Posts: 726
Join Date: Mar 2007
Location: Cowtown, CA
Default [Howto] Use your desktop keyboard & mouse on the webtop

While this may not be something that most people may want to do, it's something that I wanted to figure out here at work since I have a tri-monitor setup and wanted to use my existing keyboard & mouse on my Atrix's webtop without having to get the HD dock and use a physical KVM. Another obstacle to overcome was the fact that my linux workstation (main machine) is on a separate, wired network from my Atrix, which is connected via a 3G/4G MiFi device. You'll want to make sure you're rooted in both android OS and the webtop OS. You'll also need lxterminal working in the webtop.

So you'll need to get a couple of Jaunty packages compiled for arm:

Once downloaded, you'll need to get them onto the /osh partition for installation. I do this via adb:
  1. adb push x11vncfiles/ /sdcard/tmp/
  2. adb shell
    1. su
    2. mkdir /osh/tmp
    3. cd /sdcard/tmp
    4. cp *.deb /osh/tmp
  3. sudo -H -u adas bash (switch you to adas user in webtop)
  4. sudo /bin/bash (switches you to root in webtop; you may need to use sulogin)
  5. chroot /osh
  6. cd /tmp
  7. dpkg -i *.deb
  8. exit

Now on to testing...

If you are like me and need to be able to get to the webtop but it isn't on the same network that your desktop/laptop machine is on, you can use the USB cable and adb forward to handle the connectivity. A positive side-effect of this limitation is that x11vnc only needs to listen on the lo (localhost) interface, which helps keep that connection more secure.

LOCAL USB CONNECTION
  1. In lxterminal in the webtop, run the following (as adas) for testing:
    1. export DISPLAY=:0.0
    2. x11vnc -noncache -nolookup -localhost
  2. On your desktop/laptop, run the following:
    1. adb forward tcp:5900 tcp:5900
    2. Using a vnc viewing application (vncviewer, tightvnc, etc), connect to localhost:5900
    3. If all worked out, you should see a remote view of your webtop

REMOTE WIFI CONNECTION

If your Atrix and desktop/laptop are on the same network (or can reach each other via routing), you can do the following steps to test:
  1. In lxterminal in the webtop, run the following (as adas) for testing:
    1. export DISPLAY=:0.0
    2. ifconfig (notate the IP address for eth0)
    3. x11vnc -noncache -nolookup -listen ip_addr_from_prev_step
  2. On your desktop/laptop, run the following:
    1. Using a vnc viewing application (vncviewer, tightvnc, etc), connect to ip_addr_of_atrix:5900
    2. If all worked out, you should see a remote view of your webtop

AUTOMATING THE PROCESS

In order for the x11vnc process to spawn automatically, we need to add it to the lxsession autostart file. This file is read when lxsession starts up and in turn fires off whatever scripts are listed in there. The file is located at:

/etc/xdg/lxsession/LXDE/autostart

By default, the only thing listed in that file is start-oshwt-1.sh, which is a script located at /usr/local/bin. So to get x11vnc working, we add an additional entry into that file:

(as root in webtop): echo start-x11vnc.sh >> /etc/xdg/lxsession/LXDE/autostart

Then we need to create that script in /usr/local/bin:

vi /usr/local/bin/start-x11vnc.sh

Code:
#!/bin/sh

export DISPLAY=:0.0

cd ~
nohup /usr/bin/x11vnc -usepw -forever -nossl -logappend /home/adas/.vnc/x11vnc.log -noncache -nolookup -localhost -nofb -bg
(If you're using it on the same network, replace -localhost with -listen ip_addr like the example above)

Save that file, and make it executable:

chmod +x /usr/local/bin/start-x11vnc.sh

Also, we need to modify Tomoyo to allow it to run that script. Edit /etc/tomoyo/domain_policy.conf and around line 1440:

Code:
<kernel> /osh/usr/bin/lxsession

use_profile 3
Change the 3 to a 2.
Add the following lines to that section:

Code:
allow_execute /osh/usr/bin/x11vnc
allow_execute /osh/usr/local/bin/start-x11vnc.sh
FINAL TOUCHES

I wanted to be able to just move my mouse cursor to the right edge of my desktop machine and have it magiaclly jump to the atrix monitor. To do this, I use a piece of software called x2vnc. If you're using Windows, there's also a package called Win2VNC that will accomplish the same thing. With either software, you run the client (in my case, it's x2vnc) and tell it which direction your vnc server is located at. So to the right of my linux desktop would be east, so I run x2vnc like so:

x2vnc -east localhost:5900

And this connects me to the x11vnc instance running on the atrix. By moving my mouse to the right edge of my main screen, the cursor now appears on the webtop, and I'm able to mouse around and type using my desktop's keyboard.

USING X2X INSTEAD OF X2VNC/WIN2VNC

For anyone that would rather not install any additional packages, and are already running a local X server (XFree/Xorg/Cygwin) you can use x2x to directly connect to the X server running on the Atrix. In order to do this, you'd need to modify /etc/init.d/startXServer.sh and remove the -nolisten tcp from the startx lines and reboot. Then X will listen on port 6000 (for the first display) and that can be used via adb forward on your host machine. The keyboard entry still doesn't work in the Mobile View for some reason...still investigating this. But the mouse seems to function a lot better over native X; selecting text and dragging windows works fine, as does copy & paste.

The top section still applies (you'll need double-root), but the changes are rather minimal:

Code:
adb shell
su
sudo -H -u adas bash
sudo /bin/bash
vi /etc/init.d/startXServer.sh
At the bottom of this script you'll find the lines:

Code:
sudo -u adas -i /usr/bin/startx -- -nolisten tcp -layout HDMI vt2 & 
else                                                                                                       
sudo -u adas -i /usr/bin/startx /usr/local/bin/xnull -- -nolisten tcp -layout HDMI vt2 &
Remove the -nolisten tcp from both of those lines. Save that file.

You'll also need a method of giving your localhost access via xhost. This has to run under the user context that has the primary display (adas). Since I went to this method after the x11vnc method, I already have the /usr/local/bin/start-x11vnc.sh script setup. I modified this to not run x11vnc but to instead disable access controls for X connections:

Code:
cat /usr/local/bin/start-x11vnc.sh
#!/bin/sh                                                                                                export DISPLAY=:0.0                                                                                         
xhost +
With those set, reboot your phone. When ready, relaunch the webtop and either fire up x2x directly or via forwarding over adb like so:

adb forward tcp:6001 tcp:6000
x2x -east -to localhost:1 &

You should now be able to mouse around on your webtop. Typing in terminal, browser, etc works, but Mobile View is still not working. I think I have it narrowed down to that app (aiw) not responding to XKEYBOARD events. I'll know more once I get my usb hub working and can plug in a keyboard.
AT&T HTC One
ARHD'd

Asus Transformer Prime
AndroWook'd

"We want monies. You have monies. Give us monies.” -- Phandroid (poking fun at Gemalto lawsuit)
The Following 2 Users Say Thank You to agentdr8 For This Useful Post: [ Click to Expand ]
 
kriffer
Old
#2  
Junior Member
Thanks Meter 0
Posts: 16
Join Date: Dec 2006
This is awesome. I noticed that everything works great but then when I try to click into my mobile view and use my keyboard it wont work there. So for instance once my vnc is up, i can type in firefox, lxterminal, etc etc. But once I click into the phones mobile view the keyboard just isnt recognized. Its pretty odd.

Again though. This is great. Thanks.
 
agentdr8
Old
(Last edited by agentdr8; 16th March 2011 at 01:26 AM.)
#3  
agentdr8's Avatar
Senior Member - OP
Thanks Meter 136
Posts: 726
Join Date: Mar 2007
Location: Cowtown, CA
EDIT: After poking around some more, I guess I was mistaken. I must've been using my BT keyboard when I was typing in Handcent. The keyboard via vnc isn't being passed to the aiw (Mobile View) window. I'll try and get that resolved.
AT&T HTC One
ARHD'd

Asus Transformer Prime
AndroWook'd

"We want monies. You have monies. Give us monies.” -- Phandroid (poking fun at Gemalto lawsuit)
 
kennethpenn
Old
#4  
kennethpenn's Avatar
Retired Forum Moderator / Recognized Developer
Thanks Meter 3728
Posts: 2,702
Join Date: Nov 2006
Location: Washington, D.C.

 
DONATE TO ME
Awesome work. This is sweet.
 
drunknmunky
Old
#5  
Junior Member
Thanks Meter 0
Posts: 5
Join Date: Jun 2009
Location: Toronto
Default Synergy?

Has anyone tried installing a program called Synergy?

It's a software KVM that lets you "place" another screen beside your current screen and lets you control it by moving your mouse beyond the edge of your screen. For example, you have a desktop monitor in front of you and a laptop to the left. Running the server program on the desktop (where the mouse and keyboard are plugged in) and the client program on the laptop, after a quick setup, you can move your desktop mouse+keyboard to control the laptop. You can't drag windows or files across but copy+paste does work for text between computers, which is very useful.

It's open source and runs on Linux so I don't see any reason the client software couldn't be installed on the webtop (may have to be compiled from source).

I can't post links in the forum yet but the software is at www dot synergy-foss dot org.

I don't have an Atrix (yet) so I can't test it but if VNC works then I don't see any reason that this shouldn't work.

The default port on Synergy is 24800, so substituting that in the tutorial should allow the same thing to be achieved.

If this works it would be one more reason to get the phone when it comes out in Canada (2 days)!
 
agentdr8
Old
#6  
agentdr8's Avatar
Senior Member - OP
Thanks Meter 136
Posts: 726
Join Date: Mar 2007
Location: Cowtown, CA
Yep, I tried synergy first, but unfortunately, it wouldn't work in my situation since the synergyc (client) runs on the phone and tries to connect to the syngerys (server) on my PC. I can't redirect ports in that direction over USB, so x11vnc it was.

For those on the same network, there's no reason it wouldn't work just fine. I actually use synergy on the other side of my tri-monitor setup to control our 50" plasma when doing demos and whatnot.
AT&T HTC One
ARHD'd

Asus Transformer Prime
AndroWook'd

"We want monies. You have monies. Give us monies.” -- Phandroid (poking fun at Gemalto lawsuit)
 
moktarino
Old
#7  
Member
Thanks Meter 1
Posts: 34
Join Date: Jun 2009
Default D'oh

I was hoping this was a "got usb host working" thread

Oh well...

/me begins learning about his phone to get that project started.
 
GhostXtreme
Old
#8  
Member
Thanks Meter 1
Posts: 39
Join Date: Feb 2011
Does the hdmi cable need to be connected to phone after we setup vnc server to run automatically ? What happens after reboot without cable plugged in ..
 
agentdr8
Old
(Last edited by agentdr8; 16th March 2011 at 03:55 AM.)
#9  
agentdr8's Avatar
Senior Member - OP
Thanks Meter 136
Posts: 726
Join Date: Mar 2007
Location: Cowtown, CA
The x11vnc server will autostart whenever the webtop is started for the first time. After that, I believe that entire X instance runs in the background. It's just idle, waiting for the next time you connect the hdmi cable/dock.

x2vnc auto reconnects by default, but for those that are forwarding tcp ports via adb, you'll have to recreate the port forward prior to it reconnecting.
AT&T HTC One
ARHD'd

Asus Transformer Prime
AndroWook'd

"We want monies. You have monies. Give us monies.” -- Phandroid (poking fun at Gemalto lawsuit)
 
GhostXtreme
Old
#10  
Member
Thanks Meter 1
Posts: 39
Join Date: Feb 2011
Quote:
Originally Posted by agentdr8 View Post
The x11vnc server will autostart whenever the webtop is started for the first time. After that, I believe that entire X instance runs in the background. It's just idle, waiting for the next time you connect the hdmi cable/dock.
Was your hdmi cable always plugged in your testing ?

 
Post Reply+
Tags
vncserver, webtop, x11vnc, x2vnc
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Xposed Framework Module for the AT&T Galaxy S 4

Got yourself a brand new Galaxy S 4? Are you looking for some fun mods to make it truly your … more

Job Interview Prep: Phone Screen Part 1 – XDA Developer TV

XDA Developer TV Producer Jayce has been very busy creating videos to help … more

Auto Test Your Android Apps with Robotium

You’ve just finished coding your very first app, but before you release it to the wild, you … more

Open Source CPU Info App for Windows

So you’re playing with your shiny new Windows 8 tablet PC, when one of your like-minded geeky … more