Files
omarchycn/bin/omarchy-windows-key
David Heinemeier HanssonandGitHub 2684c4b02e Print the OEM Windows product key from firmware (#7480)
* Print the OEM Windows product key from firmware

Machines that shipped with Windows keep the OEM key in the ACPI MSDM
table. `omarchy windows license key` reads it with strings, then cat.

* Rename the firmware key command to omarchy-windows-key
2026-08-19 13:59:25 +02:00

42 lines
760 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Print the OEM Windows product key stored in firmware
# omarchy:requires-sudo=true
set -euo pipefail
MSDM=${OMARCHY_MSDM_PATH:-/sys/firmware/acpi/tables/MSDM}
if [[ ! -e $MSDM ]]; then
echo "No Windows license key found in firmware." >&2
exit 1
fi
read_msdm() {
if [[ -r $MSDM ]]; then
"$@" "$MSDM"
else
sudo "$@" "$MSDM"
fi
}
extract_key() {
grep -aoEm1 '[A-Z0-9]{5}(-[A-Z0-9]{5}){4}'
}
key=""
if omarchy-cmd-present strings; then
key=$(read_msdm strings | extract_key) || true
fi
if [[ -z $key ]]; then
key=$(read_msdm cat | extract_key) || true
fi
if [[ -z $key ]]; then
echo "Firmware license table found, but no Windows product key could be extracted." >&2
exit 1
fi
printf '%s\n' "$key"