# How Omarchy Hardware Detection Commands Like `omarchy-hw-asus-rog` Return Exit Codes for Conditionals

> Learn how Omarchy hardware detection commands like omarchy-hw-asus-rog use exit codes for shell conditionals. Discover how exit status ensures 0 for success and non-zero for failure.

- Repository: [Omacom/omarchy](https://github.com/omacom/omarchy)
- Tags: internals
- Published: 2026-09-09

---

**Omarchy's hardware detection utilities rely on Bash's exit-status propagation, chaining `[[` and `grep` tests with `&&` to return 0 for success and non-zero for failure, enabling direct use in shell conditionals without parsing output.**

The Omarchy framework provides lightweight hardware detection scripts that determine machine types without emitting output. These commands, including `omarchy-hw-asus-rog`, leverage the Unix philosophy of exit codes to signal success or failure, allowing seamless integration into installation scripts and system configuration workflows.

## Exit Code Mechanism in `omarchy-hw-asus-rog`

The script located at `bin/omarchy-hw-asus-rog` demonstrates the minimalist pattern used across the Omarchy suite. It performs two discrete validation tests and relies on Bash's logical operator behavior to surface the final exit status.

### Vendor and Family Verification Tests

The script executes two validated file reads against the system's DMI (Desktop Management Interface) data:

- **Vendor check** – Uses a conditional expression to verify the system vendor is `"ASUSTeK COMPUTER INC."` by reading `/sys/class/dmi/id/sys_vendor`.
- **Family check** – Uses `grep -q` to silently test for the presence of `"ROG"` within `/sys/class/dmi/id/product_family`.

Both commands include `2>/dev/null` to suppress error messages if the files do not exist.

```bash
#!/bin/bash

# omarchy:summary=Detect whether the computer is an Asus ROG machine.

[[ $(cat /sys/class/dmi/id/sys_vendor 2>/dev/null) == "ASUSTeK COMPUTER INC." ]] &&
   grep -q "ROG" /sys/class/dmi/id/product_family 2>/dev/null

```

### Logical Chaining and Exit Status Propagation

The tests are combined using the `&&` operator. In Bash, the exit status of a compound command equals the status of the **last executed command** in the chain.

- **Both tests succeed**: The `[[` conditional returns 0, execution continues to `grep`, which also returns 0. The script exits with **0** (success).
- **Vendor mismatch**: The `[[` conditional returns 1, causing `&&` to short-circuit and skip `grep`. The script exits with **1** (failure).
- **Vendor passes, family fails**: The `[[` conditional returns 0, execution reaches `grep`, which returns 1 (pattern not found). The script exits with **1** (failure).

Because the script produces no standard output, callers rely entirely on this exit code to determine hardware compatibility.

## Practical Conditional Usage Examples

You can invoke these detection commands directly in `if` statements, one-liners, or complex shell logic.

**Basic conditional block:**

```bash
if omarchy-hw-asus-rog; then
    echo "Running on an ASUS ROG machine"
else
    echo "Not an ASUS ROG system"
fi

```

**Inline execution with `&&` and `||`:**

```bash
omarchy-hw-asus-rog && echo "ROG detected" || echo "No ROG"

```

**Capturing exit status for subsequent commands:**

```bash
[[ $(omarchy-hw-asus-rog; echo $?) -eq 0 ]] && sudo modprobe asus_wmi

```

## Consistent Design Across the Omarchy Hardware Suite

According to the repository's documentation in [`docs/cli-router.md`](https://github.com/omacom/omarchy/blob/main/docs/cli-router.md) and the command registry in [`AGENTS.md`](https://github.com/omacom/omarchy/blob/main/AGENTS.md), all hardware detection utilities follow this exact pattern. Each script performs a series of `[[` comparisons or `grep` checks, combines them with `&&` or `||`, and exits with the resulting status. This approach ensures **zero dependencies**, **fast execution**, and **unambiguous boolean results** suitable for CI/CD pipelines and provisioning scripts.

## Summary

- **Omarchy hardware detection commands** return exit code 0 only when all internal tests succeed.
- The **`bin/omarchy-hw-asus-rog`** script chains a vendor check and a family grep using `&&`, propagating the final exit status automatically.
- These utilities produce **no standard output**, requiring callers to check `$?` or use the command directly as a conditional expression.
- The pattern is **consistent across the entire Omarchy hardware suite**, as documented in [`AGENTS.md`](https://github.com/omacom/omarchy/blob/main/AGENTS.md) and [`docs/cli-router.md`](https://github.com/omacom/omarchy/blob/main/docs/cli-router.md).

## Frequently Asked Questions

### What exit code does `omarchy-hw-asus-rog` return on non-ROG hardware?

The command returns **1** (or any non-zero value) when either the vendor string does not match `"ASUSTeK COMPUTER INC."` or the product family does not contain `"ROG"`. This non-zero signal indicates the conditional check failed, allowing scripts to fall back to generic configurations.

### Can these hardware detection commands be used in systemd service conditions?

Yes. Because they return standard Unix exit codes and produce no output, they are ideal for `ExecCondition` directives or `ConditionPathExists` logic within systemd units. You can invoke them directly to gate service startup based on hardware type without worrying about log pollution.

### Where are the hardware detection scripts located in the Omarchy repository?

The primary script referenced is located at **`bin/omarchy-hw-asus-rog`**. The complete list of hardware detection utilities is cataloged in **[`AGENTS.md`](https://github.com/omacom/omarchy/blob/main/AGENTS.md)**, and CLI routing documentation is available in **[`docs/cli-router.md`](https://github.com/omacom/omarchy/blob/main/docs/cli-router.md)**, both found in the repository root.

### Why do these scripts produce no output to stdout?

Omarchy follows the **Unix philosophy** where exit codes convey success or failure. By remaining silent, these scripts avoid polluting logs or requiring output parsing (e.g., `grep`, `awk`) when used in conditional chains like `if omarchy-hw-asus-rog; then ... fi`.