realwallpaper: redesign with new image sources
This commit is contained in:
parent
4337f9dbce
commit
c76f161894
@ -17,21 +17,6 @@ let
|
|||||||
default = "/var/realwallpaper/";
|
default = "/var/realwallpaper/";
|
||||||
};
|
};
|
||||||
|
|
||||||
nightmap = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "http://eoimages.gsfc.nasa.gov/images/imagerecords/55000/55167/earth_lights_lrg.jpg";
|
|
||||||
};
|
|
||||||
|
|
||||||
daymap = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "https://www.nnvl.noaa.gov/images/globaldata/SnowIceCover_Daily.png";
|
|
||||||
};
|
|
||||||
|
|
||||||
cloudmap = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "http://home.megapass.co.kr/~holywatr/cloud_data/clouds_2048.jpg";
|
|
||||||
};
|
|
||||||
|
|
||||||
marker = mkOption {
|
marker = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "http://graph.r/marker.json";
|
default = "http://graph.r/marker.json";
|
||||||
@ -67,9 +52,6 @@ let
|
|||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
working_dir = cfg.workingDir;
|
working_dir = cfg.workingDir;
|
||||||
nightmap_url = cfg.nightmap;
|
|
||||||
daymap_url = cfg.daymap;
|
|
||||||
cloudmap_url = cfg.cloudmap;
|
|
||||||
marker_url = cfg.marker;
|
marker_url = cfg.marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,24 +17,28 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# usage: image_size FILENAME
|
# check if file exists and fetch only if missing
|
||||||
image_size() {
|
fetch_once() {
|
||||||
identify "$1" | awk '{print$3}'
|
name=$1
|
||||||
|
url=$2
|
||||||
|
test -e "$name" || fetch "$name" "$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
# usage: make_mask DST SRC MASK
|
fetch_older_min() {
|
||||||
make_layer() {
|
min=$1
|
||||||
if needs_rebuild "$@"; then
|
name=$2
|
||||||
echo "make $1 (apply mask)" >&2
|
url=$3
|
||||||
convert "$2" "$3" -alpha off -compose copy_opacity -composite "$1"
|
if ! test "$(find $name -mmin -$min)"; then
|
||||||
|
fetch "$name" "$url"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# usage: flatten DST HILAYER LOLAYER
|
fetch_older_days() {
|
||||||
flatten() {
|
days=$1
|
||||||
if needs_rebuild "$@"; then
|
name=$2
|
||||||
echo "make $1 (flatten)" >&2
|
url=$3
|
||||||
composite "$2" "$3" "$1"
|
if ! test "$(find $name -mmin -$days)"; then
|
||||||
|
fetch "$name" "$url"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,35 +64,36 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
return $result
|
return $result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_neo_url() {
|
||||||
|
url=$1
|
||||||
|
curl -Ss "$url" | grep '3600 x 1800' | sed 's/.*href="\([^"]*\)".*/\1/'
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
cd "$working_dir"
|
cd "$working_dir"
|
||||||
|
|
||||||
# fetch source images in parallel
|
# fetch source images in parallel
|
||||||
# fetch basic images which should not change
|
fetch_once sun-raw.png \
|
||||||
test -e nightmap-raw.jpg || fetch nightmap-raw.jpg "$nightmap_url" &
|
'http://simpleicon.com/wp-content/uploads/sun-64x64.png' &
|
||||||
test -e sun-raw.png || fetch sun-raw.png \
|
fetch_once moon-raw.png \
|
||||||
"http://simpleicon.com/wp-content/uploads/sun-64x64.png" &
|
'http://simpleicon.com/wp-content/uploads/moon__star-64x64.png' &
|
||||||
|
fetch_once nightmap-raw.jpg \
|
||||||
|
'https://eoimages.gsfc.nasa.gov/images/imagerecords/144000/144898/BlackMarble_2016_3km.jpg' &
|
||||||
|
fetch_once daymap-raw.tif \
|
||||||
|
'https://eoimages.gsfc.nasa.gov/images/imagerecords/57000/57752/land_shallow_topo_8192.tif' &
|
||||||
|
|
||||||
test -e moon-raw.png || fetch moon-raw.png \
|
fetch_older_min 720 ice-raw.jpg $(get_neo_url \
|
||||||
"http://simpleicon.com/wp-content/uploads/moon__star-64x64.png" &
|
'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=NISE_D') &
|
||||||
|
fetch_older_days 3 snow-raw.jpg $(get_neo_url \
|
||||||
|
'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD10C1_E_SNOW') &
|
||||||
|
fetch_older_days 7 chlora-raw.jpg $(get_neo_url \
|
||||||
|
'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MY1DMM_CHLORA') &
|
||||||
|
fetch_older_days 3 fire-raw.jpg $(get_neo_url \
|
||||||
|
'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD14A1_E_FIRE') &
|
||||||
|
|
||||||
# regular fetches
|
# regular fetches
|
||||||
fetch marker.json "$marker_url" &
|
fetch marker.json "$marker_url" &
|
||||||
|
|
||||||
# fetch daymap twice daily
|
|
||||||
if ! test "$(find daymap-raw.png -mmin -720)"; then
|
|
||||||
fetch daymap-raw.png "$daymap_url" &
|
|
||||||
fi
|
|
||||||
|
|
||||||
# fetch cholrophyl once every week
|
|
||||||
chlora_url=$(curl -Ss \
|
|
||||||
'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MY1DMM_CHLORA&date=2999-12-31' \
|
|
||||||
| grep '3600 x 1800' | sed 's/.*href="\([^"]*\)".*/\1/')
|
|
||||||
|
|
||||||
if ! test "$(find chlora-raw.jpg -mtime -7)"; then
|
|
||||||
fetch chlora-raw.jpg "$chlora_url" &
|
|
||||||
fi
|
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
||||||
# fetch clouds if they are older than 3h
|
# fetch clouds if they are older than 3h
|
||||||
@ -96,21 +101,26 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png
|
${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_type sun-raw.png image
|
||||||
|
check_type moon-raw.png image
|
||||||
check_type nightmap-raw.jpg image
|
check_type nightmap-raw.jpg image
|
||||||
check_type daymap-raw.png image
|
check_type daymap-raw.tif image
|
||||||
|
check_type ice-raw.jpg image
|
||||||
|
check_type snow-raw.jpg image
|
||||||
|
check_type chlora-raw.jpg image
|
||||||
|
check_type fire-raw.jpg image
|
||||||
check_type clouds-raw.png image
|
check_type clouds-raw.png image
|
||||||
|
|
||||||
in_size=2048x1024
|
in_size=3600x1800
|
||||||
xplanet_out_size=1466x1200
|
xplanet_out_size=1466x1200
|
||||||
out_geometry=1366x768+100+160
|
out_geometry=1366x768+100+160
|
||||||
|
|
||||||
nightsnow_color='#0c1a49' # nightmap
|
|
||||||
|
|
||||||
for raw in \
|
for raw in \
|
||||||
nightmap-raw.jpg \
|
nightmap-raw.jpg \
|
||||||
daymap-raw.png \
|
daymap-raw.tif \
|
||||||
clouds-raw.png \
|
snow-raw.jpg \
|
||||||
chlora-raw.jpg \
|
chlora-raw.jpg \
|
||||||
|
clouds-raw.png \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
normal=''${raw%-raw.*}.png
|
normal=''${raw%-raw.*}.png
|
||||||
@ -120,6 +130,16 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# remove snow from ice map
|
||||||
|
if needs_rebuild ice.png ice-raw.jpg; then
|
||||||
|
convert ice-raw.jpg -fuzz 20% -fill black -opaque white -scale "$in_size" ice.png
|
||||||
|
fi
|
||||||
|
|
||||||
|
# make fire more red
|
||||||
|
if needs_rebuild fire.png fire-raw.jpg; then
|
||||||
|
convert fire-raw.jpg -fuzz 20% -fill '#ef840c' -opaque white -scale "$in_size" fire.png
|
||||||
|
fi
|
||||||
|
|
||||||
if needs_rebuild sun.png sun-raw.png; then
|
if needs_rebuild sun.png sun-raw.png; then
|
||||||
convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png
|
convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png
|
||||||
fi
|
fi
|
||||||
@ -131,60 +151,22 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
# -- Daymap --
|
# -- Daymap --
|
||||||
|
|
||||||
# merge with water chlora layer
|
# merge with water chlora layer
|
||||||
convert daymap.png chlora.png -compose lighten -composite daymap-final.png
|
if needs_rebuild daymap-final.png daymap.png fire.png snow.png ice.png chlora.png; then
|
||||||
|
convert daymap.png fire.png -compose lighten -composite daymap-1.png
|
||||||
|
convert daymap-1.png ice.png -compose lighten -composite daymap-2.png
|
||||||
|
convert daymap-2.png snow.png -compose lighten -composite daymap-3.png
|
||||||
|
convert daymap-3.png chlora.png -compose lighten -composite daymap-final.png
|
||||||
|
fi
|
||||||
|
|
||||||
# -- Nightmap --
|
# -- Nightmap --
|
||||||
|
|
||||||
# merge with water chlora layer
|
if needs_rebuild nightmap-final.png nightmap.png fire.png snow.png ice.png chlora.png; then
|
||||||
convert nightmap.png \( -fill black -colorize 70% chlora.png \) \
|
convert nightmap.png fire.png -compose lighten -composite nightmap-1.png
|
||||||
-compose lighten -composite nightmap-chlora.png
|
convert nightmap-1.png \( -fill black -colorize 70% ice.png \) -compose lighten -composite nightmap-2.png
|
||||||
|
convert nightmap-2.png \( -fill black -colorize 70% snow.png \) -compose lighten -composite nightmap-3.png
|
||||||
# create nightmap-fullsnow, a big blue picture
|
convert nightmap-3.png \( -fill black -colorize 70% chlora.png \) -compose lighten -composite nightmap-final.png
|
||||||
if needs_rebuild nightmap-fullsnow.png; then
|
|
||||||
convert -size $in_size xc:$nightsnow_color nightmap-fullsnow.png
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# extract daymap-snowmask from daymap-final
|
|
||||||
if needs_rebuild daymap-snowmask.png daymap.png; then
|
|
||||||
convert daymap.png -threshold 95% daymap-snowmask.png
|
|
||||||
fi
|
|
||||||
|
|
||||||
# extract nightmap-lightmask from nightmap
|
|
||||||
if needs_rebuild nightmap-lightmask.png nightmap.png; then
|
|
||||||
convert nightmap.png -threshold 25% nightmap-lightmask.png
|
|
||||||
fi
|
|
||||||
|
|
||||||
# create layers
|
|
||||||
make_layer nightmap-snowlayer.png nightmap-fullsnow.png daymap-snowmask.png
|
|
||||||
make_layer nightmap-lightlayer.png nightmap.png nightmap-lightmask.png
|
|
||||||
|
|
||||||
# apply layers
|
|
||||||
flatten nightmap-lightsnowlayer.png \
|
|
||||||
nightmap-lightlayer.png \
|
|
||||||
nightmap-snowlayer.png
|
|
||||||
|
|
||||||
flatten nightmap-final.png \
|
|
||||||
nightmap-lightsnowlayer.png \
|
|
||||||
nightmap-chlora.png
|
|
||||||
|
|
||||||
|
|
||||||
# create marker file from json
|
|
||||||
if [ -s marker.json ]; then
|
|
||||||
jq -r 'to_entries[] | @json "\(.value.latitude) \(.value.longitude)"' marker.json > marker_file
|
|
||||||
echo 'position=sun image=sun.png' >> marker_file
|
|
||||||
echo 'position=moon image=moon.png' >> marker_file
|
|
||||||
fi
|
|
||||||
|
|
||||||
# make all unmodified files as final
|
|
||||||
for normal in \
|
|
||||||
clouds.png \
|
|
||||||
;
|
|
||||||
do
|
|
||||||
final=''${normal%.png}-final.png
|
|
||||||
needs_rebuild $final &&
|
|
||||||
ln $normal $final
|
|
||||||
done
|
|
||||||
|
|
||||||
# rebuild every time to update shadow
|
# rebuild every time to update shadow
|
||||||
xplanet --num_times 1 --geometry $xplanet_out_size \
|
xplanet --num_times 1 --geometry $xplanet_out_size \
|
||||||
--output xplanet-output.png --projection merc \
|
--output xplanet-output.png --projection merc \
|
||||||
@ -193,7 +175,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
"Earth"
|
"Earth"
|
||||||
map=daymap-final.png
|
map=daymap-final.png
|
||||||
night_map=nightmap-final.png
|
night_map=nightmap-final.png
|
||||||
cloud_map=clouds-final.png
|
cloud_map=clouds.png
|
||||||
cloud_threshold=1
|
cloud_threshold=1
|
||||||
cloud_gamma=2.5
|
cloud_gamma=2.5
|
||||||
shade=15
|
shade=15
|
||||||
@ -206,7 +188,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
|
|||||||
"Earth"
|
"Earth"
|
||||||
map=daymap-final.png
|
map=daymap-final.png
|
||||||
night_map=nightmap-final.png
|
night_map=nightmap-final.png
|
||||||
cloud_map=clouds-final.png
|
cloud_map=clouds.png
|
||||||
cloud_threshold=1
|
cloud_threshold=1
|
||||||
cloud_gamma=2.5
|
cloud_gamma=2.5
|
||||||
marker_file=marker_file
|
marker_file=marker_file
|
||||||
|
Loading…
Reference in New Issue
Block a user