 
         ui_alarm = (duration=1000)=>
             @setState {alarm:true}
+            sounds.notification.muted = false
             sounds.notification.play()
             disable_alarm = =>
                 @setState {alarm:false}

    console.log "Set timeout to show window in #{format_time break_time}."
    show = ->
        show_window(true)
    show_window_timeout = setTimeout show, break_time

show_window_time = 0
show_window = (alarm)->
    hidden_window = false
    show_window_time = Date.now()
    ewin.setAlwaysOnTop true
    clearTimeout show_window_timeout
    # play again (not pause)
    if log.is_paused
        log.new_entry {pause:false, date:show_window_time}

    report_window?.close()
    settings_window?.close()

# Sound hack for Pulseaudio (using setTimeoutSH instead of setTimeout)
# we play the notification sound muted a little bit before showing
# the window and playing it again to ensure pulseaudio doesn't chop it
setTimeoutSH = (f, t) ->
    timer_id = setTimeout f, t
    hack_id = setTimeout ->
        sounds.notification.muted = true
        sounds.notification.play().then ->
            sounds.notification.src += ''
    , t-1000
    return {timer_id, hack_id}

clearTimeoutSH = (ids) ->
    {timer_id, hack_id} = ids or {}
    clearTimeout hack_id
    clearTimeout timer_id

{Tray, Menu, app, globalShortcut} = electron.remote
path = require 'path'

addEventListener 'keydown', (event)->
    if event.keyCode == 123 # F12
        ewin.webContents.openDevTools({mode:'detach'})

report_window = null
