How to use the electron-util.is.windows 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 ooni / probe-desktop / main / utils / ooni / ooniprobe.js View on Github external
return new Promise((resolve, reject) => {
      try {
        let binPath = self._binaryPath,
          options = {
            stdio: ['pipe', 'pipe', 'pipe'],
            env: {
              'OONI_HOME': getHomeDir(),
            }
          }
        if (is.windows) {
          const isAscii = /^[ -~]+$/
          let homeDir = os.homedir()
          try {
            // This is a workaround for the users home directory containing
            // non-ascii characters.
            // For more context see: https://github.com/nodejs/node/issues/17586
            if (!isAscii.test(homeDir)) {
              // eslint-disable-next-line no-console
              log.info('detected non-ascii characters in homeDir', homeDir)
              const shortHomeDir = GetHomeShortPath()
              options.env['OONI_HOME'] = path.join(shortHomeDir, path.relative(homeDir, options.env.OONI_HOME))
            }
          } catch (err) {
            // eslint-disable-next-line no-console
            console.log('failed to determine the home shortpath. Things will break with user homes which contain non-ascii characters.')
          }
github atomiclabs / hyperdex / app / marketmaker / index.js View on Github external
const {is, fixPathForAsarUnpack} = require('electron-util');
const getPort = require('get-port');
const logger = require('electron-timber');
const makeDir = require('make-dir');
const _ = require('lodash');
const {sha256} = require('crypto-hash');
const {supportedCurrencies} = require('./supported-currencies');

// `electron-builder` uses different names
const platformMapping = new Map([
	['darwin', 'mac'],
	['linux', 'linux'],
	['win32', 'win'],
]);

let binPath = path.join(__dirname, 'bin', platformMapping.get(process.platform), `marketmaker${is.windows ? '.exe' : ''}`);
binPath = fixPathForAsarUnpack(binPath);

const execFile = promisify(childProcess.execFile);

const mmLogger = logger.create({
	name: 'mm',
	ignore: /cant open\.\(|connected to push\.\(/,
});

class Marketmaker {
	_isReady() {
		return new Promise((resolve, reject) => {
			const interval = setInterval(() => {
				const request = electron.net.request({
					method: 'post',
					hostname: '127.0.0.1',
github ooni / probe-desktop / main / utils / paths.js View on Github external
// XXX only macos development is currently supported
  if (is.development) {
    const rsrcPath = path.join(__dirname, '..', '..')
    debug('💣 development mode', rsrcPath)
    return rsrcPath
  }

  const appPath = (electron.app || electron.remote.app).getPath('exe')

  if (is.macos) {
    return path.join(appPath, '../../Resources')
  }
  if (is.linux) {
    return path.join(path.dirname(appPath), './resources')
  }
  if (is.windows) {
    return path.join(path.dirname(appPath), './resources')
  }

  // Other platforms we should just use relative paths and hope
  // for the best
  return './resources'
}
github dreamnettech / dreamtime / src / electron / src / modules / tools / system.js View on Github external
async _hasWindowsMedia() {
    if (!is.windows) {
      return true
    }

    const version = this.os.release

    if (toInteger(version) < 10) {
      // no windows 10
      return true
    }

    if (!is.development) {
      // regedit commands
      regedit.setExternalVBSLocation(
        getAppResourcesPath('vbs'),
      )
    }
github samuelmeuli / mini-diary / src / renderer / electron / ipcRenderer / listeners.ts View on Github external
});

	// Overlays

	ipcRenderer.on("showPrefOverlay", (): void => {
		dispatchThunk(openOverlay("preferences"));
	});

	ipcRenderer.on("showStatsOverlay", (): void => {
		dispatchThunk(openOverlay("statistics"));
	});

	// Screen lock
	// Lock diary when screen is locked

	if (is.macos || is.windows) {
		remote.powerMonitor.on("lock-screen", (): void => {
			dispatchThunk(lock());
		});
	}

	// Theme
	// Listen to system theme changes and update the app theme accordingly

	darkMode.onChange((): void => {
		dispatchThunk(setTheme(darkMode.isEnabled ? "dark" : "light"));
	});
}
github LulumiProject / lulumi-browser / src / main / index.ts View on Github external
function createWindow(options?: Electron.BrowserWindowConstructorOptions, callback?: Function): Electron.BrowserWindow {
  let mainWindow: Electron.BrowserWindow;
  const defaultOption: Object = {
    autoHideMenuBar: autoHideMenuBarSetting,
    frame: !is.windows,
    fullscreenWindowTitle: true,
    minWidth: 320,
    minHeight: 500,
    titleBarStyle: 'hiddenInset',
    webPreferences: {
      contextIsolation: false,
      nodeIntegration: true,
      webSecurity: false,
      webviewTag: true,
    },
  };
  if (options && Object.keys(options).length !== 0) {
    mainWindow = new BrowserWindow(Object.assign({}, defaultOption, options));
  } else {
    /**
     * Initial window options
github dreamnettech / dreamtime / src / electron / src / modules / tools / shell.js View on Github external
return new Promise((resolve) => {
    if (!is.windows) {
      resolve(true)
      return
    }

    const regKey = 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\WindowsFeatures'

    regedit.list(regKey, (err, result) => {
      if (!isNil(err)) {
        resolve(false)
        return
      }

      resolve(result[regKey].keys.includes('WindowsMediaVersion'))
    })
  })
}
github LulumiProject / lulumi-browser / src / renderer / mainBrowserWindow / components / BrowserMainView.vue View on Github external
const currentWindow: Electron.BrowserWindow | null
      = this.$electron.remote.BrowserWindow.fromId(this.windowId);
    if (currentWindow) {
      const { Menu, MenuItem } = this.$electron.remote;
      const menu = new Menu();
      const navbar = document.getElementById('browser-navbar');
      const common = document.getElementById('browser-navbar__common');
      let sub: Electron.MenuItemConstructorOptions[] = [
        {
          label: this.$t('navbar.common.options.lulumi') as string,
          click: () => this.onNewTab(this.windowId, 'about:lulumi', false),
        },
      ];

      if (navbar !== null && common !== null) {
        if (is.windows) {
          menu.append(new MenuItem({
            label: this.$t('file.newTab') as string,
            accelerator: 'CmdOrCtrl+T',
            click: () => this.onNewTab(this.windowId, 'about:newtab', false),
          }));
          menu.append(new MenuItem({
            label: this.$t('file.newWindow') as string,
            accelerator: 'CmdOrCtrl+N',
            click: () => this.$electron.remote.BrowserWindow.createWindow(),
          }));
          menu.append(new MenuItem({ type: 'separator' }));
        }
        menu.append(new this.$electron.remote.MenuItem({
          label: this.$t('navbar.common.options.history.title') as string,
          submenu: ([
            {