LinuxCommandLibrary

kdeconnect-cli

Communicate with connected devices using KDE Connect

TLDR

List all devices

$ kdeconnect-cli --list-devices
copy

List available (paired and reachable) devices
$ kdeconnect-cli --list-available
copy

Request pairing with a specific device, specifying its ID
$ kdeconnect-cli --pair --device [device_id]
copy

Ring a device, specifying its name
$ kdeconnect-cli --ring --name "[device_name]"
copy

Share an URL or file with a paired device, specifying its ID
$ kdeconnect-cli --share [url|path/to/file] --device [device_id]
copy

Send an SMS with an optional attachment to a specific number
$ kdeconnect-cli --name "[device_name]" --send-sms "[message]" --destination [phone_number] --attachment [path/to/file]
copy

Unlock a specific device
$ kdeconnect-cli --name "[device_name]" --unlock
copy

Simulate a key press on a specific device
$ kdeconnect-cli --name "[device_name]" --send-keys [key]
copy

SYNOPSIS

kdeconnect-cli [options] [command] [arguments]
Example usage:
kdeconnect-cli --list-devices
kdeconnect-cli --device <device_id> --ping
kdeconnect-cli --device <device_id> --send-sms 1234567890 "Hello there!"
kdeconnect-cli --device <device_id> --send-file /path/to/document.pdf

PARAMETERS

--list-devices
    Lists all paired KDE Connect devices with their unique IDs and names.

--device <id>
    Specifies the target device using its unique ID for subsequent commands. This option is mandatory for most device-specific operations.

--ping
    Sends a ping request to the specified device to check connectivity.

--battery
    Displays the battery status (level and charging state) of the specified device.

--send-sms <number> <message>
    Sends an SMS message from the specified device to the given phone number.

--send-file <file>
    Transfers a local file to the specified device.

--open-url <url>
    Opens a URL in the default browser on the specified device.

--share-text <text>
    Shares text content from the desktop to the specified device.

--find-my-phone
    Makes the specified device ring to help locate it.

--run-command <command>
    Executes a predefined command on the specified device. Requires the command to be enabled in device settings.

--list-commands
    Lists all available predefined commands that can be executed via --run-command on the specified device.

--media-pause
    Pauses media playback on the specified device.

--media-play
    Plays or resumes media playback on the specified device.

--media-next
    Skips to the next media track on the specified device.

--media-previous
    Skips to the previous media track on the specified device.

--mute-volume
    Mutes the volume on the specified device.

--unmute-volume
    Unmutes the volume on the specified device.

--set-volume <level>
    Sets the volume level (0-100) on the specified device.

--clipboard-get
    Retrieves the current clipboard content from the specified device.

--clipboard-set <text>
    Sets the clipboard content on the specified device to the given text.

--pair
    Initiates the pairing process with a new device.

--unpair
    Unpairs the specified device.

--plugin-setting <plugin> <key> <value>
    Sets a specific setting for a KDE Connect plugin on the device.

--help
    Displays the help message and exits.

--version
    Displays the version information and exits.

DESCRIPTION

The kdeconnect-cli command provides a powerful command-line interface for interacting with devices paired via KDE Connect. KDE Connect is a versatile project that enables seamless communication and integration between your desktop, phone, and other devices. While a graphical application (kdeconnect-app) offers an intuitive user experience, kdeconnect-cli extends this functionality to the terminal, making it ideal for scripting, automation, and headless environments.

With kdeconnect-cli, users can perform a variety of actions remotely, such as sending SMS messages, transferring files, checking device battery levels, controlling media playback, locating a lost phone, and even executing custom commands on the paired device. It leverages the underlying KDE Connect daemon (kdeconnectd) and D-Bus system to facilitate robust cross-device communication, offering a programmatic way to manage your connected ecosystem without needing a graphical session.

CAVEATS

For kdeconnect-cli to function, the KDE Connect application must be installed and running on both your desktop system and the target mobile device.

Devices must be properly paired through the KDE Connect application, and strong network connectivity (Wi-Fi or LAN) is essential for reliable communication. Some commands, such as sending SMS or running remote commands, may require specific permissions to be granted within the KDE Connect mobile app settings. Device IDs obtained via --list-devices are unique and persistent for a given pairing, but will change if a device is unpaired and re-paired.

OBTAINING DEVICE IDS

Many kdeconnect-cli commands require a device ID to specify which paired device the action should be performed on. You can obtain a list of all currently paired devices, along with their unique IDs, by running:
kdeconnect-cli --list-devices
This command will output a list like:
- my_phone_name: abcd1234efgh5678
where abcd1234efgh5678 is the device ID you'll use with the --device option.

SCRIPTING AND AUTOMATION

kdeconnect-cli is invaluable for scripting. For instance, you could create a script to automatically send an SMS when a certain system event occurs, or to control media playback on your phone from a custom hotkey on your keyboard, without needing to open the full KDE Connect application. This flexibility makes it a powerful tool for power users and system administrators.

HISTORY

KDE Connect emerged as a project to seamlessly integrate Android devices with the KDE Plasma desktop, aiming to bridge the gap between mobile and desktop computing. Its development has been driven by the KDE community, continuously adding features like notification sync, file sharing, remote input, and more. The kdeconnect-cli utility was developed to complement the graphical application, providing a non-GUI interface for these features. This allows users to integrate KDE Connect functionalities into shell scripts, custom keyboard shortcuts, or other automation workflows, expanding its utility beyond interactive desktop usage.

SEE ALSO

kdeconnectd(8), kdeconnect-app(1), dbus-send(1)

Copied to clipboard