How Omarchy Hardware Detection Commands Like `omarchy-hw-asus-rog` Return Exit Codes for Conditionals
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 -qto 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.
#!/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 togrep, which also returns 0. The script exits with 0 (success). - Vendor mismatch: The
[[conditional returns 1, causing&&to short-circuit and skipgrep. The script exits with 1 (failure). - Vendor passes, family fails: The
[[conditional returns 0, execution reachesgrep, 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:
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 ||:
omarchy-hw-asus-rog && echo "ROG detected" || echo "No ROG"
Capturing exit status for subsequent commands:
[[ $(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 and the command registry in 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-rogscript 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.mdanddocs/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, and CLI routing documentation is available in 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.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →