Create an Apple like ecosystem with Linux and Android
We’ve all heard and seen how great and useful the Apple ecosystem can be. But for those who don't have an iPhone and a macOS device, a Linux-Android ecosystem might be a viable option.
In this article, we’ll take a look at a set of tools that lets you,
- Share files seamlessly and wirelessly between your devices
- Sync notification between devices (Including replying to messages from your pc)
- Pause play media on your pc with phone
- Use one keyboard and Mouse between devices (Yes, even on your mobile phone)
- Share clipboard
and many more…
All of these can be achieved by installing a few software and tweaking some very simple settings on your Linux machine.
The first software we will install which by itself provide most of the features we talked about is called “KDE connect”.
1.KDE connect
KDE Connect is a multi-platform application developed by KDE, which facilitates wireless communications and data transfer between devices over local networks.
Although the name might imply, you do not need to have the KDE Desktop Environment to run KDE connect.
To install on Linux, go to your application center on your Linux desktop and search for “KDE connect” and install it there. Or if you want to use your terminal look for a package called kdeconnect-kde
, kdeconnect-plasma
, just kdeconnect
or kde-connect
in your distribution repo. For example, on Debian it's justsudo apt install kdeconnect
.
KDE connect also requires you to have the KDE connect app installed on your phone. To do so, go to Google Play Store and search for kde connect and install it there. You can also use the F-droid app as well (to get updates automatically). Or you can find the apk file here.
After installing on both devices, open the kde app in your phone and look in available devices, you will find your pc there. Click on it and click on “request pairing”. A notification will pop up on your Linux desktop and ask you for permission to connect, click allow.
If the notification didn't show up, look for kde connect on your application menu on Linux and try running “request pairing” from your android device again.
Setting up kde connect to achieve these features.
Some of these feasters are disabled by default on kde connect, to enable them you need to enable them on both pc and android side. On Linux, open kde connect app and clicking plugin setting and enabling those features there. On android, click on the three dots and click plugin settings.
The app will also need some permission to perform some tasks. Upon opening the android app, you will be seen the following screen. You can click on each of these and follow the instructions, the app provides.
To set up your primary mobile storage as a storage location:
On your Linux,
Click on the mobile phone icon on your Linux desktop panel, then the hamburger menu and click browse this file. And just like that, you have access to your entire mobile file system wirelessly.
With this you can now share clipboard, control the media player on your pc with your phone, sync notification, pause media on call and many more…
2. Sharing a single keyboard and mouse (Universal Control)
The next part of this tutorial will be setting up universal keyboard and mouse. You can do this with KDE connect, but this method let you simple drag your mouse outside your monitor into your phone screen.
Unfortunately, the simplest way to achieve this involves using a paid proprietary software called DeskDock.
A free version of DeskDock is available, but it only allows you to share a mouse and not the keyboard.
To proceed, you need to unlock USB debugging on your phone, to do so;
Now head to Google Play Store and install the DeskDock app.
On your Linux computer, First install ADB (Android Development Bridge). Simply use your distribution's package manager to install adb
. On Debian, it’s sudo apt install adb
.
You also need Java JRE 1.7 or above to run DeskDock on Linux. To check whether you have it run java --version
. If you get something like “openjdk …” you already have it installed. If not, you need to install it first. This also varies on different systems (a simple google search will probably lead you to a tutorial on how to do this). On Debian, it's sudo apt install default-jre
.
Next up is connecting your devices through ADB. Unfortunately, you need to do this every time either your phone or your pc reconnects to your Wi-Fi.
For the initial set-up, you need to connect your pc and android device with a USB cable. If you had USB debugging enabled as show before, you will be prompted asking whether you want to trust the connected device. Click Allow. On your Linux terminal, run adb devices
. You should see something that looks like this,
List of devices attached
3300d0315750948d device
Now you need to change this connection so that the ADB is connected wirelessly. Here's a simple shell script to do that.
ip_addr=$(adb shell ip addr show wlan0 | grep "inet\s" | awk '{print $2}' | awk -F'/' '{print $1}') #look for you'r phones ip address
echo $ip_addr
port=5555
adb tcpip $port #starting adb in tcptip on port 5555
adb connect "${ip_addr}:${port}" #connecting to your phone
adb devices
To run this, first create a .sh file and paste this text into it (using a text editor like vim or nano). Make the file executable by running chmod +x ./<file_name>.sh
. Then run the file with./<file_name>.sh
. (Your phone need to be connected via USB when you run this script). You should get an output like “connected to 192.168.1.2:5555”. If not, you might have run the script a couple more times.
Next, go to this page and scroll down and click on Linux. Extract the zip file you just downloaded. To run DeckDock run :
java -jar <desk_dock_jar_download_location>.jar
Now simply click the connect button on the DeskDock mobile app, and you should be good to go. Simply drag your mouse to the right bottom and drag it outside your monitor, your cursor should appear on your phone. You can change the layout by right-clicking on the new icon on your system tray and clicking on settings.
You can also append the previous bash script so that it will start DeskDock after connecting your phone.
ip_addr=$(adb shell ip addr show wlan0 | grep "inet\s" | awk '{print $2}' | awk -F'/' '{print $1}') #look for you'r phones ip address
echo $ip_addr
port=5555
adb tcpip $port #starting adb in tcptip on port 5555
adb connect "${ip_addr}:${port}" #connecting to your phone
adb devices
nohup java -jar <desk_dock_jar_download_location>.jar &
nohup is used to run the command in background so that you can close the terminal. After you run this script, you can press ctlr+c to exit. DeskDock will run in the background.
3. Routing your pc audio through phone or vise versa
Imagine a situation where you're watching a video on your PC with your headphones connected, and you get a call. It would be nice if you can simply answer and start talking using the same headphones.
If you have a multipoint Bluetooth headphones, you can easily achieve something similar to this by connecting both devices to your headphones. If you don’t have one or if you have a wired headphone and don't want to buy something like a mixer, here's a trick. The solution is to stream your pc audio to your phone and have your headphones connected to your phone. This way, you can hear both pc and mobile audio using the same headphones.
The software we are using for this is called AudioRelay (proprietary software). If you run a Debian system, AudioRelay offer a .deb package which you can install with;
sudo apt install ./<audio_realy_deb_location>.deb
. If you're not running Debian, they also offer an executable (extract the tar.gz and look inside the “bin” folder), which you can just double-click to run. You can download either from here.
You also need to install the AudioRelay app on your mobile phone via Google Play Store.
Please note that the following instructions are taken directly from the AudioRelay website.
First, you need to create a permanent virtual audio device. To do so;
- Open the file
/etc/pulse/default.pa
using vim or nano (ex:vim /etc/pulse/default.pa
) - Add these lines to the end
# Creates a device which your PC will output sound to.
# AudioRelay will be able to listen to it.
load-module module-null-sink sink_name=audiorelay-speakers sink_properties=device.description=AudioRelay-Speakers
- Save and exit
- Type
pulseaudio -k
to make pulseaudio reload the file. - Install pavucontrol if you don't have already by running
sudo apt install pavucontrol
- Open Output Devices from your application menu
- Set AudioRelay-Speakers as the default output device
Now open AudioReay on your PC, Go to the server tab and Select Monitor of AudioRelay-Speakers
Open AudioRelay app on your phone and click on player. Click on your pc. It should start streaming your Linux system audio to your phone.
That's it for this tutorial. Of course most features of the Apple ecosystem is still missing but with just a few software you can achieve at least some of it. This was simple me showcasing my own setup that I use every day. Hope you enjoy.
I you enjoyed this read, consider supporting me.