From 36329cee7a9698d88bad0bc3a985eb11546c21b7 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 22 Jul 2026 16:10:45 -0700 Subject: [PATCH] Launch 1Password installer when missing --- bin/omarchy-launch-1password | 11 +++++++ default/hypr/bindings/applications.lua | 2 +- test/shell.d/launch-1password-test.sh | 45 ++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100755 bin/omarchy-launch-1password create mode 100755 test/shell.d/launch-1password-test.sh diff --git a/bin/omarchy-launch-1password b/bin/omarchy-launch-1password new file mode 100755 index 00000000..d50da0b2 --- /dev/null +++ b/bin/omarchy-launch-1password @@ -0,0 +1,11 @@ +#!/bin/bash + +# omarchy:summary=Launch 1Password or start its installer when missing. + +set -e + +if omarchy-cmd-present 1password; then + exec setsid uwsm-app -- 1password +else + exec omarchy-launch-floating-terminal-with-presentation omarchy-install-service-1password +fi diff --git a/default/hypr/bindings/applications.lua b/default/hypr/bindings/applications.lua index 3d223642..4c51f9dc 100644 --- a/default/hypr/bindings/applications.lua +++ b/default/hypr/bindings/applications.lua @@ -19,7 +19,7 @@ o.bind("SUPER + SHIFT + D", "Docker", { tui = "lazydocker" }) o.bind("SUPER + SHIFT + G", "Signal", { omarchy = "signal" }) o.bind("SUPER + SHIFT + O", "Obsidian", { launch = "obsidian", focus = "^obsidian$" }) o.bind("SUPER + SHIFT + W", "Omawrite", { launch = "omawrite" }) -o.bind("SUPER + SHIFT + SLASH", "Passwords", { launch = "1password" }) +o.bind("SUPER + SHIFT + SLASH", "Passwords", { omarchy = "1password" }) o.bind("SUPER + SHIFT + A", "ChatGPT", { webapp = "https://chatgpt.com" }) o.bind("SUPER + SHIFT + ALT + A", "Grok", { webapp = "https://grok.com" }) diff --git a/test/shell.d/launch-1password-test.sh b/test/shell.d/launch-1password-test.sh new file mode 100755 index 00000000..c9790d2f --- /dev/null +++ b/test/shell.d/launch-1password-test.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +mock_bin="$test_tmp/bin" +mkdir -p "$mock_bin" + +cat >"$mock_bin/omarchy-cmd-present" <<'SH' +#!/bin/bash +[[ ${OMARCHY_TEST_INSTALLED:-false} == "true" ]] +SH + +cat >"$mock_bin/setsid" <<'SH' +#!/bin/bash +shift +printf 'launch:%s\n' "$*" >"$OMARCHY_TEST_LOG" +SH + +cat >"$mock_bin/omarchy-launch-floating-terminal-with-presentation" <<'SH' +#!/bin/bash +printf 'install:%s\n' "$*" >"$OMARCHY_TEST_LOG" +SH + +chmod +x "$mock_bin"/* + +launch_log="$test_tmp/launch-log" +PATH="$mock_bin:$PATH" OMARCHY_TEST_INSTALLED=true OMARCHY_TEST_LOG="$launch_log" \ + bash "$ROOT/bin/omarchy-launch-1password" +grep -Fxq 'launch:-- 1password' "$launch_log" || fail "1Password launcher starts the installed app" +pass "1Password launcher starts the installed app" + +PATH="$mock_bin:$PATH" OMARCHY_TEST_INSTALLED=false OMARCHY_TEST_LOG="$launch_log" \ + bash "$ROOT/bin/omarchy-launch-1password" +grep -Fxq 'install:omarchy-install-service-1password' "$launch_log" || + fail "1Password launcher starts the installer when missing" +pass "1Password launcher starts the installer when missing" + +grep -Fq '{ omarchy = "1password" }' "$ROOT/default/hypr/bindings/applications.lua" || + fail "1Password keybinding uses the conditional launcher" +pass "1Password keybinding uses the conditional launcher"