Android phone to graphical workstation

If you're anything like me, you have a lot of older tech laying around that you would like to reuse.
Reusing most of these older devices is usually relatively straightforward, however, it's a lot more tricky with phones, so let me attempt to guide you through the process of turning your phone into a graphical workstation.

Sources

Below are URLs to the sources I referenced during the making of this blogpost.
Most of my information comes either directly from those URLs, or through personal experimentation and exploration, reading documentation, etc.

Prerequisites

Below is a list of prerequisites to follow along with this blogpost. Note that not everything is strictly necessary.

The phone in question

I happen to have an old OPPO Reno 10x Zoom that I left in a drawer and forgot about. This was a higher end smartphone from circa 2019, with a Qualcomm Snapdragon 855 SoC, 8GB of RAM, and 256GB of UFS 2.1 storage.

As someone who regularly uses a beat up Raspberry Pi 4 model B, this phone seems like a powerhouse!But there's two major problems for me:

It doesn't provide a familiar environment like FreeBSD or NetBSD.
It feels restrictive.

However, one application can help us claw back some freedom, with a more familiar environment to boot

Setup

This part of the blogpost will go over the software and hardware setup.

Developer Settings

From your Developer Settings menu you are required to make the following changes:

After making these changes, reboot your device to ensure the settings are cleanly applied.

X11

Open Termux:X11 and minimize it.
From within Termux, install the packages tmux, x11-repo, termux-x11, and your X11 environment of choice (here I use i3 as an example.
With that done, all that is left for us is to run a specific command: tmux new-session -s "x11" -d "termux-x11 :0 -xstartup "i3"" where i3 is your X11 environment of choice, and to open Termux:X11 again.

Wayland

Mostly ditto to the X11 section.
We add one more package: dbus, and the runner command is slightly altered: tmux new-session -s "wayland" -d "termux-x11 :0 -xstartup "dbus-run-session sway"" where sway is your Wayland environment of choice. Don't forget to add this to your shell rc, and then reload your shell:
XDG_RUNTIME_DIR="/data/data/com.termux/usr/tmp/runtime/$(id -u)"
[ -d "$XDG_RUNTIME_DIR" ] || mkdir -p "$XDG_RUNTIME_DIR"
[ -d "$XDG_RUNTIME_DIR" ] && export XDG_RUNTIME_DIR

[OPTIONAL] Use scrcpy

scrcpy is a wonderful program that allows you to mirror your Android screen on to a computer through ADB.
Simply download the larest version, install it, plug in your phone, trust ADB from your computer, and run it with the following command: scrcpy --new-display=WIDTHxHEIGHT/DPI where WIDTH is your display's width, HEIGHT is your display's height, and DPI is the DPI. I used scrcpy --new-display=1920x1080/408 for my Fairphone 5 and OPPO Reno 10x Zoom.

[OPTIONAL] Use an external display

Using an external display is simple, just plug everything in to your USB hub and plug the HDMI cable from the hub in to your display of choice.
NOTE: Not all phones support Display output over USB-C.

Potential Issues

One issue I had with my OPPO when using scrcpy, was that anything that tried to make use of audio would crash scrcpy, so I therefore had to add the --no-audio flag to the command.
I'm sure I could've fixed it in a way that would allow me to use audio, but I couldn't be bothered to go down that rabbit hole.

Table of links

I won't beat around the bush here... I was too lazy to figure out how to make a nice navbar. :)