Compare commits
7 commits
3fac68a8d7
...
a1aef0ef79
| Author | SHA1 | Date | |
|---|---|---|---|
| a1aef0ef79 | |||
| ae0fecf014 | |||
| f5eb2ff1ac | |||
| 1b03164a31 | |||
| e68569bc81 | |||
| 4645874c82 | |||
| 2acc9755e0 |
4 changed files with 63 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ DEB_PKGS=(
|
||||||
alsa-utils
|
alsa-utils
|
||||||
audacity
|
audacity
|
||||||
avahi-daemon
|
avahi-daemon
|
||||||
|
awscli
|
||||||
bluez
|
bluez
|
||||||
borgbackup
|
borgbackup
|
||||||
build-essential
|
build-essential
|
||||||
|
|
@ -27,6 +28,7 @@ DEB_PKGS=(
|
||||||
fuzzel
|
fuzzel
|
||||||
gdb
|
gdb
|
||||||
gnumeric
|
gnumeric
|
||||||
|
go-staticcheck
|
||||||
gopls
|
gopls
|
||||||
graphviz
|
graphviz
|
||||||
grim
|
grim
|
||||||
|
|
|
||||||
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