Make blob_wallpaper.sh interactive
This commit is contained in:
@@ -8,12 +8,33 @@ mkdir -p "$WALLPAPER_DIR"
|
|||||||
mkdir -p "$THEME_DIR/backgrounds"
|
mkdir -p "$THEME_DIR/backgrounds"
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Usage: blob_wallpaper <filename-or-path>"
|
|
||||||
echo "Available wallpapers in $WALLPAPER_DIR:"
|
echo "Available wallpapers in $WALLPAPER_DIR:"
|
||||||
ls -1 "$WALLPAPER_DIR" 2>/dev/null || echo "No wallpapers found."
|
|
||||||
|
# Read files into an array
|
||||||
|
mapfile -t files < <(ls -1 "$WALLPAPER_DIR" 2>/dev/null)
|
||||||
|
|
||||||
|
if [ ${#files[@]} -eq 0 ]; then
|
||||||
|
echo "No wallpapers found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Print the menu
|
||||||
|
for i in "${!files[@]}"; do
|
||||||
|
printf "%3d. %s\n" "$((i+1))" "${files[$i]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
read -p "Select a wallpaper number (1-${#files[@]}): " selection
|
||||||
|
|
||||||
|
# Validate selection
|
||||||
|
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt "${#files[@]}" ]; then
|
||||||
|
echo "Invalid selection."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SELECTED_FILE="${files[$((selection-1))]}"
|
||||||
|
IMAGE_PATH=$(realpath "$WALLPAPER_DIR/$SELECTED_FILE")
|
||||||
|
else
|
||||||
# Check if the argument is a file in the wallpapers directory
|
# Check if the argument is a file in the wallpapers directory
|
||||||
if [ -f "$WALLPAPER_DIR/$1" ]; then
|
if [ -f "$WALLPAPER_DIR/$1" ]; then
|
||||||
IMAGE_PATH=$(realpath "$WALLPAPER_DIR/$1")
|
IMAGE_PATH=$(realpath "$WALLPAPER_DIR/$1")
|
||||||
@@ -24,6 +45,7 @@ else
|
|||||||
echo "Error: File '$1' does not exist in $WALLPAPER_DIR or as a valid path."
|
echo "Error: File '$1' does not exist in $WALLPAPER_DIR or as a valid path."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Extracting colors using Pywal..."
|
echo "Extracting colors using Pywal..."
|
||||||
wal -i "$IMAGE_PATH" -n -q 2> >(grep -v "deprecated in IMv7" >&2)
|
wal -i "$IMAGE_PATH" -n -q 2> >(grep -v "deprecated in IMv7" >&2)
|
||||||
|
|||||||
Reference in New Issue
Block a user