device

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package device describes the phone the app is running on.

nimbus native plugin add device

d, err := device.Get(ctx)
b, err := device.GetBattery(ctx)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchBattery

func WatchBattery(ctx context.Context, f func(Battery)) error

WatchBattery calls f with the battery now and whenever it changes, until ctx ends. It blocks, so run it from a goroutine in an effect.

Types

type Battery

type Battery struct {
	Level    float32 `json:"level"`    // 0..1; below 0 when the phone can't say
	Charging bool    `json:"charging"` // whether it is plugged in
	// LowPower is the phone's power saving mode: a good moment to do less.
	LowPower bool `json:"lowPower"`
}

Battery is how much charge is left.

func GetBattery

func GetBattery(ctx context.Context) (Battery, error)

GetBattery returns the battery's state.

type Info

type Info struct {
	Platform     string `json:"platform"`     // "ios", "android" or "web"
	Model        string `json:"model"`        // e.g. "iPhone17,1", "Pixel 9"
	Manufacturer string `json:"manufacturer"` // e.g. "Apple", "Google"
	OSVersion    string `json:"osVersion"`    // the system version
	Memory       int64  `json:"memory"`       // bytes
	Virtual      bool   `json:"virtual"`      // a simulator or emulator
}

Info is the phone.

func Get

func Get(ctx context.Context) (Info, error)

Get returns the phone's Info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL