<commit_before>{globalShortcut} = require 'electron'
config = require './config'
Window = require './window'

log = (acc, usage) ->
  console.log "Registering shortcut: #{acc}\t=> #{usage}" if process.env.DEBUG?

registerBossKey = ->
  accelerator = config.get('poi.shortcut.bosskey', '')
  if accelerator
    log accelerator, 'Boss Key'
    globalShortcut.register accelerator, Window.toggleAllWindowsVisibility

registerDevToolShortcut = ->
  accelerator = 'Ctrl+Shift+I'
  log accelerator, 'Open Focused Window Dev Tools'
  globalShortcut.register accelerator, Window.openFocusedWindowDevTools

module.exports =
  register: ->
    if process.platform != 'darwin'
      registerBossKey()
      registerDevToolShortcut()<commit_msg>try catch when registering shortcuts<commit_after>{globalShortcut} = require 'electron'
config = require './config'
Window = require './window'

registerShortcut = (acc, desc, func) ->
  console.log "Registering shortcut: #{acc}\t=> #{desc}" if process.env.DEBUG?
  try
    globalShortcut.register acc, func
  catch err
    console.error "Failed to register shortcut[#{acc}]: #{err}"

registerBossKey = ->
  accelerator = config.get('poi.shortcut.bosskey', '')
  if accelerator
    registerShortcut accelerator, 'Boss Key', Window.toggleAllWindowsVisibility

registerDevToolShortcut = ->
  accelerator = 'Ctrl+Shift+I'
  registerShortcut accelerator, 'Open Focused Window Dev Tools', Window.openFocusedWindowDevTools

module.exports =
  register: ->
    if process.platform != 'darwin'
      registerBossKey()
      registerDevToolShortcut()
{'fraction_non_alphanumeric': 0.12007623888182974, 'fraction_numerical': 0.0, 'mean_word_length': 4.706521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5174245', 'n_tokens_mistral': 468, 'n_tokens_neox': 457, 'n_words': 114}