laptop-detect
Detect if running on a laptop
TLDR
Return an exit status of 0 if the current device is likely a laptop, else returns 1
Print the type of device that the current system is detected as
Display version
SYNOPSIS
laptop-detect [-h|--help] [-q|--quiet] [-v|--version]
PARAMETERS
-h, --help
Display help message and exit.
-q, --quiet
Suppress stdout output; errors only to stderr.
-v, --version
Print version info and exit.
DESCRIPTION
The laptop-detect command is a Debian utility that identifies if the host machine is a laptop by probing hardware features like batteries, ACPI tables (e.g., FACS, FADT), embedded controllers, suspend support, and PCI/USB devices typical of notebooks.
It outputs 'laptop' (exit 0) if detected, 'desktop' (exit 1) otherwise, or errors to stderr (exit 2). Ideal for scripts in installers or post-install configs to enable power saving, suspend, or laptop-specific tweaks.
Common in Debian Installer for automating hardware setup, avoiding desktop assumptions on mobiles. Heuristics cover most cases but evolve with hardware; run as root for full accuracy on some checks.
CAVEATS
Heuristic-based; may misclassify VMs, servers with batteries, or new hardware. Best on bare metal; run as root for complete probes.
EXIT CODES
0: laptop; 1: desktop/server; 2: error (e.g., probe failure).
SCRIPT EXAMPLE
if laptop-detect -q; then
apt install laptop-mode-tools;
fi
HISTORY
Introduced in Debian ~2003 (laptop-detect 0.8+); developed for Debian Installer to classify hardware during d-i partitioning/power config. Maintained in non-free-firmware; stable with minor updates for new ACPI.


