npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@astrohaus/networkmanager-dbus

v2.2.0

Published

A nodejs interface to communicate with NetworkManager via DBus

Downloads

9

Readme

NetworkManager DBus Client for NodeJS

Forked from https://gitlab.com/dropworks-oss/networkmanager-dbus

Credits

DBus-next

This library powers the code that interacts with DBus.

Ian's Tech Blog – Fun With NetworkManager

Great tutorial on basic interaction with NetworkManager via DBus

Introduction

NetworkManager is the program that manages network connections on Ubuntu and BalenaOS Systems (probably on some other Linux flavors too). It's super powerful; you can configure a connection to pretty much any kind of network including:

  • Enterprise WiFi
  • Bluetooth
  • Cellular Modems

This library provides some basic wrapper functionality for NodeJS apps. It was developed to perform basic wifi provisioning from within an Electron app, but it'll work well with any NodeJS app.

Installation

Note: This has only been tested on Ubuntu Linux. It should work fine on other Linux distros with some setup, and it supposedly works on Mac as well.

npm install dbus-next networkmanager-dbus

Examples

Scan for Local Access Points

import { NetworkManager } from 'network-manager-dbus';

let networkManager = await NetworkManager.init();
let wifiDevice = await networkManager.wifiDevice();

// Subscribe to discovered access points
wifiDevice.accessPoints$.subscribe((accessPoints) => {
  console.log(`access points:`);
  console.log(accessPoints);
});

// Requests a network scan
// Usually takes a few seconds to complete
// Access points will be updated
wifiDevice.requestScan();

Connect to a non-enterprise Wifi Network

import { NetworkManager, DeviceState } from 'network-manager-dbus';

let networkManager = await NetworkManager.init();
let wifiDevice = await networkManager.wifiDevice();
let connectionSettingsManager = await networkManager.connectionSettingsManager();

// Subscribe to WifiDevice properties
wifiDevice.properties$.subscribe((properties) => {
  console.log(`WiFi Status:`);
  console.log(`Connection state: ${DeviceState[properties.State.value]}`);
  if (properties.ActiveAccessPoint.value) {
    if (wifiDevice.accessPoints[properties.ActiveAccessPoint.value]) {
      console.log(`Connected to access point:`);
      console.log(wifiDevice.accessPoints[properties.ActiveAccessPoint.value]);
    } else {
      console.log(`Not connected to a discovered access point`);
    }
  } else {
    console.log(`Not connected to an Access Point`);
  }
});

let networkIsHidden = false;
let connectionProfilePath = await connectionSettingsManager.addWifiWpaConnection(
  'MY_SSID',
  networkIsHidden,
  'MY_PASSWORD',
);

// After the connection is activated, the wifiDevice.properties$ observable will update with
// a new ActiveAccessPoint
await wifiDevice.activateConnection(connectionProfilePath);

Listen to Ethernet Cable Plug/Unplug Events

import { NetworkManager } from 'network-manager-dbus';

let networkManager = await NetworkManager.init();
let ethernetDevice = await networkManager.ethernetDevice();

ethernetDevice.properties$.subscribe((properties) => {
  if (properties.Carrier.value) {
    console.log('Cable plugged in');
  } else {
    console.warn('Cable unplugged!');
  }
});

Using this in Electron

This library was originally developed for use in an Electron app running on a BalenaOS device.

When in an electron app, you can only make calls to native/nodejs libraries in the main context (i.e. electron's main.js; not in your actual webapp). However, you may still want to utilize proper types when passing information gathered from this library (like a list of local access points) to your render context.

Types for objects can be accessed by importing them from networkmanager-dbus/lib/dbus-types in your render context. This will not import any actual code, just interfaces, enums, types, etc. Example:

import { DeviceState } from `networkmanager-dbus/lib/dbus-types`;

Contributing

Contributions are welcome! Just submit a PR on Gitlab.

Additional Resources

Closing Remarks

This library was developed at Dropworks. We make a pretty incredible digital droplet PCR machine. If your lab needs an afforable and highly accurate PCR machine, keep us in mind! Additionally, if you're a developer that's looking to work on interesting projects with a great team, please check out our job openings!