You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过终端自动抓取网站图片并更新桌面壁纸?

Automatically Set Your Observatory's Clear Sky Chart as Desktop Wallpaper (No C/Advanced Command Line Needed)

Hey Tom, I feel your pain—manually updating that wallpaper multiple times a day is such a tedious distraction when you’re focused on astronomy work. Let’s walk through simple, OS-specific solutions that require zero C language skills and minimal command line effort:

Windows Solution

We’ll use a PowerShell script (built right into Windows, no extra software needed) and Task Scheduler to handle auto-updates:

  1. Grab the direct image URL:

    • Open your clear sky chart page, right-click the actual weather graph, and select Copy image address. For your Yerkes Observatory link, this should be something like http://www.cleardarksky.com/c/YerkesObILc.gif.
  2. Create the PowerShell script:

    • Open Notepad, paste the code below, replace YOUR_IMAGE_URL with the copied address, then save it as Set-ClearSkyWallpaper.ps1 (make sure to select "All Files" as the save type to avoid a .txt extension):
    # Download the latest clear sky chart to your temp folder
    $imagePath = "$env:TEMP\ClearSkyChart.gif"
    Invoke-WebRequest -Uri "YOUR_IMAGE_URL" -OutFile $imagePath
    
    # Set the image as desktop wallpaper (using fill mode)
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name Wallpaper -Value $imagePath
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name WallpaperStyle -Value 10 # 10=Fill, 6=Stretch, 0=Center
    Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name TileWallpaper -Value 0
    # Force wallpaper update
    RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 1, True
    
  3. Schedule automatic runs with Task Scheduler:

    • Open Task Scheduler → Create Basic Task
    • Name it "Update Clear Sky Wallpaper", set a trigger (e.g., every hour, or specific times of day when you need frequent updates)
    • For the action, select Start a program, enter powershell.exe as the program/script, and add -ExecutionPolicy Bypass -File "C:\Path\To\Your\Set-ClearSkyWallpaper.ps1" as arguments (replace the path with where you saved the script)
    • Finish the wizard, and your wallpaper will refresh automatically on schedule!

macOS Solution

We’ll use a simple shell script and either Calendar or a LaunchAgent to handle auto-updates:

  1. Grab the direct image URL (same step as Windows above).

  2. Create the shell script:

    • Open TextEdit, go to Format → Make Plain Text, paste the code below, replace YOUR_IMAGE_URL with the copied address, then save it as update-wallpaper.sh:
    #!/bin/bash
    IMAGE_PATH="$HOME/Documents/ClearSkyChart.gif"
    # Download the latest chart
    curl -o "$IMAGE_PATH" "YOUR_IMAGE_URL"
    # Set as desktop wallpaper (works for macOS 10.14+)
    osascript -e 'tell application "System Events" to set picture of every desktop to POSIX file "'"$IMAGE_PATH"'"'
    
    • Open Terminal, run chmod +x ~/Documents/update-wallpaper.sh to make the script executable.
  3. Schedule automatic runs:

    • Option 1 (Super Easy): Use Calendar app
      • Create a new event, set the repeat interval (e.g., every hour)
      • Under "Alert", select Custom, then Open file, and choose your update-wallpaper.sh script
    • Option 2 (More Reliable): Use LaunchAgent
      • Create a file named com.yourname.clearskywallpaper.plist in ~/Library/LaunchAgents/ with the code below (replace paths with your username/script location):
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
            <key>Label</key>
            <string>com.yourname.clearskywallpaper</string>
            <key>ProgramArguments</key>
            <array>
                <string>/Users/YourUsername/Documents/update-wallpaper.sh</string>
            </array>
            <key>StartInterval</key>
            <integer>3600</integer> <!-- Runs every 3600 seconds (1 hour) -->
            <key>RunAtLoad</key>
            <true/>
        </dict>
        </plist>
        
      • Run launchctl load ~/Library/LaunchAgents/com.yourname.clearskywallpaper.plist in Terminal to activate it.

Linux Solution (GNOME/KDE)

Most Linux desktops have built-in commands to set wallpapers—we’ll use a shell script and cron for scheduling:

For GNOME (Ubuntu, Fedora, etc.)

  1. Grab the direct image URL.
  2. Create the script:
    • Open a text editor, paste the code below, save as update-wallpaper.sh in your Pictures folder:
    #!/bin/bash
    IMAGE_PATH="$HOME/Pictures/ClearSkyChart.gif"
    wget -O "$IMAGE_PATH" "YOUR_IMAGE_URL"
    # Set as wallpaper with zoom mode
    gsettings set org.gnome.desktop.background picture-uri "file://$IMAGE_PATH"
    gsettings set org.gnome.desktop.background picture-options 'zoom' # Options: 'none', 'centered', 'stretched', 'zoom'
    
    • Make it executable: chmod +x ~/Pictures/update-wallpaper.sh
  3. Schedule with cron:
    • Run crontab -e in Terminal, add a line like:
      0 * * * * /home/YourUsername/Pictures/update-wallpaper.sh
      
      This runs the script every hour (adjust the timing as needed—0 * * * * means top of every hour).

For KDE

Replace the GNOME gsettings lines in the script with this command to set the wallpaper for all KDE desktops:

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '
var allDesktops = desktops();
for (i=0;i<allDesktops.length;i++) {
    d = allDesktops[i];
    d.wallpaperPlugin = "org.kde.image";
    d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");
    d.writeConfig("Image", "file://'"$IMAGE_PATH"'");
}
'

内容的提问来源于stack exchange,提问作者Tom Sachen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:25:50