1.0.2 • Published 6 months ago

kdeconnect v1.0.2

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
6 months ago

KDE Connect Bindings for NodeJS

Small script using DBus to allow a NodeJS application to communicate with connected devices via KDE Connect

Requirements

  • DBus support
    • NodeJS >= 10.8.0
    • Linux Desktop with DBus Support
  • KDE Connect installed and running

API

The API is written fully in Typescript, so check out the declaration file for additional infos

async getAvailableDevices()

Returns a list of KDEDevices currently known or available

class KDEDevice

Can be manually created or retrieved using getAvailableDevices

Constructor

KDEDevice(id, bus)

NameTypeInfo
idstringKDE ID, can be stored from old device or retrieved manually
busMessageBusoptional, DBus-Session to use

Properties

NameTypeInfo
idstringKDE ID
namestringDevice Name
typestringsmartphone | desktop
isReachablebooleanIs device currently reachable
isTrustedbooleanIs device trusted
connectivity{type: string, strength: number}cellular data (not wifi)
battery{charge: number, charging: boolean}battery status
mediaKDEMediaHandlerReturns a separate handler for media control. See below

Functions

SignatureInfo
async setup(): Promise<void>if a device is manually created, using its KDE ID, this must be called befor use
async shareFile(filePath: string): Promise<void>Shares the file from file path with the device (copying it to the previously chosen folder on the device)
async shareURL(urL: string): Promise<void>Shares the url with the device, either as a notification or by directly opening the link
async shareText(text: string): Promise<void>Shares the text with the device, normally copying it into the devices clipboard
async ring(): Promise<void>Let`s the device ring
async ping(msg?: string): Promise<void>Sends a notification with an optional message to the device
async getNotifications(): Promise<KDENotification[]>Returns a list of notifications currently present on the device. See below
async requestPair(): Promise<void>Request pairing
async unpair(): Promise<void>Unpair device

Events

Every device has an event handler linked to it, accessible by the events Property.

EventValues
onTrustedChanged(boolean)
onNameChanged(string)
onTypeChanged(string)
onReachableChanged(boolean)
onBatteryChanged({charge: number, charging: boolean})
onConnectivityChanged({type: string, strength: number})
onConnectivityChanged({type: string, strength: number})
onPairingRequest(KDEPairingRequest)

class KDENotification

Constructor

Not externally accessible

Properties

NameTypeInfo
appNamestringApp origin name
dismissablebooleanIs this message dismissable
silentbooleanIs it a silent message
textstringMessage text
tickerstringMessage short version
titlestringMessage title

Functions

SignatureInfo
async dismiss(): Promise<boolean>Dismisses message on device. Returns true if message is dismissable, false otherwise

Events

No events

class KDEMediaHandler

Constructor

Not externally accessible

Properties

NameTypeInfo
lengthnumberlength of currently playing track in ms
positionnumberalready passed time of currently playing track in ms
volumenumberdevice volume in %
isPlayingbooleanis music playing or paused
playerstringname of currently playing app
nowPlayingstringname & artist of track
titlestringtrack title
artiststringtrack artist name
albumstringtrack album name

Functions

SignatureInfo
async Next(): Promise<void>Play next track
async Previous(): Promise<void>Play previous track / Jump to start of current track
async Play(): Promise<void>Play track
async Pause(): Promise<void>Pause track
async PlayPause(): Promise<void>Switch Between Play/Pause
async Stop(): Promise<void>Stop track
async update(): Promise<void>Manually update data; Use to keep track of position

Events

EventValuesInfo
onMediaPlayerUpdated()Called when any data changes. Can fire multiple times in succession; Does NOT fire when position changes

class KDEPairingRequest

Constructor

Not externally accessible

Properties

None

Functions

SignatureInfo
async Accept(): Promise<void>Accept request
async Reject(): Promise<void>Reject request

Events

None

Do To / Not supported yet

  • Multiple Media Players
  • SFTP Bindings
  • Contacts / SMS / Telephone
  • Photo Requesting / Recieving
  • Remote Control / Keyboard
  • Remote Commands
1.0.2

6 months ago

1.0.1

9 months ago

1.0.0

9 months ago

0.0.1

9 months ago