system Stable WINMACLNX
OS-level information APIs: hardware info, dark mode detection, battery status, sleep prevention, and storage drives. No capability required for most of these — they read read-only OS data.
Import
import { system, battery, power, storage } from 'veloxkit'system
system.getInfo()
Returns hardware and OS information.
const info = await system.getInfo()
// → {
// cpuName: 'Apple M2 Pro',
// cpuCores: 10,
// memoryTotalMb: 16384,
// memoryUsedMb: 4221,
// osName: 'macOS',
// osVersion: '14.5',
// }Returns Promise<SystemInfo | null>
system.getDarkMode()
Returns the OS-level color scheme preference synchronously. Updates if the user changes the OS setting while the app is running.
const scheme = system.getDarkMode()
// → 'dark' | 'light' | 'unknown'VeloxKit's built-in @velox/design ThemeProvider uses this internally when colorScheme="system" is set.
system.isBatterySaverActive()
Returns whether the OS battery-saver / power-saver mode is active. Useful for reducing background work when the user is conserving power.
if (system.isBatterySaverActive()) {
// reduce polling frequency, skip non-essential network calls, etc.
}Returns boolean. On macOS and Linux, always returns false until native support is added.
battery
battery.getStatus()
const status = await battery.getStatus()
// → { level: 0.78, charging: true, timeRemainingSecs: null }
// → null if no battery (desktop without UPS)Returns Promise<BatteryStatus | null>
type BatteryStatus = {
level: number // 0.0 – 1.0
charging: boolean
timeRemainingSecs: number | null // null = unknown
}power
Sleep prevention — useful for media players, data sync, or long-running exports.
power.preventSleep(reason?)
Prevent the system from sleeping while work is in progress. Returns a guard handle string.
const guard = power.preventSleep('Exporting video')power.allowSleep(handle)
Release the guard to let the system sleep normally again.
power.allowSleep(guard)Pattern — use useEffect cleanup:
useEffect(() => {
if (!isExporting) return
const guard = power.preventSleep('Exporting project')
return () => power.allowSleep(guard)
}, [isExporting])storage
storage.getDrives()
List all mounted drives / volumes.
const drives = await storage.getDrives()
// → [
// { name: 'Macintosh HD', mountPoint: '/', totalBytes: 994662584320, availableBytes: 412058624000 },
// { name: 'USB Drive', mountPoint: '/Volumes/USB', totalBytes: 64000000000, availableBytes: 12500000000 },
// ]Returns Promise<Drive[]>
type Drive = {
name: string
mountPoint: string
totalBytes: number
availableBytes: number
}Examples
System info screen
import { system, battery } from 'veloxkit'
import { useState, useEffect } from 'react'
function AboutScreen() {
const [info, setInfo] = useState(null)
const [batt, setBatt] = useState(null)
useEffect(() => {
system.getInfo().then(setInfo)
battery.getStatus().then(setBatt)
}, [])
if (!info) return <Text>Loading…</Text>
return (
<View style={{ gap: 12, padding: 24 }}>
<Text style={{ fontSize: 20, fontWeight: '700' }}>System</Text>
{[
['CPU', info.cpuName],
['Cores', info.cpuCores],
['RAM', `${(info.memoryTotalMb / 1024).toFixed(1)} GB`],
['OS', `${info.osName} ${info.osVersion}`],
].map(([k, v]) => (
<View key={k} style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<Text style={{ color: '#9999bb' }}>{k}</Text>
<Text>{v}</Text>
</View>
))}
{batt && (
<Text style={{ color: '#9999bb', fontSize: 13 }}>
Battery: {Math.round(batt.level * 100)}%
{batt.charging ? ' (charging)' : ''}
</Text>
)}
</View>
)
}Adaptive dark mode
import { system } from 'veloxkit'
import { useState, useEffect } from 'react'
function useSystemDarkMode() {
const [dark, setDark] = useState(() => system.getDarkMode() === 'dark')
useEffect(() => {
// Poll every 2 s for OS preference changes
const id = setInterval(() => {
setDark(system.getDarkMode() === 'dark')
}, 2000)
return () => clearInterval(id)
}, [])
return dark
}@velox/design's ThemeProvider implements this pattern automatically when colorScheme="system" — you rarely need to call system.getDarkMode() directly.