fordon_greeman / sfetch

theidioticdev committed 2026-09-03 commit b5a02a245e0f74c7939a513865c34cce1329a2b7
Showing 8 changed files with 205 additions and 0 deletions. UnifiedSplit
+36 −0 Makefile new file mode 100644
@@ -0,0 +1,36 @@
1 +PREFIX ?= /usr/local
2 +BINDIR := $(PREFIX)/bin
3 +
4 +CC := clang
5 +CFLAGS := -Wall -Wextra -Werror -std=c11 -pedantic -g -fcolor-diagnostics
6 +
7 +SRC := src/main.c
8 +OBJ := build/main.o
9 +TARGET := bin/sfetch
10 +
11 +.PHONY: all clean run install uninstall
12 +
13 +all: $(TARGET)
14 +
15 +$(TARGET): $(OBJ) | bin
16 + $(CC) $(LDFLAGS) $^ -o $@
17 +
18 +build/%.o: src/%.c | build
19 + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
20 +
21 +build bin:
22 + mkdir -p $@
23 +
24 +-include build/main.d
25 +
26 +run: all
27 + @./$(TARGET)
28 +
29 +install: all
30 + install -Dm755 $(TARGET) $(DESTDIR)$(BINDIR)/sfetch
31 +
32 +uninstall:
33 + rm -f $(DESTDIR)$(BINDIR)/sfetch
34 +
35 +clean:
36 + rm -rf build bin
+0 −0 bin/sfetch new file mode 100755, Binary files /dev/null and b/bin/sfetch differ
+1 −0 build/main.d new file mode 100644
@@ -0,0 +1 @@
1 +build/main.o: src/main.c
+0 −0 build/main.o new file mode 100644, Binary files /dev/null and b/build/main.o differ
+61 −0 flake.lock new file mode 100644
@@ -0,0 +1,61 @@
1 +{
2 + "nodes": {
3 + "flake-utils": {
4 + "inputs": {
5 + "systems": "systems"
6 + },
7 + "locked": {
8 + "lastModified": 1731533236,
9 + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
10 + "owner": "numtide",
11 + "repo": "flake-utils",
12 + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
13 + "type": "github"
14 + },
15 + "original": {
16 + "owner": "numtide",
17 + "repo": "flake-utils",
18 + "type": "github"
19 + }
20 + },
21 + "nixpkgs": {
22 + "locked": {
23 + "lastModified": 1762596750,
24 + "narHash": "sha256-rXXuz51Bq7DHBlfIjN7jO8Bu3du5TV+3DSADBX7/9YQ=",
25 + "owner": "NixOS",
26 + "repo": "nixpkgs",
27 + "rev": "b6a8526db03f735b89dd5ff348f53f752e7ddc8e",
28 + "type": "github"
29 + },
30 + "original": {
31 + "owner": "NixOS",
32 + "ref": "nixos-unstable",
33 + "repo": "nixpkgs",
34 + "type": "github"
35 + }
36 + },
37 + "root": {
38 + "inputs": {
39 + "flake-utils": "flake-utils",
40 + "nixpkgs": "nixpkgs"
41 + }
42 + },
43 + "systems": {
44 + "locked": {
45 + "lastModified": 1681028828,
46 + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
47 + "owner": "nix-systems",
48 + "repo": "default",
49 + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
50 + "type": "github"
51 + },
52 + "original": {
53 + "owner": "nix-systems",
54 + "repo": "default",
55 + "type": "github"
56 + }
57 + }
58 + },
59 + "root": "root",
60 + "version": 7
61 +}
+35 −0 flake.nix new file mode 100644
@@ -0,0 +1,35 @@
1 +{
2 + description = "sfetch devshell";
3 +
4 + inputs = {
5 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 + flake-utils.url = "github:numtide/flake-utils";
7 + };
8 +
9 + outputs = {
10 + self,
11 + nixpkgs,
12 + flake-utils,
13 + }:
14 + flake-utils.lib.eachDefaultSystem (
15 + system: let
16 + pkgs = nixpkgs.legacyPackages.${system};
17 + in {
18 + devShells.default = pkgs.mkShell {
19 + buildInputs = with pkgs; [
20 + gnumake
21 + clang-tools
22 + clang
23 + valgrind
24 + bear
25 + man-pages
26 + man-pages-posix
27 + ];
28 +
29 + shellHook = ''
30 + source ~/.bashrc
31 + '';
32 + };
33 + }
34 + );
35 +}
+25 −0 readme.org new file mode 100644
@@ -0,0 +1,25 @@
1 +#+TITLE: sfetch (suckless fetch)
2 +#+AUTHOR: theidioticdev
3 +#+OPTIONS: toc:nil num:nil
4 +
5 +a suckless-adjacent fetching program I wrote to improve at C.
6 +[[./assets/screenshot.png]]
7 +
8 +just like suckless.org's projects (dwm, st, surf, etc...), sfetch is configured via editing the source code.
9 +
10 +* installation
11 +** first:
12 + -make sure you have the dependencies required:
13 + 1. a compiler (=gcc=, =clang=)
14 + 2. gnumake (make)
15 + 3. a c lib (glibc, musl, etc...)
16 +** second:
17 +#+BEGIN_SRC sh
18 +git clone https://codeberg.org/theidioticdev/sfetch
19 +cd sfetch
20 +make PREFIX=$HOME/.local install # for user-only
21 +sudo/doas make install # system-wide
22 +#+END_SRC
23 +
24 +** customization:
25 +to customize sfetch, you edit the src/main.c file
+47 −0 src/main.c new file mode 100644
@@ -0,0 +1,47 @@
1 +#include <stdio.h>
2 +#include <sys/utsname.h>
3 +#include <stdlib.h>
4 +
5 +static const char asciiArt[] =
6 +" \n"
7 +" ██████ \n"
8 +" ██████████ \n"
9 +" ███ ███ \n"
10 +" ███ \n"
11 +" ████████ \n"
12 +" █████████ \n"
13 +" ███ \n"
14 +" ███ ███ \n"
15 +" ██████████ \n"
16 +" ██████ \n"
17 +" ";
18 +
19 +void printAscii(void) {
20 + printf("%s\n\n", asciiArt);
21 +}
22 +
23 +int printStats(void) {
24 +
25 + char *wm = getenv("XDG_SESSION_DESKTOP");
26 + if (!wm) {
27 + wm = getenv("DESKTOP_SESSION");
28 + }
29 + struct utsname info;
30 +
31 + if (uname(&info) != 0) {
32 + perror("uname");
33 + return 1;
34 + }
35 + printf("OS: %s\n", info.sysname);
36 + printf("Kernel: %s\n", info.release);
37 + printf("Host: %s\n", info.nodename);
38 + printf("WM: %s\n", wm ? wm : "Unknown");
39 +
40 + return 0;
41 +}
42 +
43 +int main(void) {
44 + printAscii();
45 + printStats();
46 + return 0;
47 +}