Check Battery and Network
mcdbus includes two read-only shortcut tools for checking hardware status: battery_status reads from UPower on the system bus, and network_status reads from NetworkManager on the system bus. Both tools only read properties — they do not change any state and require no confirmation prompt.
Battery status
Section titled “Battery status”“What’s my battery level?”
battery_status()The tool enumerates all power devices through UPower, filters for battery-type devices (type 2 in the UPower spec), and returns a summary for each battery found:
## Battery Status
### DELL XXXX- **Charge:** 73%- **State:** Discharging- **Time:** 2h 14m remaining- **Power draw:** 12.3 WWhat it reads
Section titled “What it reads”The tool calls org.freedesktop.UPower.EnumerateDevices to find all power devices, then reads org.freedesktop.UPower.Device properties on each one. The fields reported are:
| Field | Source property | Notes |
|---|---|---|
| Charge | Percentage | 0-100 float |
| State | State | Mapped from integer: 1=Charging, 2=Discharging, 3=Empty, 4=Fully charged, 5=Pending charge, 6=Pending discharge |
| Time remaining | TimeToEmpty | Seconds, shown as hours and minutes when discharging |
| Time to full | TimeToFull | Seconds, shown when charging |
| Power draw | EnergyRate | Watts |
| Model | Model | Battery model string from the hardware |
Reading additional battery properties
Section titled “Reading additional battery properties”The shortcut tool shows the most useful fields. For deeper information (voltage, energy capacity, charge cycles, technology), use get_all_properties on the battery device path:
get_all_properties( bus="system", service="org.freedesktop.UPower", object_path="/org/freedesktop/UPower/devices/battery_BAT0", interface="org.freedesktop.UPower.Device")No battery found
Section titled “No battery found”On desktop machines without a battery, battery_status returns “No batteries found.” This is normal — UPower may still report other device types like line power or UPS units, but the tool filters for batteries specifically.
Network status
Section titled “Network status”“Am I connected to the internet?”
network_status()The tool reads properties from org.freedesktop.NetworkManager on the system bus and returns overall connectivity state, wireless status, and a table of active connections:
## Network Status
- **State:** Connected (global)- **Wireless:** enabled
| Connection | Type | State ||------------|------|-------|| Ethernet 1 | 802-3-ethernet | Activated || MyWiFi | 802-11-wireless | Activated |What it reads
Section titled “What it reads”The tool calls Properties.GetAll on the org.freedesktop.NetworkManager interface to get the top-level state, then iterates over ActiveConnections to read each connection’s properties.
Top-level properties:
| Field | Source property | Notes |
|---|---|---|
| State | State | Integer mapped to: 0=Unknown, 10=Asleep, 20=Disconnected, 30=Disconnecting, 40=Connecting, 50=Connected (local), 60=Connected (site), 70=Connected (global) |
| Wireless | WirelessEnabled | Boolean |
Per-connection properties (read from org.freedesktop.NetworkManager.Connection.Active on each active connection object path):
| Field | Source property |
|---|---|
| Connection | Id |
| Type | Type |
| State | State (mapped: 1=Activating, 2=Activated, 3=Deactivating, 4=Deactivated) |
Reading more network details
Section titled “Reading more network details”For detailed information about a specific network device (IP addresses, DNS servers, signal strength for wireless), use get_all_properties on the device’s object path. Network devices live under /org/freedesktop/NetworkManager/Devices/:
list_objects( bus="system", service="org.freedesktop.NetworkManager", root_path="/org/freedesktop/NetworkManager/Devices")Then introspect a specific device to see which interfaces it exposes (Wired, Wireless, Statistics) and read their properties.