mirror of
https://github.com/LukeHagar/omarchy.git
synced 2025-12-06 12:37:46 +00:00
Add Chrome and Brave browser policy support for theme colors (#1251)
* Add Chrome and Brave browser policy support for theme colors Replace chromium --set-theme-color commands with managed policies - Add RGB to hex conversion function - Create /etc/chromium/policies/managed/color.json for Chrome - Create /etc/brave/policies/managed/color.json for Brave - Remove deprecated chromium command line theme setting * force reload * remove sudo * renamed flag due to code review on google side * Add the required directories * Cleanup * Slim down * Unnecessary --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy-theme-set: Set a theme, specified by its name.
|
if [[ -z $1 && $1 != "CNCLD" ]]; then
|
||||||
# Usage: omarchy-theme-set <theme-name>
|
echo "Usage: omarchy-theme-set <theme-name>"
|
||||||
|
|
||||||
if [[ -z "$1" && "$1" != "CNCLD" ]]; then
|
|
||||||
echo "Usage: omarchy-theme-set <theme-name>" >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -16,8 +13,8 @@ THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
|||||||
|
|
||||||
# Check if the theme entered exists
|
# Check if the theme entered exists
|
||||||
if [[ ! -d "$THEME_PATH" ]]; then
|
if [[ ! -d "$THEME_PATH" ]]; then
|
||||||
echo "Theme '$THEME_NAME' does not exist in $THEMES_DIR" >&2
|
echo "Theme '$THEME_NAME' does not exist in $THEMES_DIR"
|
||||||
exit 2
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update theme symlinks
|
# Update theme symlinks
|
||||||
@@ -39,19 +36,24 @@ else
|
|||||||
gsettings set org.gnome.desktop.interface icon-theme "Yaru-blue"
|
gsettings set org.gnome.desktop.interface icon-theme "Yaru-blue"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change Chromium colors
|
# Change browser colors via policies
|
||||||
if command -v chromium &>/dev/null; then
|
if omarchy-cmd-present chromium || omarchy-cmd-present brave; then
|
||||||
if [[ -f ~/.config/omarchy/current/theme/light.mode ]]; then
|
|
||||||
chromium --no-startup-window --set-color-scheme="light"
|
|
||||||
else
|
|
||||||
chromium --no-startup-window --set-color-scheme="dark"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f ~/.config/omarchy/current/theme/chromium.theme ]]; then
|
if [[ -f ~/.config/omarchy/current/theme/chromium.theme ]]; then
|
||||||
chromium --no-startup-window --set-theme-color="$(<~/.config/omarchy/current/theme/chromium.theme)"
|
rgb=$(<~/.config/omarchy/current/theme/chromium.theme)
|
||||||
|
THEME_HEX_COLOR=$(printf '#%02x%02x%02x' ${rgb//,/ })
|
||||||
else
|
else
|
||||||
# Use a default, neutral grey if theme doesn't have a color
|
# Use a default, neutral grey if theme doesn't have a color
|
||||||
chromium --no-startup-window --set-theme-color="28,32,39"
|
THEME_HEX_COLOR="#1c2027"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if omarchy-cmd-present chromium; then
|
||||||
|
echo "{\"BrowserThemeColor\": \"$THEME_HEX_COLOR\"}" | tee "/etc/chromium/policies/managed/color.json" >/dev/null
|
||||||
|
chromium --refresh-platform-policy --no-startup-window
|
||||||
|
fi
|
||||||
|
|
||||||
|
if omarchy-cmd-present brave; then
|
||||||
|
echo "{\"BrowserThemeColor\": \"$THEME_HEX_COLOR\"}" | tee "/etc/brave/policies/managed/color.json" >/dev/null
|
||||||
|
brave --refresh-platform-policy --no-startup-window
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -19,3 +19,10 @@ ln -snf ~/.config/omarchy/current/theme/btop.theme ~/.config/btop/themes/current
|
|||||||
|
|
||||||
mkdir -p ~/.config/mako
|
mkdir -p ~/.config/mako
|
||||||
ln -snf ~/.config/omarchy/current/theme/mako.ini ~/.config/mako/config
|
ln -snf ~/.config/omarchy/current/theme/mako.ini ~/.config/mako/config
|
||||||
|
|
||||||
|
# Add managed policy directories for Chromium and Brave for theme changes
|
||||||
|
sudo mkdir -p /etc/chromium/policies/managed
|
||||||
|
sudo chmod a+rw /etc/chromium/policies/managed
|
||||||
|
|
||||||
|
sudo mkdir -p /etc/brave/policies/managed
|
||||||
|
sudo chmod a+rw /etc/brave/policies/managed
|
||||||
|
|||||||
7
migrations/1757147211.sh
Normal file
7
migrations/1757147211.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
echo "Create managed policy directories for Chromium and Brave for theme switching"
|
||||||
|
|
||||||
|
sudo mkdir -p /etc/chromium/policies/managed
|
||||||
|
sudo chmod a+rw /etc/chromium/policies/managed
|
||||||
|
|
||||||
|
sudo mkdir -p /etc/brave/policies/managed
|
||||||
|
sudo chmod a+rw /etc/brave/policies/managed
|
||||||
Reference in New Issue
Block a user