Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions bin/omarchy-icon-dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

ICON_URL="$1"
OUTPUT_PATH="$2"

if [[ -z "$ICON_URL" || -z "$OUTPUT_PATH" ]]; then
echo "Usage: omarchy-icon-dl <icon_url> <output_path>"
exit 1
fi

ICON_DIR="$(dirname "$OUTPUT_PATH")"
mkdir -p "$ICON_DIR"

# Extract extension from URL
EXT=$(echo "${ICON_URL##*.}" | sed 's/\?.*//' | tr '[:upper:]' '[:lower:]')
SOURCE_ICON="/tmp/icon_download_$$_${RANDOM}.${EXT}"

# Download icon
if curl -sL -o "$SOURCE_ICON" "$ICON_URL" 2>/dev/null; then
if [[ "$EXT" == "png" ]]; then
mv "$SOURCE_ICON" "$OUTPUT_PATH"
else
# Find largest resolution index for multi-resolution formats
LARGEST_IDX=$(magick identify "$SOURCE_ICON" 2>/dev/null | awk '{split($3, a, "x"); size=a[1]*a[2]; if(size>max){max=size; idx=NR-1}} END{print idx}')

# Convert to PNG
magick "$SOURCE_ICON[${LARGEST_IDX:-0}]" "$OUTPUT_PATH" 2>/dev/null || \
magick "$SOURCE_ICON[${LARGEST_IDX:-0}]" -flatten "$OUTPUT_PATH" 2>/dev/null || {
echo "Error: Could not convert icon to PNG."
rm -f "$SOURCE_ICON"
exit 1
}
rm -f "$SOURCE_ICON"
fi
else
echo "Error: Failed to download icon from $ICON_URL"
exit 1
fi
10 changes: 3 additions & 7 deletions bin/omarchy-tui-install
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [ "$#" -ne 4 ]; then
APP_NAME=$(gum input --prompt "Name> " --placeholder "My TUI")
APP_EXEC=$(gum input --prompt "Launch Command> " --placeholder "lazydocker or bash -c 'dust; read -n 1 -s'")
WINDOW_STYLE=$(gum choose --header "Window style" float tile)
ICON_URL=$(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)")
ICON_URL=$(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com")
else
APP_NAME="$1"
APP_EXEC="$2"
Expand All @@ -23,13 +23,9 @@ DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop"

if [[ ! "$ICON_URL" =~ ^https?:// ]] && [ -f "$ICON_URL" ]; then
ICON_PATH="$ICON_URL"
else
elif [[ "$ICON_URL" =~ ^https?:// ]]; then
ICON_PATH="$ICON_DIR/$APP_NAME.png"
mkdir -p "$ICON_DIR"
if ! curl -sL -o "$ICON_PATH" "$ICON_URL"; then
echo "Error: Failed to download icon."
exit 1
fi
omarchy-icon-dl "$ICON_URL" "$ICON_PATH" || exit 1
fi

if [[ $WINDOW_STYLE == "float" ]]; then
Expand Down
29 changes: 18 additions & 11 deletions bin/omarchy-webapp-install
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [ "$#" -lt 3 ]; then
if [ "$#" -lt 2 ]; then
echo -e "\e[32mLet's create a new web app you can start with the app launcher.\n\e[0m"
APP_NAME=$(gum input --prompt "Name> " --placeholder "My favorite web app")
APP_URL=$(gum input --prompt "URL> " --placeholder "https://example.com")
ICON_REF=$(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)")
ICON_REF=$(gum input --prompt "Icon URL> " --placeholder "URL or leave blank for auto-detection")
CUSTOM_EXEC=""
MIME_TYPES=""
INTERACTIVE_MODE=true
Expand All @@ -18,21 +18,28 @@ else
fi

# Ensure valid execution
if [[ -z "$APP_NAME" || -z "$APP_URL" || -z "$ICON_REF" ]]; then
echo "You must set app name, app URL, and icon URL!"
if [[ -z "$APP_NAME" || -z "$APP_URL" ]]; then
echo "You must set app name and app URL!"
exit 1
fi

# Refer to local icon or fetch remotely from URL
# Normalize APP_URL - add https:// if no protocol specified
if [[ ! "$APP_URL" =~ ^https?:// ]]; then
APP_URL="https://$APP_URL"
fi

# Auto-detect icon from google favicons if ICON_REF is empty
if [[ -z "$ICON_REF" ]]; then
DOMAIN=$(echo "$APP_URL" | sed -E 's#^https?://([^/]+).*#\1#')
ICON_REF="https://www.google.com/s2/favicons?domain=${DOMAIN}&sz=128"
fi

# Download and convert icon
ICON_DIR="$HOME/.local/share/applications/icons"

if [[ $ICON_REF =~ ^https?:// ]]; then
ICON_PATH="$ICON_DIR/$APP_NAME.png"
if curl -sL -o "$ICON_PATH" "$ICON_REF"; then
ICON_PATH="$ICON_DIR/$APP_NAME.png"
else
echo "Error: Failed to download icon."
exit 1
fi
omarchy-icon-dl "$ICON_REF" "$ICON_PATH" || exit 1
else
ICON_PATH="$ICON_DIR/$ICON_REF"
fi
Expand Down