Compare commits
6 commits
a1aef0ef79
...
3fac68a8d7
| Author | SHA1 | Date | |
|---|---|---|---|
| 3fac68a8d7 | |||
| d90c70b050 | |||
| 7cb6d3f92e | |||
| 83ddcb48fc | |||
| f4a86e2373 | |||
| 8beb5d8a98 |
4 changed files with 62 additions and 0 deletions
|
|
@ -87,6 +87,7 @@ DEB_PKGS=(
|
|||
xdg-desktop-portal-wlr
|
||||
xournalpp
|
||||
yt-dlp
|
||||
awscli
|
||||
zip
|
||||
# keep-sorted end
|
||||
)
|
||||
|
|
|
|||
10
.config/systemd/user/get-nasa-apod.service
Normal file
10
.config/systemd/user/get-nasa-apod.service
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Refresh the wallpaper using the NASA Astronomy Picture of the Day
|
||||
Wants=get-nasa-apod.timer
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=%h
|
||||
ExecStart=%h/.local/bin/get-nasa-apod
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
10
.config/systemd/user/get-nasa-apod.timer
Normal file
10
.config/systemd/user/get-nasa-apod.timer
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Daily NASA wallpaper fetch
|
||||
Requires=get-nasa-apod.service
|
||||
|
||||
[Timer]
|
||||
Unit=nasa-apod.service
|
||||
OnCalendar=daily
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
41
.local/bin/get-nasa-apod
Executable file
41
.local/bin/get-nasa-apod
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#! /usr/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
API_KEY="${NASA_API_KEY:-DEMO_KEY}"
|
||||
if [ "${API_KEY}" = "DEMO_KEY" ]; then
|
||||
echo "No API key set! using demo key."
|
||||
fi
|
||||
|
||||
WALLPAPERS="$(systemd-path user)"/Wallpapers
|
||||
|
||||
mkdir --parents "${WALLPAPERS}"
|
||||
|
||||
APOD_URL="https://api.nasa.gov/planetary/apod?api_key=${API_KEY}"
|
||||
response="$(curl --silent "${APOD_URL}")"
|
||||
picture_date="$(printf '%s' "${response}" | jq --raw-output .date)"
|
||||
picture_url="$(printf '%s' "${response}" | jq --raw-output .hdurl)"
|
||||
|
||||
extension="${picture_url##*.}"
|
||||
filename="${picture_date}.${extension}"
|
||||
outfile="${WALLPAPERS}/${filename}"
|
||||
|
||||
if [ -f "${outfile}" ]; then
|
||||
echo "Target file already exists"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tempfile="$(mktemp)"
|
||||
curl \
|
||||
--location \
|
||||
--output "${tempfile}" \
|
||||
--silent \
|
||||
"${picture_url}"
|
||||
mv "${tempfile}" "${outfile}"
|
||||
ln \
|
||||
--force \
|
||||
--symbolic \
|
||||
"${outfile}" \
|
||||
"${WALLPAPERS}/today"
|
||||
swaymsg reload
|
||||
Loading…
Add table
Add a link
Reference in a new issue