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
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 Chromium, Chrome, Edge, Brave, and Zen
# omarchy:hidden=true

CHROMIUM_THEME=~/.config/omarchy/current/theme/chromium.theme
Expand Down Expand Up @@ -42,3 +42,4 @@ refresh_running_browser msedge microsoft-edge-stable
set_browser_policy /etc/brave/policies/managed
refresh_running_browser brave brave
refresh_running_browser brave-origin-beta brave-origin-beta -f
omarchy-theme-set-zen
175 changes: 175 additions & 0 deletions bin/omarchy-theme-set-zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#!/bin/bash

# omarchy:summary=Apply the current theme color to Zen browser
# omarchy:hidden=true
# omarchy:aliases=omarchy set-zen-theme

THEME_COLORS=~/.config/omarchy/current/theme/colors.toml
ZEN_CONFIG_DIR=~/.config/zen

read_theme_color() {
sed -n "s/^$1 = \"\([^\"]*\)\"$/\1/p" "$THEME_COLORS"
}

set_zen_theme() {
[[ -d $ZEN_CONFIG_DIR && -f $THEME_COLORS ]] || return

local background foreground accent cursor surface profile_dir chrome_dir omarchy_css user_chrome_css user_js
background=$(read_theme_color background)
foreground=$(read_theme_color foreground)
accent=$(read_theme_color accent)
cursor=$(read_theme_color cursor)
surface=$(read_theme_color color0)

[[ -n $background && -n $foreground && -n $accent && -n $cursor && -n $surface ]] || return

for profile_dir in "$ZEN_CONFIG_DIR"/*; do
[[ -f "$profile_dir/prefs.js" ]] || continue

chrome_dir="$profile_dir/chrome"
omarchy_css="$chrome_dir/omarchy-theme.css"
user_chrome_css="$chrome_dir/userChrome.css"
user_js="$profile_dir/user.js"

mkdir -p "$chrome_dir"

cat >"$omarchy_css" <<EOF
/* Generated by Omarchy */
:root {
color-scheme: dark !important;
--zen-primary-color: $background !important;
--zen-colors-primary: $background !important;
--zen-colors-secondary: $surface !important;
--lwt-accent-color: $background !important;
--lwt-text-color: $foreground !important;
--lwt-frame: $background !important;
--lwt-frame-inactive: $background !important;
--toolbar-bgcolor: $background !important;
--toolbar-color: $foreground !important;
--toolbar-field-background-color: $surface !important;
--toolbar-field-color: $cursor !important;
--toolbar-field-border-color: $accent !important;
--toolbar-field-focus-background-color: $surface !important;
--toolbar-field-focus-color: $cursor !important;
--toolbar-field-focus-border-color: $accent !important;
--tab-selected-bgcolor: $surface !important;
--tab-selected-textcolor: $cursor !important;
--tab-hover-background-color: color-mix(in srgb, $accent 16%, transparent) !important;
--toolbarbutton-hover-background: color-mix(in srgb, $accent 16%, transparent) !important;
--toolbarbutton-active-background: color-mix(in srgb, $accent 28%, transparent) !important;
--arrowpanel-background: $surface !important;
--arrowpanel-color: $foreground !important;
--arrowpanel-border-color: $accent !important;
--sidebar-background-color: $background !important;
--sidebar-text-color: $foreground !important;
--sidebar-border-color: $accent !important;
--newtab-background-color: $background !important;
--newtab-text-primary-color: $foreground !important;
}

#main-window,
#main-window::before,
#main-window::after,
#zen-sidebar-icons-wrapper,
#zen-sidebar-icons,
#zen-sidebar,
#zen-sidebar-panel,
#zen-vertical-tabs,
#zen-workspaces-button,
#browser,
#appcontent,
#tabbrowser-tabbox,
#tabbrowser-tabpanels,
#zen-appcontent-wrapper,
#navigator-toolbox,
#navigator-toolbox-background,
#nav-bar,
#TabsToolbar,
#titlebar,
#titlebar-spacer,
#zen-sidebar-top-buttons,
#zen-sidebar-foot-buttons,
#sidebar-box,
#zen-sidebar-web-panel-wrapper,
browser[type="content-primary"] {
background-color: $background !important;
color: $foreground !important;
}

#urlbar-background,
.searchbar-textbox {
background-color: $surface !important;
color: $cursor !important;
border-color: $accent !important;
}

#sidebar-box,
#sidebar-main,
#sidebar,
#sidebar-splitter,
#sidebar-splitter::before,
#sidebar-splitter::after,
#zen-sidebar-splitter,
#zen-sidebar-splitter::before,
#zen-sidebar-splitter::after,
.sidebar-splitter::before,
.sidebar-splitter::after,
.sidebar-splitter,
.zen-sidebar-splitter,
.zen-sidebar-splitter::before,
.zen-sidebar-splitter::after,
splitter,
splitter::before,
splitter::after {
border-right: 0 !important;
border-left: 0 !important;
box-shadow: none !important;
background-color: $background !important;
background: $background !important;
}

#zen-sidebar-icons-wrapper,
#zen-sidebar-icons,
#zen-sidebar,
#zen-sidebar-panel,
#zen-vertical-tabs {
background: $background !important;
background-color: $background !important;
}

splitter#zen-sidebar-splitter,
splitter#zen-sidebar-splitter:hover,
splitter#zen-sidebar-splitter::before,
splitter#zen-sidebar-splitter::after {
appearance: none !important;
border: 0 !important;
border-inline: 0 !important;
box-shadow: none !important;
outline: 0 !important;
opacity: 1 !important;
background: $background !important;
background-color: $background !important;
}
EOF

if [[ ! -f $user_chrome_css ]]; then
cat >"$user_chrome_css" <<'EOF'
@import url("omarchy-theme.css");
EOF
elif ! grep -Fq '@import url("omarchy-theme.css");' "$user_chrome_css"; then
printf '\n@import url("omarchy-theme.css");\n' >>"$user_chrome_css"
fi

if [[ ! -f $user_js ]] || ! grep -Fq 'toolkit.legacyUserProfileCustomizations.stylesheets' "$user_js"; then
cat >>"$user_js" <<'EOF'
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
EOF
fi
done

if pgrep -x zen-browser >/dev/null; then
omarchy-restart-app zen-browser
fi
}

set_zen_theme