diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f4ea04..2791684b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ release is checked here and released on by hand. ### Desktop +- Upstream's commands show their texts instead of raw keys like + `webapp.intro`, in every language upstream has, and Install > Browser + gets past its browser policy step. + - Actions that need the password ask for it: choosing Cloudflare or Google as DNS provider or setting up Tailscale did nothing before. Tapping the password field brings the on-screen keyboard back after it was put away, diff --git a/desktop/install-tree b/desktop/install-tree index ed917a7f..178f1590 100755 --- a/desktop/install-tree +++ b/desktop/install-tree @@ -20,7 +20,10 @@ project=$(dirname "$here") shell=$here/shell config=$here/configuration omarchy=$root/usr/share/omarchy for input in "$build/wvkbd-mobintl" "$build/wtype" "$build/wtype.LICENSE" "$upstream/themes" "$upstream/bin" \ - "$upstream/themes/jade-horse/colors.toml" "$upstream/icons/papercraft" "$upstream/applications/foot.desktop" "$upstream/default/hypr/toggles/bar-glassy.lua" "$dbus_next/dbus_next/__init__.py"; do + "$upstream/themes/jade-horse/colors.toml" "$upstream/icons/papercraft" "$upstream/applications/foot.desktop" "$upstream/default/hypr/toggles/bar-glassy.lua" \ + "$upstream/default/i18n/en/cli.json" "$upstream/install/helpers/as-root.sh" "$upstream/install/helpers/browser-policy.sh" \ + "$upstream/default/chromium/policies/omarchy.json" "$upstream/default/firefox/policies.json" "$upstream/config/chromium-flags.conf" \ + "$dbus_next/dbus_next/__init__.py"; do [[ -e $input ]] || { echo "Missing input: $input" >&2; exit 1; } done umask 022 @@ -47,6 +50,34 @@ for script in "$upstream"/bin/*; do cp -P "$script" "$omarchy/bin/" done cp -R "$shell/." "$omarchy/" +# Upstream's command texts at the pin, in each of its languages: the commands +# above print them through omarchy-i18n, which shows the bare key for a text +# its catalogs lack. English is upstream's with ours over it, where the +# tablet words a text its own way. The shell's own texts (shell.json) stay ours. +for catalog in "$upstream"/default/i18n/*/cli.json; do + language=${catalog%/cli.json} + language=${language##*/} + if [[ $language == en ]]; then + jq -s '.[0] * .[1]' "$catalog" "$shell/default/i18n/en/cli.json" > "$omarchy/default/i18n/en/cli.json.new" + put "$omarchy/default/i18n/en/cli.json.new" "$omarchy/default/i18n/en/cli.json" + rm "$omarchy/default/i18n/en/cli.json.new" + else + put "$catalog" "$omarchy/default/i18n/$language/cli.json" + fi +done +# Upstream's browser policy helper and what it installs, at the pin: Install > +# Browser, the browser extensions and the theme's browser colour source it. +# The other install/helpers serve upstream's installer and its pacman +# channels, which stay out. +for name in install/helpers/as-root.sh install/helpers/browser-policy.sh \ + default/firefox/policies.json config/chromium-flags.conf; do + put "$upstream/$name" "$omarchy/$name" +done +# -L: some are links within upstream's tree (copy-url's icon.png is its +# icon.png); the extension needs the file itself. +(cd "$upstream" && find -L default/chromium -type f | LC_ALL=C sort) | while read -r name; do + put "$upstream/$name" "$omarchy/$name" +done # The upstream release the pin belongs to, which `omarchy version` prints for # programs that check what Omarchy they run on (Omafox needs 4 or newer). # Recorded with the pin: upstream's own version file reads 4.0.0.alpha even at diff --git a/docs/upstream.md b/docs/upstream.md index 184778f8..a4d62ea4 100644 --- a/docs/upstream.md +++ b/docs/upstream.md @@ -81,8 +81,16 @@ installed, Screensaver only where a screensaver is, and each Setup > Defaults li command is. `desktop/install-tree` also points Suspend at the kernel's charger PM readiness. -**Translations.** `default/i18n/en/cli.json` holds only the keys of the commands -shipped here; `shell.json` adds the auto-brightness and captive-portal keys. +**Translations.** `desktop/install-tree` ships upstream's `cli.json` in every +language at the pin, for the upstream commands it ships; English is upstream's +with our `default/i18n/en/cli.json` over it. `shell.json` is ours: it adds the +auto-brightness and captive-portal keys. + +**Upstream files besides `bin/`.** `desktop/install-tree` also takes the +browser policy helper (`install/helpers/as-root.sh`, `browser-policy.sh`) and +what it installs (`default/chromium/`, `default/firefox/policies.json`, +`config/chromium-flags.conf`), for Install > Browser. Upstream's other +`install/helpers` serve its installer and pacman channels and stay out. **Our own files** (no upstream counterpart): the control center (`shell/controlcenter/`, its bar button `shell/plugins/control-center/`), the status cluster (`shell/plugins/status/`), the launcher diff --git a/tests/package_tree.py b/tests/package_tree.py index 4e715a84..46caa702 100644 --- a/tests/package_tree.py +++ b/tests/package_tree.py @@ -56,6 +56,31 @@ def inputs(base): (upstream / 'default/hypr/toggles/bar-glassy.lua').write_text('-- glassy\n') # Upstream's own version file is stale (4.0.0.alpha even at 4.6 RCs). (upstream / 'version').write_text('4.0.0.alpha\n') + # Upstream's command texts: an English text ours words the same, one only + # upstream has, and another language's catalog. + (upstream / 'default/i18n/en').mkdir(parents=True) + (upstream / 'default/i18n/en/cli.json').write_text( + '{"system.rebooting": "Rebooting", "webapp.intro": "Let\'s create a new web app"}\n') + (upstream / 'default/i18n/en/shell.json').write_text('{"upstream.only": "Upstream"}\n') + (upstream / 'default/i18n/da').mkdir() + (upstream / 'default/i18n/da/cli.json').write_text('{"webapp.intro": "Lad os lave en webapp"}\n') + # The browser policy helper and what it installs, and one helper that stays out. + (upstream / 'install/helpers').mkdir(parents=True) + for name in ('as-root.sh', 'browser-policy.sh', 'pacman.sh'): + (upstream / 'install/helpers' / name).write_text('# %s\n' % name) + (upstream / 'default/chromium/policies').mkdir(parents=True) + (upstream / 'default/chromium/policies/omarchy.json').write_text('{}\n') + # An extension whose icon links to upstream's own icon.png. + (upstream / 'icon.png').write_bytes(b'\x89PNG') + (upstream / 'default/chromium/extensions/copy-url').mkdir(parents=True) + (upstream / 'default/chromium/extensions/copy-url/manifest.json').write_text('{"icons": {"16": "icon.png"}}\n') + (upstream / 'default/chromium/extensions/copy-url/icon.png').symlink_to('../../../../icon.png') + (upstream / 'default/chromium/native-messaging-hosts').mkdir() + (upstream / 'default/chromium/native-messaging-hosts/com.omarchy.copy_url.json').write_text('{}\n') + (upstream / 'default/firefox').mkdir() + (upstream / 'default/firefox/policies.json').write_text('{}\n') + (upstream / 'config').mkdir() + (upstream / 'config/chromium-flags.conf').write_text('--ozone-platform=wayland\n') (upstream / 'applications').mkdir() (upstream / 'applications/foot.desktop').write_text('[Desktop Entry]\nName=Terminal\n') (wheel / 'dbus_next/aio').mkdir(parents=True) diff --git a/tests/test_upstream_files.py b/tests/test_upstream_files.py new file mode 100644 index 00000000..1ac547d8 --- /dev/null +++ b/tests/test_upstream_files.py @@ -0,0 +1,75 @@ +"""Files upstream's shipped commands read: their texts (#278) and the browser policy helper (#279).""" +import json +from pathlib import Path +import re +import shutil +import unittest + +from package_tree import mode, tree + +PROJECT = Path(__file__).resolve().parents[1] + + +@unittest.skipUnless(shutil.which('bash') and shutil.which('jq'), 'bash and jq run desktop/install-tree') +class Texts(unittest.TestCase): + def setUp(self): + self.i18n = tree() / 'usr/share/omarchy/default/i18n' + + def test_english_is_upstreams_with_ours_over_it(self): + english = json.loads((self.i18n / 'en/cli.json').read_text()) + ours = json.loads((PROJECT / 'desktop/shell/default/i18n/en/cli.json').read_text()) + self.assertEqual(english['webapp.intro'], "Let's create a new web app") + for key, text in ours.items(): + self.assertEqual(english[key], text, key) + # Readable by everyone, whatever mode our own catalog had: omarchy-i18n + # runs as the tablet user and prints the bare key for a catalog it can't read. + self.assertEqual(mode(self.i18n / 'en/cli.json'), 0o644) + + def test_each_upstream_language_ships_its_catalog(self): + self.assertEqual(json.loads((self.i18n / 'da/cli.json').read_text()), + {'webapp.intro': 'Lad os lave en webapp'}) + self.assertEqual(mode(self.i18n / 'da/cli.json'), 0o644) + + def test_the_shells_texts_stay_ours(self): + shell = json.loads((self.i18n / 'en/shell.json').read_text()) + self.assertNotIn('upstream.only', shell) + self.assertEqual(shell, json.loads((PROJECT / 'desktop/shell/default/i18n/en/shell.json').read_text())) + + +@unittest.skipUnless(shutil.which('bash') and shutil.which('jq'), 'bash and jq run desktop/install-tree') +class BrowserPolicy(unittest.TestCase): + def setUp(self): + self.omarchy = tree() / 'usr/share/omarchy' + + def test_the_helper_and_its_files_ship(self): + for name in ('install/helpers/as-root.sh', 'install/helpers/browser-policy.sh', + 'default/chromium/policies/omarchy.json', + 'default/chromium/native-messaging-hosts/com.omarchy.copy_url.json', + 'default/firefox/policies.json', 'config/chromium-flags.conf'): + self.assertTrue((self.omarchy / name).is_file(), name) + self.assertEqual(mode(self.omarchy / name), 0o644, name) + + def test_an_extensions_linked_icon_ships_as_a_file(self): + # Chromium refuses an extension whose manifest names an icon it can't + # read: copy-url's icon.png links to upstream's icon.png. + icon = self.omarchy / 'default/chromium/extensions/copy-url/icon.png' + self.assertFalse(icon.is_symlink()) + self.assertEqual(icon.read_bytes(), b'\x89PNG') + self.assertEqual(mode(icon), 0o644) + + def test_upstreams_installer_helpers_stay_out(self): + # pacman.sh rewrites pacman.conf from upstream's channel templates, + # which the tablet's repositories are not. + self.assertEqual(sorted(p.name for p in (self.omarchy / 'install/helpers').iterdir()), + ['as-root.sh', 'browser-policy.sh']) + + def test_install_tree_names_every_helper_a_shipped_command_sources(self): + # The menu's browser commands source these two; install-tree copies + # exactly the helpers it checks for. + text = (PROJECT / 'desktop/install-tree').read_text() + self.assertEqual(sorted(set(re.findall(r'install/helpers/([a-z-]+\.sh)', text))), + ['as-root.sh', 'browser-policy.sh']) + + +if __name__ == '__main__': + unittest.main()