#!/usr/bin/env bash
{ set +x; } 2>/dev/null

usage() {
    cat <<EOF 1>&2
usage: $(basename $0) command [args]

Available commands:
    sleep                    sleep display
    wake                     wake display

    state                    0 - sleeping, 1 - active

run \`$(basename $0) COMMAND --help\` for more infos
EOF
    [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; exit
}

[[ $1 == "-h" ]] || [[ $1 == "--help" ]] && usage "$@"

[[ $OSTYPE != *"darwin"* ]] && echo "OS X only" && exit

[[ $# == 0 ]] && usage "$@"

"${BASH_SOURCE[0]%/*}"/"${BASH_SOURCE[0]##*/}"-"$1" "${@:2}"
