mirror of
https://github.com/basecamp/omarchy.git
synced 2025-07-27 12:19:24 +00:00
Fixup and tuneup
This commit is contained in:
@ -1,24 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy-theme-install: Install a new theme from a git repo for Omarchy
|
# omarchy-theme-install: Install a new theme from a git repo for Omarchy
|
||||||
# Usage: omarchy-theme-install <git-repo-url>
|
# Usage: omarchy-theme-install <git-repo-url>
|
||||||
|
|
||||||
REPO_URL="$1"
|
|
||||||
THEMES_DIR="$HOME/.config/omarchy/themes"
|
|
||||||
THEME_NAME=$(basename "$REPO_URL" .git)
|
|
||||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
|
||||||
BACKGROUND_DIR="$HOME/.config/omarchy/backgrounds"
|
|
||||||
CURRENT_DIR="$HOME/.config/omarchy/current"
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Usage: omarchy-theme-install <git-repo-url>"
|
echo "Usage: omarchy-theme-install <git-repo-url>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure theme directories exist
|
REPO_URL="$1"
|
||||||
mkdir -p "$THEMES_DIR" "$BACKGROUND_DIR" "$CURRENT_DIR"
|
THEMES_DIR="$HOME/.config/omarchy/themes"
|
||||||
|
THEME_NAME=$(basename "$REPO_URL" .git)
|
||||||
|
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||||
|
THEME_BACKGROUND_PATH="$THEME_PATH/backgrounds"
|
||||||
|
BACKGROUNDS_PATH="$HOME/.config/omarchy/backgrounds"
|
||||||
|
BACKGROUNDS_THEME_PATH="$BACKGROUNDS_PATH/$THEME_NAME"
|
||||||
|
|
||||||
# Remove existing theme if present
|
# Remove existing theme if present
|
||||||
if [ -d "$THEME_PATH" ]; then
|
if [ -d "$THEME_PATH" ]; then
|
||||||
@ -32,15 +28,11 @@ if ! git clone "$REPO_URL" "$THEME_PATH"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy backgrounds if present
|
# Copy backgrounds if present
|
||||||
if [ -d "$THEME_PATH/backgrounds" ]; then
|
if [ -d $THEME_BACKGROUND_PATH ]; then
|
||||||
DEST_BG="$BACKGROUND_DIR/$THEME_NAME"
|
mkdir -p $BACKGROUNDS_THEME_PATH
|
||||||
rm -rf "$DEST_BG"
|
cp $THEME_BACKGROUND_PATH/* $BACKGROUNDS_THEME_PATH/
|
||||||
mkdir -p "$DEST_BG"
|
|
||||||
cp -r "$THEME_PATH/backgrounds/." "$DEST_BG/"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply the new theme with omarchy-theme-set
|
# Apply the new theme with omarchy-theme-set
|
||||||
"$HOME/.local/share/omarchy/bin/omarchy-theme-set" "$THEME_NAME"
|
omarchy-theme-set $THEME_NAME
|
||||||
|
|
||||||
# Notify of the new theme
|
|
||||||
notify-send "Theme changed to $THEME_NAME" -t 2000
|
|
@ -3,6 +3,11 @@
|
|||||||
# omarchy-theme-remove: Remove a theme from Omarchy by name
|
# omarchy-theme-remove: Remove a theme from Omarchy by name
|
||||||
# Usage: omarchy-theme-remove <theme-name>
|
# Usage: omarchy-theme-remove <theme-name>
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: omarchy-theme-remove <theme-name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
THEME_NAME="$1"
|
THEME_NAME="$1"
|
||||||
THEMES_DIR="$HOME/.config/omarchy/themes"
|
THEMES_DIR="$HOME/.config/omarchy/themes"
|
||||||
BACKGROUND_DIR="$HOME/.config/omarchy/backgrounds"
|
BACKGROUND_DIR="$HOME/.config/omarchy/backgrounds"
|
||||||
@ -11,43 +16,18 @@ CURRENT_DIR="$HOME/.config/omarchy/current"
|
|||||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||||
BACKGROUND_PATH="$BACKGROUND_DIR/$THEME_NAME"
|
BACKGROUND_PATH="$BACKGROUND_DIR/$THEME_NAME"
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "Usage: omarchy-theme-remove <theme-name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Count available themes (directories in ~/.config/omarchy/themes)
|
|
||||||
THEMES=($(find "$THEMES_DIR" -mindepth 1 -maxdepth 1 -type d | sort))
|
|
||||||
if [ ${#THEMES[@]} -le 1 ]; then
|
|
||||||
echo "Error: Cannot remove the last remaining theme. At least one theme must be installed."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if theme exists before attempting removal
|
# Check if theme exists before attempting removal
|
||||||
if [ ! -d "$THEME_PATH" ]; then
|
if [ ! -d "$THEME_PATH" ]; then
|
||||||
echo "Error: Theme '$THEME_NAME' not found."
|
echo "Error: Theme '$THEME_NAME' not found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the theme to be removed is the current theme
|
|
||||||
IS_CURRENT=0
|
|
||||||
# Use readlink -f to resolve symlinks and get the absolute path
|
# Use readlink -f to resolve symlinks and get the absolute path
|
||||||
if [ "$(readlink -f "$CURRENT_DIR/theme")" = "$(readlink -f "$THEME_PATH")" ]; then
|
if [ "$(readlink -f "$CURRENT_DIR/theme")" = "$(readlink -f "$THEME_PATH")" ]; then
|
||||||
IS_CURRENT=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If it is, switch to the next theme before removing
|
|
||||||
if [ $IS_CURRENT -eq 1 ]; then
|
|
||||||
"$HOME/.local/share/omarchy/bin/omarchy-theme-next"
|
"$HOME/.local/share/omarchy/bin/omarchy-theme-next"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Now remove the theme directory and backgrounds for THEME_NAME
|
# Now remove the theme directory and backgrounds for THEME_NAME
|
||||||
rm -rf "$THEME_PATH"
|
rm -rf "$THEME_PATH"
|
||||||
|
rm -rf "$BACKGROUND_PATH"
|
||||||
|
|
||||||
if [ -d "$BACKGROUND_PATH" ]; then
|
|
||||||
rm -rf "$BACKGROUND_PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
notify-send "Theme '$THEME_NAME' removed." -t 2000
|
|
Reference in New Issue
Block a user