 
 seqreq = require './seqreq'
 
-saveConfig = ->
-    nconf.save (err) ->
-        console.log 'error while writing config.json', err if err
-
-# Load configuration
+# serverside configuration management
 nconf = require 'nconf'
 nconf.file { file: paths.configpath }
 nconf.defaults {
     'startminimized': false
-    'minimizetotray': false
 }
+saveConfig = ->
+    nconf.save (err) ->
+        console.log 'error while writing config.json', err if err
 
 mainWindow = null
 

toggleWindowVisible = ->
    if mainWindow.isVisible() then mainWindow.hide() else mainWindow.show()

toggleDockIcon = ->
    if nconf.get 'minimizetotray'
      app.dock.show()
      nconf.set 'minimizetotray', false
    else
      app.dock.hide()
      nconf.set 'minimizetotray', true
    saveConfig()

# helper wait promise
wait = (t) -> Q.Promise (rs) -> setTimeout rs, t

app.on 'ready', ->
    if nconf.get 'minimizetotray'
      app.dock.hide()

    proxycheck = ->
        todo = [


    # Emitted when the window is about to close.
    # For OSX only hides the window if we're not force closing.
    mainWindow.on 'close', (ev) ->
        darwinHideOnly = process.platform == 'darwin' and not mainWindow?.forceClose

        if darwinHideOnly
            ev.preventDefault()
            mainWindow.hide()
