diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 87 | ||||
-rw-r--r-- | conv.c | 180 | ||||
-rw-r--r-- | scalable/actions/paint-order-mfs.svg | 2 | ||||
-rw-r--r-- | scalable/actions/paint-order-smf.svg | 2 |
5 files changed, 212 insertions, 62 deletions
@@ -2,3 +2,6 @@ *\#* /*x*/ *.theme +conv +*.o +*.su @@ -3168,6 +3168,8 @@ ALL_PNG_ICONS = $(foreach S,$(SIZES),$(foreach I,$(ICONS),$(S)x$(S)/$(I).png)) all: index.theme $(ALL_PNG_ICONS) +all-fast: index.theme all-fast-icons + index.theme: Makefile set -e;\ printf '%s\n' \ @@ -3213,68 +3215,34 @@ index.theme: Makefile done;\ done >> index.theme -8x8/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +all-fast-icons: $(ICONS:=.x) + +%.x: conv + ./conv scalable/$*.svg $(SIZES) + +conv: conv.c + $(CC) -o $@ $< $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) + +8x8/%.png: scalable/%.svg conv + ./conv $@ -16x16/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +16x16/%.png: scalable/%.svg conv + ./conv $@ -22x22/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +22x22/%.png: scalable/%.svg conv + ./conv $@ -24x24/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +24x24/%.png: scalable/%.svg conv + ./conv $@ -32x32/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +32x32/%.png: scalable/%.svg conv + ./conv $@ -36x36/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +36x36/%.png: scalable/%.svg conv + ./conv $@ -48x48/%.png: scalable/%.svg - mkdir -p -- $(@D) - s="$$(printf '%s\n' $@ | cut -d x -f 1)";\ - if test -L $<; then\ - ln -sf "$$(readlink $< | sed 's/\.svg$$/\.png/')" $@;\ - else\ - rsvg-convert -w $$s -h $$s -f png $< > $@;\ - fi +48x48/%.png: scalable/%.svg conv + ./conv $@ install: index.theme $(ALL_PNG_ICONS) mkdir -p -- "$(DESTDIR)$(ICONPREFIX)" @@ -3298,8 +3266,7 @@ uninstall: rm -rf -- "$(DESTDIR)$(ICONPREFIX)/simple" clean: - -rm -f -- index.theme - -rm -f -- $(foreach S,$(SIZES),$(foreach I,$(ICONS),$(S)x$(S)/$(I).png)) - -rmdir -- $(foreach S,$(SIZES),$(foreach D,$(DIRS),$(S)x$(S)/$(D)) $(S)x$(S)) + -rm -f -- index.theme *.o *.su conv + -for s in $(SIZES); do printf "$${s}x$${s}\n"; done | xargs rm -rf -- -.PHONY: all install uninstall clean +.PHONY: all all-fast all-fast-icons install uninstall clean @@ -0,0 +1,180 @@ +#include <sys/stat.h> +#include <sys/wait.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +static char *argv0; + + +static int +single(int argc, char *argv[]) +{ + char size[10], target[4096], source[4096]; + char *p; + ssize_t r; + int fd; + + p = strchr(argv[0], 'x'); + if (!p) + return 1; + *p = '\0'; + stpcpy(size, argv[0]); + *p = 'x'; + + p = strchr(p, '/'); + if (!p) + return 1; + p = stpcpy(stpcpy(source, "scalable"), p); + if (strcmp(&p[-4], ".png")) + return 1; + stpcpy(&p[-4], ".svg"); + + for (p = argv[0]; (p = strchr(p, '/')); p++) { + *p = '\0'; + if (mkdir(argv[0], 0777) && errno != EEXIST) { + fprintf(stderr, "%s: mkdir %s 0777: %s\n", argv0, argv[0], strerror(errno)); + return 1; + } + *p = '/'; + } + + r = readlink(source, target, sizeof(target) - 1); + if (r >= 0) + target[r] = 0; + if (r >= 0 && (r >= sizeof(target) - 1 || r < 4 || strcmp(&target[r - 4], ".svg"))) { + return 1; + } else if (r < 0 && errno == EINVAL) { + fd = open(argv[0], O_WRONLY | O_CREAT | O_TRUNC, 0666); + if (fd < 0) { + fprintf(stderr, "%s: open %s O_WRONLY|O_CREAT|O_TRUNC 0666: %s\n", argv0, argv[0], strerror(errno)); + return 1; + } + if (fd != STDOUT_FILENO) { + if (dup2(fd, STDOUT_FILENO) != STDOUT_FILENO) + fprintf(stderr, "%s: dup2 %i 1: %s\n", argv0, fd, strerror(errno)); + close(fd); + } + execlp("rsvg-convert", "rsvg-convert", "-w", size, "-h", size, "-f", "png", source, NULL); + fprintf(stderr, "%s: execvp rsvg-convert: %s\n", argv0, strerror(errno)); + return 1; + } else if (r < 0) { + fprintf(stderr, "%s: readlink %s: %s\n", argv0, source, strerror(errno)); + return 1; + } else { + stpcpy(&target[r - 4], ".png"); + if (symlink(target, argv[0])) { + if (errno == EEXIST) { + unlink(argv[0]); + if (!symlink(target, argv[0])) + return 0; + } + fprintf(stderr, "%s: symlink %s %s: %s\n", argv0, target, argv[0], strerror(errno)); + return 1; + } + return 0; + } +} + + +static int +multi(int argc, char *argv[]) +{ + char *source, output[4096], target[4096]; + char *p, *q; + pid_t pid; + int status, fd, i; + ssize_t r; + + source = *argv++, argc--; + + q = strchr(source, '/'); + if (!q) + return 1; + + for (i = 0; i < argc; i++) { + stpcpy(stpcpy(stpcpy(stpcpy(output, argv[i]), "x"), argv[i]), q); + for (p = output; (p = strchr(p, '/')); p++) { + *p = '\0'; + if (mkdir(output, 0777) && errno != EEXIST) { + fprintf(stderr, "%s: mkdir %s 0777: %s\n", argv0, output, strerror(errno)); + return 1; + } + *p = '/'; + } + } + + r = readlink(source, target, sizeof(target) - 1); + if (r >= 0) + target[r] = 0; + if (r >= 0 && (r >= sizeof(target) - 1 || r < 4 || strcmp(&target[r - 4], ".svg"))) { + return 1; + } else if (r < 0 && errno == EINVAL) { + p = stpcpy(stpcpy(stpcpy(stpcpy(output, argv[0]), "x"), argv[0]), q); + stpcpy(&p[-4], ".png"); + for (; *argv; argv++, argc--) { + pid = argc == 1 ? 0 : fork(); + if (pid == -1) { + fprintf(stderr, "%s: fork: %s\n", argv0, strerror(errno)); + return 1; + } + if (pid) { + p = stpcpy(stpcpy(stpcpy(stpcpy(output, argv[1]), "x"), argv[1]), q); + stpcpy(&p[-4], ".png"); + if (waitpid(pid, &status, 0) != pid) { + fprintf(stderr, "%s: waitpid rsvg-convert: %s\n", argv0, strerror(errno)); + return 1; + } + if (status) + return 1; + continue; + } + fd = open(output, O_WRONLY | O_CREAT | O_TRUNC, 0666); + if (fd < 0) { + fprintf(stderr, "%s: open %s O_WRONLY|O_CREAT|O_TRUNC 0666: %s\n", argv0, output, strerror(errno)); + return 1; + } + if (fd != STDOUT_FILENO) { + if (dup2(fd, STDOUT_FILENO) != STDOUT_FILENO) + fprintf(stderr, "%s: dup2 %i 1: %s\n", argv0, fd, strerror(errno)); + close(fd); + } + execlp("rsvg-convert", "rsvg-convert", "-w", *argv, "-h", *argv, "-f", "png", source, NULL); + fprintf(stderr, "%s: execvp rsvg-convert: %s\n", argv0, strerror(errno)); + return 1; + } + } else if (r < 0) { + fprintf(stderr, "%s: readlink %s: %s\n", argv0, source, strerror(errno)); + return 1; + } else { + stpcpy(&target[r - 4], ".png"); + for (; *argv; argv++) { + p = stpcpy(stpcpy(stpcpy(stpcpy(output, *argv), "x"), *argv), q); + stpcpy(&p[-4], ".png"); + if (symlink(target, output)) { + if (errno == EEXIST) { + unlink(output); + if (!symlink(target, output)) + continue; + } + fprintf(stderr, "%s: symlink %s %s: %s\n", argv0, target, output, strerror(errno)); + return 1; + } + } + return 0; + } +} + + +int +main(int argc, char *argv[]) +{ + argv0 = *argv++, argc--; + if (argc == 1) + return single(argc, argv); + if (argc > 1) + return multi(argc, argv); + return 1; +} diff --git a/scalable/actions/paint-order-mfs.svg b/scalable/actions/paint-order-mfs.svg index c11aefb..bde4305 100644 --- a/scalable/actions/paint-order-mfs.svg +++ b/scalable/actions/paint-order-mfs.svg @@ -1 +1 @@ -<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#bebebe"><path d="m14.029297 10a7 7 0 0 1 -4.029297 4.035156v1.964844h6v-6z" opacity=".75"/><path d="m13.234375 3.5a7 7 0 0 1 1.09375 2.5h.671875v1h-.517578a7 7 0 0 1 .017578.5 7 7 0 0 1 -.294922 2h1.794922v-6zm-9.734375 9.742188v2.757812h6v-1.798828a7 7 0 0 1 -2 .298828 7 7 0 0 1 -.5-.025391v.525391h-1v-.666016a7 7 0 0 1 -2.5-1.091796z" opacity=".5"/><path d="m12.851562 3a7 7 0 0 1 .701172 1h2.447266v-1zm-9.851562 9.861328v3.138672h1v-2.445312a7 7 0 0 1 -1-.69336z" fill-rule="evenodd"/><path d="m14.333984 9a7 7 0 0 1 -.304687 1h1.970703v-1zm-4.333984 5.035156a7 7 0 0 1 -1 .292969v1.671875h1z" fill-rule="evenodd"/><circle cx="7.5" cy="7.5" fill-opacity=".501961" r="7"/><path d="m7.5 0c-4.136213 0-7.5 3.363787-7.5 7.5s3.363787 7.5 7.5 7.5 7.5-3.363787 7.5-7.5-3.363787-7.5-7.5-7.5zm0 1c3.595773 0 6.5 2.904227 6.5 6.5s-2.904227 6.5-6.5 6.5-6.5-2.904227-6.5-6.5 2.904227-6.5 6.5-6.5z"/></g></svg>
\ No newline at end of file +<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10 10h6v6h-6z" fill="#bebebe" opacity=".75"/><path d="m3.5 3.5v.1660156 5.8339844 6.5h6v-6.5h6.5v-6zm2.5 2.5h1v1h-1zm2 0h1v1h-1zm2 0h1v1h-1zm2 0h1v1h-1zm2 0h1v1h-1zm-8 2h1v1h-1zm0 2h1v1h-1zm0 2h1v1h-1zm0 2h1v1h-1z" fill="#bebebe" opacity=".5"/><path d="m3.5 16v-12.5000005l12.499997.0000005" fill="none" stroke="#bebebe"/><path d="m9.5 16.000001v-6.500001h6.499997" fill="none" stroke="#bebebe"/><g fill="#bebebe"><path d="m7.5.5a7 7 0 0 0 -7 7 7 7 0 0 0 3 5.742188v-3.742188-5.833984-.166016h9.734375a7 7 0 0 0 -5.734375-3z" opacity=".5"/><path d="m7.5 0c-4.136213 0-7.5 3.363787-7.5 7.5 0 2.665173 1.400049 5.003475 3.5 6.333984v-1.214843c-1.520277-1.18866-2.5-3.035163-2.5-5.119141 0-3.595773 2.904227-6.5 6.5-6.5 2.083978 0 3.930481.979723 5.119141 2.5h1.214843c-1.330509-2.099951-3.668811-3.5-6.333984-3.5z"/></g></svg>
\ No newline at end of file diff --git a/scalable/actions/paint-order-smf.svg b/scalable/actions/paint-order-smf.svg index b453412..ae5692c 100644 --- a/scalable/actions/paint-order-smf.svg +++ b/scalable/actions/paint-order-smf.svg @@ -1 +1 @@ -<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#bebebe"><path d="m14.421875 6.5a7 7 0 0 1 .07813 1 7 7 0 0 1 -7 7 7 7 0 0 1 -1-.08008v1.58008h9.499995v-9.5z" opacity=".75"/><path d="m13.234375 3.5a7 7 0 0 1 1.09375 2.5h.671875v.5h1v-3zm-9.734375 9.742188v2.757812h3v-1h-.5v-.666016a7 7 0 0 1 -2.5-1.091796z" opacity=".5"/><path d="m12.851562 3a7 7 0 0 1 .701172 1h2.447266v-1zm-9.851562 9.861328v3.138672h1v-2.445312a7 7 0 0 1 -1-.69336z" fill-rule="evenodd"/><circle cx="7.5" cy="7.5" fill-opacity=".501961" r="7"/></g><circle cx="7.5" cy="7.5" fill="none" r="7" stroke="#bebebe" stroke-linecap="square"/></svg>
\ No newline at end of file +<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#bebebe"><path d="m13.234375 3.5a7 7 0 0 1 1.09375 2.5h.671875v.5h1v-3zm-9.734375 9.742188v2.757812h3v-1h-.5v-.666016a7 7 0 0 1 -2.5-1.091796z" opacity=".5"/><path d="m12.851562 3a7 7 0 0 1 .701172 1h2.447266v-1zm-9.851562 9.861328v3.138672h1v-2.445312a7 7 0 0 1 -1-.69336z" fill-rule="evenodd"/><path d="m7.5.5a7 7 0 0 0 -7 7 7 7 0 0 0 6 6.919922v-7.919922h7.921875a7 7 0 0 0 -6.921875-6z" fill-opacity=".501961"/><path d="m7.5 0c-4.1362133 0-7.5 3.3637867-7.5 7.5 0 3.796305 2.8362775 6.934415 6.5 7.425781v-1.009765c-3.1182406-.480411-5.5-3.161098-5.5-6.416016 0-3.5957732 2.9042268-6.5 6.5-6.5 3.254918 0 5.935605 2.3817594 6.416016 5.5h1.009765c-.491366-3.6637225-3.629476-6.5-7.425781-6.5z"/><path d="m6.499998 6.5h9.5v9.5h-9.5z" opacity=".75"/></g></svg>
\ No newline at end of file |