Skip to content

Commit

Permalink
Add background XML file
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Sep 21, 2017
1 parent c233cf8 commit cbdcc6a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
build
scaled
45 changes: 32 additions & 13 deletions Makefile
@@ -1,31 +1,50 @@
ORIGINAL=$(wildcard original/*.jpg)
SCALED=$(patsubst original/%.jpg, scaled/%.jpg, $(ORIGINAL))
SCALED=$(sort $(patsubst original/%.jpg, scaled/%.jpg, $(ORIGINAL)))

prefix ?= /usr
datarootdir = $(prefix)/share
datadir = $(datarootdir)

.PHONY: all clean install uninstall

all: $(SCALED)
all: $(SCALED) scaled/info.xml

clean:
rm -rf scaled
rm -rf build scaled

install: all
for file in $(SCALED); do \
install -D -m 0644 "$$file" "$(DESTDIR)$(datadir)/backgrounds/$$(basename "$$file")"; \
install -D -m 0644 "$$file" "$(DESTDIR)$(datadir)/backgrounds/pop/$$(basename "$$file")"; \
done
install -D -m 0644 "scaled/info.xml" "$(DESTDIR)$(datadir)/gnome-background-properties/pop-wallpapers.xml"

uninstall:
for file in $(SCALED); do \
rm -f "$(DESTDIR)$(datadir)/backgrounds/$$(basename "$$file")"; \
rm -f "$(DESTDIR)$(datadir)/backgrounds/pop/$$(basename "$$file")"; \
done
rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(datadir)/backgrounds/"

scaled:
mkdir -p scaled
touch scaled

scaled/%.jpg: original/%.jpg scaled
convert "$<" -resize "3840x2160^" "$@"
rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(datadir)/backgrounds/pop/"
rm -f "$(DESTDIR)$(datadir)/gnome-background-properties/pop-wallpapers.xml"
rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(datadir)/gnome-background-properties/"

scaled/%.jpg: original/%.jpg
@mkdir -p build scaled
convert "$<" -resize "3840x2160^" "build/$*.jpg"
mv "build/$*.jpg" "$@"

scaled/info.xml: $(SCALED)
@mkdir -p build scaled
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > "build/info.xml"
echo "<!DOCTYPE wallpapers SYSTEM \"gnome-wp-list.dtd\">" >> "build/info.xml"
echo "<wallpapers>" >> "build/info.xml"
for file in $(SCALED); do \
echo " <wallpaper>" >> "build/info.xml"; \
echo " <name>$$(basename "$$file" .jpg)</name>" >> "build/info.xml"; \
echo " <filename>/usr/share/backgrounds/pop/$$(basename "$$file")</filename>" >> "build/info.xml"; \
echo " <options>zoom</options>" >> "build/info.xml"; \
echo " <pcolor>#000000</pcolor>" >> "build/info.xml"; \
echo " <scolor>#000000</scolor>" >> "build/info.xml"; \
echo " <shade_type>solid</shade_type>" >> "build/info.xml"; \
echo " </wallpaper>" >> "build/info.xml"; \
done
echo "</wallpapers>" >> "build/info.xml"
mv "build/info.xml" "$@"

0 comments on commit cbdcc6a

Please sign in to comment.