GithubHelp home page GithubHelp logo

apod's Introduction

APOD Wallpaper

Warning

This script only works on macOS.

You can probably make it work on Linux by changing the osascript command to gsettings or feh or whatever you use to set your wallpaper.

I don't know how to make it work on Windows. ๐Ÿ’€

A TypeScript script to download the Astronomy Picture of the Day from NASA and set it as your wallpaper.

If there is not an image available for the current day, it will set a random image from the wallpapers directory as the wallpaper. (This can happen if the APOD is a video, for example.)

It also includes a Discord webhook integration to send the APOD to a Discord channel automatically.

Usage

  1. Clone the repository.
  2. Create a .env file with the following content:
    DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your/webhook/url # optional for Discord integration
    WALLPAPER_PATH=/path/to/your/wallpapers
  3. Install the dependencies with bun install.
  4. Run the script with bun run src/index.ts.

Automation (macOS)

If you're using a UNIX machine, you can probably use a cron job. However, it doesn't work when your machine is asleep.

This is where LaunchAgents are useful. They have similar functionality, but they also work when your macOS machine is asleep.

  1. Create a .plist file in ~/Library/LaunchAgents with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
       <key>Label</key>
       <!-- This should be the same as your file's name -->
       <string>com.example.wallpaper</string>
       <key>ProgramArguments</key>
       <array>
          <string>/bin/bash</string>
          <!-- You can change this to be in another folder if you want -->
          <string>change_wallpaper.sh</string>
       </array>
       <!-- StartCalendarInterval sets the script to run like a cron, but it also works when your macOS machine is asleep -->
       <key>StartCalendarInterval</key>
       <dict>
          <key>Hour</key>
          <integer>1</integer>
          <key>Minute</key>
          <integer>0</integer>
       </dict>
       <!-- RunAtLoad makes sure the task will start whenever you login to your macOS -->
       <key>RunAtLoad</key>
       <true />
    </dict>
    </plist>
  2. Create a change_wallpaper.sh file in your home directory with the following content:

    #!/bin/bash
    
    # Change the path to the script to wherever you cloned the repository
    cd "/path/to/your/repo"
    
    # Run the script using your local installation of bun
    # You can find the path by running `which bun` in your terminal
    # It most likely will be at /Users/YOUR_USER/.bun/bin/bun
    /path/to/your/bun run "src/index.ts"
  3. Load the LaunchAgent with launchctl load ~/Library/LaunchAgents/com.example.wallpaper.plist.

  4. Profit ๐Ÿ”ฅ

apod's People

Contributors

durocodes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.