How to use the electron-util.api.app function in electron-util

To help you get started, we’ve selected a few electron-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atomiclabs / hyperdex / app / config.js View on Github external
'use strict';
const {api, is} = require('electron-util');
const Store = require('electron-store');
const {minWindowSize} = require('./constants');

// Note: This is hardcoded here instead of being imported
// from `util-common` to prevent cyclic dependencies
const isNightlyBuild = api.app.getName() === 'HyperDEX Nightly';

const defaults = {
	windowState: {
		width: minWindowSize.width,
		height: minWindowSize.height,
	},
	theme: is.macos ? 'system' : 'dark',
	swapModalShowAdvanced: false,
	enabledCoins: [
		'BCH',
		'BEER',
		'BTC',
		'CHIPS',
		'DASH',
		'DNR',
		'DOGE',
github npezza93 / archipelago / app / renderer / about / about.jsx View on Github external
-331 -399 -698 -203 -368 -372 -670 -376 -670 -3 -1 -383 655 -844 1457 -523
          912 -847 1466 -863 1479 -35 25 -106 32 -141 12z m514 -1133 l436 -767 -226
          -3 -227 -2 -393 -393 -392 -392 -309 310 -308 310 486 852 c267 469 488 853
          491 853 3 0 201 -345 442 -768z m2335 -1045 l132 -242 -195 -195 -194 -195
          -116 116 -117 117 174 321 c96 176 176 320 179 320 3 1 64 -108 137 -242z
          m-955 -1406 c451 -788 817 -1435 815 -1437 -2 -2 -1196 -3 -2654 -2 l-2649 3
          775 1362 776 1362 373 -372 372 -372 448 448 447 447 239 -2 240 -3 818 -1434z
          m1858 -231 c348 -630 641 -1160 652 -1178 l20 -32 -698 2 -698 3 -161 280
          c-88 154 -319 558 -514 897 l-354 617 68 123 c37 68 90 163 118 212 l50 88
          178 -178 179 -179 257 257 c164 164 260 253 264 245 4 -6 291 -527 639 -1157z"/>
        
      

      <div>
        <div>Archipelago</div>
        <div id="version">v{api.app.getVersion()}</div>
      </div>

      <p>
        Archipelago is an open-source terminal emulator built on web technology.
      </p>

      <p>
        Bug reports and pull requests are welcome on
        <a href="https://github.com/npezza93/archipelago/" rel="noopener noreferrer"> GitHub</a>.
      </p>

      <p>
        This app is available as open source under the terms of the
        <a href="http://opensource.org/licenses/MIT" rel="noopener noreferrer"> MIT License</a>.
      </p>
github npezza93 / archipelago / app / renderer / about / about.jsx View on Github external
-331 -399 -698 -203 -368 -372 -670 -376 -670 -3 -1 -383 655 -844 1457 -523
          912 -847 1466 -863 1479 -35 25 -106 32 -141 12z m514 -1133 l436 -767 -226
          -3 -227 -2 -393 -393 -392 -392 -309 310 -308 310 486 852 c267 469 488 853
          491 853 3 0 201 -345 442 -768z m2335 -1045 l132 -242 -195 -195 -194 -195
          -116 116 -117 117 174 321 c96 176 176 320 179 320 3 1 64 -108 137 -242z
          m-955 -1406 c451 -788 817 -1435 815 -1437 -2 -2 -1196 -3 -2654 -2 l-2649 3
          775 1362 776 1362 373 -372 372 -372 448 448 447 447 239 -2 240 -3 818 -1434z
          m1858 -231 c348 -630 641 -1160 652 -1178 l20 -32 -698 2 -698 3 -161 280
          c-88 154 -319 558 -514 897 l-354 617 68 123 c37 68 90 163 118 212 l50 88
          178 -178 179 -179 257 257 c164 164 260 253 264 245 4 -6 291 -527 639 -1157z"/&gt;
        
      

      <div>
        <div>Archipelago</div>
        <div id="version">v{api.app.getVersion()}</div>
      </div>

      <p>
        Archipelago is an open-source terminal emulator built on web technology.
      </p>

      <p>
        Bug reports and pull requests are welcome on
        <a href="https://github.com/npezza93/archipelago/" rel="noopener noreferrer"> GitHub</a>.
      </p>

      <p>
        This app is available as open source under the terms of the
        <a href="http://opensource.org/licenses/MIT" rel="noopener noreferrer"> MIT License</a>.
      </p>
github karaggeorge / mac-screen-capture-permissions / index.js View on Github external
const execa = require('execa');
const {isElectron, fixPathForAsarUnpack} = require('electron-util/node');
const macosVersion = require('macos-version');

const binary = path.join(fixPathForAsarUnpack(__dirname), 'screen-capture-permissions');

const permissionExists = macosVersion.isGreaterThanOrEqualTo('10.15');

let filePath;

if (isElectron) {
	const {api, openSystemPreferences} = require('electron-util');

	exports.openSystemPreferences = () => openSystemPreferences('security', 'Privacy_ScreenCapture');

	filePath = api.app && path.join(api.app.getPath('userData'), '.has-app-requested-screen-capture-permissions');
}

exports.hasScreenCapturePermission = () => {
	if (!permissionExists) {
		return true;
	}

	const {stdout} = execa.sync(binary);
	const hasPermission = stdout === 'true';

	if (!hasPermission && filePath) {
		try {
			fs.writeFileSync(filePath, '');
		} catch (error) {
			if (error.code === 'ENOENT') {
				fs.mkdirSync(path.dirname(filePath));
github atomiclabs / hyperdex / app / util-common.js View on Github external
'use strict';
const {api, is} = require('electron-util');
const config = require('./config');

const isNightlyBuild = api.app.getName() === 'HyperDEX Nightly';

const isDevelopment = config.get('isDebugMode') || is.development || isNightlyBuild;

module.exports = {
	isNightlyBuild,
	isDevelopment,
};
github npezza93 / archipelago / app / main / menus / about.js View on Github external
import {api, platform} from 'electron-util'
import about from '../windows/about'
import settings from '../windows/settings'
import {accelerators} from '../utils'

export default {
  label: api.app.getName(),
  submenu: [
    {
      label: 'About Archipelago',
      click: about.toggle
    },
    {
      label: `Version ${api.app.getVersion()}`,
      enabled: false
    },
    {type: 'separator'},
    {
      label: 'Settings',
      accelerator: accelerators.settings,
      click: settings.toggle
    },
    {type: 'separator'},
github npezza93 / archipelago / app / main / menus / about.js View on Github external
import {api, platform} from 'electron-util'
import about from '../windows/about'
import settings from '../windows/settings'
import {accelerators} from '../utils'

export default {
  label: api.app.getName(),
  submenu: [
    {
      label: 'About Archipelago',
      click: about.toggle
    },
    {
      label: `Version ${api.app.getVersion()}`,
      enabled: false
    },
    {type: 'separator'},
    {
      label: 'Settings',
      accelerator: accelerators.settings,
      click: settings.toggle
    },
    {type: 'separator'},
    ...platform({
      macos: [
        {role: 'services', submenu: []},
        {type: 'separator'},
        {role: 'hide'},
        {role: 'hideothers'},
        {role: 'unhide'},
github zce / electron-boilerplate / src / common / store.ts View on Github external
name: 'state',
  defaults: {
    lastWindowState: {
      width: 1024,
      height: 768,
      x: undefined as number | undefined,
      y: undefined as number | undefined
    }
  }
})

export const settings = new Store({
  name: 'settings',
  defaults: {
    theme: darkMode.isEnabled ? 'dark' : 'light',
    locale: api.app.getLocale(),
    titleBarStyle: 'custom' as 'custom' | 'native'
  }
})
github npezza93 / archipelago / app / main / pty.js View on Github external
get sessionArgs() {
    return {
      name: 'xterm-256color',
      cwd: process.env.HOME,
      env: {
        LANG: (api.app.getLocale() || '') + '.UTF-8',
        TERM: 'xterm-256color',
        COLORTERM: 'truecolor',
        ...process.env
      }
    }
  }