/ de-omarchy / bin / omarchy-windows-key
swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
42 lines · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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"