Tutorial: build and run Tetheron without a phone
In this tutorial we take a fresh clone of Tetheron and end with three things working on one Linux computer:
- the desktop workspace built and its tests passing,
- the GTK app running against its built-in fake daemon,
- the real daemon paired with a fake phone, driven from the command line.
We need neither an Android phone nor the Android toolchain. Allow about half an hour, most of it for the first compilation. The tutorial is written for Ubuntu 24.04 and Linux Mint 22.
Important
You can follow this tutorial on a computer where Tetheron is already installed and paired with your phone. Every command below uses its own bus name, its own ports and its own directory,
~/tether-tutorial, so the installed daemon, its settings and its data are never touched. That only holds if you type the commands as they are written, including the environment variables in front of them.
1. Install the build tools
Install the libraries that the desktop side builds against:
sudo apt update
sudo apt install git curl \
libgtk-4-dev libadwaita-1-dev libdbus-1-dev pkg-config build-essential \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-libav gstreamer1.0-gl
The build needs Rust 1.85 or newer, which the distribution’s archive does not have. Install the current stable Rust with rustup and accept the default choices:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Open a new terminal so that cargo is on the PATH, then check the version:
rustc --version
We see a version number of 1.85 or higher.
2. Get the source
git clone https://github.com/tetheron/tetheron.git
cd tetheron/desktop
All commands in the rest of the tutorial run in this desktop directory.
3. Build the workspace
cargo build --workspace
The first build compiles every dependency and takes several minutes. It ends with a line like this:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 4m 12s
We now have three programs in target/debug/: the daemon tetherd, the GTK
app tether and the command-line tool tether-cli.
4. Run the tests
cargo test --workspace
Cargo prints one block per crate and per integration test. Every block ends
with a line that starts with test result: ok., and none reports a failure:
test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
The numbers differ from crate to crate.
5. Make a directory for the tutorial
The GTK app and the daemon store settings and data in your home directory. We give them a directory of their own:
mkdir -p ~/tether-tutorial/config/tether ~/tether-tutorial/data ~/tether-tutorial/cache
6. Run the app against its fake daemon
The GTK app can be built with a fake daemon inside it, which invents two devices and a stream of events:
XDG_CONFIG_HOME=$HOME/tether-tutorial/config \
XDG_DATA_HOME=$HOME/tether-tutorial/data \
cargo run -p tether-gtk --features mock -- --mock
Cargo compiles the app once more with the mock feature and opens its window.
In it we see:
- two devices, Galaxy S24 and Pixel Tablet,
- a battery level that drains and notifications that arrive on their own,
- after about 8 seconds a request to pair,
- after about 12 seconds an incoming call.
Nothing here is real. Click through the tabs, answer the call, send a message.
Note
About 45 seconds after the start the fake phone sends a clipboard text, and the app puts it on your desktop clipboard, as it would for a real phone. If you have something on the clipboard that you still need, paste it first.
Closing the window may leave the app running in the system tray. Press
Ctrl+C in the terminal to stop it.
The mock app has its own application id, org.tether.Tether.Mock, so it opens
a window even when the installed app is running.
7. Start the real daemon under a private name
A daemon normally takes the bus name org.tether.Daemon, listens on port 7360
and reads ~/.config/tether. An installed daemon already does all of that, so
ours gets a different bus name, different ports and the tutorial directory.
First we write a configuration file for it:
cat > ~/tether-tutorial/config/tether/config.toml <<'EOF'
discoverable = false
show_desktop_notifications = false
message_notifications = false
clipboard_sync = "off"
adb_path = "/nonexistent/adb"
EOF
With these five lines the daemon does not announce itself on the network, does not show the fake phone’s notifications on the desktop, does not send the desktop clipboard to the fake phone, and does not use adb. Every setting is described in Configuration and files.
Then we start the daemon:
TETHER_BUS_NAME=org.tether.Debug \
TETHER_PORT=7362 \
TETHER_PEER_PORT=7363 \
XDG_CONFIG_HOME=$HOME/tether-tutorial/config \
XDG_DATA_HOME=$HOME/tether-tutorial/data \
XDG_CACHE_HOME=$HOME/tether-tutorial/cache \
cargo run -p tetherd
The daemon logs to the terminal. The first start pauses for a few seconds while GStreamer indexes its plug-ins into the new cache directory. Among the lines we see these (timestamps left out, and the id and the name are those of your computer):
INFO tetherd: tetherd 0.4.1 starting as "my-computer" (config /home/me/tether-tutorial/config/tether/config.toml)
INFO tether_core::core: tether core: id 8baf3454… name "my-computer" listening on TCP port 7362
WARN tetherd::features::enhance: enhanced tier unavailable: adb_path "/nonexistent/adb" is not an executable
INFO tetherd: D-Bus: owning org.tether.Debug
The adb warning comes from the last line of our configuration file. The line
D-Bus: owning org.tether.Debug tells us that the daemon is ready. Leave it
running in this terminal.
8. Connect the fake phone
tether-core contains an example program that behaves like a phone. Open a
second terminal, change to the desktop directory, and start it:
cargo run -p tether-core --example fake_phone -- \
--port 7363 --dial 127.0.0.1:7362 \
--data $HOME/tether-tutorial/fake-phone --no-beacon --no-mdns
The fake phone listens on port 7363 and dials our daemon on port 7362.
--no-beacon and --no-mdns stop it from announcing itself on the network,
where an installed daemon would pick it up. It prints:
fake phone Fake Phone id 5e9907fd… on port 7363 caps []
device added 8baf3454
INFO tether_core::core: session 1 up: my-computer (8baf3454) Outbound 127.0.0.1:7362 paired=false
device 8baf3454 "my-computer" paired=false connected=true reachable=false held=false state=none
The two programs are connected but do not trust each other yet: paired=false.
9. Pair the two from the command line
Open a third terminal and change to the desktop directory. tether-cli
talks to the daemon over D-Bus. We point it at our daemon for this terminal:
export TETHER_BUS_NAME=org.tether.Debug
Important
Without
TETHER_BUS_NAME,tether-clitalks to the installed daemon. Use this terminal for everytether-clicommand in this tutorial.
List the devices that our daemon knows:
cargo run -p tether-cli -- devices
ID NAME KIND PAIRED CONNECTED BATTERY STATE
5e9907fd40bc Fake Phone phone no yes - none
The id is different on your computer. A real phone on your network that runs the Android app may be listed too, as not paired. Our daemon only lists it and never connects to it.
Ask for pairing with the fake phone:
cargo run -p tether-cli -- pair <id>
Replace <id> with the start of the id from the list, for example 5e99.
The command prints a six-digit pairing code and asks whether the codes match:
pairing requested with Fake Phone; waiting for the phone…
Pairing code: 505 310
Make sure the same code is shown on Fake Phone.
Do the codes match? [y/N] (Enter = N, reject)
In the second terminal the fake phone shows the same code and has already confirmed its side:
SAS for 8baf3454: 505310
auto-confirming
The codes are the same, so we type y and press Enter. The command ends
with:
confirmed; waiting for the phone…
paired with Fake Phone
The desktop and a real phone pair with the same exchange. The security model explains what the code protects against.
10. Look at what the phone sent
Once the two are paired, the daemon asks the phone for its data. In the second terminal the fake phone lists the requests it answers:
-> my-computer: battery 93% + notification #1
<- 8baf3454 ConversationsRequest since 0 -> 3 threads
<- 8baf3454 ContactsRequest (0 known) -> 2 upserts
In the third terminal we ask the daemon for some of it:
cargo run -p tether-cli -- devices
cargo run -p tether-cli -- notifications <id>
cargo run -p tether-cli -- conversations <id>
devices now shows yes under PAIRED and a battery level. notifications
lists a notification from the app “Fake Chat”. conversations lists three
message threads.
While the fake phone is connected, your desktop’s media controls may show a player for it, because the fake phone reports a playing media session.
11. Stop and clean up
-
In the second terminal, press
Ctrl+Cto stop the fake phone. -
In the first terminal, press
Ctrl+Cto stop the daemon. It logsSIGINT receivedandshutting down. -
Close the third terminal, or run
unset TETHER_BUS_NAMEin it. -
Remove the tutorial’s data, which includes the fake phone’s identity:
rm -r ~/tether-tutorial
The mock and the fake phone are the everyday tools for work on the desktop side. Test your changes lists their other switches, and Build, run and install from source shows how to run a debug build with a real phone.