Setup kde-connect on macOS

Hello there!

Since the time I started using Macbook, I have been sadly away from KDE. That’s around 3 years from now. I have gained skills from contributing to KDE which I could have never achieved otherwise.

After long time, I decided to try out kde-connect on macOS. I knew it won’t work properly on macOS because of deep coupling with linux specific stuff but still I wanted to give it a try.

Few years back, I had tried to use homebrew-kde taps but that wasn’t really a good experience as there was no kdeconnect formula defined in it. I learnt that KDE starting maintaining new build system - Craft. After trying it out, I found that building KDE applications had never been this easy.

Steps to build kdeconnect:

  1. Make sure xcode cli tools and python3 is installed.
  2. Install craft on your system.

    curl https://raw.githubusercontent.com/KDE/craft/master/setup/CraftBootstrap.py -o setup.py && python3 setup.py --prefix ~/CraftRoot
  3. Load craft specific scripts/tools into env.

    source ~/CraftRoot/craft/craftenv.sh
  4. Build kdeconnect. It’s gonna build Qt and all other dependencies of the project. So, it will take around 10-15 minutes. Go brew some coffee in the meanwhile.

    craft kdeconnect-kde
  5. After this is done, you can run cb kdeconnect-kde to go inside kdeconnect build directory. Now try to run the kdeconnectd inside bin directory.

    CRAFT: % cb kdeconnect-kde
    CRAFT: % cd bin
    CRAFT: % ./kdeconnectd
    qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
    This application failed to start because no Qt platform plugin could be initialized.
    Reinstalling the application may fix this problem.
    [1] 9397 abort ./kdeconnectd

    This error means it’s unable to find Qt Platform plugins. Those plugins are installed in the $(craftRoot)/plugins directory. So, we need to set QT_PLUGIN_PATH environment variable.

    export QT_PLUGIN_PATH=$(craftRoot)/plugins
  6. Try running kdeconnect daemon again.

    CRAFT: % ./kdeconnectd                                   
    dbus[9538]: Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!
    "Session bus not found\nTo circumvent this problem try the following command (with Linux and bash)\nexport $(dbus-launch)"

    It’s because kdeconnect need dbus for interprocess communication. You can either use dbus from the Craft directory or install dbus using brew and then run it. I prefer second way since brew manages dbus daemon and injects all the required environment variables required to connect to the bus.

    brew install dbus
    brew services start dbus

    You can check if it ran successfully by using dbus-monitor or dbus-test-tool echo. Then try running kdeconnect again.

    CRAFT: % ./kdeconnectd
    kdeconnect.core: KdeConnect daemon starting
    kdeconnect.core: onStart
    kdeconnect.core: KdeConnect daemon started
    kdeconnect.core: Broadcasting identity packet

Hurray! Finally daemon started and it broadcasted identity datagram on the network. Now go and install Android application expecting all the plugins to work flawlessly. Well, as of now, all the plugins are non-functional due to incompatibility. I hope someday I’ll fetch some time and hack into the code to at least get the basic functionality working.

That’s it for now. Thanks for reading!