 // TODO: What about dispatch_after?
 dispatch_source_set_timer(source,
                           dispatch_time(DISPATCH_TIME_NOW, 0),
-                          FREQ * NSEC_PER_SEC, 0)
+                          updateFrequency * NSEC_PER_SEC, 0)
 
 dispatch_source_set_event_handler(source) {
     for var i = 0; i < widgets.count; ++i {

// THE SOFTWARE.

import IOKit
import Darwin
import Darwin.ncurses
import Dispatch
import Foundation

//------------------------------------------------------------------------------
// MARK: GLOBAL PROPERTIES
//------------------------------------------------------------------------------

/// Application version
let DSHB_VERSION = "0.0.4"

/// Does this machine have a battery?
let hasBattery: Bool

/// Does this machine have a SMC (System Management Controller)?
let hasSMC: Bool

/// Statistic widgets that are on (displayed)
var widgets = [WidgetType]()

//------------------------------------------------------------------------------
// MARK: COMMAND LINE INTERFACE
//------------------------------------------------------------------------------

let CLIFrequencyFlag = IntOption(shortFlag: "f", longFlag: "frequency",
                                 required: false,
            helpMessage: "Statistic update frequency in seconds. Default is 1.")
let CLIHelpFlag      = BoolOption(shortFlag: "h", longFlag: "help",
               helpMessage: "Show the help message (list of options) and exit.")
let CLIVersionFlag   = BoolOption(shortFlag: "v", longFlag: "version",
                                  helpMessage: "Show dshb version and exit.")

let CLI = CommandLine()
CLI.addOptions(CLIFrequencyFlag, CLIHelpFlag, CLIVersionFlag)

let (success, error) = CLI.parse()
if !success {
    println(error!)
    CLI.printUsage()
    exit(EX_USAGE)
}


// Give precedence to help flag
if CLIHelpFlag.value {
    CLI.printUsage()
    exit(EX_USAGE)
}
else if CLIVersionFlag.value {
    println(dshbVersion)
    exit(EX_USAGE)
}


if let customFrequency = CLIFrequencyFlag.value {
    if customFrequency < 1 {
        println("Usage: Statistic update frequency must be >= 1")
        exit(EX_USAGE)
    }

    updateFrequency = UInt64(customFrequency)
}
else { updateFrequency = 1 }

//------------------------------------------------------------------------------
// MARK: NCURSES SETTINGS
