Skip to content

Script to install as KDE Plasma 6 day/night dynamic wallpapers #66

Description

@dylandhall

Hi guys, I wanted to use the standard KDE Plasma 6 dynamic wallpapers, so I made a script (can be added to the repository root as install_plasma6.sh - happy to do a PR with it if anyone wants it) to use all wallpapers with two images, and create the appropriate structure for dynamic wallpapers in KDE.

Script:

#!/bin/bash
#
# Convert Dynamic Wallpapers to KDE Plasma 6 packages
# Processes folders with exactly 2 images (day/night pairs)
# Requires: ImageMagick (for 'identify' command)
#

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SOURCE_DIR="$SCRIPT_DIR/Dynamic_Wallpapers"
OUTPUT_DIR="$HOME/.local/share/wallpapers"

# Check for ImageMagick
if ! command -v identify &> /dev/null; then
    echo "Error: ImageMagick is required but not installed."
    echo "Install with: sudo apt install imagemagick"
    exit 1
fi

# Create output directory
mkdir -p "$OUTPUT_DIR"

processed=0
skipped=0

# Process each subfolder
for folder in "$SOURCE_DIR"/*/; do
    [ -d "$folder" ] || continue
    
    folder_name=$(basename "$folder")
    
    # Skip Output folder if it exists
    [ "$folder_name" = "Output" ] && continue
    
    # Get image files (common formats)
    mapfile -t images < <(find "$folder" -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.webp" \) | sort)
    
    # Only process folders with exactly 2 images
    if [ "${#images[@]}" -ne 2 ]; then
        echo "✗ Skipped: $folder_name (${#images[@]} images, need 2)"
        ((skipped++))
        continue
    fi
    
    day_image="${images[0]}"
    night_image="${images[1]}"
    
    # Get dimensions using ImageMagick identify
    dimensions=$(identify -format "%wx%h" "$day_image" 2>/dev/null)
    if [ -z "$dimensions" ]; then
        echo "✗ Skipped: $folder_name (could not read image dimensions)"
        ((skipped++))
        continue
    fi
    
    # Get file extension from day image
    extension="${day_image##*.}"
    extension="${extension,,}"  # lowercase
    new_filename="${dimensions}.${extension}"
    
    # Create package structure
    package_dir="$OUTPUT_DIR/${folder_name}_Wallpaper"
    images_dir="$package_dir/contents/images"
    images_dark_dir="$package_dir/contents/images_dark"
    
    mkdir -p "$images_dir" "$images_dark_dir"
    
    # Copy and rename images
    cp "$day_image" "$images_dir/$new_filename"
    cp "$night_image" "$images_dark_dir/$new_filename"
    
    # Create metadata.json
    cat > "$package_dir/metadata.json" << EOF
{
    "KPackageStructure": "Wallpaper/Images",
    "KPlugin": {
        "Id": "$folder_name",
        "Name": "$folder_name",
        "ServiceTypes": ["Plasma/Wallpaper"]
    }
}
EOF
    
    echo "✓ Created: ${folder_name}_Wallpaper"
    ((processed++))
done

echo ""
echo "Done! Processed: $processed, Skipped: $skipped"
echo "Output: $OUTPUT_DIR"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions