# shellcheck shell=dash

___x_cmd_mac_sleep(){
    [ $# -gt 0 ]    ||  set -- --machine

    case "$1" in
        -h|--help)      ___x_cmd help -m mac sleep                  ;;
        -s|--screen)    ___x_cmd_mac_sleep___screen_cmd             ;;
        --machine)      ___x_cmd_mac_sleep___machine_cmd            ;;
        *)              N=mac M="Unknown argument -> $1" log:ret:64 ;;
    esac
}

___x_cmd_mac_sleep___machine_cmd(){
    # osascript -e 'tell app "System Events" to sleep'
    mac:info "Running -> pmset sleepnow"
    ___x_cmd_mac___cmd pmset sleepnow
}

___x_cmd_mac_sleep___screen_cmd(){
    mac:info "Running -> pmset displaysleepnow"
    ___x_cmd_mac___cmd pmset displaysleepnow
}

# no sleep until 3600 seconds
# caffeinate -u -t 3600

# no sleep until the process id ends
# caffeinate -w <pid> <64377>
