-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 49485de
Showing
11 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nasa-apod-background.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
nasa-apod-background.deb: $(wildcard src/**/*) | ||
dpkg-deb --root-owner-group --build ./src nasa-apod-background.deb | ||
|
||
clean: | ||
rm -f nasa-apod-background.deb | ||
.PHONY: clean | ||
|
||
configure: | ||
|
||
.PHONY: configure | ||
|
||
install: nasa-apod-background.deb | ||
apt-get install --reinstall ./nasa-apod-background.deb | ||
.PHONY: install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh -e | ||
|
||
. /usr/share/debconf/confmodule | ||
|
||
db_input critical nasa-apod-background/api_key || : | ||
db_go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Package: nasa-apod-background | ||
Version: 1.0.0 | ||
Maintainer: Shamus <[email protected]> | ||
Description: Automatically set your background to the NASA picture of the day | ||
Homepage: https://github.com/Shamus03/nasa-apod-background | ||
Architecture: all | ||
Depends: curl, debconf (>= 0.2.17), fish, imagemagick, jp, logrotate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh -e | ||
|
||
. /usr/share/debconf/confmodule | ||
|
||
db_get nasa-apod-background/api_key | ||
|
||
mkdir -p /opt/nasa-apod-background | ||
printf '%s' "$RET" > /opt/nasa-apod-background/api.key | ||
|
||
/usr/bin/fish /opt/nasa-apod-background/nasa-apod-background.fish | ||
|
||
pid="$(pgrep gnome-session)" | ||
export DBUS_SESSION_BUS_ADDRESS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$pid/environ | cut -d= -f2-)" | ||
|
||
gsettings set org.gnome.desktop.background picture-uri file:///opt/nasa-apod-background/apod_desktop.jpg | ||
gsettings set org.gnome.desktop.background picture-options wallpaper | ||
gsettings set org.gnome.desktop.screensaver picture-uri file:///opt/nasa-apod-background/apod_lock.jpg | ||
gsettings set org.gnome.desktop.screensaver picture-options wallpaper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh -e | ||
|
||
if [ "$1" = "purge" -a -e /usr/share/debconf/confmodule ]; then | ||
. /usr/share/debconf/confmodule | ||
db_purge | ||
fi | ||
|
||
rm -rf /opt/nasa-apod-background |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Template: nasa-apod-background/api_key | ||
Type: string | ||
Description: Enter your NASA API key. Get one from https://api.nasa.gov/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
0 * * * * root /usr/bin/fish /opt/nasa-apod-background/nasa-apod-background.fish >> /opt/nasa-apod-background/cron.log 2>&1 | ||
1 * * * * root logrotate -s /opt/nasa-apod-background/logrotate.status /opt/nasa-apod-background/logrotate.config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/opt/nasa-apod-background/cron.log { | ||
rotate 2 | ||
olddir oldlogs | ||
createolddir | ||
dateext | ||
size 100k | ||
create | ||
nocompress | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/fish | ||
|
||
argparse --name=nasa-apod-background 'f/force' -- $argv | ||
or return | ||
|
||
set config_dir /opt/nasa-apod-background | ||
set date_file $config_dir/date.txt | ||
set api_key_file $config_dir/api.key | ||
|
||
set img_full $config_dir/apod_full.jpg | ||
set img_desktop $config_dir/apod_desktop.jpg | ||
set img_lock $config_dir/apod_lock.jpg | ||
|
||
if not test -f $api_key_file | ||
echo "Api key not found - please create a file $api_key_file containing your NASA API key" | ||
exit 1 | ||
end | ||
set api_key (cat $api_key_file) | ||
|
||
set apod (curl -s "https://api.nasa.gov/planetary/apod?api_key=$api_key") | ||
set apod_url (echo $apod | jp -u url) | ||
set apod_hdurl (echo $apod | jp -u hdurl) | ||
set apod_explanation (echo $apod | jp -u explanation) | ||
set apod_date (echo $apod | jp -u date) | ||
|
||
set last_downloaded_date (cat $date_file 2>/dev/null) | ||
|
||
if string length -- $_flag_force; or test "$apod_date" != "$last_downloaded_date" | ||
rm -f $date_file | ||
if not wget -O $img_full $apod_hdurl | ||
echo "HD image not found: $apod_hdurl" | ||
echo "Will download low quality version" | ||
wget -O $img_full $apod_url | ||
end | ||
|
||
# Resize full image to fit screen | ||
and convert -background black -resize 1920 -extent 1920x1080 -gravity center -quiet $img_full $img_desktop | ||
|
||
# Create captioned image for lock screen | ||
and convert $img_desktop \( -background none -size 1920x -fill white -undercolor black -pointsize 20 caption:(string replace --all "'" "\'" $apod_explanation) \) -gravity southwest -compose over -composite $img_lock | ||
|
||
and echo $apod_date > $date_file | ||
end | ||
|
22 changes: 22 additions & 0 deletions
22
src/usr/share/gnome-background-properties/nasa-apod-background.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd"> | ||
<wallpapers> | ||
<wallpaper deleted="false"> | ||
<name>NASA APOD</name> | ||
<name xml:lang="en">NASA APOD</name> | ||
<filename>/opt/nasa-apod-background/apod_desktop.jpg</filename> | ||
<options>zoom</options> | ||
<shade_type>solid</shade_type> | ||
<pcolor>#ffffff</pcolor> | ||
<scolor>#000000</scolor> | ||
</wallpaper> | ||
<wallpaper deleted="false"> | ||
<name>NASA APOD (captioned)</name> | ||
<name xml:lang="en">NASA APOD (captioned)</name> | ||
<filename>/opt/nasa-apod-background/apod_lock.jpg</filename> | ||
<options>zoom</options> | ||
<shade_type>solid</shade_type> | ||
<pcolor>#ffffff</pcolor> | ||
<scolor>#000000</scolor> | ||
</wallpaper> | ||
</wallpapers> |