Repository navigation
Stop Zen asking to be the default, in a file zen-browser-bin updates leave alone - #15909
stevederico wants to merge 2 commits into
Conversation
…leave alone Since links go through omarchy-browser.desktop, Zen never sees itself as the default and asks on every launch. omacom#14441 stops that with Firefox's DontCheckDefaultBrowser policy, but looked for Zen in /opt/zen-browser. The zen-browser-bin package lives in /opt/zen-browser-bin, and the distribution/policies.json there belongs to the package: pacman writes it back on every upgrade, so a setting added to it lasts until the next omarchy update. On Linux, Zen reads /etc/zen/policies/policies.json in place of that file whenever it exists (the system config dir is /etc plus the lowercased app name, and the JSON provider takes the first file it finds, without merging). The Zen installer now starts that file from the package's policies, so DisableAppUpdate and DefaultSerialGuardSetting still apply, and adds DontCheckDefaultBrowser with the helper omacom#14441 added. A file an administrator already put there is kept and only gets the setting. A migration does the same for Zen installs that predate this. The file Omarchy writes carries a top-level __COMMENT__ marker beside "policies", which Zen ignores. Removing Zen deletes that file, and only that file, once the package is gone, then /etc/zen/policies and /etc/zen if they are empty. An administrator's file stays, as Firefox's policies.json does when Firefox is removed.
[Medium impact] The PR appears safe to merge; the previous test-safety issue is fixed. SummaryThe PR keeps Zen’s default-browser setting in
Reviews (2) · Last reviewed commit: "Keep the Zen test's privileged writes in..." · Reviewed by Greptile |
… root as_root runs commands directly when EUID is 0, so a root run skipped the sudo stub and the real installer's browser_policy_setup_firefox_distribution wrote the host's /opt/zen-browser/distribution/policies.json, while the scratch-tree check still passed. Route as_root through the stub, as brave-widevine-test does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and verified on a disposable Omarchy worker with real zen-browser-bin 1.23.2b. The fix works, and I pushed one commit that changes only the new test. Reproduction. On Pushed: 2cf5703. If Tests on the worker. Second opinion. Codex Medium reviewed the head with my commit and raised three points, none of which I changed:
In a second round, shown that reasoning, it agreed nothing blocking remains. That is agreement with reasoning it had read, so independence is not guaranteed. For the maintainer. The body's phrase "Both fix #7411" makes GitHub link #7411 as closed by this PR. This PR does not fix #7411: Omarchy's Firefox preferences still go to This waits on the maintainer: on the pre-existing suite failures, and on whether to merge. |
Fixes #15870
Since 4.0.5, every link goes through
omarchy-browser.desktop. Zen never sees itself as the default browser, so it asks to become the default on every launch. #14441 turns that check off for Firefox-family browsers with theDontCheckDefaultBrowserpolicy, but for Zen it looked in/opt/zen-browser/distribution. Thezen-browser-binpackage the menu installs lives in/opt/zen-browser-bin.Pointing at the right directory is not enough.
/opt/zen-browser-bin/distribution/policies.jsonbelongs to the package and is not in itsbackuparray. Every zen-browser-bin upgrade (omarchy updaterunsyay -Sua) writes the package's copy back, so a setting added there lasts only until the next update.What changed
install/helpers/browser-policy.sh: newbrowser_policy_setup_zen_policies./etc/zen/policies/policies.jsonfrom the package'spolicies.json, soDisableAppUpdateandDefaultSerialGuardSettingstill apply.DontCheckDefaultBrowserwithbrowser_policy_firefox_skip_default_check, the helper Route links from every app through the running default browser #14441 added./etc/zen/policies/policies.json, it is kept and only gets the setting added.0755and the file is root0644, using the existing hardened helpers.__COMMENT__marker next to"policies". Zen reads only.policies(JSON.parse(data).policies), so the marker has no effect on Zen.bin/omarchy-install-browser zencalls it.migrations/1792363203.shcalls it for existing Zen installs, which Route links from every app through the running default browser #14441's migration missed.bin/omarchy-remove-browser zencalls the newbrowser_policy_remove_zen_policies, onceomarchy-pkg-missing zen-browser-binconfirms the package is gone./etc/zen/policies/policies.jsononly if it carries Omarchy's marker./etc/zen/policiesand/etc/zenonly if they are empty./etc/opt/<browser>/policies/managed. Brave checks that the package is gone before it touches/etc/brave.DontCheckDefaultBrowserit was given, just as an administrator's Firefoxpolicies.jsonkeeps it after Firefox is removed. Nothing removes merged keys today, and the setting does nothing once Zen is gone.pacman never writes to
/etc/zen, so the setting survives package updates.Why
/etc/zen/policies, and not a pacman hookJSONPoliciesProvider._getLocalConfigurationFile()returnsSysConfD/policies/policies.jsonwhen that file exists. Otherwise it returnsdistribution/policies.json.SysConfDis/etcplus the app name, lowercased (GetUnixSystemConfigDirinxpcom/io/SpecialSystemDirectory.cpp).AppConstantshasMOZ_APP_NAME: "zen"andMOZ_SYSTEM_POLICIES: true, and itsapplication.inihasName=Zen./app/etc/zen, which is the Flatpak form of the same directory./etcfile starts as a copy of the package's policies./etc/<browser>/policies/managed. The open LibreWolf PR (Add LibreWolf as supported browser #13309) uses/etc/librewolf/policiesthe same way, seeded from the packaged file.omarchy-pkgs/pkgbuilds/omarchy/PKGBUILDinstalls each hook by name. Temporary passwordless sudo always fails: 05-omarchy-passwordless-revoke.hook is never installed by packaging #14733 is a hook that sits in this repo but was never packaged, so a hook here alone would ship nothing. No existing hook targets a browser package.DontCheckDefaultBrowsersets and locksbrowser.shell.checkDefaultBrowserto false. Zen's startup prompt is Firefox'sDefaultBrowserCheck, which skips its check when that pref is false.Relation to #12148 / #7444
Both fix #7411: Omarchy's Firefox preferences never reach Zen. They write into the package's
distribution/policies.json, which has the same update problem. Once/etc/zen/policies/policies.jsonexists, Zen ignores that file./etc, preferences included./etc/zen/policies. Whichever PR lands second should seed or merge there.This PR does not touch the
/opt/zen-browser/distributionline orBROWSER_POLICY_FIREFOX_DIRS; that is #12148's fix.Testing
bash test/shell.d/zen-default-browser-check-test.sh: 7/7 ok.sudostub only runs commands whose paths are all inside the scratch dir./etc/zenfirst, then distribution) after the migration and after the installer.policies.jsonback, as an upgrade does, and checks again.omarchy-remove-browser zenafter an install leaves no/etc/zen/etc/zen/policies/policies.jsonsurvives both install and removalpolicies.jsoninstead:not ok - Zen keeps DontCheckDefaultBrowser after zen-browser-bin rewrites its policies.jsonnot ok - the installer adds DontCheckDefaultBrowser to Zen's policies and keeps the package'snot ok - a migration adds Zen's default browser settingquattro:not ok - the helper keeps Zen's setting in /etc/zen/policies, ...not ok - removing Zen deletes the /etc/zen Omarchy wrotepolicies.json, without the marker check:not ok - removing Zen keeps an administrator's /etc/zen policiesplatform-app-hooks-test.shstubs the new helper. It passes, as dodefault-apps,browser-policy-dir,default-browser-check-migration,browser-link-handoffandconfig.bash test/shell, run twice on this branch:i18n-test.sh(da/menu.json mirrors the English catalog) fails both times. It also fails on unmodifiedquattro(60f5b49).input-indicator,update-stay-awake-security,menu-imagesandpacman-templates, a different set each run. Each one passes alone, and none of them touches browsers or policies.Not tested:
about:policieslistingDontCheckDefaultBrowseromarchy remove browser zenKnown limits:
/etcfile is a copy of the package's policies taken at install or migration time. If zen-browser-bin later adds a policy key, it will not show up there./etc/zenfile in place, the marker stays, and removing Zen deletes it along with their edits.