first commit
This commit is contained in:
Executable
+127
@@ -0,0 +1,127 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
HOME_DIR="$(eval echo ~$(whoami))"
|
||||
|
||||
echo "=== Omarchy Config Installer ==="
|
||||
echo ""
|
||||
echo "Installing for user: $(whoami)"
|
||||
echo "Home directory: $HOME_DIR"
|
||||
echo ""
|
||||
|
||||
# Function to backup and copy
|
||||
backup_and_copy() {
|
||||
local src="$1"
|
||||
local dest="$2"
|
||||
local name="$3"
|
||||
|
||||
if [ -e "$dest" ]; then
|
||||
echo "Backing up existing $name..."
|
||||
mkdir -p "$dest.bak.$TIMESTAMP"
|
||||
cp -r "$dest"/* "$dest.bak.$TIMESTAMP/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "Copying $name..."
|
||||
mkdir -p "$(dirname "$dest")"
|
||||
cp -r "$src"/* "$dest"/
|
||||
}
|
||||
|
||||
# Backup and copy waybar config
|
||||
backup_and_copy "$SCRIPT_DIR/waybar" "$HOME_DIR/.config/waybar" "Waybar config"
|
||||
|
||||
# Backup and copy branding
|
||||
backup_and_copy "$SCRIPT_DIR/branding" "$HOME_DIR/.config/omarchy/branding" "Branding files"
|
||||
|
||||
# Copy scripts to ~/scripts/
|
||||
mkdir -p "$HOME_DIR/scripts"
|
||||
backup_and_copy "$SCRIPT_DIR/scripts" "$HOME_DIR/scripts" "Custom scripts"
|
||||
|
||||
# Create omarchy-style command wrappers in ~/.local/bin
|
||||
create_command_wrappers() {
|
||||
local bin_dir="$HOME_DIR/.local/bin"
|
||||
local scripts_dir="$HOME_DIR/scripts"
|
||||
mkdir -p "$bin_dir"
|
||||
|
||||
for script in "$SCRIPT_DIR/scripts"/*.sh; do
|
||||
if [ -f "$script" ]; then
|
||||
local base_name=$(basename "$script" .sh)
|
||||
local wrapper_name="$base_name"
|
||||
local wrapper_path="$bin_dir/$wrapper_name"
|
||||
|
||||
cat > "$wrapper_path" <<EOF
|
||||
#!/bin/bash
|
||||
# Blob-Config command: $base_name
|
||||
# Generated by install.sh
|
||||
|
||||
SCRIPT_DIR="$scripts_dir"
|
||||
"\$SCRIPT_DIR/$base_name.sh" "\$@"
|
||||
EOF
|
||||
chmod +x "$wrapper_path"
|
||||
echo "Created command: $wrapper_name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
create_command_wrappers
|
||||
|
||||
# Add ~/scripts to system-wide PATH (available to all users/shells)
|
||||
add_system_path() {
|
||||
local profile_script="/etc/profile.d/omarchy-scripts.sh"
|
||||
local path_line='export PATH="$HOME/scripts:$HOME/.local/bin:$PATH"'
|
||||
if [ ! -f "$profile_script" ]; then
|
||||
if echo "$path_line" | sudo tee "$profile_script" > /dev/null 2>&1; then
|
||||
sudo chmod 644 "$profile_script"
|
||||
echo "Added system-wide PATH in /etc/profile.d/"
|
||||
else
|
||||
echo "Skipped system PATH (no sudo available)"
|
||||
fi
|
||||
else
|
||||
echo "System PATH already configured"
|
||||
fi
|
||||
}
|
||||
|
||||
add_system_path
|
||||
|
||||
# Also add to user's shell rc files for immediate effect
|
||||
add_path_to_shell() {
|
||||
local shell_rc="$1"
|
||||
local path_line='export PATH="$HOME/scripts:$HOME/.local/bin:$PATH"'
|
||||
|
||||
if [ -f "$shell_rc" ]; then
|
||||
if ! grep -q 'scripts' "$shell_rc" 2>/dev/null; then
|
||||
echo "" >> "$shell_rc"
|
||||
echo "# Added by Omarchy-Config installer" >> "$shell_rc"
|
||||
echo "$path_line" >> "$shell_rc"
|
||||
echo "Added to $shell_rc"
|
||||
else
|
||||
echo "$path_line already in $shell_rc"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
add_path_to_shell "$HOME_DIR/.bashrc"
|
||||
add_path_to_shell "$HOME_DIR/.zshrc"
|
||||
|
||||
# Make scripts executable
|
||||
chmod +x "$HOME_DIR/scripts/"*.sh 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "=== Restarting Waybar ==="
|
||||
if command -v omarchy-restart-waybar &> /dev/null; then
|
||||
omarchy-restart-waybar
|
||||
else
|
||||
echo "Warning: omarchy-restart-waybar not found. Please restart waybar manually."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Installation Complete ==="
|
||||
echo "Scripts are in: $HOME_DIR/scripts/"
|
||||
echo "Custom commands available as: blob_<script-name>"
|
||||
echo ""
|
||||
echo "Example:"
|
||||
echo " blob_wifi"
|
||||
echo ""
|
||||
echo "To apply PATH changes, run: source ~/.bashrc (or ~/.zshrc)"
|
||||
Reference in New Issue
Block a user