beetlebug▾
/

ztcl::device battery

Gives the level and the state of the battery.

ztcl::device battery

Description

Gives a dict: level, the charge in percent from 0 to 100, or -1 when the host has no level, and state: charging, full, unplugged, or unknown. iOS gives the level in steps of 5%, and its Simulator gives -1 and unknown.

Returns

A dict with the keys level and state.

Examples

# A host with no battery service, as a desktop.
% catch {ztcl::device battery} msg; set msg
the battery is not available on this platform

Errors

% ztcl::device battery
the battery is not available on this platform
-errorcode ZTCL DEVICE UNAVAILABLE

% ztcl::device battery x
wrong # args: should be "ztcl::device battery"
-errorcode TCL WRONGARGS

Facts

Capability
device. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.6

See also