Get Your Battery's Serial Number From A Terminal

For my work laptop (Lenovo T530) I've been seeing the battery life quickly declining in the past few weeks. I've been meaning to check the warranty on it but, every time I think about it, I'm ON the laptop at work and don't want to have to undock it to get the serial number.

I figured I'd just get it from the command line somehow. And that's what I found using the upower command.

O_o (1) [J:0/1113] mcpierce@mcpierce-laptop:acpi $ upower -h
Usage:
  upower [OPTION...] UPower tool

Help Options:
  -h, --help           Show help options

Application Options:
  -e, --enumerate      Enumerate objects paths for devices
  -d, --dump           Dump all parameters for all objects
  -w, --wakeups        Get the wakeup data
  -m, --monitor        Monitor activity from the power daemon
  --monitor-detail     Monitor with detail
  -i, --show-info      Show information about object path
  -v, --version        Print version of client and daemon

The first thing to do is to enumerate the list of power devices available using the -e or --enumerate command line option:

^_^ [J:0/1115] mcpierce@mcpierce-laptop:acpi $ upower --enumerate
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/battery_BAT0

Here we can see two devices relating to power: battery_BAT0 and line_power_AC. And I'm going to go out on a limb here and say that battery_BAT0 is the one we want to interrogate.

So now we ask it for information using the -i or --show-info command line option:

^_^ [J:0/1116] mcpierce@mcpierce-laptop:acpi $ upower --show-info /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               LGC
  model:                45N1011
  serial:               XXXXX
  power supply:         yes
  updated:              Fri 29 Aug 2014 09:20:05 AM EDT (1932 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    energy:              72.25 Wh
    energy-empty:        0 Wh
    energy-full:         72.25 Wh
    energy-full-design:  93.6 Wh
    energy-rate:         2.82857 W
    voltage:             12.854 V
    percentage:          100%
    capacity:            77.1902%
    technology:          lithium-ion

As we can see in the output the serial number for the laptop batter is listed, along with the vendor tag and model number.

Comments