summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorauric <104602845+ihateamongus@users.noreply.github.com>2025-09-07 19:12:26 -0500
committerGitHub <noreply@github.com>2025-09-07 19:12:26 -0500
commit8661540682391f5f6db33a86747028d90dda09ed (patch)
tree4061ec1e88b608bfaab2b0fabbd0c5a9c9a955bc /tools
parent5cf3a788d2335d79c2e26c133f013c994f035ad7 (diff)
parent9717eef7ca42d4c912aa082f6e05dd6a3f0beac6 (diff)
Merge pull request #9 from ihateamongus/codex/analyze-oldresources-folder-for-performance-zm9nfy
Add glass-style transparency and dynamic tags
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile16
-rw-r--r--tools/exofetch.c213
2 files changed, 229 insertions, 0 deletions
diff --git a/tools/Makefile b/tools/Makefile
new file mode 100644
index 0000000..ae33902
--- /dev/null
+++ b/tools/Makefile
@@ -0,0 +1,16 @@
+CC = cc
+CFLAGS = -std=c99 -Wall -Wextra -pedantic -Os
+LDFLAGS =
+PREFIX ?= /usr/local
+
+all: exofetch
+
+exofetch: exofetch.c
+ $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+
+clean:
+ rm -f exofetch
+
+install: exofetch
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+ cp -f exofetch $(DESTDIR)$(PREFIX)/bin
diff --git a/tools/exofetch.c b/tools/exofetch.c
new file mode 100644
index 0000000..bc5548a
--- /dev/null
+++ b/tools/exofetch.c
@@ -0,0 +1,213 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <sys/sysinfo.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <locale.h>
+
+#define SHMNAME "/breathing_color_shm"
+
+typedef struct {
+ uint32_t seq;
+ char color[8];
+} ColorShm;
+
+static ColorShm *accentshm;
+static char accentcol[8] = "#005577";
+
+static int
+openaccent(void)
+{
+ int fd;
+ if (accentshm)
+ return 0;
+ if ((fd = shm_open(SHMNAME, O_RDONLY, 0)) < 0)
+ return -1;
+ accentshm = mmap(NULL, sizeof(ColorShm), PROT_READ, MAP_SHARED, fd, 0);
+ close(fd);
+ if (accentshm == MAP_FAILED) {
+ accentshm = NULL;
+ return -1;
+ }
+ return 0;
+}
+
+static void
+updateaccent(void)
+{
+ uint32_t s1, s2;
+ char tmp[8];
+ if (!accentshm && openaccent() < 0)
+ return;
+ do {
+ s1 = accentshm->seq;
+ memcpy(tmp, accentshm->color, 8);
+ s2 = accentshm->seq;
+ } while (s1 != s2);
+ if (tmp[0] == '#')
+ memcpy(accentcol, tmp, 8);
+}
+
+static void
+hex2rgb(const char *hex, int *r, int *g, int *b)
+{
+ unsigned int ri, gi, bi;
+ if (sscanf(hex + 1, "%02x%02x%02x", &ri, &gi, &bi) != 3) {
+ *r = 0x00; *g = 0x55; *b = 0x77;
+ return;
+ }
+ *r = ri; *g = gi; *b = bi;
+}
+
+static const char *icon[] = {
+" ██████████████ ██████████████ ",
+" ██████████████ ██████████████ ",
+" ██████▓▓▓█████ █████▓▓▓██████ ",
+" █████▓▓▓▓█████ █████▓▓▓▓█████ ",
+" █████▓▓▓▓█████ █████▓▓▓▓█████ ",
+" █████▓▓▓▓▓████ ████▓▓▓▓▓█████ ",
+" █████▓▓▓▓▓████████ █████████████████████ ████████▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓█████ █████████████████████ █████▓▓▓▓▓▓▓██████ ",
+"▓▓▓▓▓▓▓▓ ██████▓▓▓▓▓▓▓█████ █████████████████████ █████▓▓▓▓▓▓▓██████ ▓▓▓▓▓▓▓▓",
+"▓▓▓▓▓▓▓▓▓ █████▓▓▓▓▓████ ████▓▒▒▒▒▓▓▓▒▒▒▒▓████ ████▓▓▓▓▓█████ ▓▓▓▓▓▓▓▓▓",
+"▓▓▓▓▓▓▓▓▓ █████▓▓▓▓▓████ ████▓▒▒▒▒▓▓▓▒▒▒▒▓████ ████▓▓▓▓▓█████ ▓▓▓▓▓▓▓▓▓",
+"▓▓▓▓▒░░░▒▓▓▓▓ █████▓▓▓▓▓▓▓▓█████▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓█████▓▓▓▓▓▓▓▓█████ ▓▓▓▓▒░░░▒▓▓▓▓",
+"▓▓▓▓▒░░░▒▓▓▓▓ █████▓▓▓▓▓▓▓▓█████▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓█████▓▓▓▓▓▓▓▓█████ ▓▓▓▓▒░░░░▓▓▓▓",
+"▓▓▓▓▒▒▒▒░░░░▒▓▓▓▓ █████████▓▓▓▓▓▒▒▒▓███▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓███▓▒▒▒▒▓▓▓▓█████████ ▓▓▓▓▒░░░░▒▒▒▒▓▓▓▓",
+" ▒▒▒▒▒░░░░▒▓▓▓▓ ██████████▓▓▓▒▒▒▒▓███▓▓▓▓▓███████████▓▓▓▓▓███▓▒▒▒▒▓▓▓▓█████████ ▓▓▓▓▒░░░░▒▒▒▒▒ ",
+" ▓▓▓▓▓░░░░▒▒▒▒▓▓▓▓████████████▓▒▒▒▓███████▓▓▓▓█████▓▓▓▓███████▓▒▒▒▒▓████████████▓▓▓▒▒▒▒░░░░▒▓▓▓▓ ",
+" ████▓▒░░░░░░▒▒▓▓▓████████████▓▒▒▒▓████████▓▓▓▓▓▓▓▓▓▓▓████████▓▒▒▒▓████████████▓▓▓▓▒░░░░░░░▓████ ",
+" ████▓▒▒▒▒░░░░▒▓▓▓▓███████████▓▒▒▒▓▓▓▓████▓▒▒▒▒▒▒▒▒▒▒▒▓████▓▓▓▓▒▒▒▓████████████▓▓▓▒▒░░░▒▒▒▒▓████ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▓▓▓▓▓███████▓▒▒▒▒▒▒▒▓███▒░░░░░░░░░░░▒▓██▓▒▒▒▒▒▒▒▒▓██████▓▓▓▓▓▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▒▓▓▓▓███████▓▒▒▒▒▒▒▒▓███▒░░░░░░░░░░░▒▓██▓▒▒▒▒▒▒▒▓▓██████▓▓▓▓▓▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▒▒▒▒▓▓▓▓████▓▓▓▒▒░░░▒███▒░░░░░░░░░░░▒▓██▓░░░▒▒▓▓▓████▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▒▒▒▒▓▓▓▓████▓▓▓▒▒░░░▒███▒░░░░░░░░░░░▒▓██▓░░░▒▒▓▓▓████▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▓██████▓▒░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░▒▓██████▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓ ",
+" ▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▓██████▓▒░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░▒▓██████▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓ ",
+" ████▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓████ ",
+" ████▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓████ ",
+" █████▓▓▓▓▓███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▓▓█████ ",
+" █████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████ ",
+" █████▓▓▓▓████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████▓▓▓▓█████ ",
+" ████▓▓▒▒▒▓███████████▓▓▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▓▓▓███████████▓▒▒▒▒▓████ ",
+" ████▓▓▓▓▒▒▒▒▓▓▓▓████████▓▓▓▓▓▓▓▓▒▒▒▒▒░░░░░░░░░░░░▒▒▒▒▓▓▓▓▓▓▓▓█████████▓▓▓▒▒▒▒▓▓▓▓████ ",
+" █████▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓████████████▓▓▓▓▒░░░░░░░░░░░▒▓▓▓▓████████████▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓█████ ",
+" █████▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓████████████▓▓▓▓▒░░░░░░░░░░░▒▓▓▓▓████████████▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓█████ ",
+" █████▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓█████ ",
+" █████▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓█████ ",
+" █████▓▓▓▓▓▓▓▓▓▓▓▓█████████████████████▓▓▓██████▓▓█████████████████████▓▓▓▓▓▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓▓████████▓▓▓█████████████▓▓▓█████▓▓▓█████████████▓▓▓████████▓▓▓▓▓▓▓▓▓█████ ",
+" █████████▓▓▓▓▓████████▓▓▓▓████████████▓▓▓█████▓▓▓▓████████████▓▓▓████████▓▓▓▓▓█████████ ",
+" █████▓▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓▓████████▓▓▓█████████▓▓▓▓▓▓▓▓▓▓▓█████████▓▓▓████████▓▓▓▓▓▓▓▓██████ ",
+" ██████▓▓▓▓▓▓▓▓████████████████████▓▓▓▓▓▓▓▓▓▓▓████████████████████▓▓▓▓▓▓▓▓██████ ",
+" ██████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████████ ",
+" ██████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████████ ",
+" ██████▓▓▓▓▓▓██████▓▓▓████▓▓▓▓▓████▓▓▓██████▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓█████▓▓▓████▓▓▓▓▓████▓▓▓██████▓▓▓▓▓▓▓█████ ",
+" █████▓▓▓▓▓▓▓▓█████████████████████████████▓▓▓▓▓▓▓▓█████ ",
+" █████▓▓▓▓▓▓▓▓█████████▓▓▓█████▓▓▓█████████▓▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓█████████▓▓▓▓███▓▓▓▓██████████▓▓▓▓▓▓██████ ",
+" ██████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████████████ ",
+" █████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████████████ ",
+" █████████████████▓▓▓▓▓▓▓▓▓▓▓██████████████████ ",
+" ██████████████████████████████████████████████ ",
+" █████████████ ",
+" █████████████ ",
+NULL};
+
+int
+main(void)
+{
+ setlocale(LC_ALL, "");
+ openaccent();
+ updateaccent();
+ int r, g, b;
+ hex2rgb(accentcol, &r, &g, &b);
+
+ for (int i = 0; icon[i]; i++)
+ printf("\x1b[38;2;%d;%d;%dm%s\x1b[0m\n", r, g, b, icon[i]);
+
+ printf("\n");
+
+ char host[256] = "";
+ gethostname(host, sizeof host);
+ struct utsname uts;
+ uname(&uts);
+ struct sysinfo info;
+ sysinfo(&info);
+
+ char os[128] = "Unknown";
+ FILE *fp = fopen("/etc/os-release", "r");
+ if (fp) {
+ char line[256];
+ while (fgets(line, sizeof line, fp)) {
+ if (strncmp(line, "PRETTY_NAME=", 12) == 0) {
+ char *p = line + 12;
+ if (*p == '"') p++;
+ char *e = strchr(p, '"');
+ if (e) *e = '\0';
+ snprintf(os, sizeof os, "%s", p);
+ break;
+ }
+ }
+ fclose(fp);
+ }
+
+ long updays = info.uptime / 86400;
+ long uphours = (info.uptime / 3600) % 24;
+ long upmins = (info.uptime / 60) % 60;
+
+ char cpu[128] = "Unknown";
+ fp = fopen("/proc/cpuinfo", "r");
+ if (fp) {
+ char line[256];
+ while (fgets(line, sizeof line, fp)) {
+ if (strncmp(line, "model name", 10) == 0) {
+ char *p = strchr(line, ':');
+ if (p) {
+ p += 2;
+ p[strcspn(p, "\n")] = '\0';
+ snprintf(cpu, sizeof cpu, "%s", p);
+ }
+ break;
+ }
+ }
+ fclose(fp);
+ }
+
+ long totalmem = info.totalram / 1024 / 1024;
+ long freemem = info.freeram / 1024 / 1024;
+ long usedmem = totalmem - freemem;
+
+ char shell[64];
+ snprintf(shell, sizeof shell, "%s", getenv("SHELL") ? getenv("SHELL") : "Unknown");
+ char term[64];
+ snprintf(term, sizeof term, "%s", getenv("TERM") ? getenv("TERM") : "Unknown");
+
+ char packages[32] = "Unknown";
+ if ((fp = popen("dpkg-query -f '${binary:Package}\\n' -W 2>/dev/null | wc -l", "r"))) {
+ if (fgets(packages, sizeof packages, fp))
+ packages[strcspn(packages, "\n")] = '\0';
+ pclose(fp);
+ }
+
+ printf("\x1b[38;2;%d;%d;%dmHost:\x1b[0m %s\n", r, g, b, host);
+ printf("\x1b[38;2;%d;%d;%dmOS:\x1b[0m %s\n", r, g, b, os);
+ printf("\x1b[38;2;%d;%d;%dmKernel:\x1b[0m %s\n", r, g, b, uts.release);
+ printf("\x1b[38;2;%d;%d;%dmUptime:\x1b[0m %ldd %ldh %ldm\n", r, g, b, updays, uphours, upmins);
+ printf("\x1b[38;2;%d;%d;%dmPackages:\x1b[0m %s\n", r, g, b, packages);
+ printf("\x1b[38;2;%d;%d;%dmShell:\x1b[0m %s\n", r, g, b, shell);
+ printf("\x1b[38;2;%d;%d;%dmTerminal:\x1b[0m %s\n", r, g, b, term);
+ printf("\x1b[38;2;%d;%d;%dmCPU:\x1b[0m %s\n", r, g, b, cpu);
+ printf("\x1b[38;2;%d;%d;%dmMemory:\x1b[0m %ldMiB / %ldMiB\n", r, g, b, usedmem, totalmem);
+
+ return 0;
+}