     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
+    if event.keyCode == 123 # F12
         ewin.webContents.openDevTools({mode:'detach'})
 
 report_window = null

sound_test = false

apply_settings = ->
    clearTimeout show_window_timeout
    clearInterval last_check_inactivity_interval

    if settings.open_on_startup
        auto_launcher.isEnabled().then (enabled)->


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