Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions bin/omarchy-default-browser
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# omarchy:summary=Set the default browser for Omarchy and XDG handlers
# omarchy:args=[chromium|chrome|brave|brave-origin|edge|firefox|zen]
# omarchy:examples=omarchy default browser firefox | omarchy default browser brave
# omarchy:args=[chromium|ungoogled-chromium|helium|chrome|brave|brave-origin|edge|firefox|zen]
# omarchy:examples=omarchy default browser helium | omarchy default browser firefox

installing=false
if [[ ${1:-} == "--install" ]]; then
Expand All @@ -12,7 +12,14 @@ fi

if (($# == 0)); then
case "$(env -u BROWSER xdg-settings get default-web-browser)" in
chromium.desktop) echo "chromium" ;;
chromium.desktop)
if omarchy-pkg-present ungoogled-chromium-bin; then
echo "ungoogled-chromium"
else
echo "chromium"
fi
;;
helium.desktop) echo "helium" ;;
google-chrome.desktop) echo "chrome" ;;
brave-browser.desktop) echo "brave" ;;
brave-origin.desktop) echo "brave-origin" ;;
Expand All @@ -26,19 +33,23 @@ fi

case "$1" in
chromium) browser="chromium"; command="chromium"; desktop_id="chromium.desktop"; name="Chromium"; glyph= ;;
ungoogled-chromium) browser="ungoogled-chromium"; command="chromium"; desktop_id="chromium.desktop"; name="Ungoogled Chromium"; glyph= ;;
helium) browser="helium"; command="helium-browser"; desktop_id="helium.desktop"; name="Helium"; glyph= ;;
chrome) browser="chrome"; command="google-chrome-stable"; desktop_id="google-chrome.desktop"; name="Chrome"; glyph=󰊯 ;;
brave) browser="brave"; command="brave"; desktop_id="brave-browser.desktop"; name="Brave"; glyph=󰖟 ;;
brave-origin) browser="brave-origin"; command="brave-origin"; desktop_id="brave-origin.desktop"; name="Brave Origin"; glyph=󰖟 ;;
edge) browser="edge"; command="microsoft-edge-stable"; desktop_id="microsoft-edge.desktop"; name="Edge"; glyph=󰇩 ;;
firefox) browser="firefox"; command="firefox"; desktop_id="firefox.desktop"; name="Firefox"; glyph=󰈹 ;;
zen) browser="zen"; command="zen-browser"; desktop_id="zen.desktop"; name="Zen"; glyph=󰖟 ;;
*)
echo "Usage: omarchy-default-browser <chromium|chrome|brave|brave-origin|edge|firefox|zen>"
echo "Usage: omarchy-default-browser <chromium|ungoogled-chromium|helium|chrome|brave|brave-origin|edge|firefox|zen>"
exit 1
;;
esac

if omarchy-cmd-missing "$command"; then
if omarchy-cmd-missing "$command" ||
{ [[ $browser == "chromium" ]] && omarchy-pkg-missing chromium; } ||
{ [[ $browser == "ungoogled-chromium" ]] && omarchy-pkg-missing ungoogled-chromium-bin; }; then
if [[ $installing == "false" ]]; then
exec omarchy-launch-floating-terminal-with-presentation omarchy-default-browser --install "$browser"
else
Expand Down
29 changes: 26 additions & 3 deletions bin/omarchy-install-browser
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# omarchy:summary=Install a supported browser
# omarchy:args=<chromium|chrome|brave|brave-origin|edge|firefox|zen>
# omarchy:examples=omarchy install browser chromium | omarchy install browser firefox
# omarchy:args=<chromium|ungoogled-chromium|helium|chrome|brave|brave-origin|edge|firefox|zen>
# omarchy:examples=omarchy install browser chromium | omarchy install browser helium

set -e

Expand Down Expand Up @@ -45,6 +45,29 @@ chromium)
omarchy-theme-set-browser
announce_browser_installed "Chromium"
;;
ungoogled-chromium)
echo "Installing Ungoogled Chromium..."
# The package provides Chromium and must replace the stock Chromium package.
yay -S --noconfirm --needed --ask 4 ungoogled-chromium-bin

setup_policy_directory /etc/chromium/policies/managed
copy_chromium_flags ~/.config/chromium-flags.conf
omarchy-theme-set-browser
announce_browser_installed "Ungoogled Chromium"
;;
helium)
echo "Installing Helium..."
helium_signing_key=BE677C1989D35EAB2C5F26C9351601AD01D6378E
if ! gpg --list-keys "$helium_signing_key" &>/dev/null; then
gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys "$helium_signing_key"
fi
omarchy-pkg-aur-add helium-browser-bin

setup_policy_directory /etc/chromium/policies/managed
copy_chromium_flags ~/.config/helium-browser-flags.conf
omarchy-theme-set-browser
announce_browser_installed "Helium"
;;
chrome)
echo "Installing Chrome..."
omarchy-pkg-aur-add google-chrome || exit 1
Expand Down Expand Up @@ -98,7 +121,7 @@ zen)
announce_browser_installed "Zen"
;;
*)
echo "Usage: omarchy-install-browser <chromium|chrome|brave|brave-origin|edge|firefox|zen>"
echo "Usage: omarchy-install-browser <chromium|ungoogled-chromium|helium|chrome|brave|brave-origin|edge|firefox|zen>"
exit 1
;;
esac
18 changes: 15 additions & 3 deletions bin/omarchy-remove-browser
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

# omarchy:summary=Remove a supported browser and clean up Omarchy browser defaults
# omarchy:args=<chrome|brave|brave-origin|edge|firefox|zen>
# omarchy:examples=omarchy remove browser firefox | omarchy remove browser brave
# omarchy:args=<ungoogled-chromium|helium|chrome|brave|brave-origin|edge|firefox|zen>
# omarchy:examples=omarchy remove browser helium | omarchy remove browser firefox
# omarchy:requires-sudo=true

set_fallback_default_browser() {
Expand All @@ -19,6 +19,18 @@ set_fallback_default_browser() {
}

case $1 in
ungoogled-chromium)
echo "Removing Ungoogled Chromium..."
omarchy-pkg-drop ungoogled-chromium-bin
# Ungoogled Chromium replaces the stock package, so restore Omarchy's base browser.
omarchy-install-browser chromium
;;
helium)
echo "Removing Helium..."
set_fallback_default_browser helium.desktop
omarchy-pkg-drop helium-browser-bin
rm -f ~/.config/helium-browser-flags.conf
;;
chrome)
echo "Removing Chrome..."
set_fallback_default_browser google-chrome.desktop
Expand Down Expand Up @@ -64,7 +76,7 @@ zen)
omarchy-pkg-drop zen-browser-bin
;;
*)
echo "Usage: omarchy-remove-browser <chrome|brave|brave-origin|edge|firefox|zen>"
echo "Usage: omarchy-remove-browser <ungoogled-chromium|helium|chrome|brave|brave-origin|edge|firefox|zen>"
exit 1
;;
esac
3 changes: 2 additions & 1 deletion bin/omarchy-theme-set-browser
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# omarchy:summary=Apply the current theme color to Chromium, Chrome, Edge, and Brave
# omarchy:summary=Apply the current theme color to supported Chromium-based browsers
# omarchy:hidden=true

CHROMIUM_THEME=$HOME/.local/state/omarchy/current/theme/chromium.theme
Expand Down Expand Up @@ -32,6 +32,7 @@ refresh_running_browser() {

set_browser_policy /etc/chromium/policies/managed
refresh_running_browser chromium chromium
refresh_running_browser helium helium-browser

set_browser_policy /etc/opt/chrome/policies/managed
refresh_running_browser chrome google-chrome-stable || refresh_running_browser chrome google-chrome
Expand Down
6 changes: 6 additions & 0 deletions default/omarchy/omarchy-menu.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@
"setup.default.agent.pi": {"icon":"","iconFont":"omarchy","label":"Pi","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"},
"setup.default.browser": {"icon":"","label":"Browser","title":"Default Browser"},
"setup.default.browser.chromium": {"icon":"","label":"Chromium","checked":"[[ \"$(omarchy-default-browser)\" == \"chromium\" ]]","action":"omarchy-default-browser chromium"},
"setup.default.browser.ungoogled-chromium": {"icon":"","label":"Ungoogled Chromium","checked":"[[ \"$(omarchy-default-browser)\" == \"ungoogled-chromium\" ]]","action":"omarchy-default-browser ungoogled-chromium"},
"setup.default.browser.helium": {"icon":"","label":"Helium","checked":"[[ \"$(omarchy-default-browser)\" == \"helium\" ]]","action":"omarchy-default-browser helium"},
"setup.default.browser.chrome": {"icon":"󰊯","label":"Chrome","checked":"[[ \"$(omarchy-default-browser)\" == \"chrome\" ]]","action":"omarchy-default-browser chrome"},
"setup.default.browser.brave": {"icon":"󰖟","label":"Brave","checked":"[[ \"$(omarchy-default-browser)\" == \"brave\" ]]","action":"omarchy-default-browser brave"},
"setup.default.browser.brave-origin": {"icon":"󰖟","label":"Brave Origin","checked":"[[ \"$(omarchy-default-browser)\" == \"brave-origin\" ]]","action":"omarchy-default-browser brave-origin"},
Expand Down Expand Up @@ -211,6 +213,8 @@
"install.windows": {"icon":"󰍲","label":"Windows","disabled":"[[ -f $HOME/.local/share/applications/windows-vm.desktop ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-windows-vm install'"},
"install.preinstalls": {"icon":"󰏓","label":"Preinstalls","disabled":"[[ ! -f $HOME/.local/state/omarchy/preinstalls-removed ]]","action":"omarchy-launch-floating-terminal-with-presentation omarchy-install-preinstalls"},
"install.browser.chrome": {"icon":"","label":"Chrome","disabled":"omarchy-pkg-present google-chrome","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-install-browser chrome'"},
"install.browser.ungoogled-chromium": {"icon":"","label":"Ungoogled Chromium","disabled":"omarchy-pkg-present ungoogled-chromium-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-install-browser ungoogled-chromium'"},
"install.browser.helium": {"icon":"","label":"Helium","disabled":"omarchy-pkg-present helium-browser-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-install-browser helium'"},
"install.browser.edge": {"icon":"󰇩","label":"Edge","disabled":"omarchy-pkg-present microsoft-edge-stable-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-install-browser edge'"},
"install.browser.brave": {"icon":"","label":"Brave","disabled":"omarchy-pkg-present brave-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-install-browser brave'"},
"install.browser.brave-origin": {"icon":"","label":"Brave Origin","disabled":"omarchy-pkg-present brave-origin-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-install-browser brave-origin'"},
Expand Down Expand Up @@ -293,6 +297,8 @@
"remove.security.sshd": {"icon":"󰣀","label":"SSHD","when":"systemctl is-enabled --quiet sshd","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-security-sshd"},
"remove.security.sudoless-docker": {"icon":"󰡨","label":"Sudoless Docker","when":"! omarchy-sudo-docker --configured","action":"omarchy-launch-floating-terminal-with-presentation omarchy-remove-security-sudoless-docker"},
"remove.browser.chrome": {"icon":"","label":"Chrome","when":"omarchy-pkg-present google-chrome","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser chrome'"},
"remove.browser.ungoogled-chromium": {"icon":"","label":"Ungoogled Chromium","when":"omarchy-pkg-present ungoogled-chromium-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser ungoogled-chromium'"},
"remove.browser.helium": {"icon":"","label":"Helium","when":"omarchy-pkg-present helium-browser-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser helium'"},
"remove.browser.edge": {"icon":"󰇩","label":"Edge","when":"omarchy-pkg-present microsoft-edge-stable-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser edge'"},
"remove.browser.brave": {"icon":"","label":"Brave","when":"omarchy-pkg-present brave-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser brave'"},
"remove.browser.brave-origin": {"icon":"","label":"Brave Origin","when":"omarchy-pkg-present brave-origin-bin","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-remove-browser brave-origin'"},
Expand Down
75 changes: 74 additions & 1 deletion test/shell.d/default-apps-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ cat >"$mock_bin/omarchy-cmd-missing" <<'SH'
[[ ! -e $OMARCHY_TEST_INSTALLED_DIR/$1 ]]
SH

cat >"$mock_bin/omarchy-pkg-present" <<'SH'
#!/bin/bash
[[ -e $OMARCHY_TEST_INSTALLED_DIR/pkg-$1 ]]
SH

cat >"$mock_bin/omarchy-pkg-missing" <<'SH'
#!/bin/bash
[[ ! -e $OMARCHY_TEST_INSTALLED_DIR/pkg-$1 ]]
SH

cat >"$mock_bin/omarchy-launch-floating-terminal-with-presentation" <<'SH'
#!/bin/bash
printf '%s\0' "$@" >"$OMARCHY_TEST_TERMINAL_LOG"
Expand Down Expand Up @@ -64,6 +74,8 @@ case $installer in
omarchy-pkg-add)
package=$1
printf 'pkg:%s\n' "$package" >>"$OMARCHY_TEST_INSTALL_LOG"
touch "$OMARCHY_TEST_INSTALLED_DIR/pkg-$package"
[[ $package == "chromium" ]] && rm -f "$OMARCHY_TEST_INSTALLED_DIR/pkg-ungoogled-chromium-bin"
case $package in
chromium) command=chromium ;;
cursor-bin) command=cursor ;;
Expand All @@ -72,18 +84,28 @@ omarchy-pkg-add)
neovim) command=nvim ;;
esac
;;
omarchy-pkg-aur-add)
package=$1
printf 'aur:%s\n' "$package" >>"$OMARCHY_TEST_INSTALL_LOG"
touch "$OMARCHY_TEST_INSTALLED_DIR/pkg-$package"
[[ $package == "helium-browser-bin" ]] && command=helium-browser
;;
omarchy-install-browser)
selection=$1
printf 'browser:%s\n' "$selection" >>"$OMARCHY_TEST_INSTALL_LOG"
case $selection in
chromium) command=chromium ;;
chromium) command=chromium; package=chromium; replaced_package=ungoogled-chromium-bin ;;
ungoogled-chromium) command=chromium; package=ungoogled-chromium-bin; replaced_package=chromium ;;
helium) command=helium-browser ;;
chrome) command=google-chrome-stable ;;
brave) command=brave ;;
brave-origin) command=brave-origin ;;
edge) command=microsoft-edge-stable ;;
firefox) command=firefox ;;
zen) command=zen-browser ;;
esac
[[ -n ${package:-} ]] && touch "$OMARCHY_TEST_INSTALLED_DIR/pkg-$package"
[[ -n ${replaced_package:-} ]] && rm -f "$OMARCHY_TEST_INSTALLED_DIR/pkg-$replaced_package"
;;
omarchy-install-terminal)
command=$1
Expand All @@ -105,8 +127,27 @@ esac
touch "$OMARCHY_TEST_INSTALLED_DIR/$command"
SH

cat >"$mock_bin/gpg" <<'SH'
#!/bin/bash
case $1 in
--list-keys) [[ -e $OMARCHY_TEST_INSTALLED_DIR/helium-signing-key ]] ;;
--keyserver)
printf 'gpg:%s\n' "$*" >>"$OMARCHY_TEST_SETUP_LOG"
touch "$OMARCHY_TEST_INSTALLED_DIR/helium-signing-key"
;;
esac
SH

cat >"$mock_bin/yay" <<'SH'
#!/bin/bash
printf 'yay:%s\n' "$*" >>"$OMARCHY_TEST_INSTALL_LOG"
touch "$OMARCHY_TEST_INSTALLED_DIR/pkg-ungoogled-chromium-bin" "$OMARCHY_TEST_INSTALLED_DIR/chromium"
rm -f "$OMARCHY_TEST_INSTALLED_DIR/pkg-chromium"
SH

for installer in \
omarchy-pkg-add \
omarchy-pkg-aur-add \
omarchy-install-browser \
omarchy-install-terminal \
omarchy-install-editor-vscode \
Expand Down Expand Up @@ -147,6 +188,8 @@ assert_missing_opens_installer() {

browser_cases=(
'chromium chromium browser:chromium'
'ungoogled-chromium chromium browser:ungoogled-chromium'
'helium helium-browser browser:helium'
'chrome google-chrome-stable browser:chrome'
'brave brave browser:brave'
'brave-origin brave-origin browser:brave-origin'
Expand Down Expand Up @@ -217,6 +260,36 @@ grep -Fxq 'omarchy-theme-set-browser:' "$setup_log" ||
fail "Chromium browser installer applies the current theme"
pass "Chromium browser installer restores the complete Omarchy setup"

: >"$install_log"
: >"$setup_log"
rm -f "$installed_dir/helium-browser" "$installed_dir/pkg-helium-browser-bin" "$installed_dir/helium-signing-key"
OMARCHY_TEST_REAL_BROWSER_INSTALL=true omarchy-default-browser --install helium >/dev/null
[[ $(<"$install_log") == "aur:helium-browser-bin" ]] || fail "Helium browser installer installs the AUR package"
[[ $(omarchy-default-browser) == "helium" ]] || fail "Helium becomes the default after its full installer succeeds"
cmp -s "$ROOT/config/chromium-flags.conf" "$test_home/.config/helium-browser-flags.conf" ||
fail "Helium browser installer copies the default flags"
grep -Fq "gpg:--keyserver hkps://keyserver.ubuntu.com --recv-keys BE677C1989D35EAB2C5F26C9351601AD01D6378E" "$setup_log" ||
fail "Helium browser installer imports the upstream signing key"
grep -Fxq 'sudo:mkdir -p /etc/chromium/policies/managed' "$setup_log" ||
fail "Helium browser installer creates its Chromium policy directory"
grep -Fxq 'omarchy-theme-set-browser:' "$setup_log" ||
fail "Helium browser installer applies the current theme"
pass "Helium browser installer restores the complete Omarchy setup"

: >"$install_log"
: >"$setup_log"
touch "$installed_dir/pkg-chromium"
rm -f "$installed_dir/pkg-ungoogled-chromium-bin"
OMARCHY_TEST_REAL_BROWSER_INSTALL=true omarchy-default-browser --install ungoogled-chromium >/dev/null
grep -Fxq 'yay:-S --noconfirm --needed --ask 4 ungoogled-chromium-bin' "$install_log" ||
fail "Ungoogled Chromium browser installer allows replacing stock Chromium"
[[ ! -e $installed_dir/pkg-chromium ]] || fail "Ungoogled Chromium replaces the stock package"
[[ $(omarchy-default-browser) == "ungoogled-chromium" ]] ||
fail "Ungoogled Chromium becomes the default after its full installer succeeds"
cmp -s "$ROOT/config/chromium-flags.conf" "$test_home/.config/chromium-flags.conf" ||
fail "Ungoogled Chromium browser installer copies the default flags"
pass "Ungoogled Chromium browser installer replaces stock Chromium with the complete Omarchy setup"

omarchy-default-browser zen
rm -f "$installed_dir/chromium"
if OMARCHY_TEST_REAL_BROWSER_INSTALL=true OMARCHY_TEST_INSTALL_FAIL=true \
Expand Down
2 changes: 1 addition & 1 deletion test/shell.d/menu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ assertDeepEqual(
'menu sorts coding agents alphabetically'
)
const expectedDefaults = {
browser: ['Chromium', 'Chrome', 'Brave', 'Brave Origin', 'Edge', 'Firefox', 'Zen'],
browser: ['Chromium', 'Ungoogled Chromium', 'Helium', 'Chrome', 'Brave', 'Brave Origin', 'Edge', 'Firefox', 'Zen'],
terminal: ['Alacritty', 'Foot', 'Ghostty', 'Kitty'],
editor: ['Neovim', 'VSCode', 'Cursor', 'Zed', 'Sublime Text', 'Helix', 'Vim', 'Emacs']
}
Expand Down