UNPKG

409 BJavaScriptView Raw
1'use strict'
2
3function toggle (onoff) {
4 const cp = require('child_process')
5 if (exports.platform !== 'darwin') return
6 try {
7 cp.execSync(`osascript -e 'if application "yubiswitch" is running then tell application "yubiswitch" to ${onoff}'`, {stdio: 'inherit'})
8 } catch (err) {}
9}
10
11exports.enable = () => toggle('KeyOn')
12exports.disable = () => toggle('KeyOff')
13
14exports.platform = process.platform