How `omarchy-hw-asus-rog` Returns Exit Codes in Omarchy
omarchy-hw-asus-rog returns exit code 0 if no Asus ROG hardware is detected, exit code 1 if ROG hardware is found, and codes greater than 1 for probe errors.
This small shell script in the Omarchy repository follows a Unix-convention where process exit codes serve as boolean-like status indicators, enabling other Omarchy tools to branch on hardware detection without parsing text output.
What omarchy-hw-asus-rog Does
Located at bin/omarchy-hw-asus-rog in the Omarchy source tree, this utility script probes Linux system interfaces to identify Asus Republic of Gamers (ROG) machines. It reads DMI/SMBIOS data from /sys/class/dmi/id/ and examines ACPI tables for known ROG identifiers.
The script intentionally produces no standard output. Instead, it communicates entirely through its exit status, making it ideal for use in if statements and shell pipelines.
Exit Code Reference
| Exit code | Meaning | Typical caller behavior |
|---|---|---|
| 0 | No Asus ROG hardware detected | Skip ROG-specific configuration |
| 1 | Asus ROG hardware detected | Enable ROG-only features |
| >1 | Error during hardware probe (e.g., missing /sys files) |
Log failure and fall back to safe defaults |
This three-code scheme follows defensive scripting practices: callers can distinguish between "definitely not ROG" (0), "definitely ROG" (1), and "could not determine" (>1).
Practical Usage Examples
Basic conditional check
if omarchy-hw-asus-rog; then
echo "ROG hardware detected – loading custom profiles"
omarchy-toggle-rog-mode on
else
echo "Standard hardware – using generic configuration"
omarchy-toggle-rog-mode off
fi
One-liner with logical operators
omarchy-hw-asus-rog && echo "Enabling ROG features" || echo "Keeping defaults"
Explicit exit code inspection
omarchy-hw-asus-rog
exit_status=$?
case $exit_status in
0) echo "Not an ROG machine" ;;
1) echo "ROG machine identified" ;;
*) echo "Detection failed with code $exit_status" ;;
esac
Integration in setup scripts
# Inside an Omarchy system initialization script
if omarchy-hw-asus-rog; then
# Apply ROG-specific keybindings and RGB control
omarchy-theme-set-keyboard-asus-rog
omarchy-fan-profile-load rog-silent
fi
How Detection Works
The script implements detection through standard Linux interfaces without requiring elevated privileges:
- DMI vendor check — Reads
/sys/class/dmi/id/sys_vendorfor "ASUS" or "ASUSTeK" - Product name matching — Scans
/sys/class/dmi/id/product_namefor ROG substrings ("ROG", "Strix", "Zephyrus", "Flow") - ACPI table inspection — Examines
/sys/firmware/acpi/tables/for ROG-specific OEM identifiers - Exit status assignment — Sets
exit 0,exit 1, orexit 2based on findings
Because all data sources reside in sysfs and procfs, the script executes quickly and adds minimal overhead to system initialization.
Integration with Omarchy Commands
Multiple Omarchy tools consume omarchy-hw-asus-rog exit codes:
omarchy-toggle-rog-mode— Queries hardware before applying ROG-specific settings- Theme selectors — Conditionally load ROG-branded visual themes
- Fan control daemons — Branch between generic and ROG-optimized thermal profiles
This design avoids fragile text parsing and ensures robust hardware detection across diverse Asus product lines.
Summary
omarchy-hw-asus-roguses exit codes (0,1,>1) to signal hardware detection results- Zero means no ROG hardware; one confirms ROG hardware; higher values indicate probe failures
- The script reads
/sys/class/dmi/id/and ACPI tables without requiring root privileges - Omarchy commands call this utility and branch on its exit status for clean, parse-free conditional logic
- Source location:
bin/omarchy-hw-asus-rogin the Omarchy repository
Frequently Asked Questions
What does exit code 0 mean for omarchy-hw-asus-rog?
Exit code 0 indicates no Asus ROG hardware was detected. In shell scripting, this evaluates as "false" in conditionals, causing if omarchy-hw-asus-rog; then blocks to skip their contents unless you invert the test with ! or ||.
Why does omarchy-hw-asus-rog produce no output?
The script follows the Unix philosophy of silence: successful operations communicate through exit codes alone. This eliminates string parsing, reduces locale dependencies, and makes the tool composable in pipelines and shell scripts where stdout consumption would interfere with data flow.
How do I handle detection errors in my own scripts?
Capture the exit code with $? and test for values greater than 1. An exit code of 2 or higher typically means the script could not read required /sys files, which may indicate a containerized environment, restricted sysfs permissions, or a non-standard kernel configuration. Treat these cases as unknown hardware and apply conservative defaults.
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 →