-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·40 lines (33 loc) · 890 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var menubar = require('menubar')
var clipboard = require('clipboard')
var globalShortcut = require('global-shortcut')
var mb = menubar({
width: 200,
height: 100,
preloadWindow: true,
})
mb.on('ready', function ready(){
var ret = globalShortcut.register('ctrl+alt+\\', function() {
console.log('ctrl+alt+\\ is pressed')
// Emit show event
mb.showWindow()
// Wait one second, then close window
setTimeout(function(){
mb.hideWindow()
}, 1000)
})
if (!ret) {
console.log('registration failed')
}
// Check whether a shortcut is registered
console.log(globalShortcut.isRegistered('ctrl+alt+\\'))
})
// When menubar opens
mb.on('show', function ready () {
clipboard.writeText('¯\\_(ツ)_/¯')
})
// When menubar application closes
mb.on('will-quit', function ready(){
// Unregister all shortcuts.
globalShortcut.unregisterAll()
})