[Atrix 4G General] glocklee:
Introduction

Thin client

By "thin client" I mean running a remote desktop on atrix webtop. Atrix itself doesn't have powerful processors(okay okay, I know 2x1.0Ghz cores are good for a phone. Go ahead, compare it with 24core+96GB memory big-ass blade server. Do it. :D ), but with a lapdock it has very good battery life and good connectivity. Also, the overall weight/size of this device is unbeatable, compared to any notebook/ultrabook. These factors together make atrix+lapdock the very best form of a thin client.

If you still don't get it, think about running MS Word/ Visual studio/ Anything X86 on your lapdock.

Citrix

If you have ever used a stock webtop, you might have heard of something called "citrix" -- a commercial cloud-based thin-client solution, which will turn an atrix with lapdock to a mobile workstation. Indeed, citrix is cool, but you have to pay for it... And since it's cloud-based, you cannot access your own computer in this way.

So, why not pull together a free toolset and let it run on your own computer?

Get most goodies out of citrix, and throw it away :D

Wait...Did you say "power-saving"?

Yes I did. To connect to the host computer, it must stay operational. But you definitely don't want it to stay there and draw power for nothing right? My goal is, automatically wake up the host on-demand, and automatically put it back to sleep when atrix is disconnected.

Recommended configuration

I'm not going to write a super-complete guide to build such a system. It's not hard at all, and also it's different for every one of us. So, say "recommended environment" is better than "prerequisites".

To get an ideal experience, you'll probably need:

Gentop. Thanks to Gendol, now we have a very flexible & fast gentoo distribution. My solution is based on his work. It should also run on modified stock webtop, but it would be hard to get the up-to-date packages you need.

A windows-based computer. Ideally it should be Windows 7/8/Server 2008/R2/2012. Because, with these versions, the remote desktop protocol is upgraded to 7.1, much better than previous versions. RDP 7.1 is really cool. Until the Linux community invents something similar to this, I'm not going to recommend linux as the host.

Good network condition. For my case, I live in a university campus. My host computer is connected to 100Mbps LAN with a fixed domain name, and the whole campus is covered by very fast wireless network. Theoretically it can support me to play 720p video / run RemoteFX demo on the phone. (see this RemoteFX+FreeRDP demo )

And you probably don't want:

vnc. dog-slow! don't use this!

rdesktop. This one supports RDP, but only an ancient version. Don't use this, or you'll get laggy display but waste higher bandwidth. not worthy at all.

Deployment

Client side

I'll assume a clean Gentop installation here.

Fire up a terminal, and emerge these packages:

emerge wol freerdp

You may need to do some --autounmask-write.

wol is used for waking the host computer up. And freerdp is the next-generation RDP protocol library. The X11 front-end is called xfreerdp.

After you've got these packages ready, create bin/ in your home directory and add it to your $PATH:

echo "export PATH=$PATH:~/bin/" >> ~/.bashrc
echo "export PATH=$PATH:~/bin/" >> ~/.bash_login
cd ~
mkdir bin
cd bin

Create a file called rdp, and give it execution permission:

touch rdp
chmod +x rdp
leafpad rdp #or any other file editor you like

Paste these stuff in, modify user settings, save and close:

#!/bin/bash

############ User settings #############
host='your_host, or ip'
username='your username'
password='your password'
mac_addr='XX:XX:XX:XX:XX:XX' # you can find it with cmd.exe -> ipconfig /all

############ User settings end #########

echo -n 'Waiting for the host to wake up.'
ping_result=''
while [ -z "$ping_result" ]
do
wol -h $host $mac_addr > /dev/null
echo -n '.'
ping_result=`ping $host -c 1 | head -n 2 | tail -n 1`
done
echo ''
echo 'Host is awaken.'
session_result=`xfreerdp -u $username -p $password -x lan -f --plugin rdpsnd x61 | tail -n 1`
if [ "$session_result" == 'Closed from X' ]
then
echo 'Session successfully closed.'
echo 'Putting host to sleep again...'
echo "sleep 1;echo -e '$username\r';sleep 1;echo -e '$password\r';sleep 1;echo -e 'wizmo standby\r';sleep 1;" > ~/bin/telnet_sleep
chmod +x ~/bin/telnet_sleep
~/bin/telnet_sleep | telnet $host > ~/bin/telnet_sleep.log
else
echo 'Session disconnected unexpectedly.'
echo 'I will not put the host to sleep in this case.'
echo $session_result
fi

That's it, client side ready to go.

Server side

First for some versions you need to enable remote desktop:

Follow this.

Then, for server systems, if you need sound, you need to follow this.

After that, enable telnet server.

Follow this.

Then, download this nice small tool(very useful!) from here, put it into your Windows folder, for example, C:\Windows\

This small tool will enable putting computer to sleep via telnet.

The important last step:

Enable wake-on-lan. This is perhaps the most hard-to-explain part, since it's related to multiple steps, and will vary with different hardwares. But basically, first you need to ensure that in BIOS settings Wake-On-Lan is enabled. Second, make sure that you've installed the correct driver so that your network card works correctly with Windows. Third, some cards need special patches. For example, Lenovo/IBM Thinkpads need this. Last, enable WOL-related power-management settings in windows, follow this. Note: It seems that not all steps are necessary. I only had my network card power management settings tweaked and it worked. Proceed incrementally.

That's all about the server side.

Usage

To connect to the (may be asleep) host, fire up a terminal, and run this:

rdp

It will probe, until the host is awaken.

Note that the session will start in full screen mode. To exit full screen, simultaneously press "ctrl-alt-enter".

Normally, to end the session, exit full screen mode, click on "x" in the title bar.

The script will detect this action and automatically put the host to sleep.

In other cases, for example, killed from terminal, or disconnected due to network problems, it won't put remote computer to sleep.

That's all about it. Hope you'll enjoy this. And drop me message if you encounter any problem with this. :)