Skip to content

Commit f668700

Browse files
Copilotjiacai2050
andauthored
Add fastfetch binary: system information fetcher (#69)
* Initial plan * Add fastfetch binary: system information fetcher Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com> * Use fs.cwd().openFile for absolute paths (Zig 0.15 API) Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com> * feat(fastfetch): Show detailed system info for Linux and macOS Expand fastfetch output with host model, disk usage, display resolution, battery, and theme. Add cross-platform C imports and correct framework linking on macOS. Improve CPU, memory, and uptime reporting to show more details and handle both Linux and macOS OS-specific fields. This change allows users to quickly view comprehensive hardware and OS information, motivating the update to facilitate troubleshooting and system inventory. * docs(programs): add fastfetch introduction and usage guide Introduce documentation for fastfetch, including usage examples, key features, and output demonstration. This provides new and existing users with a clear overview of fastfetch's capabilities and platform support, enhancing accessibility and understanding without requiring inspection of the source code. * feat(build): extend compile blacklist to include fastfetch Add "fastfetch" to the build blacklist to prevent compilation on non-Darwin systems. This change ensures platform-specific targets are handled consistently and avoids build errors caused by unsupported executables. * feat(resolution): Display refresh rate in resolution output Show monitor refresh rate in resolution info on macOS, providing users a more accurate overview of display settings. Improves UX for those needing detailed screen specs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com> Co-authored-by: jiacai2050 <dev@liujiacai.net>
1 parent 8263179 commit f668700

3 files changed

Lines changed: 709 additions & 2 deletions

File tree

build.zig

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ fn buildBinaries(
119119
"tcp-proxy",
120120
"timeout",
121121
"cowsay",
122+
"fastfetch",
122123
"progress",
123124
}) |name| {
124125
try buildBinary(
@@ -200,8 +201,10 @@ fn makeCompileStep(
200201
const is_darwin = @import("builtin").os.tag == .macos and target.result.os.tag == .macos;
201202
const is_win = target.result.os.tag == .windows;
202203
if (!is_darwin) {
203-
if (std.mem.eql(u8, name, "night-shift") or std.mem.eql(u8, name, "dark-mode")) {
204-
return null;
204+
inline for (.{ "night-shift", "dark-mode", "fastfetch" }) |blacklist| {
205+
if (std.mem.eql(u8, name, blacklist)) {
206+
return null;
207+
}
205208
}
206209
}
207210
const exe = b.addExecutable(.{
@@ -244,6 +247,17 @@ fn makeCompileStep(
244247
} else {
245248
return null;
246249
}
250+
} else if (std.mem.eql(u8, name, "fastfetch")) {
251+
if (is_win) {
252+
return null;
253+
}
254+
// fastfetch uses @cImport which requires linking libc to find headers.
255+
exe.linkLibC();
256+
if (is_darwin) {
257+
exe.linkFramework("CoreGraphics");
258+
exe.linkFramework("Foundation");
259+
exe.linkFramework("IOKit");
260+
}
247261
} else if (std.mem.eql(u8, name, "progress")) {
248262
// Linux uses the /proc filesystem; macOS uses libproc.
249263
if (target.result.os.tag == .linux) {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#+TITLE: fastfetch
2+
#+DATE: 2026-03-16T20:30:00+0800
3+
#+TYPE: docs
4+
#+DESCRIPTION: A high-performance system information fetcher written in Zig
5+
6+
#+begin_src bash :results verbatim :exports results :wrap example :dir ../../..
7+
./zig-out/bin/fastfetch -h
8+
#+end_src
9+
10+
#+RESULTS:
11+
#+begin_example
12+
USAGE:
13+
./zig-out/bin/fastfetch [OPTIONS]
14+
15+
OPTIONS:
16+
-h, --help Print help information.
17+
-v, --version Print version.
18+
#+end_example
19+
20+
** Features
21+
=fastfetch= is a lightweight, high-performance system information fetcher inspired by the original =fastfetch=. It aims to be extremely fast by avoiding external process calls and using native C APIs or virtual filesystems instead.
22+
23+
- **Cross-platform**: Supports both macOS and Linux.
24+
- **Detailed Memory Info**:
25+
- On macOS: Provides breakdown of App Memory, Wired Memory, and Compressed Memory (matching Activity Monitor).
26+
- On Linux: Provides Swap usage details.
27+
- **Hardware Insights**: Displays CPU core distribution (Performance vs. Efficiency cores on Apple Silicon), GPU (macOS), and Page Size.
28+
- **High Performance**: Uses =sysctl=, =IOKit=, =CoreFoundation= on macOS and =procfs=, =sysfs= on Linux.
29+
30+
** Demo
31+
#+begin_src bash :results verbatim :exports results :wrap example :dir ../../..
32+
./zig-out/bin/fastfetch
33+
#+end_src
34+
35+
#+RESULTS:
36+
#+begin_example
37+
jiacai@mario
38+
────────────
39+
OS: macOS 26.3 aarch64
40+
Host: Mac14,10
41+
Kernel: 25.3.0
42+
Uptime: 18 days, 12 hours, 15 mins
43+
Shell: bash
44+
Resolution: 1728x1117 @ 120Hz
45+
Theme: Light
46+
CPU: Apple M2 Pro (12 cores: 8P + 4E)
47+
Memory: 25583 MiB / 32768 MiB (78%) [App: 8817 MiB, Wired: 3915 MiB, Compressed: 12851 MiB]
48+
Disk: 827 GiB / 926 GiB (89%)
49+
Battery: 80% [Discharging]
50+
Page: 16 KiB
51+
#+end_example

0 commit comments

Comments
 (0)