Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dbus-ts

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dbus-ts

Re-implementation of dbus-native in typescript using promises

  • 0.0.3
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
402
decreased by-18.95%
Maintainers
1
Weekly downloads
 
Created
Source

dbus-ts

This project is a fork of dbus-native, rewritten with promises and TypeScript definitions.

Installation

npm install dbus-ts

Usage

Short example using systemd & desktop notifications service

import { sessionBus } from 'dbus-ts';
import { Interfaces as Notifications } from '@dbus-types/notifications'
import { Interfaces as Systemd } from '@dbus-types/systemd'

async function run() {

    // Hint when creating object which dbus type definitions should be used
    const bus = await sessionBus<Notifications & Systemd>();

    const systemd = await bus.getInterface("org.freedesktop.systemd1", "/org/freedesktop/systemd1","org.freedesktop.systemd1.Manager")
    const [units] = await systemd.ListUnits()

    const numRunningUnits = units.filter(u => u[4] == 'running').length;

    const notifications = await bus.getInterface("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications")
    await notifications.on('ActionInvoked', (id, action_key) => console.log("ActionInvoked", id, action_key));
    await notifications.on('NotificationClosed', (id, reason) => console.log("NotificationClosed", id, reason));

    const [id] = await notifications.Notify('dbus-ts', 0, '', `${numRunningUnits} units!`, `${numRunningUnits} units are currently running`,
        ['Yes', 'No', 'Maybe'], {},  30);

    console.log("Notification sent successfully with id " + id)

}

run().catch(err => console.log(err))

Check out npmjs/@dbus-types for all available type definitions

type hints

Keywords

FAQs

Package last updated on 06 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc