peekfetch 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amine Alouini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,176 @@
1
- # Temporary Holding Version
1
+ # peekfetch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A fast, dependency-free system info tool for your terminal. It's a neofetch alternative that
4
+ runs every probe concurrently, so it is about 2.5× faster on macOS, and it fixes several of
5
+ neofetch's wrong readings along the way.
6
+
7
+ ```
8
+ 'c. amine@macbook
9
+ ,xNMM. -------------
10
+ .OMMMMo OS: macOS Tahoe 26.1 (25B78) arm64
11
+ OMMM0, Host: MacBook Air (Mac14,15)
12
+ .;loddo:' loolloddol;. Kernel: Darwin 25.1.0
13
+ cKMMMMMMMMMMNWMMMMMMMMMM0: Uptime: 3 days, 8 hours, 21 mins
14
+ .KMMMMMMMMMMMMMMMMMMMMMMMWd. Packages: 157 (brew), 2 (brew-cask)
15
+ XMMMMMMMMMMMMMMMMMMMMMMMX. Shell: zsh 5.9
16
+ ;MMMMMMMMMMMMMMMMMMMMMMMM: Resolution: 1710x1107 @ 60Hz
17
+ :MMMMMMMMMMMMMMMMMMMMMMMM: DE: Aqua
18
+ .MMMMMMMMMMMMMMMMMMMMMMMMX. WM: Quartz Compositor
19
+ kMMMMMMMMMMMMMMMMMMMMMMMMWd. Theme: Multicolor (Light)
20
+ .XMMMMMMMMMMMMMMMMMMMMMMMMMMk Terminal: Apple Terminal 455.1
21
+ .XMMMMMMMMMMMMMMMMMMMMMMMMK. Terminal Font: SFMonoTerminal-Regular 12
22
+ kMMMMMMMMMMMMMMMMMMMMMMd CPU: Apple M2 (8) [4P + 4E]
23
+ ;KMMMMMMMWXXWMMMMMMMk. GPU: Apple M2 (10 cores)
24
+ .cooc,. .,coo:. Memory: 19.67 GiB / 24.00 GiB (82%)
25
+ Swap: 1.02 GiB / 2.00 GiB (51%)
26
+ Disk (/): 372.08 GiB / 460.43 GiB (81%)
27
+ Battery: 85% (charging)
28
+ Locale: en_US.UTF-8
29
+ ```
30
+
31
+ ## Install
32
+
33
+ ```sh
34
+ # npm (any OS with Node.js 18.15+)
35
+ npm install -g peekfetch
36
+
37
+ # or run it without installing
38
+ npx peekfetch
39
+
40
+ # Homebrew (macOS, Linux)
41
+ brew install alouini333/tap/peekfetch
42
+ ```
43
+
44
+ ## Why another fetch tool?
45
+
46
+ neofetch was archived in 2024. It is a single 10,500-line Bash script that runs about 490
47
+ subshells one after another. peekfetch started as a reverse-engineering exercise: read
48
+ neofetch, document how it works ([docs/HOW-NEOFETCH-WORKS.md](docs/HOW-NEOFETCH-WORKS.md)),
49
+ then rebuild it properly.
50
+
51
+ | | neofetch | peekfetch |
52
+ | --- | --- | --- |
53
+ | Speed (M2 MacBook Air, all modules) | ~0.6 s | ~0.25 s |
54
+ | Probes | sequential | concurrent, each with a time budget |
55
+ | Memory on Apple Silicon | wrong: assumes 4 KiB pages, under-reports ~4× | Activity Monitor's numbers |
56
+ | Output in pipes and files | cursor escape codes | the same text you see in the terminal |
57
+ | Narrow terminals | lines cut off | small logo, then no logo, then `…` truncation |
58
+ | Machine-readable output | no | `--json` |
59
+ | Config | Bash, `eval`'d | JSON (comments allowed) |
60
+ | Logos | 230+ | the same 230+, extracted from neofetch |
61
+ | Dependencies | Bash + coreutils | Node.js, nothing else |
62
+
63
+ ## Usage
64
+
65
+ ```sh
66
+ peekfetch # the full picture
67
+ peekfetch --logo arch --small # any of the 230+ logos, small variant if there is one
68
+ peekfetch -m os,cpu,memory # only these lines
69
+ peekfetch --bars # usage bars for memory, swap, disk, battery
70
+ peekfetch --json | jq .memory # structured output for scripts
71
+ peekfetch --stdout # plain "Label: value" lines (neofetch compatible)
72
+ peekfetch --timing # see which probe is slow
73
+ ```
74
+
75
+ | Option | |
76
+ | --- | --- |
77
+ | `-l, --logo <name\|path\|none>` | Distro logo (see `--list-logos`), a text file with ASCII art, or `none` |
78
+ | `--small` | Small logo variant when one exists |
79
+ | `--no-logo` | Hide the logo |
80
+ | `--logo-colors <list>` | Override logo colors: `4,6`, `208,fg`, `#ff8800` |
81
+ | `-m, --modules <list>` | Comma-separated lines to show, in order |
82
+ | `--bars` | Usage bars |
83
+ | `--no-color` / `--color` | Turn colors off / force them on (`NO_COLOR` and `FORCE_COLOR` work too) |
84
+ | `--json` | All detected info as JSON |
85
+ | `--stdout` | Plain text, no logo, no colors |
86
+ | `-c, --config <path>` | Use a specific config file |
87
+ | `--print-config`, `--gen-config` | Print / write the default config |
88
+ | `--no-cache` | Skip the cache (`~/Library/Caches/peekfetch`, `~/.cache/peekfetch`) |
89
+ | `--list-logos`, `--list-modules` | What's available |
90
+ | `--timing` | Per-module timings on stderr |
91
+
92
+ ### Modules
93
+
94
+ `title` `separator` `os` `host` `kernel` `uptime` `packages` `shell` `resolution` `de` `wm`
95
+ `theme` `icons` `terminal` `font` `cpu` `gpu` `memory` `swap` `disk` `battery` `ip` `locale`
96
+ `break` `colors`
97
+
98
+ Modules that find nothing (no battery on a desktop, no swap, …) are skipped. `ip` is off by
99
+ default, so screenshots don't leak your local address.
100
+
101
+ ## Configuration
102
+
103
+ `peekfetch --gen-config` writes the defaults to `~/.config/peekfetch/config.json`
104
+ (`%APPDATA%\peekfetch\config.json` on Windows; `PEEKFETCH_CONFIG` overrides the path).
105
+ Comments and trailing commas are fine.
106
+
107
+ ```jsonc
108
+ {
109
+ "modules": ["title", "separator", "os", "host", "kernel", "uptime", "packages", "shell",
110
+ "terminal", "cpu", "gpu", "memory", "disk", "break", "colors"],
111
+ "logo": "auto", // or "arch", "ubuntu_small", "/path/to/art.txt", "none"
112
+ "smallLogo": false,
113
+ "logoColors": null, // e.g. [4, 6]. 0-255, "fg", or "#rrggbb"
114
+ "textColors": null, // e.g. { "title": 4, "label": 6, "info": "fg" }
115
+ "labels": { "memory": "RAM" },
116
+ "gap": 3,
117
+ "separator": ":",
118
+ "underline": "-",
119
+ "bars": false,
120
+ "barWidth": 12,
121
+ "disks": ["/", "/home"], // null = "/" (or the system drive on Windows)
122
+ "bold": true,
123
+ "timeout": 2500 // ms per module; slow probes are dropped, not waited for
124
+ }
125
+ ```
126
+
127
+ Custom ASCII art works the neofetch way: put `${c1}`…`${c6}` where colors should change.
128
+
129
+ ## Platform support
130
+
131
+ | | |
132
+ | --- | --- |
133
+ | macOS | Full. Tested on Apple Silicon. |
134
+ | Linux | Full. Tested in Debian, Ubuntu, Fedora, Arch and Alpine containers. DE/WM detection covers X11 and Wayland but has not been tested on a desktop yet. |
135
+ | Windows | Core modules (OS, host, CPU, GPU, memory, disk, battery, shell, terminal). Runs in CI. |
136
+ | FreeBSD and other BSDs | Basic (OS, kernel, CPU, memory, disk, packages via `pkg`). Untested. |
137
+
138
+ A few deliberate differences from neofetch:
139
+
140
+ - **Disk on macOS** reports the APFS container, which is what Finder shows. `df /` shows only
141
+ the sealed system volume (~13 GiB).
142
+ - **Shell** is the shell that launched peekfetch, not `$SHELL`.
143
+ - **Kernel** includes the kernel name (`Darwin 25.1.0`, `Linux 6.8.0-45-generic`).
144
+
145
+ ## Development
146
+
147
+ ```sh
148
+ npm test # node:test, no dependencies
149
+ node bin/peekfetch.js --timing # run from the checkout
150
+ npm run logos -- /path/to/neofetch # regenerate src/logos/logos.json
151
+ ```
152
+
153
+ The code is small and split by concern:
154
+
155
+ ```
156
+ src/
157
+ index.js main(): parse args, load config, run modules concurrently, render
158
+ context.js memoized shared probes (process tree, os-release, system_profiler)
159
+ modules/ one file per area: system, packages, terminal, desktop, hardware
160
+ parsers.js pure parsers for vm_stat, /proc/meminfo, lspci, xrandr, … (unit tested)
161
+ render.js logo coloring, info lines, side-by-side layout
162
+ logos/ logos.json (extracted from neofetch) and the matcher
163
+ ```
164
+
165
+ Adding a module means adding `{ key, label, get(ctx) }` to one of the files in `src/modules/`.
166
+ `get` returns a string, an array of strings, or `{ text, data }`, where `data` is what `--json`
167
+ prints.
168
+
169
+ ## Credits
170
+
171
+ The ASCII logos come from [neofetch](https://github.com/dylanaraps/neofetch) by Dylan Araps,
172
+ used under the MIT license (see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)).
173
+
174
+ ## License
175
+
176
+ MIT
@@ -0,0 +1,29 @@
1
+ # Third-party notices
2
+
3
+ `src/logos/logos.json` contains ASCII art extracted from neofetch
4
+ (https://github.com/dylanaraps/neofetch) by `scripts/extract-neofetch-logos.mjs`.
5
+ neofetch is distributed under the following license:
6
+
7
+ ```
8
+ The MIT License (MIT)
9
+
10
+ Copyright (c) 2015-2020 Dylan Araps
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ ```
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../src/index.js';
3
+
4
+ // `peekfetch | head -3` closes the pipe early; that is not an error.
5
+ process.stdout.on('error', (err) => {
6
+ if (err.code === 'EPIPE') process.exit(0);
7
+ throw err;
8
+ });
9
+
10
+ const code = await main(process.argv.slice(2));
11
+
12
+ // A probe that timed out may still have a child process running. Exit once stdout
13
+ // has flushed instead of waiting for it.
14
+ process.stdout.write('', () => process.exit(code));
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "peekfetch",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "A fast, dependency-free neofetch alternative: system info next to your distro's logo",
5
+ "type": "module",
6
+ "bin": {
7
+ "peekfetch": "bin/peekfetch.js"
8
+ },
9
+ "exports": {
10
+ ".": "./src/index.js"
11
+ },
12
+ "files": [
13
+ "bin",
14
+ "src",
15
+ "THIRD_PARTY_NOTICES.md"
16
+ ],
17
+ "engines": {
18
+ "node": ">=18.15"
19
+ },
20
+ "scripts": {
21
+ "start": "node bin/peekfetch.js",
22
+ "test": "node --test",
23
+ "logos": "node scripts/extract-neofetch-logos.mjs"
24
+ },
25
+ "keywords": [
26
+ "neofetch",
27
+ "fetch",
28
+ "sysinfo",
29
+ "system-information",
30
+ "cli",
31
+ "terminal",
32
+ "ascii-art",
33
+ "screenfetch",
34
+ "fastfetch"
35
+ ],
36
+ "author": "Amine Alouini",
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/alouini333/peekfetch.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/alouini333/peekfetch/issues"
44
+ },
45
+ "homepage": "https://github.com/alouini333/peekfetch#readme"
46
+ }
package/src/ansi.js ADDED
@@ -0,0 +1,89 @@
1
+ // Terminal color and width helpers.
2
+
3
+ export const RESET = '\x1b[0m';
4
+ export const BOLD = '\x1b[1m';
5
+ export const DIM = '\x1b[2m';
6
+
7
+ const ANSI_RE = /\x1b\[[0-9;?]*[A-Za-z]/g;
8
+
9
+ export const stripAnsi = (s) => String(s).replace(ANSI_RE, '');
10
+
11
+ /**
12
+ * neofetch-compatible color codes:
13
+ * 0-6 -> standard foreground colors (preceded by a reset, like neofetch)
14
+ * 7 / "fg" -> the terminal's default foreground
15
+ * 8-255 -> 256-color palette
16
+ * "#rrggbb" -> truecolor (a peekfetch extension)
17
+ */
18
+ export function color(c) {
19
+ if (c === undefined || c === null || c === '') return '';
20
+ if (c === 'fg' || c === 7 || c === '7') return RESET;
21
+ if (typeof c === 'string' && /^#?[0-9a-f]{6}$/i.test(c)) {
22
+ const hex = c.replace('#', '');
23
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16));
24
+ return `\x1b[38;2;${r};${g};${b}m`;
25
+ }
26
+ const n = Number(c);
27
+ if (!Number.isInteger(n) || n < 0 || n > 255) return '';
28
+ if (n <= 6) return `${RESET}\x1b[3${n}m`;
29
+ return `\x1b[38;5;${n}m`;
30
+ }
31
+
32
+ // Display width of a code point: 0 for control/combining, 2 for wide East Asian and emoji.
33
+ function charWidth(cp) {
34
+ if (cp < 32 || (cp >= 0x7f && cp < 0xa0)) return 0;
35
+ if ((cp >= 0x300 && cp <= 0x36f) || cp === 0x200b || cp === 0x200d || (cp >= 0xfe00 && cp <= 0xfe0f)) return 0;
36
+ if (
37
+ (cp >= 0x1100 && cp <= 0x115f) ||
38
+ (cp >= 0x2e80 && cp <= 0xa4cf && cp !== 0x303f) ||
39
+ (cp >= 0xac00 && cp <= 0xd7a3) ||
40
+ (cp >= 0xf900 && cp <= 0xfaff) ||
41
+ (cp >= 0xfe30 && cp <= 0xfe4f) ||
42
+ (cp >= 0xff00 && cp <= 0xff60) ||
43
+ (cp >= 0xffe0 && cp <= 0xffe6) ||
44
+ (cp >= 0x1f300 && cp <= 0x1f64f) ||
45
+ (cp >= 0x1f900 && cp <= 0x1f9ff) ||
46
+ (cp >= 0x20000 && cp <= 0x3fffd)
47
+ ) {
48
+ return 2;
49
+ }
50
+ return 1;
51
+ }
52
+
53
+ export function visibleWidth(s) {
54
+ let w = 0;
55
+ for (const ch of stripAnsi(s)) w += charWidth(ch.codePointAt(0));
56
+ return w;
57
+ }
58
+
59
+ export function padEnd(s, width) {
60
+ const w = visibleWidth(s);
61
+ return w >= width ? s : s + ' '.repeat(width - w);
62
+ }
63
+
64
+ /** Cut a string to `max` visible columns, keeping escape codes intact. */
65
+ export function truncate(s, max) {
66
+ if (max <= 0) return '';
67
+ if (visibleWidth(s) <= max) return s;
68
+ let out = '';
69
+ let w = 0;
70
+ let i = 0;
71
+ const str = String(s);
72
+ while (i < str.length) {
73
+ if (str[i] === '\x1b') {
74
+ const m = /^\x1b\[[0-9;?]*[A-Za-z]/.exec(str.slice(i));
75
+ if (m) {
76
+ out += m[0];
77
+ i += m[0].length;
78
+ continue;
79
+ }
80
+ }
81
+ const ch = String.fromCodePoint(str.codePointAt(i));
82
+ const cw = charWidth(ch.codePointAt(0));
83
+ if (w + cw > max - 1) break;
84
+ out += ch;
85
+ w += cw;
86
+ i += ch.length;
87
+ }
88
+ return out + '…' + (str.includes('\x1b') ? RESET : '');
89
+ }
package/src/cache.js ADDED
@@ -0,0 +1,52 @@
1
+ // A tiny JSON file cache for probes that are slow but rarely change (e.g. the Mac model name).
2
+
3
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import { homedir } from 'node:os';
5
+ import { join } from 'node:path';
6
+
7
+ export function cacheDir() {
8
+ const env = process.env;
9
+ if (process.platform === 'darwin') return join(homedir(), 'Library', 'Caches', 'peekfetch');
10
+ if (process.platform === 'win32') return join(env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local'), 'peekfetch', 'Cache');
11
+ return join(env.XDG_CACHE_HOME ?? join(homedir(), '.cache'), 'peekfetch');
12
+ }
13
+
14
+ export function createCache({ enabled = true, dir = cacheDir() } = {}) {
15
+ const file = join(dir, 'cache.json');
16
+ let data = null;
17
+ let dirty = false;
18
+
19
+ const load = () => {
20
+ if (data) return data;
21
+ try {
22
+ data = enabled ? JSON.parse(readFileSync(file, 'utf8')) : {};
23
+ } catch {
24
+ data = {};
25
+ }
26
+ return data;
27
+ };
28
+
29
+ return {
30
+ /** Return the cached value for `key`, or compute, store and return it. */
31
+ async remember(key, compute, ttlMs = Infinity) {
32
+ const store = load();
33
+ const hit = store[key];
34
+ if (enabled && hit && (ttlMs === Infinity || Date.now() - hit.t < ttlMs)) return hit.v;
35
+ const value = await compute();
36
+ if (value !== null && value !== undefined) {
37
+ store[key] = { t: Date.now(), v: value };
38
+ dirty = true;
39
+ }
40
+ return value;
41
+ },
42
+ flush() {
43
+ if (!enabled || !dirty) return;
44
+ try {
45
+ mkdirSync(dir, { recursive: true });
46
+ writeFileSync(file, JSON.stringify(data));
47
+ } catch {
48
+ // A read-only home directory should never break the output.
49
+ }
50
+ },
51
+ };
52
+ }
package/src/cli.js ADDED
@@ -0,0 +1,91 @@
1
+ // Argument parsing. Hand-rolled to keep peekfetch dependency-free.
2
+
3
+ const FLAGS = {
4
+ '-h': 'help', '--help': 'help',
5
+ '-v': 'version', '--version': 'version',
6
+ '--json': 'json',
7
+ '--stdout': 'stdout',
8
+ '--no-logo': 'noLogo',
9
+ '--no-color': 'noColor',
10
+ '--color': 'forceColor',
11
+ '--small': 'small',
12
+ '--bars': 'bars',
13
+ '--list-logos': 'listLogos',
14
+ '--list-modules': 'listModules',
15
+ '--print-config': 'printConfig',
16
+ '--gen-config': 'genConfig',
17
+ '--force': 'force',
18
+ '--timing': 'timing',
19
+ '--no-cache': 'noCache',
20
+ };
21
+
22
+ const OPTIONS = {
23
+ '-l': 'logo', '--logo': 'logo',
24
+ '-m': 'modules', '--modules': 'modules',
25
+ '-c': 'config', '--config': 'config',
26
+ '--logo-colors': 'logoColors',
27
+ };
28
+
29
+ const list = (v) => v.split(',').map((s) => s.trim()).filter(Boolean);
30
+ const colorValue = (v) => (/^\d+$/.test(v) ? Number(v) : v);
31
+
32
+ export function parseArgs(argv) {
33
+ const args = {};
34
+ for (let i = 0; i < argv.length; i++) {
35
+ let arg = argv[i];
36
+ let value;
37
+ const eq = arg.indexOf('=');
38
+ if (arg.startsWith('--') && eq > 0) {
39
+ value = arg.slice(eq + 1);
40
+ arg = arg.slice(0, eq);
41
+ }
42
+ if (FLAGS[arg]) {
43
+ if (value !== undefined) throw new Error(`option ${arg} does not take a value`);
44
+ args[FLAGS[arg]] = true;
45
+ } else if (OPTIONS[arg]) {
46
+ value ??= argv[++i];
47
+ if (value === undefined || value === '') throw new Error(`option ${arg} needs a value`);
48
+ args[OPTIONS[arg]] = value;
49
+ } else {
50
+ throw new Error(arg.startsWith('-') ? `unknown option: ${arg}` : `unexpected argument: ${arg}`);
51
+ }
52
+ }
53
+ if (args.modules) args.modules = list(args.modules);
54
+ if (args.logoColors) args.logoColors = list(args.logoColors).map(colorValue);
55
+ return args;
56
+ }
57
+
58
+ export const HELP = `peekfetch - a fast, dependency-free system info tool (a neofetch alternative)
59
+
60
+ Usage: peekfetch [options]
61
+
62
+ Display:
63
+ -l, --logo <name|path|none> Logo to show: a distro name (see --list-logos),
64
+ a text file with ASCII art, or "none"
65
+ --small Use the small logo variant when one exists
66
+ --no-logo Hide the logo
67
+ --logo-colors <list> Logo colors, e.g. "4,6" or "#ff8800,fg"
68
+ -m, --modules <list> Lines to show, comma-separated, e.g. "os,cpu,memory"
69
+ --bars Draw usage bars for memory, swap, disk and battery
70
+ --no-color Disable colors (NO_COLOR is honored too)
71
+ --color Force colors even when not writing to a terminal
72
+
73
+ Output:
74
+ --json Print all detected info as JSON
75
+ --stdout Plain "Label: value" lines, no logo or colors
76
+
77
+ Config:
78
+ -c, --config <path> Use this config file
79
+ --print-config Print the default config
80
+ --gen-config [--force] Write the default config to the config path
81
+ --no-cache Ignore and do not write the cache
82
+
83
+ Info:
84
+ --list-logos List available logos
85
+ --list-modules List available modules
86
+ --timing Show how long each module took (on stderr)
87
+ -v, --version Print the version
88
+ -h, --help Show this help
89
+
90
+ Config file: $XDG_CONFIG_HOME/peekfetch/config.json (override with PEEKFETCH_CONFIG)
91
+ `;
package/src/config.js ADDED
@@ -0,0 +1,65 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { DEFAULT_MODULES } from './modules/index.js';
5
+ import { stripJsonComments } from './parsers.js';
6
+
7
+ export const DEFAULT_CONFIG = {
8
+ // Which lines to show, in order. Layout entries: "separator", "break", "colors".
9
+ modules: DEFAULT_MODULES,
10
+ // "auto" (detect), a distro name (see --list-logos), "none", or a path to a text file.
11
+ logo: 'auto',
12
+ // Use the small logo variant when one exists.
13
+ smallLogo: false,
14
+ // Override logo colors, e.g. [4, 6]. Values: 0-255, "fg", or "#rrggbb".
15
+ logoColors: null,
16
+ // Override text colors: { title, at, separator, label, colon, info }. Default: derived from the logo.
17
+ textColors: null,
18
+ // Rename labels, e.g. { "os": "System", "memory": "RAM" }.
19
+ labels: {},
20
+ // Spaces between logo and info.
21
+ gap: 3,
22
+ // Character between label and value.
23
+ separator: ':',
24
+ // Character used for the line under the title.
25
+ underline: '-',
26
+ // Draw usage bars for memory, swap, disk and battery.
27
+ bars: false,
28
+ barWidth: 12,
29
+ // Mount points for the disk module. null = "/" (or the system drive on Windows).
30
+ disks: null,
31
+ // Bold logo and labels, like neofetch.
32
+ bold: true,
33
+ // Per-module time budget in milliseconds. Slow probes are dropped, not waited for.
34
+ // Windows gets more: its probes share one PowerShell call that is slow to start.
35
+ timeout: process.platform === 'win32' ? 6000 : 2500,
36
+ };
37
+
38
+ export function configPath(env = process.env) {
39
+ if (env.PEEKFETCH_CONFIG) return env.PEEKFETCH_CONFIG;
40
+ if (process.platform === 'win32') return join(env.APPDATA ?? join(homedir(), 'AppData', 'Roaming'), 'peekfetch', 'config.json');
41
+ return join(env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'peekfetch', 'config.json');
42
+ }
43
+
44
+ /** Load the user's config (JSON with comments allowed). Missing file = defaults. */
45
+ export function loadConfig(path = configPath(), { required = false } = {}) {
46
+ let text;
47
+ try {
48
+ text = readFileSync(path, 'utf8');
49
+ } catch (err) {
50
+ if (required) throw new Error(`cannot read config ${path}: ${err.code ?? err.message}`);
51
+ return { ...DEFAULT_CONFIG };
52
+ }
53
+ let user;
54
+ try {
55
+ user = JSON.parse(stripJsonComments(text));
56
+ } catch (err) {
57
+ throw new Error(`invalid JSON in ${path}: ${err.message}`);
58
+ }
59
+ if (typeof user !== 'object' || user === null || Array.isArray(user)) throw new Error(`config ${path} must be a JSON object`);
60
+ return { ...DEFAULT_CONFIG, ...user, labels: { ...DEFAULT_CONFIG.labels, ...(user.labels ?? {}) } };
61
+ }
62
+
63
+ export function defaultConfigText() {
64
+ return JSON.stringify(DEFAULT_CONFIG, null, 2) + '\n';
65
+ }