AnX11 Phone Project
docking your phone
AnX11 Phone Project
table of contents
The dock is one of the most useful features of a Debian installation on an Android phone. In addition to running X11 applications with the phone in our hands, we can also run the X11 applications off of the phone, but view them in a full monitor and interact with them with a full keyboard and mouse.
The dock also provides access to the file system. Personally, this is my favorite feature because it allows me to keep important files synchronized between my phone and my desktop computer. Synchronization enables me to do the same work on both devices and it provides a "backup" should I ever need it.
For the purpose, I have also included a phone dock script for d4cm. It uses the same tools (SSH and VNC) that we used before. This page explains those features once again, then it shows how to conveniently run them with the phone-dock script.
It's simplest to connect via WiFi. For example, suppose that your phone is connected to your home wireless network at 192.168.0.100 and your desktop computer is connected to the same network. In such a case, you start the OpenSSH server on your phone:
a$ deb s
then turn to your desktop computer and connect:
c$ ssh -p 22 firstname.lastname@example.org
Connecting via USB is just as simple, but requires you to take the additional step of using ADB to forward the SSH port first. In ADB syntax, we forward "to the local from the remote" so in this case we forward "to the local (desktop) port 5022 from the remote (phone) port 22."
c$ adb forward tcp:5022 tcp:22
c$ ssh -p 5022 email@example.com
If you frequently connect your phone to this computer (for example, it's your home computer), you should use the appendix to set up SSH login without password.
Because we have access to the phone's file system, we can use SSHFS to mount one of it's directories on the desktop computer's file system. For example, I work with my phone's /storage/extSdCard/ inside of my desktop computer's /home/soul/android/ directory. In this setup, I can quickly transfer files back and forth, thus keeping files on the two devices synchronized.
c$ sshfs -p 5022 firstname.lastname@example.org:/home/soul/storage /desktop/path/to/android
After you have logged out of your SSH session, you should remove the forward:
c$ adb forward --remove tcp:5022
A convenient alternative is:
c$ adb forward --remove-all
You can get a list of forwarded ports with:
c$ adb forward --list
We can also forward ports to open a VNC connection to the phone's Debian desktop. Using the vdesk script from the package of /usr/local/bin scripts for d4cm, we start the VNC session by running:
d$ vdesk start
then we can call up the phone's LXDE desktop onto the desktop computer's (larger) screen.
c$ adb forward tcp:5901 tcp:5901
c$ xtightvncviewer 127.0.0.1::5901
"phone dock" script
The phone dock script for d4cm provides a docking script that manages these features.
The script takes two arguments: method of connection ("usb" or "wifi") and action. The action can be a command to run over SSH or one of the actions predefined by the script. For example:
c$ phone-dock usb dock
will "dock" the phone to your desktop. Specifically, the script starts the SSH on the phone's Debian system. Then it forwards ports for VNC and SSH connections over USB. It uses SSHFS to mount the phone's external SD card within the $HOME directory of your desktop computer. Finally, it starts your phone's LXpanel on your desktop's computer screen (a visual dock!).
Two more predefined actions are
c$ phone-dock usb ssh
c$ phone-dock usb vnc
The first logs you into your phone via SSH. The second logs you into your phone via VNC.
When the action is not one of the script's predefined actions, the script assumes that the action is a command to be executed over SSH. For example, the command
c$ phone-dock usb abiword
starts your phone's AbiWord (a word processor) on your desktop computer screen.
When you are ready to remove your phone from the computer, the command:
c$ phone-dock usb undock
will close LXpanel, unmount the external SD card, remove the forwarded ports and stop Debian daemons running on the phone.
Whenever you "dock" or "undock," the script will print a "status" report. You can also run that status report at any time with the command:
c$ phone-dock usb status
Copyright © 2014-2019 Eryk Wdowiak