JSPM

electron-os-integration-pro

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q54055F
  • License MIT

An Electron module that provides high-level APIs for deep OS integration (power, storage, cloud, and sensors).

Package Exports

  • electron-os-integration-pro
  • electron-os-integration-pro/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (electron-os-integration-pro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Electron OS Integration Pro

NPM Version License: MIT Build Status Downloads

electron-os-integration-pro is a powerful Node.js module for Electron that extends the framework’s built-in OS APIs with advanced native integrations.

It provides a unified, high-level API for accessing system-level features like power management, audio, storage, displays, notifications, and hardware sensors β€” all with minimal boilerplate.

Developed and maintained by Fernando Martini.


πŸš€ Why use Electron OS Integration Pro?

Building a native-like desktop experience in Electron often requires juggling platform-specific APIs (macOS, Windows, Linux).
This module removes that complexity by offering a cross-platform abstraction layer with advanced capabilities not directly exposed by Electron.

βœ”οΈ Reduces boilerplate
βœ”οΈ Simplifies native API learning curve
βœ”οΈ Enables advanced, production-ready Electron apps


✨ Features

  • ⚑ Power Management – Monitor detailed battery status & prevent sleep during critical tasks.
  • ☁️ Storage & Cloud – Detect local sync folders for iCloud, OneDrive, Google Drive & watch directories natively.
  • πŸ”Š System Audio – Get/set system volume, mute state & default output device.
  • πŸ–₯️ Display Control – Control brightness, check HDR mode & display support.
  • πŸ”” Rich Notifications – Interactive notifications with buttons & input fields.
  • πŸ’‘ Hardware Sensors – Access ambient light sensor (where supported).

πŸ“¦ Installation

npm install electron-os-integration-pro

⚠️ Note: This package uses native C++ addons. You’ll need a build environment:

  • Node.js & npm
  • node-gyp
  • Python (2.7 or >=3.6)
  • C++ compiler (MSVC on Windows, GCC/Clang on Linux/macOS)

⚑ Quick Start

const { app } = require('electron');
const os = require('electron-os-integration-pro');

app.whenReady().then(async () => {
  try {
    const batteryState = await os.power.getBatteryState();
    console.log(`Battery: ${batteryState.percentage}% (Charging: ${batteryState.isCharging})`);
  } catch (err) {
    console.error('Battery check failed:', err.message);
  }

  if (os.audio.isAudioSupported()) {
    await os.audio.setSystemVolume(0.5);
    console.log('System volume set to 50%.');
  }
});

πŸ“– API Reference

The API is organized into modules:

  • os.power β†’ Battery & sleep control
  • os.storage β†’ Cloud services & file watching
  • os.audio β†’ System volume & devices
  • os.display β†’ Brightness & HDR
  • os.notifications β†’ Interactive native notifications
  • os.sensors β†’ Hardware sensors

os.power

getBatteryState(): Promise<object>

Returns the current battery status.
Returns: Promise<object>

  • percentage: number (0–100)
  • isCharging: boolean
  • error?: string (if no battery is found)

preventSystemSleep(reason: string): number | null

Prevents the system from entering idle sleep and returns a blocker ID.

  • reason: Description shown in macOS Activity Monitor.

allowSystemSleep()

Releases the sleep blocker, allowing normal sleep.


os.storage

getCloudServices(): Promise<object[]>

Detects installed cloud storage providers.
Returns: Promise<object[]> with:

  • name: string (e.g., "iCloud Drive", "OneDrive")
  • path: string (absolute local sync folder)
  • isAvailable: boolean

watchDirectory(path: string, callback: (eventType, filePath) => void): { stop: () => void }

Watches a directory for changes.

  • path: Absolute directory path.
  • callback: Called with eventType ('added', 'removed', 'modified', etc.) and filePath.
    Returns: A watcher object with stop().

os.audio

isAudioSupported(): boolean

Whether the audio module is supported on the current platform.

getSystemVolume(): Promise<number>

Gets the master system volume.
Returns: Promise<number> (0.0–1.0).

setSystemVolume(level: number): Promise<void>

Sets the master system volume.

  • level: number (0.0–1.0).

isSystemMuted(): Promise<boolean>

Whether the system audio is muted.

getDefaultOutputDevice(): Promise<string>

Gets the name of the default audio output device.


os.display

isDisplaySupported(): boolean

Whether the display module is supported on the current platform.

getBrightness(): Promise<number>

Gets the main display brightness.
Returns: Promise<number> (0.0–1.0).

setBrightness(level: number): Promise<void>

Sets the main display brightness.

  • level: number (0.0–1.0).

isHDRActive(): Promise<boolean>

Checks if the main display is in HDR mode.


os.notifications

A singleton EventEmitter instance for interactive notifications.

isSupported(): boolean

Whether rich notifications are supported.

initialize(appId?: string)

Initializes the notification system (call once).

  • appId: Windows only – AppUserModelID (AUMID).

send(options: { id: string; title: string; body: string; })

Sends a notification.

Event: 'action' – fired on user interaction.
Callback:

{
  notificationId: string;
  actionId: string;     // e.g. 'reply'
  responseText?: string // if input action
}

Example

os.notifications.initialize('Your.App.ID');

os.notifications.on('action', (data) => {
  console.log(`User clicked '${data.actionId}' on '${data.notificationId}'`);
  if (data.responseText) console.log(`User replied: ${data.responseText}`);
});

os.notifications.send({
  id: 'welcome-notif',
  title: 'Welcome!',
  body: 'Click a button to interact.'
});

os.sensors

isSupported(): boolean

Whether the sensors module is supported.

getAmbientLightSensorValue(): Promise<{ value: number; unit: 'lux' | 'raw'; }>

Reads the ambient light sensor.
Returns:

  • value: number
  • unit: 'lux' | 'raw'

πŸ–₯️ Platform Support

Feature macOS Windows Linux
Power Management βœ… βœ… βœ…
Storage & Cloud βœ… βœ… βœ…
Audio Control βœ… βœ… ⚠️ Partial
Display Brightness βœ… βœ… ⚠️ Driver‑dependent
Rich Notifications βœ… βœ… ⚠️ Limited
Ambient Light Sensor βœ… ⚠️ Some devices ❌

Notes: Linux support for audio/brightness/notifications depends on distribution, drivers and desktop environment.


πŸ› οΈ Troubleshooting

  • Build fails on Windows β†’ Ensure Visual Studio Build Tools and Python are installed.
  • Permission errors on macOS β†’ System Settings β†’ Privacy & Security β†’ grant access.
  • Notifications missing on Windows β†’ Set a valid AppUserModelID via notifications.initialize(appId).

🀝 Contributing

  1. Fork the repo
  2. Create a branch: git checkout -b feat/my-feature
  3. Commit and push
  4. Open a Pull Request πŸš€

πŸ“„ License

MIT – free for personal and commercial use.