From 24e76a3b90c706cf34e2743050ed259725e1dc66 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 18 Oct 2025 16:11:49 +0200 Subject: [PATCH] Add hooks for theme set, font set, and post update (#2527) Ala git hooks --- bin/omarchy-font-set | 2 ++ bin/omarchy-hook | 14 ++++++++++++++ bin/omarchy-theme-set | 3 +++ bin/omarchy-update-perform | 1 + config/omarchy/hooks/font-set.sample | 7 +++++++ config/omarchy/hooks/post-update.sample | 7 +++++++ config/omarchy/hooks/theme-set.sample | 7 +++++++ 7 files changed, 41 insertions(+) create mode 100755 bin/omarchy-hook create mode 100644 config/omarchy/hooks/font-set.sample create mode 100644 config/omarchy/hooks/post-update.sample create mode 100644 config/omarchy/hooks/theme-set.sample diff --git a/bin/omarchy-font-set b/bin/omarchy-font-set index 5ac0ef4b..6cc312d0 100755 --- a/bin/omarchy-font-set +++ b/bin/omarchy-font-set @@ -28,6 +28,8 @@ if [[ -n "$font_name" && "$font_name" != "CNCLD" ]]; then omarchy-restart-waybar omarchy-restart-swayosd omarchy-restart-walker + + omarchy-hook font-set "$font_name" else echo "Font '$font_name' not found." exit 1 diff --git a/bin/omarchy-hook b/bin/omarchy-hook new file mode 100755 index 00000000..caa83988 --- /dev/null +++ b/bin/omarchy-hook @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ $# -lt 1 ]]; then + echo "Usage: omarchy-hook [name] [args...]" + exit 1 +fi + +HOOK=$1 +HOOK_PATH="$HOME/.config/omarchy/hooks/$1" +shift + +if [[ -f $HOOK_PATH ]]; then + bash "$HOOK_PATH" "$@" +fi diff --git a/bin/omarchy-theme-set b/bin/omarchy-theme-set index b729dee6..c90d11eb 100755 --- a/bin/omarchy-theme-set +++ b/bin/omarchy-theme-set @@ -39,3 +39,6 @@ omarchy-theme-set-browser omarchy-theme-set-vscode omarchy-theme-set-cursor omarchy-theme-set-obsidian + +# Call hook on theme set +omarchy-hook theme-set "$THEME_NAME" diff --git a/bin/omarchy-update-perform b/bin/omarchy-update-perform index f31e3c88..9e68a67b 100755 --- a/bin/omarchy-update-perform +++ b/bin/omarchy-update-perform @@ -5,4 +5,5 @@ set -e omarchy-update-available-reset omarchy-update-system-pkgs omarchy-migrate +omarchy-hook post-update omarchy-update-restart diff --git a/config/omarchy/hooks/font-set.sample b/config/omarchy/hooks/font-set.sample new file mode 100644 index 00000000..36d8c3ec --- /dev/null +++ b/config/omarchy/hooks/font-set.sample @@ -0,0 +1,7 @@ +#!/bin/bash + +# This hook is called with the snake-cased name of the font that has just been set. +# To put it into use, remove .sample from the name. + +# Example: Show the name of the theme that was just set. +# notify-send "New font" "Your new font is $1" diff --git a/config/omarchy/hooks/post-update.sample b/config/omarchy/hooks/post-update.sample new file mode 100644 index 00000000..486352e5 --- /dev/null +++ b/config/omarchy/hooks/post-update.sample @@ -0,0 +1,7 @@ +#!/bin/bash + +# This hook is called after an Omarchy system update has been performed. +# To put it into use, remove .sample from the name. + +# Example: Show notification after the system has been updated. +# notify-send "Update Performed" "Your system is now up to date" diff --git a/config/omarchy/hooks/theme-set.sample b/config/omarchy/hooks/theme-set.sample new file mode 100644 index 00000000..b2a5fe1d --- /dev/null +++ b/config/omarchy/hooks/theme-set.sample @@ -0,0 +1,7 @@ +#!/bin/bash + +# This hook is called with the snake-cased name of the theme that has just been set. +# To put it into use, remove .sample from the name. + +# Example: Show the name of the theme that was just set. +# notify-send "New theme" "Your new theme is $1"