How to integrate #Android into #KDE #Linux desktop



KDE desktop has long been favored by many Linux geeks because it has every element to fulfill their appetite: customizable every bit of it, aesthetically pleasing desktop effects, openness to adopting new technologies such as semantic desktop, etc. Beyond all these bells and whistles, the KDE desktop community constantly tries to advance the state of the art of the desktop, experimenting with wild new ideas.
One such effort is so-called KDE Connect, which is a brainchild of Albert Vaca, as part of his Google Summer of Code 2013. The objective of KDE Connect is to seamlessly connect all sorts of devices to KDE desktop, so they can talk to each other. KDE Connect currently supports Android device and WiFi network based sharing, but support for diverse device profiles and network backends are planned for the future.
In this tutorial, I will demonstrate how to integrate Android into KDE Linux desktop by using KDE Connect. The (growing) feature set of KDE Connect is as follows.
  • Show Android battery status on KDE.
  • Share clipboard between Android and KDE.
  • Remote control music/video playback on KDE from Android.
  • Show Android notification in KDE, and keep them in sync.
  • Pause music/video playback during a phone call.
  • Send and receive simple ping messages between Android and KDE.
  • Exchange files, URLs or plain text between Android and KDE.
  • Show call and SMS notifications on KDE.
KDE Connect has two components: KDE desktop component (kde-connect) and device components (e.g., Android app). Currently, for KDE Connect to work, the desktop computer and an Android device need to be on the same local network (via WiFi). Android app relies on UDP broadcast to advertise its presence to the desktop over the local network. Once paired, Android app communicates with the desktop via a public-key based encrypted channel.
In the following, I will go over how to install and set up KDE Connect on both KDE desktop and Android device.

Install kde-connect on KDE Desktop

Kubuntu or Debian KDE
On Kubuntu, kde-connect is included in the base repositories starting from 13.10. So simply using apt-get will do the installation on Kubuntu 13.10 or higher.
$ sudo apt-get install kdeconnect-kde qt5-default qdbus-qt5
To install kde-connect on Kubuntu 13.04 or earlier, you can build it from the source as follows. You can use the same building procedure on Debian KDE.
$ sudo apt-get install build-essential cmake kdebase-workspace-dev libqjson-dev git libqca2-dev
$ git clone git://anongit.kde.org/kdeconnect-kde
$ cd kdeconnect-kde
$ cmake -DCMAKE_INSTALL_PREFIX=/usr ./
$ make
$ sudo make install
Fedora KDE Spin
Installation instruction for Fedora KDE edition is as follows.
$ sudo yum groupinstall "Development Tools"
$ sudo yum install gcc-c++ kdelibs-devel cmake qjson-devel qca2-devel git
$ git clone git://anongit.kde.org/kdeconnect-kde
$ cd kdeconnect-kde
$ cmake -DCMAKE_INSTALL_PREFIX=/usr ./
$ make
$ sudo make install

Configure kde-connect on KDE Desktop

The first step after installing kde-connect is to run the following command as a non-root user, which will activate kde-connect on the user's KDE desktop.
$ qdbus org.kde.kded /kded loadModule kdeconnect
If successful, the above command should return "true".
Now go ahead and rebuild system configuration cache as follows.
$ kbuildsycoca4 -noincremental
At this point, you should find KDE Connect menu under "Systems Settings" (which will remain empty until you pair any Android device).

Android Pairing via KDE Connect

Connecting an Android device to KDE desktop is straightforward.
First, install KDE Connect app on your Android device.
To use most features of KDE Connect, Android 4.1 or higher is recommended. You could still install KDE Connect on up to Android 2.3, but the functionality of KDE Connect will be limited.
After installation, make sure that your Android device and KDE desktop are connected to the same WiFi network.
Launch KDE Connect on Android. You should see the hostname of your KDE destop listed under "Not paired devices".
Click on the hostname, and click on "Request pairing" button on the next screen.
At this point, you should see a pairing request notification on your KDE desktop. Simply accept it.
Now you will see your host listed under "Connected devices" on Android.
Also, the paired Android phone (e.g., Samsung Droid Charge) will appear in the KDE Connect Settings of your desktop. Now KDE Connect should be fully functional between your desktop and a paired Android phone.
One simple demonstration of KDE Connect is shown as follows, where ping notification sent by Android appears in KDE desktop.

Remove kde-connect from KDE Desktop

To deactivate kde-connect from your desktop, run the following commands.
$ qdbus org.kde.kded /kded unloadModule kdeconnect
$ kbuildsycoca4 -noincremental

Troubleshooting kde-connect Installation

1. If kde-connect is successfully built, but your Android device cannot discover the desktop, check if the firewall on your desktop is blocking traffic from Android device. It uses dynamic ports in the range 1714-1764 for UDP and TCP.
2. If you get the following error while building kde-connect, this is due to minimum version requirement (0.8.1) oflibqjson-dev.
  Could not find a configuration file for package "QJSON" that is compatible
  with requested version "0.8.1".

  The following configuration files were considered but not accepted:

    /usr/lib/x86_64-linux-gnu/
cmake/qjson/qjson-config.cmake, version: 0.7.1
    /usr/lib/x86_64-linux-gnu/cmake/qjson/qjson-config.cmake, version: 0.7.1
To fix this problem, you need to download and install the latest libqjson-dev. For example, on Ubuntu 12.10, downloading and installing the latest libqjson-dev (and its dependency) from the following locations solves the problem.
http://packages.ubuntu.com/raring/libqjson-dev
http://packages.ubuntu.com/raring/libqjson0
$ sudo dpkg -i libqjson0_0.8.1-1_amd64.deb
$ sudo dpkg -i libqjson-dev_0.8.1-1_amd64.deb