Ever found yourself on the run, needing a multiple-monitor setup but only have your *nix machine and an Android device handy? Following is a few commands to run applications on the Android device.
Additionally, this method uses the Android development tool adb
with the option to use a USB cable instead of WiFi for a little extra speed.
Requirements
The steps are as follows:
- Install an X server on your Android device. I’m using XSDL.
- Run and customise the server e.g. choose the desired resolution etc.
- Install
adb
on your *nix machine, like:
Arch-based distros
yay -S android-platform-tools
Debian-based distros
sudo apt-get install android-tools-adb
Fedora/SUSE-based distros
sudo yum install android-tools
Macos/OSX-based
brew cask install android-platform-tools
- Connect your Android device to your machine via USB.
- Enable USB debugging on the device under “Developer Settings” within the Android “Settings”. If you don’t have the “Developer Settings” menu item you need to enable¹ it.
- Then, in on your favourite CLI forward from your local TCP port
6100
to the remote6000
.
adb forward tcp:6100 tcp:6000
- Next, set up the environment variable to point to the new monitor like so:
export DISPLAY=:100
- Install
x2x
via your package manager if it is present, or from Github.
Arch-based distros
yay -S x2x
- Run
x2x
in the background with the following:
x2x -east -to :100 -from :0 &
- Install the
xfwm4
package thusly:
Arch-based distros
yay -S xfwm4
Debian-based distros
sudo apt-get install xfwm4
Fedora/SUSE-based distros
sudo yum install xfwm4 # presumably?
- And lastly run
xfwm4
and the application you need in a separate terminal editor or via a launcher, script etc. DO REMEMBER though to set theDISPLAY
variable before running said applications.
With xfwm4
DISPLAY=:100 && xfwm4 & terminator
Without xfwm4, such as would be the case on Mac
DISPLAY=:100 && terminator
Notes
- If you end up using this a lot or find the steps tedious, run the following script:
#!/usr/bin/env bash
export DISPLAY=:100
adb forward tcp:6100 tcp:6000
x2x -east -to :100 -from :0
- and use
dmenu
or similar launcher to to prefix the environment variable to and executable.
May the force be with you.
Footnotes
- Tap on the “Build number” label seven times (or until you’re notified that “Developer Settings” has been enabled)