#!/bin/bash # omarchy:summary=Remove a user-installed theme # omarchy:args=[theme-name] # omarchy:examples=omarchy theme remove "My Theme" if [[ -z $1 ]]; then mapfile -t extra_themes < <(find ~/.config/omarchy/themes -mindepth 1 -maxdepth 1 -type d ! -xtype l -printf '%f\n') if (( ${#extra_themes[@]} > 0 )); then mapfile -t extra_themes < <(printf '%s\n' "${extra_themes[@]}" | sort) THEME_NAME=$(omarchy-menu-select "$(omarchy-i18n theme.removeExtraTitle)" "${extra_themes[@]}" -- --width 520 --maxheight 520) else echo "No extra themes installed." exit 1 fi else THEME_NAME="$1" fi THEMES_DIR="$HOME/.config/omarchy/themes" # The name omarchy-theme-list shows (My Theme) finds its folder (my-theme) when no folder has that exact name. if [[ ! -d $THEMES_DIR/$THEME_NAME && ! -d $OMARCHY_PATH/themes/$THEME_NAME ]]; then THEME_NAME=$(echo "$THEME_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') fi THEME_PATH="$THEMES_DIR/$THEME_NAME" # Ensure a theme was set, and that the name cannot climb out of THEMES_DIR # on its way into the rm below. if [[ -z $THEME_NAME || $THEME_NAME == .* || $THEME_NAME == */* ]]; then exit 1 fi # Check if theme exists before attempting removal if [[ ! -d $THEME_PATH ]]; then if [[ -d $OMARCHY_PATH/themes/$THEME_NAME ]]; then echo "Error: Theme '$THEME_NAME' comes with Omarchy and cannot be removed." else echo "Error: Theme '$THEME_NAME' not found." fi exit 1 fi # Now remove the theme directory for THEME_NAME rm -rf "$THEME_PATH" omarchy-notification-send "$(omarchy-i18n theme.removed)" "$THEME_NAME" || true echo "Removed $THEME_NAME"