summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile14
-rw-r--r--tools/colorstagger.c97
-rwxr-xr-xtools/exofetchbin28736 -> 0 bytes
-rw-r--r--tools/exofetch.c2
4 files changed, 107 insertions, 6 deletions
diff --git a/tools/Makefile b/tools/Makefile
index ae33902..e42f8bf 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,16 +1,20 @@
+.RECIPEPREFIX = >
CC = cc
CFLAGS = -std=c99 -Wall -Wextra -pedantic -Os
LDFLAGS =
PREFIX ?= /usr/local
-all: exofetch
+all: exofetch colorstagger
exofetch: exofetch.c
- $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+>$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+
+colorstagger: colorstagger.c
+>$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) -lX11
clean:
- rm -f exofetch
+>rm -f exofetch colorstagger
install: exofetch
- mkdir -p $(DESTDIR)$(PREFIX)/bin
- cp -f exofetch $(DESTDIR)$(PREFIX)/bin
+>mkdir -p $(DESTDIR)$(PREFIX)/bin
+>cp -f exofetch $(DESTDIR)$(PREFIX)/bin
diff --git a/tools/colorstagger.c b/tools/colorstagger.c
new file mode 100644
index 0000000..3e68faf
--- /dev/null
+++ b/tools/colorstagger.c
@@ -0,0 +1,97 @@
+#define _XOPEN_SOURCE 500
+#include <X11/Xlib.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+typedef struct { unsigned char r, g, b; } Color;
+
+static Color
+parse(const char *hex)
+{
+ Color c = {0};
+ if (hex[0] == '#')
+ hex++;
+ if (strlen(hex) >= 6) {
+ char buf[3] = {0};
+ buf[0] = hex[0]; buf[1] = hex[1]; c.r = strtol(buf, NULL, 16);
+ buf[0] = hex[2]; buf[1] = hex[3]; c.g = strtol(buf, NULL, 16);
+ buf[0] = hex[4]; buf[1] = hex[5]; c.b = strtol(buf, NULL, 16);
+ }
+ return c;
+}
+
+static unsigned long
+pack(Color c)
+{
+ return ((unsigned long)c.r << 16) |
+ ((unsigned long)c.g << 8) |
+ ((unsigned long)c.b);
+}
+
+static Color
+mix(Color a, Color b, double t)
+{
+ Color c;
+ c.r = a.r + (b.r - a.r) * t;
+ c.g = a.g + (b.g - a.g) * t;
+ c.b = a.b + (b.b - a.b) * t;
+ return c;
+}
+
+int
+main(void)
+{
+ char *colors[] = {"#ff5555", "#f1fa8c", "#50fa7b", "#8be9fd", "#bd93f9"};
+ const int ncolors = sizeof(colors) / sizeof(colors[0]);
+
+ Display *d = XOpenDisplay(NULL);
+ if (!d) {
+ fprintf(stderr, "cannot open display\n");
+ return 1;
+ }
+ int s = DefaultScreen(d);
+ int width = 600, height = 100;
+ Window w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, width, height,
+ 1, BlackPixel(d, s), WhitePixel(d, s));
+ XSelectInput(d, w, KeyPressMask);
+ XMapWindow(d, w);
+ GC gc = XCreateGC(d, w, 0, NULL);
+
+ int grad = 60, solid = 60;
+ int running = 1;
+ while (running) {
+ while (XPending(d)) {
+ XEvent e;
+ XNextEvent(d, &e);
+ if (e.type == KeyPress)
+ running = 0;
+ }
+
+ int x = 0;
+ for (int i = 0; i < ncolors; i++) {
+ Color a = parse(colors[i]);
+ Color b = parse(colors[(i + 1) % ncolors]);
+ for (int k = 0; k < grad; k++) {
+ double t = k / (double)(grad - 1);
+ Color c = mix(a, b, t);
+ XSetForeground(d, gc, pack(c));
+ XDrawLine(d, w, gc, x + k, 0, x + k, height);
+ }
+ x += grad;
+ XSetForeground(d, gc, pack(b));
+ XFillRectangle(d, w, gc, x, 0, solid, height);
+ x += solid;
+ }
+ XFlush(d);
+ usleep(500000);
+ char *tmp = colors[0];
+ memmove(colors, colors + 1, (ncolors - 1) * sizeof(char *));
+ colors[ncolors - 1] = tmp;
+ XClearWindow(d, w);
+ }
+
+ XCloseDisplay(d);
+ return 0;
+}
diff --git a/tools/exofetch b/tools/exofetch
deleted file mode 100755
index 425ffa4..0000000
--- a/tools/exofetch
+++ /dev/null
Binary files differ
diff --git a/tools/exofetch.c b/tools/exofetch.c
index 826464d..361aeae 100644
--- a/tools/exofetch.c
+++ b/tools/exofetch.c
@@ -10,7 +10,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <locale.h>
-#include "../accent.h"
+#include "../core/accent.h"
static ColorShm *accentshm;
static char accentcol[8] = "#005577";