豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Sandith-WGK/dynamic-weather-wallpaper

Repository files navigation

Dynamic Weather Wallpaper

A Python application that automatically changes your desktop wallpaper based on current weather conditions. The app downloads beautiful nature landscape images from Unsplash that match the current weather and overlays weather information on them.

Features

  • 🌤️ Real-time Weather Integration: Uses WeatherAPI.com to get current weather data
  • 🖼️ Dynamic Image Downloads: Fetches relevant landscape images from Unsplash
  • 📍 Weather Overlay: Displays temperature, condition, and location on wallpapers
  • 🔄 Automatic Updates: Changes wallpaper every 10 minutes when weather changes
  • 🧹 Smart Cleanup: Automatically removes old images to save disk space
  • Multi-threaded: Efficient background operation with graceful shutdown

Prerequisites

  • Python 3.7 or higher
  • Windows OS (wallpaper changing functionality)
  • Internet connection for weather and image APIs

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/dynamic-weather-wallpaper.git
    cd dynamic-weather-wallpaper
  2. Create a virtual environment:

    python -m venv venv
    venv\Scripts\activate  # On Windows
  3. Install dependencies:

    # Option 1: Use the setup script (recommended)
    python setup.py
    
    # Option 2: Manual installation
    pip install -r requirements.txt
  4. Set up API keys:

    • Get a free API key from WeatherAPI.com
    • Get a free API key from Unsplash
    • Copy env.example to .env and fill in your API keys:
    copy env.example .env
    • Edit .env file with your actual API keys and preferences

Usage

  1. Configure your settings in the .env file (see Installation step 4)

  2. Run the application:

    python main.py
  3. The app will:

    • Check current weather every 10 minutes
    • Download relevant landscape images
    • Add weather overlay to images
    • Change your desktop wallpaper automatically
  4. To stop the application: Press Ctrl+C for graceful shutdown

Configuration

You can customize the application by modifying these settings in main.py:

  • Update frequency: Change the delay parameter (default: 600 seconds)
  • Overlay position: Use set_position() method ('top-right', 'top-left', 'bottom-right', 'bottom-left')
  • Font size: Use set_font_size() method
  • Colors: Use set_colors() method for text and shadow colors

Project Structure

dynamic-weather-wallpaper/
├── main.py                 # Main application entry point
├── weather_check.py        # Weather API integration
├── image_downloader.py     # Unsplash image downloading
├── weather_overlay.py      # Weather information overlay
├── changeWallpaper.py      # Desktop wallpaper management
├── config.py              # Configuration management
├── requirements.txt        # Python dependencies
├── setup.py               # Setup script
├── README.md              # This file
├── LICENSE                # MIT License
├── .gitignore             # Git ignore rules
├── env.example            # Environment variables template
├── .env                   # API keys and configuration (create from env.example)
└── images/                # Downloaded wallpaper images

API Requirements

WeatherAPI.com

  • Free tier: 1,000,000 calls per month
  • Rate limit: 1 call per second
  • Sign up: WeatherAPI.com

Unsplash

  • Free tier: 5,000 requests per hour
  • Rate limit: 50 requests per hour
  • Sign up: Unsplash Developers

Troubleshooting

Common Issues

  1. "API key not found" error:

    • Ensure your .env file exists and contains valid API keys
    • Check that API keys are complete (not truncated)
  2. "Failed to change wallpaper" error:

    • Ensure you're running on Windows
    • Check that image files exist and are accessible
    • Run as administrator if needed
  3. "Weather API request failed" error:

    • Check your internet connection
    • Verify your WeatherAPI key is valid
    • Ensure the city name is correct
  4. "Failed to get image from Unsplash" error:

    • Check your internet connection
    • Verify your Unsplash access key is valid
    • Check if you've exceeded rate limits

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

A Python application that automatically changes desktop wallpaper based on current weather conditions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages