Repository navigation
fix(theme): establish OMARCHY_PATH in entry points for non-interactive shells - #9103
harshithnadig wants to merge 1 commit into
Conversation
…e shells 'omarchy theme list' and 'omarchy theme set' depended on OMARCHY_PATH being exported in the caller's environment. Because OMARCHY_PATH was only exported in '~/.bashrc' via 'env-bootstrap', non-interactive shells (cron, SSH, scripts, CI, systemd) evaluated OMARCHY_PATH as empty, causing 'theme list' to query '/themes/' (failing silently with exit 0) and 'theme set' to report that existing themes do not exist. Establish OMARCHY_PATH in 'bin/omarchy', 'bin/omarchy-theme-list', and 'bin/omarchy-theme-set' if unset, falling back to '/etc/omarchy.conf' and '/usr/share/omarchy'. Also exit non-zero if the themes directory cannot be found. Fixes omacom#9065
|
Reviewed at 4206914 and tested on a disposable Omarchy VM. The bug in #9065 is real and this fixes it, but the approach goes against a rule in this repository's What ran. In The concern. The Runtime Environment section of Related. #12860 and #12796 handle the same unset variable in the update commands, one command at a time. #8769 is still open for Second opinion. Only Claude Opus 5.5 reviewed this. The configured second reviewer, Codex Medium, did not review it because omabot's daily review budget was used up, so this is one model's reading. |
|
There's still an exit-status gap in Here's a patch and regression test you can fold into this PR. It tracks failures from both scans and enables The regression fails on this PR head and passes with the patch. Patch against 4206914--- a/bin/omarchy-theme-list
+++ b/bin/omarchy-theme-list
@@ -2,6 +2,8 @@
# omarchy:summary=List available themes
# omarchy:examples=omarchy theme list | omarchy theme set "Tokyo Night"
+
+set -o pipefail
if [[ -z ${OMARCHY_PATH:-} ]]; then
if [[ -f /etc/omarchy.conf ]]; then
@@ -16,7 +18,13 @@
exit 1
fi
+scan_failed=0
{
- [[ -d "$HOME/.config/omarchy/themes" ]] && find ~/.config/omarchy/themes/ -mindepth 1 -maxdepth 1 \( -type d -o -type l \) -printf '%f\n'
- [[ -d "$OMARCHY_PATH/themes" ]] && find "$OMARCHY_PATH/themes/" -mindepth 1 -maxdepth 1 -type d -printf '%f\n'
+ if [[ -d $HOME/.config/omarchy/themes ]]; then
+ find ~/.config/omarchy/themes/ -mindepth 1 -maxdepth 1 \( -type d -o -type l \) -printf '%f\n' || scan_failed=1
+ fi
+ if [[ -d $OMARCHY_PATH/themes ]]; then
+ find "$OMARCHY_PATH/themes/" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' || scan_failed=1
+ fi
+ (( scan_failed == 0 ))
} | sort -u | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g'Runnable regression testSave this as python3 regression-test.py ./bin/omarchy-theme-listRun unprivileged. It checks real permission-denied failures using temporary theme directories and a temporary HOME, without changing your actual themes. If privileges bypass the fixture permissions, it reports that instead of claiming a pass. """Run: python3 regression-test.py path/to/bin/omarchy-theme-list (unprivileged)."""
import subprocess
import sys
import tempfile
from pathlib import Path
script = Path(sys.argv[1]).resolve()
failed = 0
for unreadable in ("packaged", "user"):
with tempfile.TemporaryDirectory() as temporary:
root = Path(temporary)
home = root / "home"
package = root / "package"
user_themes = home / ".config/omarchy/themes"
packaged_themes = package / "themes"
(user_themes / "custom-theme").mkdir(parents=True)
(packaged_themes / "packaged-theme").mkdir(parents=True)
denied = packaged_themes if unreadable == "packaged" else user_themes
denied.chmod(0)
try:
result = subprocess.run(["/bin/bash", "--noprofile", "--norc", str(script)],
env={"HOME": str(home), "OMARCHY_PATH": str(package), "PATH": "/usr/bin:/bin", "LC_ALL": "C.UTF-8"},
capture_output=True, text=True, timeout=5)
finally:
denied.chmod(0o700)
if "Permission denied" not in result.stderr:
raise RuntimeError("Fixture wasn't unreadable. Run without root/DAC-override privileges.")
ok = result.returncode != 0
print(f"{'ok' if ok else 'not ok'} - {unreadable} scan failure exits {result.returncode}")
failed += not ok
sys.exit(1 if failed else 0)AI-assisted; tested offline. |
|
The second opinion that was missing from the review on October 1 has now run. Codex Medium read this branch at 4206914 against current On @SafiullahRattar's suggested patch: it's true that an unreadable theme directory makes Nothing has been pushed. This is waiting on the maintainer to decide whether |
Problem
In #9065,
omarchy theme listandomarchy theme setfail in non-interactive environments (scripts, cron, SSH, CI, AI agents) because$OMARCHY_PATHis only exported by~/.bashrcin interactive login sessions.When
$OMARCHY_PATHis unset:omarchy theme listqueries/themes/, outputs a find error to stderr, and silently exits0with an empty list.omarchy theme set <name>queries/themes/<name>and falsely reports that the theme does not exist.Solution
bin/omarchy(the root entry dispatcher), establishOMARCHY_PATHif unset before executing sub-commands.bin/omarchy-theme-listandbin/omarchy-theme-set, check and fallbackOMARCHY_PATHfrom/etc/omarchy.confor/usr/share/omarchy.bin/omarchy-theme-list, exit with code1if neither system nor user theme directories exist.Fixes #9065