electron-util
Version:
Useful utilities for Electron apps and modules
34 lines (26 loc) • 831 B
JavaScript
import { shell } from 'electron';
import { is } from './is.js';
/**
Open the System Preferences on macOS.
This method does nothing on other systems.
Optionally provide a pane and section.
@example
```
import {openSystemPreferences} from 'electron-util';
openSystemPreferences();
// or
openSystemPreferences('security', 'Firewall');
```
@param pane - The pane to open.
@param section - The section within that pane.
@returns A Promise that resolves when the preferences window is opened.
*/
export const openSystemPreferences = async (...args) => {
const [pane, section] = args;
if (is.macos) {
await shell.openExternal(`x-apple.systempreferences:com.apple.preference.${pane}${section ? `?${section}` : ''}`);
}
else if (is.windows) {
await shell.openExternal(`ms-settings:${pane}`);
}
};