Compare commits

..

632 Commits

Author SHA1 Message Date
Carter Li 5ede47fede Merge pull request #665 from fastfetch-cli/dev
Release v2.4.0
2023-12-18 23:02:03 +00:00
李通洲 d84ae91f59 Release: v2.4.0 2023-12-18 23:55:11 +08:00
apocelipes 70160d324f fix(DiskIO, PhysicalDisk): fix readlink 2023-12-18 14:31:05 +00:00
李通洲 600f6c7f24 Image: don't dlclose(imageMagick)
Fix: #552
2023-12-18 21:25:15 +08:00
李通洲 11b1b97567 IO: only retry when open() error is ENOENT / ERROR_PATH_NOT_FOUND
Close: #663
2023-12-18 21:08:29 +08:00
李通洲 4ae0c43c6f IO: remove support of FF_PATHTYPE_LINK 2023-12-18 20:49:32 +08:00
李通洲 e89d475a3b Presets: remove flag based config files 2023-12-18 16:13:45 +08:00
李通洲 4f3cd46f96 Presets: rename all flag based files to *.conf 2023-12-18 16:09:24 +08:00
李通洲 c076f5ae98 Github: update issue templates 2023-12-18 16:04:56 +08:00
李通洲 064d7d3c3a Doc: update changelog 2023-12-18 15:58:01 +08:00
李通洲 9937eeab1d Logo (Builtin): add EshanizedOS 2023-12-18 15:57:35 +08:00
李通洲 e8326306f8 Doc: add module physical disk 2023-12-18 15:53:15 +08:00
李通洲 89bc7eb015 DiskIO: move device info detected in PhysicalDisk module 2023-12-18 15:12:52 +08:00
李通洲 3cd81ec3ad PhysicalDisk: add new module 2023-12-18 15:12:52 +08:00
李通洲 0f497a53ad DiskIO (macOS): detect serial number and removable 2023-12-18 09:57:19 +08:00
Carter Li 569883a1a1 DiskIO (FreeBSD): detect disk serial number 2023-12-18 09:01:33 +08:00
李通洲 04a41cbd6b DiskIO (Windows): don't use registry 2023-12-17 21:49:54 +08:00
李通洲 4e4246a46a DiskIO (Windows): fix segfault and memleak 2023-12-17 19:40:24 +08:00
李通洲 c3a28064f6 DiskIO: tidy 2023-12-17 19:29:45 +08:00
李通洲 ce9f9ed7ed Windows: try fixing --no-buffer 2023-12-17 19:04:49 +08:00
李通洲 fb8c7d6e4a DiskIO: add property removable 2023-12-17 18:40:41 +08:00
李通洲 70f39e641c DiskIO (Windows): improve device name detection 2023-12-17 18:24:01 +08:00
李通洲 1dbd8474c2 DiskIO (Linux): fix serial number detection 2023-12-17 17:27:38 +08:00
李通洲 e7c787159a DiskIO: print serial number in json format
Always init serial property
2023-12-17 13:51:17 +08:00
李通洲 9339a0fb4e DiskIO (Windows): detect serial number 2023-12-17 13:43:52 +08:00
Carter Li b692b759c7 DiskIO (Linux): detect interconnect more aggressively 2023-12-17 12:52:34 +08:00
李通洲 529f94c64a DiskIO (Linux): better handling virtual devices 2023-12-17 12:21:12 +08:00
李通洲 e071a1eeb2 Disk (Linux): improve removable type detection 2023-12-17 12:13:28 +08:00
李通洲 3400e40e47 DiskIO (Linux): detect device serial number 2023-12-17 11:48:59 +08:00
李通洲 d32125e988 DiskIO (Linux): improve device name detection 2023-12-17 11:47:05 +08:00
李通洲 b3484088e9 FFPlatform (Linux): tidy 2023-12-17 11:46:28 +08:00
Carter Li f91a8aea4d DiskIO (Linux): improve detection
1. Ignore `dm-*`
2. Add devices that don't have disk ids
3. Fix  device size detection
2023-12-17 10:39:25 +08:00
Carter Li 335022e034 SMBIOS: ignore more meaningless values 2023-12-17 09:10:11 +08:00
Carter Li 8fa073b1e4 DisplayServer (Linux): test for status instead of enabled 2023-12-17 01:00:37 +08:00
李通洲 10e1753c03 DisplayServer (Linux): better handling abnormal situations
Try fix #660
2023-12-17 00:41:59 +08:00
李通洲 224a6a9881 TerminalShell: code cleanup 2023-12-15 14:29:51 +08:00
李通洲 e804dfc49e Memory (macOS): align algo of memory usage counting to stats
Which seems to print the same result of neofetch
2023-12-14 16:13:05 +08:00
李通洲 8048101eca Doc: fix documentation of --ds-force-drm 2023-12-14 16:13:05 +08:00
Horst G. Burkhardt 833727f333 remove unnecessary escaping for Adelie logo 2023-12-14 15:15:52 +08:00
李通洲 8ed5d30b3e Wifi (Windows): use less magic numbers 2023-12-13 19:33:20 +08:00
Carter Li f62cdff924 README: add start history 2023-12-13 02:56:13 -06:00
Carter Li 25a792743b WMDE: tidy 2023-12-12 18:22:20 +08:00
Carter Li b63e6a3053 DE (Linux): add support for CDE
Fix #658
2023-12-12 18:20:02 +08:00
李通洲 a565dcfb9e Doc: update changelog
Fix: #655
2023-12-12 10:12:12 +08:00
Carter Li 453f4757ed DE (FreeBSD): support detection with processes 2023-12-12 10:10:08 +08:00
李通洲 0555fb97e8 TerminalShell (Linux): tidy 2023-12-12 09:51:09 +08:00
李通洲 663d568927 DE (Linux): fix xfce4 version detection 2023-12-11 16:36:12 +08:00
李通洲 165c213ed0 FFstrbuf: don't crash with ffStrbufAppendNC(&str, 0, 'c') 2023-12-11 15:21:16 +08:00
李通洲 a28dc8a9bf DisplayServer (Linux): support --ds-force-drm sysfs-only 2023-12-11 13:25:58 +08:00
李通洲 f20b6d4387 Temps (macOS): support Apple M3 2023-12-08 16:10:10 +08:00
李通洲 4925222dab CI: run basic modules only in FreeBSD 2023-12-08 10:58:11 +08:00
李通洲 77cc0c61d7 Doc: update changelog 2023-12-08 10:28:03 +08:00
李通洲 a19888bb33 CI: don't run cpuusage in FreeBSD, which seems to have issues when running in VM 2023-12-08 10:28:03 +08:00
李通洲 40aa4a60d6 Packages: improve performance of pkg and rpm detection 2023-12-08 09:49:17 +08:00
Carter Li c4824b2b5d Merge pull request #654 from fastfetch-cli/dev
Release v2.3.4
2023-12-08 00:10:31 +08:00
李通洲 dcbda6c0d5 Release: v2.3.4 2023-12-08 00:04:38 +08:00
李通洲 91e4e94aaa CMake: fix --help doesn't work when building without python3 2023-12-07 23:51:56 +08:00
apocelipes 1504e26e38 optimize(Packages): optimize reading large files
Using less syscalls and processing data in memory
makes getNumStringsImpl ~300% faster.

The code is much simpler.
2023-12-07 20:32:14 +08:00
李通洲 a9c5c2892c Memory (Linux): Use MemAvailable if available 2023-12-07 16:30:10 +08:00
Carter Li 923997f0a2 Merge pull request #651 from fastfetch-cli/dev
Release v2.3.3
2023-12-07 09:39:07 +08:00
李通洲 0182e32f00 Release: v2.3.3 2023-12-07 09:33:26 +08:00
李通洲 bd40205427 Help: fix json text loading 2023-12-06 23:55:34 +08:00
Carter Li 30b9f95b49 Merge pull request #649 from fastfetch-cli/dev
Release v2.3.2
2023-12-06 11:20:24 +08:00
李通洲 74b9fd01ff CI (macOS): try fixing compiling 2023-12-06 11:06:52 +08:00
李通洲 03f4ffb9d7 Release: v2.3.2 2023-12-06 10:48:06 +08:00
李通洲 a00cb2aede CMake: install fish completion script 2023-12-06 10:38:55 +08:00
李通洲 6799076fa6 Logo (Builtin): fix compiling 2023-12-06 10:30:56 +08:00
李通洲 573a315d61 Help: tweaks 2023-12-06 10:29:28 +08:00
李通洲 0cd6cb841d Completion (Fish): fix fastfetch detection 2023-12-06 10:29:28 +08:00
xray_os af94cf4d0d fixing the name of my distro 2023-12-06 08:51:29 +08:00
Carter Li ac76107940 Merge pull request #647 from fastfetch-cli/dev
Release v2.3.1
2023-12-05 20:52:37 +08:00
李通洲 c25fe53251 Merge remote-tracking branch 'upstream/master' into dev 2023-12-05 20:50:10 +08:00
李通洲 4137b3829a Release v2.3.1 2023-12-05 20:48:09 +08:00
Viorel 0bb08049bf Fix man page install location 2023-12-05 20:41:20 +08:00
Carter Li 293576f6d6 Merge pull request #645 from fastfetch-cli/dev
Release 2.3.0
2023-12-05 18:45:02 +08:00
李通洲 0bc725c5f6 Release: v2.3.0 2023-12-05 15:56:10 +08:00
李通洲 c1c735001c Doc: update readme and changelog 2023-12-05 15:55:41 +08:00
李通洲 e350cce99e Logo: fix building on Windows 2023-12-04 20:32:46 +08:00
apocelipes 1c24cb3ebb refactor: simplify parsing 2023-12-04 19:47:34 +08:00
apocelipes 0662af17f4 fix(TerminalShell): fix reading procfs files 2023-12-04 19:47:34 +08:00
apocelipes 9fee532cb6 fix(CPUUsage): fix reading procfs files and simplify data parsing 2023-12-04 19:47:34 +08:00
apocelipes 57f88d2167 fix(Uptime): fix reading procfs files and simplify data parsing 2023-12-04 19:47:34 +08:00
apocelipes ed879ee53c fix(Swap): fix reading procfs files and simplify data parsing 2023-12-04 19:47:34 +08:00
apocelipes 6eae425679 fix(Memory): fix reading procfs files and simplify data parsing
Files in procfs are always changed by kernel.

It means if we read the data with more than one read syscall,
we could get an incorrect data which was broken by kernel.

A typical case about this problem was reported by psutil in
https://github.com/giampaolo/psutil/issues/2050

Using an big buffer let read reads the whole file can fix this.
psutil uses a 32K buffer while procps-ng uses a 8K buffer, i think a 8K buffer is enough.
2023-12-04 19:47:34 +08:00
李通洲 182c90b22c CI: fix macOS (2nd try) 2023-12-04 19:12:58 +08:00
李通洲 2c2e0582a9 CI: try fixing macOS 2023-12-04 16:31:38 +08:00
李通洲 4216d40696 Doc: update changelog 2023-12-04 16:08:22 +08:00
李通洲 af6f395ba3 DiskIO: increase number of format args for disk size 2023-12-04 16:08:04 +08:00
李通洲 3fda6e425a Global: never leak fd to child processes 2023-12-04 15:14:40 +08:00
李通洲 82581aa9e4 Processing: increase buffer size 2023-12-04 15:10:58 +08:00
李通洲 6bd515fed4 Packages (macOS): rename port to macports 2023-12-04 15:07:13 +08:00
李通洲 20970c6b71 CMake: silence compiler warnings 2023-12-04 15:00:25 +08:00
李通洲 532007267c Logo (Builtin): add Ironclad 2023-12-04 14:55:10 +08:00
李通洲 87a4758497 Logo (Builtin): update parch 2023-12-04 14:49:43 +08:00
李通洲 6a9cce62ab Logo (Builtin): add Adelie 2023-12-04 14:47:28 +08:00
李通洲 2816ea3797 Readme: update badge links (v2) 2023-12-04 14:40:35 +08:00
李通洲 5144081971 Readme: update badge links 2023-12-04 14:39:03 +08:00
李通洲 ccfe961a1f DiskIO (FreeBSD): support disk name, size and physical type detection 2023-12-04 13:54:26 +08:00
李通洲 97211df285 DiskIO (macOS): detect disk size 2023-12-04 08:59:41 +08:00
apocelipes 4868517d53 optimize(IO): reduce memory usage during reading data from files to FFstrbufs
Avoid unnecessary calls of ffStrbufEnsureFree and only allocate
necessary memory.

In most cases, this will save 30% ~ 50% of memory used by ffAppendFDBuffer.
2023-12-03 19:57:49 +08:00
李通洲 2979bfe4ca DiskIO: detect physical drive size 2023-12-03 19:02:29 +08:00
李通洲 42fd1a9cd7 DisplayServer (FreeBSD): enable libdrm support 2023-12-03 12:10:52 +08:00
李通洲 36298b8e93 Swap (FreeBSD): fix impl 2023-12-01 23:23:29 +08:00
李通洲 7168cc2ef2 Completions (Fish): reduce external dependencies 2023-12-01 16:01:14 +08:00
apocelipes c398dc6c07 fix(Cursor): fix a memory leak detected by valgrind 2023-12-01 15:49:48 +08:00
李通洲 390801aee7 DisplayServer: fix build on FreeBSD 2023-11-30 20:25:23 +08:00
李通洲 e3f5563f8d DisplayServer (Linux): fix build for Ubuntu 20.04 (v2) 2023-11-30 20:05:51 +08:00
李通洲 4a54b20c68 DisplayServer (Linux): fix compiling on Ubuntu 20.04 2023-11-30 16:42:56 +08:00
李通洲 ea3d904bfe DisplayServer (Linux): improve performance for X11
Try fixing #634
2023-11-30 16:31:35 +08:00
李通洲 67f4b991d7 DisplayServer (Linux): use libdrm
Which correctly detects current mode ( instead of preferred mode ) and
supports refresh rate
2023-11-30 10:47:03 +08:00
apocelipes 53922779ba fix(Common): fixes for ffProcessAppendOutput
- Use pipe2 on Linux and BSDs, which can set all flags through a single syscall.
- macOS/darwin does not support pipe2, add a wrapper for it.
- Close pipes when fork() failed. These fds should be closed when
  the function returns.
- Set O_CLOEXEC at pipes, the exec() family of functions will close
  this fds automatically.
- Use _exit instead of exit. Exit calls the callbacks registered by atexit
  and flushes the stdio's buffer, which can lead to some unexpected behavior,
  especially after an exec syscall failure.
- Fix timeout.
- Not use non-blocking IO. because we only wait for one file, and cannot
  do other things during waiting.
2023-11-30 10:10:40 +08:00
apocelipes 1431cdcc83 fix(Terminal): make fastfetch works under ltrace and perf
Fastfetch incorrectly displays the terminal name as
"ltrace" or "perf" when debugging itself with ltrace and perf.

minor fix: remove duplicated ffStrbufClear since getShellVersion
already called it.
2023-11-28 23:22:51 +08:00
李通洲 968a43cb29 Monitor (Linux): don't report disabled monitors 2023-11-28 16:11:32 +08:00
李通洲 0c522bdc10 Display (Linux): don't report disabled displays when using DRM
Ref: #634
2023-11-28 07:59:28 +00:00
李通洲 5db3c903e5 Host (macOS): fix build 2023-11-28 15:05:10 +08:00
李通洲 91c23c533a Host (macOS): add general method to query product name 2023-11-28 13:36:19 +08:00
李通洲 00721630ce Board (Apple): use machine model indentifier as motherboard name 2023-11-28 13:36:19 +08:00
李通洲 167b130011 Uptime (Linux): fix maybe uninitialized variable errors 2023-11-27 20:52:14 +08:00
Sunderland93 aca502e9a0 Add TileOS logo 2023-11-27 19:17:00 +08:00
apocelipes 36f18d0961 optimize(IO): speed up createSubfolders
Avoiding unnecessary ffStrbufAppendC calls to speed up createSubfolders.

Now it finds and adds a subdirectory at a time instead of just appending a char.
2023-11-27 19:16:05 +08:00
李通洲 e67a6856ce Completion (Fish): use fastfetch --help-raw 2023-11-27 15:37:01 +08:00
李通洲 3a0b132001 TerminalFont: support alacritty.toml
Fix #631
2023-11-27 10:12:22 +08:00
李通洲 f63f31db0a Memory (Linux): fix compiler warnings 2023-11-25 19:40:36 +08:00
李通洲 96d60184d5 Memory (Linux): try improving performance 2023-11-24 10:12:34 +08:00
李通洲 919bd8231e Swap (Linux): don't use syscall
Fix #620
2023-11-24 10:12:22 +08:00
李通洲 41fed1da5f Uptime (Linux): don't use syscall
Fix #620
2023-11-24 10:12:10 +08:00
李通洲 a846780382 py 2023-11-22 16:36:05 +08:00
李通洲 c10d7a8233 Help: small fixes 2023-11-22 15:36:48 +08:00
李通洲 cdcc976cd3 Help: small improvements 2023-11-22 09:32:38 +08:00
李通洲 b52e812c2c Help: support --help-raw 2023-11-22 09:14:27 +08:00
李通洲 aa45945b57 Logo (Builtin): add Peropesis 2023-11-22 09:10:44 +08:00
李通洲 eea6e81276 Logo (Builtin): add XrayOS
Ref: https://github.com/dylanaraps/neofetch/pull/2413
2023-11-22 09:07:00 +08:00
李通洲 0bac93093b Help: fix typo 2023-11-21 21:39:10 +08:00
李通洲 7bcb015a06 Help: print command specific help message 2023-11-21 16:39:38 +08:00
李通洲 02bdcd355c Help: minify JSON string 2023-11-21 15:11:49 +08:00
李通洲 fa90e01bc5 Helo: correctly display italic text 2023-11-20 22:51:01 +08:00
李通洲 1dec514129 Help: fix colors 2023-11-20 22:04:03 +08:00
李通洲 f81d09bddc Help: fix typo 2023-11-20 18:28:12 +08:00
李通洲 03916b6a1d Help: convert to parsable JSON format 2023-11-20 16:37:59 +08:00
李通洲 5338583c48 Logo (Chafa): accept enum strings instead of numbers 2023-11-20 14:27:48 +08:00
李通洲 6c492882a3 Doc: fix some bugs 2023-11-20 14:27:03 +08:00
李通洲 98c7c7ed4f Completions (Bash): remove unsupported flags 2023-11-20 14:26:15 +08:00
李通洲 a7a96a8954 Fastfetch: remove config-system & config-user 2023-11-19 11:15:06 +08:00
Carter Li 1a5044add9 Merge pull request #626 from mame98/spellcheck
Spellchecking
2023-11-19 00:13:36 +08:00
Marius Messerschmidt 7befd71069 Config: remove misspelled 'integrated' 2023-11-18 16:46:08 +01:00
Marius Messerschmidt 3d44a1befe Spelling: add new entries to .codespellrc 2023-11-18 15:52:28 +01:00
Marius Messerschmidt 57e734e628 Spelling: fix typo in Manpage 2023-11-18 15:48:02 +01:00
Marius Messerschmidt 3eadd332bb Workflows: add spellcheck job 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 825db4fead Spelling: add .codespellrc 2023-11-18 15:47:22 +01:00
Marius Messerschmidt ad5be0f0c2 Spelling: fix spelling of files in remaining files 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 6d22a76946 Spelling: fix spelling of files in src/modules/ 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 40e977be31 Spelling: fix spelling of files in src/detection/ 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 29d93d5c67 Spelling: fix spelling of files in src/common 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 9b2c59936f Spelling: fix spelling of help files 2023-11-18 15:47:22 +01:00
Marius Messerschmidt bb02ba0b2e Spelling: fix spelling of CMakeLists.txt 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 0987f68409 Spelling: fix spelling in top-level documentation files 2023-11-18 15:47:22 +01:00
Marius Messerschmidt 647403fc30 Add manpage (#625)
* Manpage: add initial manpage template

* CMake: integrate manpage installation to CMake

* Manpage: add details about JSONC based config files

* Manpage: minor cleanups

* Manpage: fix --print-structure

* Manpage: fix --structure

* help: change load-config -> config

* Manpage: remove legacy config file description

* Manpage: remove --print-config- commands

* help: remove --print-config- commands

* Manpage: change migrate-config to gen-config

* Manpage: add -h as shortcut for help

* Manpage: escaped all '-'
2023-11-18 22:18:08 +08:00
Carter Li 854a7cfeba Merge pull request #624 from mame98/cleanup
Minor cleanups reported by clang-tidy
2023-11-18 21:05:21 +08:00
Marius Messerschmidt f78f6ceb54 fixup! ClangTidy: avoid reserved identifier names 2023-11-18 12:31:57 +01:00
Marius Messerschmidt 975081aa27 ClangTidy: make pid pointer const 2023-11-18 12:31:57 +01:00
Marius Messerschmidt b0d3e7ef9e ClangTidy: avoid implicit widening of multiplication result 2023-11-18 12:31:57 +01:00
Marius Messerschmidt 6fe0eb5677 ClangTidy: avoid different parameter names for same function 2023-11-18 12:31:57 +01:00
Marius Messerschmidt 42c03b2383 ClangTidy: avoid reserved identifier names 2023-11-18 12:31:57 +01:00
Marius Messerschmidt b1319b34e7 ClangTidy: remove duplicated includes 2023-11-18 12:31:57 +01:00
Marius Messerschmidt 5162b4fdec ClangTidy: add missing unsigned specifier 2023-11-18 12:31:57 +01:00
Marius Messerschmidt 42f647378a ClangTidy: remove redundant expression 2023-11-18 12:31:57 +01:00
李通洲 97b3938dd5 Doc: update changelog
Fix: #623
2023-11-18 16:41:40 +08:00
李通洲 2e46b5932e Terminal (Windows): ignore the shell warpper servercoreshell 2023-11-18 16:38:01 +08:00
李通洲 4510ef7e1c Shell (Windows): tidy 2023-11-18 16:24:23 +08:00
李通洲 36bf978dc1 Bluetooth (Windows): remove hard dep of bthprops
Also fix resource leaks and better error message

Ref: https://github.com/fastfetch-cli/fastfetch/issues/623#issuecomment-1815682290
2023-11-18 16:09:54 +08:00
李通洲 7f999dfaaf OpenGL (Windows): remove hard dep of opengl32
Ref: https://github.com/fastfetch-cli/fastfetch/issues/623#issuecomment-1815682290
2023-11-18 15:40:09 +08:00
李通洲 6f6a68f7e5 Brightness (Windows): remove hard dep of dxva2
Ref: https://github.com/fastfetch-cli/fastfetch/issues/623#issuecomment-1815682290
2023-11-18 15:25:47 +08:00
Marius Messerschmidt 960bbfef59 ClangTidy: fix misplaced cast 2023-11-17 22:18:19 +01:00
李通洲 cabd5899f7 Doc: update help.txt 2023-11-17 15:39:25 +08:00
李通洲 730c0d1c92 Fastfetch: print module description for --list-modules 2023-11-17 14:12:57 +08:00
李通洲 ce6041938a CI: fix build 2023-11-16 18:49:27 +08:00
李通洲 998193b014 Fastfetch: support -c none; remove --load-user-config 2023-11-16 16:41:08 +08:00
李通洲 f8ba138b8d Completion: tidy 2023-11-16 14:21:24 +08:00
李通洲 3f9462d7c8 Package (macOS): try supporting nix 2023-11-16 10:04:17 +08:00
李通洲 413984963e TerminalShell: support oils and elvish 2023-11-15 16:30:46 +08:00
李通洲 5aab0e2dd9 Completion (Fish): built-in logos auto-completion 2023-11-15 16:21:07 +08:00
李通洲 1ba5e6e8f7 Doc: better document for logo types 2023-11-15 10:38:32 +08:00
李通洲 2a53b012ea Completion (Fish): clean up 2023-11-14 16:36:08 +08:00
李通洲 5d44efbf62 Colors: don't use background color
It causes some weird behavior on some old terminals.

Ref: https://www.reddit.com/r/HomeServer/comments/16ys32a/guess_the_power_consumption_of_ryzen57600x/
2023-11-14 10:01:29 +08:00
李通洲 6ad83af2b5 Host: clean up 2023-11-14 09:59:15 +08:00
李通洲 fceb19affe Fastfetch: change the order of loading config files 2023-11-14 09:58:42 +08:00
李通洲 ee7d3d471e Completions (Fish): inital support 2023-11-13 22:44:58 +08:00
李通洲 8e9c571293 Flashfetch: simplify implementation 2023-11-13 16:36:25 +08:00
李通洲 a44b8264af Fastfetch: remove the old function of --gen-config
The file `config_user.txt` has not been maintained for long. Let's remove it.
2023-11-13 10:32:45 +08:00
李通洲 84a5a4033e Fastfetch: parse some switches in advance 2023-11-13 10:32:45 +08:00
李通洲 f2fc92dbf7 Brightness (Linux): better ddcutil 2.x compatibility 2023-11-12 10:47:04 +08:00
李通洲 2af338f425 CI (Linux): build with ddcutil and remove unused deps 2023-11-09 14:24:49 +08:00
李通洲 41aaaa3429 Global: silence compiler warnings 2023-11-09 13:46:45 +08:00
李通洲 f9597eba39 Global: remove #ifndef FF_INCLUDED_* guards 2023-11-09 13:46:45 +08:00
Mohammed Keyvanzadeh b4cd47cbc4 src: end va_list before returning (#618)
Explicitly end the `va_list` before returning in the `ffStrbufSetF()`
function as `va_list`s are not ended implicitly.
2023-11-08 20:16:44 +08:00
Carter Li 22de71efeb Merge pull request #617 from fastfetch-cli/dev
Release v2.2.3
2023-11-08 12:33:16 +08:00
李通洲 ac654ff346 Host (macOS): update the latest models 2023-11-08 10:43:17 +08:00
李通洲 df2fdf05e6 Release v2.2.3 2023-11-08 10:14:31 +08:00
李通洲 788307e98d Doc: update changelog 2023-11-08 09:11:16 +08:00
李通洲 f93341ac61 TerminalShell: fix terminal name detection on NixOS
oops. No one report that...
2023-11-08 09:02:52 +08:00
李通洲 3e0d97db2e Platform: detect system page size 2023-11-08 00:10:16 +08:00
李通洲 864e707224 LocalIP (Android): don't set --default-route-only to true by default on Android
As we can't detect default route on that platform
2023-11-07 20:17:08 +08:00
李通洲 c42b68404f Logo (Image): try improving performace of base64 encoding 2023-11-07 19:04:16 +08:00
Carter Li 18374467e6 Merge pull request #615 from fastfetch-cli/dev
Release v2.2.2
2023-11-07 10:02:19 +08:00
李通洲 499e6c85a0 Battery (Windows): slilence compiler warnings 2023-11-07 09:59:00 +08:00
李通洲 0610faf1be Release v2.2.2 2023-11-07 09:47:37 +08:00
李通洲 778c6f0513 Doc: update changelog 2023-11-07 09:03:01 +08:00
李通洲 c55ba2685f Battery (macOS): add status Discharging to be consistant with other platforms 2023-11-07 08:56:07 +08:00
李通洲 aae66aa966 Logo (Image): fix spelling of --preserve-aspect-ratio
Fix #614
2023-11-07 08:49:22 +08:00
李通洲 a95b60167c Doc: fix typo in README
Fix #613
2023-11-07 08:37:29 +08:00
李通洲 f5b987dba9 Battery (Windows): detect cycle count 2023-11-06 19:40:40 +08:00
李通洲 f8eabdd8a6 Battry (Linux): try detecting cycle count and temperature 2023-11-06 19:08:17 +08:00
李通洲 5ab2c3456d Battery (Apple): better detection 2023-11-06 16:42:16 +08:00
李通洲 97d9ffd193 Bios: detect firmware type 2023-11-06 15:29:55 +08:00
李通洲 fa86bb1f0b CI (FreeBSD): update action version 2023-11-06 10:24:06 +08:00
李通洲 5b9c5ebb5a CI (Win64): improve speed 2023-11-06 10:11:51 +08:00
李通洲 56b03a93c5 CI (Linux): build with imagemagick7 2023-11-06 10:05:01 +08:00
李通洲 3b319f0a1e Global: add missing changes 2023-11-05 13:25:54 +08:00
李通洲 c3352d6d28 CI: always update dependencies explicitly
Fix macOS build
2023-11-05 13:25:13 +08:00
李通洲 f8426384d8 CI: print verbose logs when building 2023-11-05 13:02:48 +08:00
李通洲 8791281b48 CI: try fixing macOS build 2023-11-05 10:38:43 +08:00
李通洲 76ec8aff2e Doc: update changelog 2023-11-05 10:16:48 +08:00
李通洲 7660b0a091 Global: defaults percentType to 9 ( colored number ) 2023-11-05 10:11:53 +08:00
李通洲 7a8e484634 Global: prints LocalIp by default
Fix #611
2023-11-05 10:11:40 +08:00
李通洲 ed01272b91 LocalIP: detect netmask 2023-11-05 09:42:28 +08:00
Viorel 1c660caa85 Fix unitialized variables (#609)
Compiling with gcc 13 and -O3 -flto -Werror=uninitialized found two
possibly unitialized variables.

See also: https://bugs.gentoo.org/916722
2023-11-03 23:03:14 +08:00
李通洲 c241ead1d5 Logo (Builtin): update nixos_small, add nixos_old_small
Fix #608
2023-11-02 23:22:48 +08:00
Carter Li 168d96a182 Merge pull request #607 from fastfetch-cli/dev
Release v2.2.1
2023-11-02 15:34:16 +08:00
李通洲 2075761282 fastfetch: --help honors --pipe 2023-11-02 14:44:18 +08:00
李通洲 d59de1f158 Release v2.2.1 2023-11-02 14:35:16 +08:00
李通洲 d64716ab74 fastfetch: pretty printing --help 2023-11-02 14:11:06 +08:00
李通洲 0ffbb8c364 Doc: update help messages 2023-11-02 14:11:06 +08:00
李通洲 c29960abf2 Presets: fix regression #606 2023-11-02 09:32:58 +08:00
Carter Li 315cb24046 Merge pull request #604 from fastfetch-cli/dev
Fix CI of FreeBSD
2023-11-01 16:06:10 +08:00
李通洲 4cabc5684b CPUUsage: don't count NaN values 2023-11-01 15:55:13 +08:00
李通洲 256c9be19b CPUUsage: skip NaN when summarizing values 2023-11-01 15:49:51 +08:00
李通洲 1b3d713e50 CPUUsage: always print something 2023-11-01 15:36:13 +08:00
李通洲 6e816fca6e CPUUsage: don't hang on weird host
Try fixing CI of FreeBSD
2023-11-01 15:26:24 +08:00
李通洲 5a699af610 OS (macOS): improve performance 2023-11-01 15:24:52 +08:00
Carter Li 390119c592 Merge pull request #603 from fastfetch-cli/dev
Release v2.2.0
2023-11-01 14:04:08 +08:00
李通洲 11d7eec4db Revert "FreeBSD: debug"
This reverts commit 6508ccfc0d.
2023-11-01 12:22:28 +08:00
李通洲 f59be1faf2 Release v2.2.0 2023-11-01 11:29:03 +08:00
李通洲 7bc4c63eb4 Migration: don't overwrite existing files 2023-11-01 11:28:08 +08:00
李通洲 4bf9f524d9 Logo (Builtin): add Interix 2023-11-01 11:16:16 +08:00
李通洲 6508ccfc0d FreeBSD: debug 2023-11-01 09:52:15 +08:00
李通洲 d0a8d3cdc4 TerminalFont (Linux): early return 2023-11-01 09:42:52 +08:00
李通洲 494cc1493e TerminalFont (Linux): support xfce4-terminal 1.1.0+
Fixes #602
2023-11-01 09:40:49 +08:00
李通洲 761c649817 TerminalShell: better support for environment running with su 2023-11-01 08:55:00 +08:00
李通洲 a2f576f3e5 GPU (WSL): support nvml too 2023-11-01 00:10:24 +08:00
李通洲 3b9b03a086 FreeBSD: fix build 2023-10-31 23:45:38 +08:00
李通洲 ab51a209d7 CI: try fixing FreeBSD build 2023-10-31 22:53:06 +08:00
李通洲 38ac339011 WM: support WindowBlinds detection 2023-10-31 22:40:44 +08:00
李通洲 b4777fe73a Windows: silence compiler warnings 2023-10-31 22:40:44 +08:00
李通洲 b6e759f3a2 LocalIP / NetIO: make defaultRouteOnly defaults to true 2023-10-31 19:53:25 +08:00
李通洲 9ddefbc1a2 Doc: update README 2023-10-31 16:32:57 +08:00
李通洲 a16851f5de JsonConfig: update json schema; change most title to description 2023-10-31 15:47:55 +08:00
李通洲 8fe291d161 Doc: remove information of flag based configuration 2023-10-31 15:47:23 +08:00
李通洲 9ac50fc42f GPU: add more vendors 2023-10-31 15:11:22 +08:00
李通洲 c6e5221826 CMake: build with ASAN conditionally 2023-10-31 14:57:32 +08:00
李通洲 5b2006cd06 Global: get rid of locks
Psychological burden NO MORE
2023-10-31 14:42:45 +08:00
李通洲 d3f673dc6f Init: remove separate thread of displayserver and qt/gtk stuff detection
These threads are detached. If the main thread exits before the sub threads end, fastfetch may crash in various ways.

It barely benefits performance. `hyperfine` shows completely no difference between `--thread` enabled and disabled. Let's get rid of it.
2023-10-31 14:32:30 +08:00
李通洲 b99f444234 Global: remove --allow-slow-operations 2023-10-31 14:10:21 +08:00
李通洲 c504096181 Processing (Linux): fix hanging if a child process prints to both stdout and stderr 2023-10-31 14:06:08 +08:00
李通洲 c9ef47271a Brightness: fix flag --brightness-ddcci-sleep 2023-10-31 10:09:31 +08:00
李通洲 fc3891c913 DE: implement --de-slow-version-detection 2023-10-31 10:07:41 +08:00
李通洲 cd07354b6f Doc: update changelog and other docs 2023-10-31 09:50:54 +08:00
kojq fd5aeb2052 Update structure.txt (#600)
add swap information as default
2023-10-30 20:27:10 -05:00
李通洲 b1b583721a Logo (Builtin): add MainsailOS
Ref: https://github.com/dylanaraps/neofetch/pull/2407
2023-10-31 09:15:15 +08:00
李通洲 4c3372a886 Logo (Builtin): fix phyOS 2023-10-31 08:51:56 +08:00
李通洲 cf66679323 DE: move version detection code to separate files 2023-10-30 22:46:38 +08:00
李通洲 55b41144db WM: add flag --wm-detect-plugin 2023-10-30 16:34:35 +08:00
李通洲 ae34208247 Battery (Windows): add flag --battery-use-setup-api 2023-10-30 14:49:00 +08:00
李通洲 b462006280 Chassis (Windows): add flag --chassis-use-wmi 2023-10-30 14:31:19 +08:00
李通洲 485bcbf054 GPU: add flag --gpu-use-nvml 2023-10-30 13:46:51 +08:00
李通洲 2e30a57889 TerminalFont: always use kitten to detect kitty term fonts 2023-10-30 11:05:43 +08:00
李通洲 b439d9c203 Doc: we use Apple80211 instead of IO80211 2023-10-30 09:21:01 +08:00
李通洲 08a717f5f7 JsonConfig: more friendly error message 2023-10-30 09:14:13 +08:00
李通洲 3a84a1a5fa Packages (Windows): add option --packages-winget 2023-10-29 19:37:31 +08:00
李通洲 627d5fc659 JsonConfig: restructure some keys 2023-10-29 00:17:24 +08:00
李通洲 25849dc4bb Migration (Logo): fix --logo-color-num (v2) 2023-10-28 23:39:15 +08:00
李通洲 63032cd840 Doc: update help.txt 2023-10-28 23:02:28 +08:00
李通洲 2414246de9 Migration (Logo): fix --logo-color-num 2023-10-28 21:52:28 +08:00
李通洲 c52353b4b8 Vulkan: remove used GPU memory detection, which is unreliable
Ref: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_memory_budget.html#_description
2023-10-28 20:25:39 +08:00
李通洲 799628c083 GPU: guard nvml related code behind --allow-slow-operations 2023-10-28 17:23:49 +08:00
李通洲 38d5791d57 GPU: support memory, core count detection 2023-10-28 13:56:43 +08:00
李通洲 9d664e2b61 GPU (Linux): support driver version detection 2023-10-28 13:11:04 +08:00
李通洲 2eb21e3521 TerminalFont: fix memleaks 2023-10-28 13:00:45 +08:00
李通洲 bfe1265c44 Logo (Builtin): add azos
Ref: https://github.com/dylanaraps/neofetch/pull/2339
2023-10-27 22:57:16 +08:00
李通洲 dd3109cd89 GPU: better nvidia GPU temp detection 2023-10-27 21:16:03 +08:00
Carter Li 130d5a5202 Sound (macOS): fix no sound devices detected error on old macOS version 2023-10-27 17:35:28 +08:00
Carter Li cda4c62e9e macOS: fix building on old macOS version 2023-10-27 16:59:10 +08:00
李通洲 df245f32ec FFlist: add FF_LIST_GET
this macro can be safer to use than `ffListGet` because it detects wrong type convertion
2023-10-27 12:02:01 +08:00
李通洲 04409f4381 Wifi (macOS): better (or worse) support of security detection 2023-10-27 12:02:01 +08:00
李通洲 155e4a5b80 Doc: update doc for --migrate-config 2023-10-27 00:00:48 +08:00
李通洲 59a9209621 GPU: support Nvidia GPU temp detection 2023-10-27 00:00:19 +08:00
李通洲 cd5e14a834 LM (Linux): tidy 2023-10-26 23:27:40 +08:00
李通洲 e707cf8464 Migration: deprecate --gen-config conf 2023-10-26 16:34:38 +08:00
李通洲 8bdd410e97 Migration: support specifying config file path 2023-10-26 16:22:05 +08:00
李通洲 f45654620f Global: code refactor 2023-10-26 15:39:28 +08:00
李通洲 72d138f8c4 Migration (Modules): only generate objects when necessary 2023-10-26 14:28:47 +08:00
李通洲 6a0df7ae49 Migration: simplify json result 2023-10-26 14:06:47 +08:00
李通洲 23def0a1c7 Options (Library): add definitions only when used on the platform 2023-10-26 13:55:26 +08:00
李通洲 3236ef075d Migration (Library): support library options 2023-10-26 13:55:26 +08:00
李通洲 d00b301904 Migration (General): support general options 2023-10-26 13:55:26 +08:00
李通洲 6c82686283 Migration (Display): support display options 2023-10-26 13:55:21 +08:00
李通洲 399e2235d4 Options (Display): split code 2023-10-26 10:26:15 +08:00
李通洲 bd898e4006 Wifi (macOS): additional fix of Sonoma compatibility 2023-10-26 09:50:51 +08:00
李通洲 2c49dcceaf Options (Library): split code 2023-10-25 16:24:24 +08:00
李通洲 3c5b002414 Options (Modules): split code 2023-10-25 15:38:46 +08:00
李通洲 ca37206a49 Options (Logo): renaming symbols 2023-10-25 15:31:13 +08:00
李通洲 8a939e981c Options (General): symbol renaming to prevent from possible naming conflicts 2023-10-25 14:43:15 +08:00
李通洲 bed1b4cf0f Global: move general options to a new separate folder 2023-10-25 13:39:13 +08:00
李通洲 04c3a4ccf7 Logo: move logo options related code to a new folder 2023-10-25 10:44:34 +08:00
李通洲 f50368a949 Migration: support logo 2023-10-25 10:18:07 +08:00
李通洲 4e018dbf26 JsonConfig: code refactor 2023-10-25 09:13:04 +08:00
李通洲 fa02217ff4 Doc: update changelog 2023-10-25 09:03:44 +08:00
Martin Valba 22080d36b0 Add Evolinx distro banner (#596)
* Add Evolinx banner

* Removed accidental local bad save
2023-10-24 22:23:33 +08:00
westpain 3303f4e1ce Add cycledream logo (#595) 2023-10-24 21:15:56 +08:00
李通洲 11d03ad59e TerminalFont: support st 2023-10-24 16:48:22 +08:00
李通洲 504f1533c2 Terminal: support st version detection 2023-10-24 15:57:40 +08:00
李通洲 bf1d1cbac5 Terminal: support urxvt version detection 2023-10-24 15:56:43 +08:00
李通洲 94119d1674 OpenGL (Linux): fix build 2023-10-24 15:17:27 +08:00
李通洲 f4a263df01 Migration: finish modules support 2023-10-24 14:41:29 +08:00
李通洲 533231825c Terminal (Linux): detect tmux: server as tmux 2023-10-24 10:20:41 +08:00
李通洲 40e2787d94 Revert "Terminal (Linux): better support for tmux"
This reverts commit 281af9c86f.
2023-10-24 10:09:43 +08:00
李通洲 281af9c86f Terminal (Linux): better support for tmux 2023-10-23 23:38:18 +08:00
matoro fc0db8c291 Host (Linux): devicetree path for OBP hosts (#591)
At least SPARC devices have their model name in this devicetree node
and do not have a "model" node.  Possibly also POWER Macs, do not have
one to test though.
2023-10-23 23:37:37 +08:00
李通洲 48d2dbad34 Battery (Linux): fix build 2023-10-23 18:42:40 +08:00
李通洲 be2af8aeaf Migration: support bluetooth and board 2023-10-23 16:34:33 +08:00
李通洲 a7621a7301 Break: remove redundant code 2023-10-23 16:33:25 +08:00
李通洲 ec87790e4f Global: init support for JSON config file migration (WIP) 2023-10-23 16:17:07 +08:00
李通洲 44632e9bf6 Global: don't expose internal functions 2023-10-23 13:32:40 +08:00
李通洲 824ada49b6 Global: :%s/generateJson/generateJsonResult/g 2023-10-23 13:32:39 +08:00
李通洲 e7938216ba Global: :%s/ffGenerate\w+Json/$0Result/g 2023-10-23 13:32:39 +08:00
matoro 40d6d0b7b5 CPU (Linux): quirks for MIPS platforms (#590)
CPU name is in "cpu model" field on MIPS.  Also, /proc/cpuinfo contains
an "isa" field, but rather than being a single string like RISC-V it is
instead a space-separated list of every ISA flavor that the chip is
compatible with.  Since these are mostly incremental, just make the
cpuISA value set to the last one.

Before:
```
$ fastfetch --structure "cpu" --logo none
CPU: mips1 mips2 mips3 mips4 mips5 mips32r1 mips32r2 mips64r1 mips64r2 (16)
```

After:
```
$ fastfetch --structure "cpu" --logo none
CPU: Cavium Octeon II V0.10 mips64r2 (16)
```
2023-10-22 22:09:43 -05:00
李通洲 3f4d4c8eea GPU: add more vendors 2023-10-21 17:36:13 +08:00
李通洲 e2fe94d4e4 DisplayServer (Android): tidy 2023-10-21 15:44:38 +08:00
李通洲 debb5d8ad1 Display: don't print display type twice 2023-10-21 15:44:08 +08:00
李通洲 f61794ea70 GPU (Windows): better GPU memory and type detection 2023-10-18 10:52:29 +08:00
李通洲 d15a977431 Logo (Builtin): add Black Mesa
Fix #586
2023-10-17 23:46:38 +08:00
Carter Li ef5268f78d Merge pull request #584 from fastfetch-cli/dev
Release v2.1.2
2023-10-15 04:09:03 -05:00
李通洲 7362808d5d Brightness (Linux): fix compatibility for ddcutil 2.0
3rd try
2023-10-15 13:46:58 +08:00
李通洲 27cfec68ed Brightness (Linux): fix compatibility for ddcutil 2.0 2023-10-15 12:27:38 +08:00
李通洲 ea85f40682 Release v2.1.2 2023-10-15 10:52:05 +08:00
李通洲 0cc38c20be CPUUsage (FreeBSD): silence compiler warnings 2023-10-15 10:52:05 +08:00
李通洲 d29931a91a Brightness (Linux): fix compatibility for ddcutil 2.0
Ref: https://github.com/fastfetch-cli/fastfetch/issues/576#issuecomment-1763184172
2023-10-15 10:52:05 +08:00
李通洲 17c007348b Icons (Windows): fix detection 2023-10-14 21:55:55 +08:00
Carter Li 33953a0d18 Merge pull request #583 from fastfetch-cli/dev
Release v2.1.1
2023-10-14 06:08:00 -05:00
李通洲 98e8e599a6 Release v2.1.1 2023-10-14 18:24:58 +08:00
李通洲 5e19838713 Doc: update changelog 2023-10-14 18:19:10 +08:00
李通洲 501803c873 Logo (Builtin): add Xenia
https://github.com/hykilpikonna/hyfetch/issues/197
2023-10-14 18:15:04 +08:00
李通洲 e9c2a43de1 Brightness: add --brightness-ddcci-sleep to set the sleep times (in ms) when sending DDC/CI requests
Fix #580
2023-10-14 10:04:08 +08:00
李通洲 af94596202 Revert "Brightness (Linux): allow specifying busno for ddcutil"
This doesn't seem to improve much performance, but increase code
complexity a lot

This reverts commit 42e87b498c.
2023-10-14 09:35:40 +08:00
李通洲 42e87b498c Brightness (Linux): allow specifying busno for ddcutil
Ref: #580
2023-10-14 01:38:02 +08:00
李通洲 839ff311de Wifi (macOS): work around #581 2023-10-13 16:47:45 +08:00
李通洲 ebab281471 Processes (Linux): fix implementation
`sysinfo.procs` reports number of all running threads, instead of processes
2023-10-11 21:10:47 +08:00
李通洲 582788645d Doc: add information about how to make Termux API actually work 2023-10-11 16:32:20 +08:00
李通洲 643fed7d1c Doc: metion bug #581 2023-10-11 16:31:47 +08:00
李通洲 076324e60e Wifi (macOS): remove undesired code 2023-10-11 15:23:21 +08:00
李通洲 1fe92738d8 macOS: embed Info.plist 2023-10-11 15:17:14 +08:00
李通洲 e319be19de Wifi (macOS): print <unknown ssid> when we can't get SSID
SSID is not available after Sonoma. According to the doc: SSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.
2023-10-11 14:48:48 +08:00
李通洲 ab8448ee47 DiskIO (Windows): fix device name detection 2023-10-10 21:51:15 +08:00
李通洲 5493f418ed Users: fix crashing on Windows; rename tty to more common name sessionName 2023-10-10 20:21:11 +08:00
李通洲 4e75fa958d Logo (Builtin): add EndeavourSmall
Ref: https://github.com/dylanaraps/neofetch/pull/2391
2023-10-10 19:21:05 +08:00
李通洲 0847432dd9 CPUUsage: rename cpuusage-display-type to separate 2023-10-10 19:02:42 +08:00
李通洲 e297144fe2 CPUUsage: fix multi core data detection 2023-10-10 18:46:59 +08:00
李通洲 42cf88be9d CPUUsage: support display value per core 2023-10-10 16:24:44 +08:00
李通洲 6b008ed93b CPUUsage (FreeBSD): count cpu cores separately 2023-10-10 13:56:19 +08:00
李通洲 c96d21c7c0 CPUUsage (Linux): count cpu cores separately 2023-10-10 13:41:08 +08:00
李通洲 2feb53149a Revert "CpuUsage (apple): simplify implementation"
This reverts commit cabd36d078.
2023-10-10 13:41:08 +08:00
李通洲 e7df94495c Temp (FreeBSD): improve CPU temp detection 2023-10-10 13:41:08 +08:00
李通洲 42f6d029b0 Doc: update JSON schema; make it more IDE friendly 2023-10-09 20:27:40 +08:00
李通洲 ccbb252466 DiskIO: update doc and json schema 2023-10-09 19:24:25 +08:00
李通洲 d16bdb30b9 DiskIO: update formatting help messages; update json keys 2023-10-09 16:40:47 +08:00
李通洲 8fa6aee571 Disk: move physicalType to module DiskIO
Physical type applies to physical disks, not partitions
2023-10-09 16:32:31 +08:00
李通洲 4194e56912 DiskIO (Windows): better name detection for Github Action 2023-10-09 15:39:34 +08:00
李通洲 a0343d6bf7 CI: run --format json 2023-10-09 14:56:28 +08:00
李通洲 44b417deca DiskIO (FreeBSD): skip /dev/pass* 2023-10-09 14:26:51 +08:00
李通洲 5ccd196ae4 DiskIO: print devPath 2023-10-09 14:24:29 +08:00
李通洲 b76d6e9faa DiskIO (FreeBSD): add support 2023-10-09 14:20:40 +08:00
李通洲 2d2e0ddc6d Libc (FreeBSD): detect FBSD version 2023-10-09 13:28:30 +08:00
李通洲 430da1578d Libc (macOS): detect libSystem version 2023-10-09 10:43:58 +08:00
李通洲 1188db9475 CMake: simplify musl version detection 2023-10-09 10:43:40 +08:00
李通洲 685676bd0f CMake: don't hardcode system arch 2023-10-09 09:05:11 +08:00
李通洲 fa46dce0e1 CMake: detect uclibc and musl version 2023-10-08 21:03:10 +08:00
李通洲 2e60f34cd8 DiskIO: add to presets/all 2023-10-08 21:02:48 +08:00
李通洲 dc50e24a29 Doc: update changelog and readme 2023-10-08 21:02:31 +08:00
Jami Kettunen 1f23e93951 Logo: add Chimera Linux
Ref: https://github.com/chimera-linux/cports/blob/master/contrib/neofetch/patches/chimera.patch
2023-10-08 19:26:11 +08:00
李通洲 8df6409cb1 DiskIO (Windows): better device name detection 2023-10-08 16:46:53 +08:00
李通洲 5c5c66d960 DiskIO: fix segfault... 2023-10-08 16:38:50 +08:00
李通洲 0b0e286b9c DiskIO: support --diskio-name-prefix 2023-10-08 16:30:09 +08:00
李通洲 b2130477ae DiskIO (macOS): add support 2023-10-08 16:29:53 +08:00
李通洲 085d0924db Brightness (Linux): try improving compatibility of ddcutil 2.0
ddcutil 2.0 increases SONAME version to `libddcutil.so.5`. More testing needed

Ref: #576
2023-10-08 10:34:01 +08:00
李通洲 78249bf4f7 CPU: add new option --cpu-freq-ndigits
Fix #578
2023-10-08 10:10:06 +08:00
李通洲 4c9d9f6223 TerminalFont (Linux): fix typo 2023-10-08 09:56:45 +08:00
李通洲 d7649d9f8f DiskIO: fix building 2023-10-08 09:51:51 +08:00
李通洲 49e2acd15e Printing: fix --help *-format 2023-10-08 09:51:51 +08:00
李通洲 e4a6bf17e4 Terminal: support kgx (gnome console)
Fix #577
2023-10-08 09:51:32 +08:00
李通洲 276e22f6b0 DiskIO: init module 2023-10-07 23:56:15 +08:00
李通洲 b1d63e03d8 NetIO: fix --help netio-format 2023-10-07 22:58:50 +08:00
李通洲 55f0f75c95 Packages (Linux): print opkg in JSON format 2023-10-07 17:26:57 +08:00
李通洲 fe4eb564e1 NetIO: add missing #pragma once 2023-10-07 16:12:37 +08:00
李通洲 90ea096ca3 macOS: don't keep variable matchDict 2023-10-07 15:51:05 +08:00
李通洲 3077f885d8 Sound (macOS): ignore input devices 2023-10-07 15:45:14 +08:00
李通洲 41551ef200 Sound: fix typo 2023-10-07 15:15:39 +08:00
李通洲 4c96d0453e TerminalShell (Linux): add ash as a known shell 2023-10-07 15:15:24 +08:00
李通洲 d7ef7bc078 Doc: update changelog 2023-10-07 15:14:16 +08:00
李通洲 c77a758741 Packages (Linux): support opkg
Fix #574
2023-10-07 14:02:16 +08:00
李通洲 12208b2c7c Global: improve support of --help *-format
Also fix some bugs found when refactoring
2023-10-07 13:40:40 +08:00
李通洲 23d2cc3fdc Version: print libc version used when compiling 2023-10-05 22:23:22 +08:00
Md Rasel Hossain 1dfa0315db Fix several --help command related issues (#572)
* Help: fix wrong output for irrelevant commands

* Help: fix `module-format` related issues

* Help: remove unnecessary code
2023-10-05 19:59:24 +08:00
李通洲 f78f97a726 Revert "DisplayServer (Linux): add debug log for #568"
This reverts commit 1a4eb25194.
2023-10-04 16:28:54 +08:00
Carter Li 9972c61bbe Sound (macOS): support non-controllable devices 2023-10-04 14:59:13 +08:00
Carter Li 8795d99f79 Brightness: add DDC/CI support for Intel
Doesn't work for me. Need more testing
2023-10-04 14:41:06 +08:00
Carter Li f8aafb7ce4 Monitor (macOS): better intel platform support 2023-10-04 00:30:35 +08:00
Carter Li 27581d92b5 Disk (macOS): detect physical type 2023-10-04 00:30:35 +08:00
Carter Li 4a89b92185 Disk: allow custiomize disk key with mountFrom 2023-10-04 00:30:35 +08:00
李通洲 1a4eb25194 DisplayServer (Linux): add debug log for #568 2023-10-04 00:30:35 +08:00
李通洲 3eb9acea2e Doc: update changelog 2023-10-03 17:04:08 +08:00
李通洲 be860064c5 Users (Windows): fix crashing caused by uninitialized strings 2023-10-03 17:01:57 +08:00
李通洲 1985552636 Disk (Windows): fix crashing on Windows 7 VM 2023-10-03 16:50:57 +08:00
李通洲 985264d485 Fastfetch: add Directx Headers to --list-features 2023-10-02 23:19:44 +08:00
Carter Li e3c69c4569 Merge pull request #571 from fastfetch-cli/dev
Release v2.1.0
2023-10-02 19:23:07 +08:00
李通洲 45f523adb8 Release v2.1.0 2023-10-02 18:03:10 +08:00
李通洲 f7cc4fb4b1 Doc: update changelog 2023-10-02 18:00:30 +08:00
Alxhr0 ddec13be29 Fix Slackware 2023-10-01 22:37:18 +08:00
李通洲 74ac023cb0 Logo (Builtin): support Oracle Linux Server
Fix #569
2023-10-01 20:52:05 +08:00
李通洲 7f75d42ec8 Logo (Builtin): tidy 2023-10-01 20:50:10 +08:00
李通洲 e53acf42ec Disk (Linux): detect physical type 2023-09-30 20:32:14 +08:00
李通洲 18233a27c5 Disk (Windows): detect disk physical type 2023-09-30 15:00:59 +08:00
李通洲 9857f48bb9 OS (Linux): actually display debian .x version
Also display code name on Linux
2023-09-28 23:40:03 +08:00
李通洲 289976372f Shell: improve nu version detection performance 2023-09-27 20:05:55 +08:00
李通洲 72d2ce4b43 Logo: add LainOS
Ref: https://github.com/dylanaraps/neofetch/pull/2382
2023-09-27 15:52:52 +08:00
李通洲 eb0faec74a NetIO (Android): fix building
Doesn't work because `/sys` is unaccessable on Android
2023-09-27 15:34:53 +08:00
李通洲 767f99cffa CPU (Linux): only try lscpu on Linux
Since `lscpu` is a program of `util-linux`
2023-09-27 15:11:05 +08:00
李通洲 7caa8d4618 CPU (Linux): try detecting CPU name using lscpu
Fix #567
2023-09-27 15:05:26 +08:00
李通洲 88c12486bf Processing (Linux): always set LANG to C before executing child process 2023-09-27 15:02:55 +08:00
李通洲 8b357c27b4 Logo (Builtin): add Amazon LInux
Fix #566
2023-09-27 11:06:09 +08:00
李通洲 a7a8f2f461 NetIO (BSD): fix compiling 2023-09-27 10:48:54 +08:00
李通洲 5e5c0b4a58 NetIO: improve performance 2023-09-27 10:31:35 +08:00
李通洲 154657b455 NetUsage: rename to NetIO 2023-09-27 00:06:11 +08:00
李通洲 3866f27448 NetUsage (BSD): fix compiling 2023-09-26 23:58:05 +08:00
李通洲 b4f29918ed NetUsage: finish docs 2023-09-26 23:18:19 +08:00
李通洲 b29b78b321 NetUsage: finish module 2023-09-26 23:00:31 +08:00
李通洲 917b049030 LocalIP: cache default route value 2023-09-26 21:49:01 +08:00
李通洲 4843dedb4d LocalIp: filter --localip-default-route-only inside detection code 2023-09-26 20:57:02 +08:00
李通洲 69373906ca Windows: pre-basic msvc support 2023-09-26 20:13:32 +08:00
李通洲 24a6efa227 NetUsage: finish first working version 2023-09-26 19:54:19 +08:00
李通洲 9004d9e05c NetUsage (BSD): add detection support 2023-09-26 12:04:19 +08:00
李通洲 fa4fccd426 NetUsage (Windows): add detection support 2023-09-26 11:20:26 +08:00
李通洲 57bd741d96 NetUsage (Linux): new module (WIP) 2023-09-26 11:20:26 +08:00
李通洲 50c8809d51 LocalIp (Linux): add ioCounter detection 2023-09-26 09:52:10 +08:00
李通洲 e4c1ec916b FFstrbuf: change ffStrbufToUInt16 to more general function ffStrbufToUInt 2023-09-26 09:52:10 +08:00
李通洲 a4bc07cba5 LocalIp (Windows): add ioCounter detection 2023-09-26 09:52:10 +08:00
李通洲 40e542852f CMake: disable ASan on macOS
Ref: https://stackoverflow.com/questions/64126942/malloc-nano-zone-abandoned-due-to-inability-to-preallocate-reserved-vm-space
2023-09-26 09:14:39 +08:00
李通洲 bde2d67f25 CMake: disable UBSan 2023-09-26 08:58:16 +08:00
李通洲 6d1bde17c8 Wifi (macOS): silence compiler warnings 2023-09-25 16:11:00 +08:00
李通洲 ad0c2aa2e9 Version: detect compiler and compile time 2023-09-24 23:07:03 +08:00
李通洲 ddbd198864 Doc: update changelog 2023-09-24 22:21:18 +08:00
李通洲 3e768ddfd4 OS (Linux): detect detailed debian version
Ref: https://github.com/dylanaraps/neofetch/issues/2381
2023-09-24 21:50:12 +08:00
李通洲 6ccf8856b9 Bluetooth (Windows): fix mac address detection 2023-09-24 21:16:54 +08:00
李通洲 1caaa69deb Platform: fix memleaks 2023-09-23 11:58:46 +08:00
李通洲 5aa2798e42 Kernel (Windows): detect service pack version 2023-09-23 11:51:37 +08:00
李通洲 597daddf2a Fastfetch: add -c as a shortcut of --load-config 2023-09-23 09:56:34 +08:00
李通洲 ff1c3d9888 Doc: update changelog 2023-09-23 09:56:34 +08:00
李通洲 cc6cdb96fb Networking: support timeout on Linux 2023-09-23 09:56:34 +08:00
李通洲 db5619541a Init (Windows): actually disable stdout buffer with --no-buffer 2023-09-22 15:06:02 +08:00
李通洲 d94fc32f45 Colors: support --colors-key 2023-09-22 15:05:27 +08:00
李通洲 34723bba89 Colors: don't parse --colors-* as --color * 2023-09-22 15:05:27 +08:00
李通洲 a0efbd20a1 Title: make this module formattable 2023-09-22 15:05:27 +08:00
李通洲 4d86c53e81 Custom: code cleanup 2023-09-22 14:57:04 +08:00
李通洲 560c2acb88 Global: add --module-key " " as a magic case for hiding keys 2023-09-21 16:17:23 +08:00
李通洲 592de4c8f2 CI: print dependencies 2023-09-21 16:11:04 +08:00
李通洲 8cbe3f6453 GPU (Linux): add full GPU detection support in WSL
With DX12 API ;)
2023-09-21 15:47:03 +08:00
李通洲 ec8ee1a509 TerminalFont: fix compiler warnings 2023-09-21 15:47:03 +08:00
李通洲 30ae8a2f96 Packages (Linux): fix dpkg package number detection 2023-09-20 16:17:02 +08:00
李通洲 5337e5cead Packages (Linux): fix snap package number detection on systems other than Ubuntu
Fixes 562
2023-09-20 16:03:35 +08:00
李通洲 576fcd7d3d Display: print display type 2023-09-20 16:03:35 +08:00
李通洲 64615e635f Doc: update changelog 2023-09-20 10:16:18 +08:00
李通洲 38c22bf771 Disk (FreeBSD): hide /boot like what linux does 2023-09-20 10:16:18 +08:00
李通洲 064f624eab macOS: fix compiler warnings on latest xcode 2023-09-19 14:43:55 +08:00
李通洲 26e5790a78 Brightness: report more detailed values 2023-09-19 13:25:50 +08:00
李通洲 48cecd0ad1 CPU: update JSON format structure 2023-09-19 10:50:52 +08:00
李通洲 69e57e52ab Disk (Android): fix detection on Android 2023-09-18 23:03:14 +08:00
李通洲 dbd6e45aba Disk (Android): fix build 2023-09-18 22:25:15 +08:00
李通洲 3714dfdca7 Presets: new example 2023-09-18 20:51:09 +08:00
李通洲 06b1051a7e Global: don't trim custom strings
It can be useful to align separators
2023-09-18 20:46:30 +08:00
李通洲 8edb7d3833 Logo: fix Windows 11_small 2023-09-18 20:45:23 +08:00
李通洲 8a14cbae0c JSON: don't print the non-standand NaN 2023-09-18 20:12:33 +08:00
李通洲 7f727086af Disk: move filesystem outside of files (JSON format) 2023-09-18 20:01:41 +08:00
李通洲 7cd79d34bb Presets: remove devinfo and verbose 2023-09-18 14:19:19 +08:00
李通洲 939165d4cf Platform: align logic of getting host name to neofetch
Fixes: #561
2023-09-18 13:56:32 +08:00
李通洲 b4f063e1da Disk (Linux): detect external disk more accurately 2023-09-18 10:06:14 +08:00
李通洲 bdc79a2995 Doc: update changelog 2023-09-18 00:15:15 +08:00
李通洲 2bb78af1a7 Disk (Linux): detect USB devices as external volumes only
Fixes #559
2023-09-18 00:14:05 +08:00
李通洲 d8e4575157 Disk (Linux): fix ZFS subvolume detection 2023-09-17 22:28:03 +08:00
李通洲 b54e182c0f Disk (Windows): detect volume name 2023-09-17 20:41:07 +08:00
李通洲 fe89e71200 Disk (Linux): try fixing zpool detection
Ref: #559
2023-09-17 20:08:46 +08:00
xbt573 fb69d56297 Arguments: handle --lib-pulse properly 2023-09-17 02:13:48 -04:00
李通洲 6c1b39ae60 Shell (FreeBSD): remove trailing \0 2023-09-16 20:46:49 +08:00
李通洲 2082e01555 Theme: support JSON format (2) 2023-09-16 20:36:28 +08:00
李通洲 24a9231ad0 Kernel (Windows): remove trailing \0 2023-09-15 20:58:57 +08:00
李通洲 3c7903cc14 JsonSchema: add processingTimeout 2023-09-15 19:06:32 +08:00
李通洲 b721f9020e Logo (Builtin): improve performance on Windows 2023-09-15 11:07:47 +08:00
李通洲 bd02e5c632 Logo: code refactor 2023-09-15 10:53:09 +08:00
李通洲 0d5cf52f08 FFstrbuf: add ffStrbufAppendNC 2023-09-15 10:35:12 +08:00
李通洲 f97cddf2da JSON: support --stat for flag based configurations 2023-09-14 15:53:44 +08:00
李通洲 49f42cd003 Doc: update changelog 2023-09-14 15:29:15 +08:00
李通洲 0d7dc2d692 Logo (Ubuntu): changed the edges of the Ubuntu logo to make it rounder
Ref: https://github.com/dylanaraps/neofetch/pull/2378
2023-09-14 15:28:33 +08:00
xbt573 2039bed70d Logo (Builtin): add Elbrus 2023-09-14 01:20:40 -04:00
李通洲 9535b6a8bf PublicIP: fix missing new line 2023-09-14 08:55:33 +08:00
李通洲 df945e824b Deps: upgrade yyjson 2023-09-14 08:38:59 +08:00
李通洲 237c6f1c9e Processes / LocalIP: try increasing stability 2023-09-13 23:41:26 +08:00
李通洲 61131073f2 Global: silence compiler warnings 2023-09-13 22:46:11 +08:00
李通洲 013abe2b3e Weather: support JSON format 2023-09-13 18:38:02 +08:00
李通洲 63c29b10fe Weather: code refactor 2023-09-13 18:31:22 +08:00
李通洲 f5ad07a87b PublicIP: support JSON format 2023-09-13 17:56:50 +08:00
李通洲 28d40d9037 Global: fix some memleaks 2023-09-13 17:42:22 +08:00
李通洲 b3bdf494ab PublicIP: code refactor 2023-09-13 17:41:48 +08:00
李通洲 8d914ace33 Doc: update changelog 2023-09-13 17:36:39 +08:00
李通洲 58f234638b Users: make --users-compact false by default 2023-09-13 17:36:39 +08:00
李通洲 7dfc0d8e60 Shell: don't detect user shell 2023-09-13 17:36:39 +08:00
李通洲 2963e3bd93 Terminal: don't print shell information in Terminal module 2023-09-13 17:36:39 +08:00
李通洲 3dfa99c232 WMTheme: support JSON format 2023-09-13 14:25:00 +08:00
李通洲 804463a470 WM: support JSON format 2023-09-13 14:22:04 +08:00
李通洲 77466ba6f5 GPU: tidy 2023-09-13 14:07:14 +08:00
李通洲 3a8819d42b Wifi: support JSON format 2023-09-13 14:01:15 +08:00
李通洲 9765885fe6 Wallpaper: support JSON format 2023-09-13 13:39:56 +08:00
李通洲 16b01a06e0 Vulkan: support JSON format 2023-09-13 09:53:25 +08:00
李通洲 c400261a11 Deps: update yyjson 2023-09-13 09:42:34 +08:00
李通洲 9b72971dc9 Uptime (FreeBSD): fix building 2023-09-13 08:49:10 +08:00
李通洲 4449173b3d Version: support JSON config 2023-09-12 20:36:00 +08:00
李通洲 10a249d3a8 Title: support JSON support 2023-09-12 20:31:19 +08:00
李通洲 e91d011c8c Theme: support JSON format 2023-09-12 20:23:58 +08:00
李通洲 4124c12bac TerminalSize: support JSON format 2023-09-12 16:17:17 +08:00
李通洲 a927f4a04d DateTime: code refactor using ffTimeGetNow 2023-09-12 16:15:57 +08:00
李通洲 f3ec60a061 Uptime: add ffTimeGetNow() and use it 2023-09-12 14:55:33 +08:00
李通洲 2251086c0f TerminalFont: support JSON format 2023-09-12 11:18:05 +08:00
李通洲 9447f1ca80 Terminal: support JSON format 2023-09-12 09:49:36 +08:00
李通洲 f13b771317 Sound: support JSON format 2023-09-12 09:37:24 +08:00
李通洲 257439477e CI: update deps 2023-09-12 09:12:28 +08:00
李通洲 c702865332 Presets: add a new example
Ref: https://github.com/fastfetch-cli/fastfetch/discussions/556
2023-09-11 23:03:03 +08:00
李通洲 e2abe31fc1 Monitor: fix memleaks 2023-09-10 18:39:45 +08:00
李通洲 82c300f7f6 Logo (Builtin): add Afterglow
https://github.com/hykilpikonna/hyfetch/pull/
2023-09-08 21:22:00 +08:00
李通洲 94eb3b89e8 Logo (Builtin): use first color as title color
As what neofetch does
2023-09-08 21:22:00 +08:00
李通洲 f662cc0aa2 Logo (Builtin): update AOSC OS
Ref: https://github.com/hykilpikonna/hyfetch/pull/185
2023-09-08 21:21:33 +08:00
李通洲 1526930e54 Logo (Builtin): update EvolutionOS
Ref: #555
2023-09-08 21:06:37 +08:00
李通洲 1cdc99f327 JSON format: fix some memleaks 2023-09-08 20:25:41 +08:00
李通洲 d97b16950c Shell: JSON format support 2023-09-08 20:02:59 +08:00
李通洲 aff4a57092 Processes: JSON format support 2023-09-08 15:47:37 +08:00
李通洲 826aa2e46d Packages: support JSON format 2023-09-08 15:44:44 +08:00
李通洲 2c59a05dff Users: JSON format support 2023-09-08 15:31:58 +08:00
李通洲 aafd773fe7 Uptime: JSON format support 2023-09-08 15:31:58 +08:00
李通洲 4356974c5b Image: fix separated image printing 2023-09-08 15:31:58 +08:00
李通洲 7f1e2d2f03 Packages (Windows): support winget packages count
Guarded behind `--allow-slow-operations`
2023-09-08 15:25:22 +08:00
李通洲 cde2ba2c18 Uptime: detect boot time 2023-09-08 14:17:34 +08:00
李通洲 a093ca2001 Users: add more detailed information 2023-09-08 10:11:57 +08:00
李通洲 fe9fcd603b CPU (Windows): fix possible memory errors 2023-09-08 10:11:57 +08:00
李通洲 d8b2151143 CPU (macOS): support Apple Silicon frequency detection 2023-09-08 10:11:56 +08:00
李通洲 904c9eb3c4 CPU (macOS): code refactor 2023-09-08 10:11:31 +08:00
李通洲 598dfd2b02 Disk (Apple): use getattrlist to detect volume name
No functional changes
2023-09-08 10:11:29 +08:00
李通洲 77d388ce1d Disk (BSD): use getfsstat instead of getmntinfo for thread safety 2023-09-07 15:47:49 +08:00
李通洲 9eb35d3967 OS: JSON format support 2023-09-07 09:36:04 +08:00
李通洲 34902db21c OpenGL: JSON format support 2023-09-07 09:28:04 +08:00
李通洲 cdaf5e9281 OpenCL: JSON format support 2023-09-07 09:20:52 +08:00
李通洲 98833b4d74 Monitor: add JSON support 2023-09-06 16:33:51 +08:00
李通洲 f995d8d806 PowerAdapter: rename PowerAdapterResult to FFPowerAdapterResult 2023-09-06 16:27:02 +08:00
李通洲 eb4636b947 PowerAdapter: JSON format support 2023-09-06 16:23:57 +08:00
李通洲 a7c6e1165c Swap: JSON format support 2023-09-06 16:01:10 +08:00
李通洲 8bb88d1806 Memory: JSON format support 2023-09-06 15:59:56 +08:00
李通洲 849ff95116 Player: JSON format support 2023-09-06 15:53:52 +08:00
李通洲 dc29271987 Media: add JSON format support 2023-09-06 15:48:39 +08:00
李通洲 623c5d8eb9 LocalIP: add JSON format support 2023-09-05 16:31:54 +08:00
李通洲 e0ce520e0a Locale: add JSON format support 2023-09-05 16:25:08 +08:00
李通洲 f9cd032a5f LM: add JSON format support 2023-09-05 16:22:37 +08:00
李通洲 39b21f95b7 Kernel: add JSON format support 2023-09-05 16:10:28 +08:00
李通洲 dfbfb88a45 Icons: add JSON formatting support 2023-09-05 16:10:28 +08:00
李通洲 971a69ad1b Host: add JSON formatting support 2023-09-05 15:57:18 +08:00
李通洲 fddf6ddf1e CPU: don't use NaN in JSON 2023-09-05 15:51:09 +08:00
李通洲 81c625e7c9 GPU: add JSON printing support 2023-09-05 15:49:22 +08:00
李通洲 97293ddee1 Gamepad: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 21f36b564f Font: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 34e2b0f89c Display: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 d5ca6aa462 Disk: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 639ad436a0 Global: code refactor 2023-09-05 15:29:46 +08:00
李通洲 76fce2c5a9 DE: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 632718e1d0 DateTime: support JSON printing 2023-09-05 15:29:46 +08:00
李通洲 a4fababb71 Cursor: add JSON format support 2023-09-05 15:29:46 +08:00
李通洲 ac8741d57d CPUUsage: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 28e412b79d CPU: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 01aa9b9516 Command: add JSON printing support 2023-09-05 15:29:46 +08:00
李通洲 acd353b8b3 Chassis: add Json printing support 2023-09-05 15:29:46 +08:00
李通洲 c5d8d976f6 Brightness: add Json printing support 2023-09-05 15:29:46 +08:00
李通洲 3d44514b24 Board: support Json printing 2023-09-05 15:29:46 +08:00
李通洲 fb3fb1bf99 Bluetooth: rename FFBluetoothDevice to FFBluetoothResult 2023-09-05 15:29:46 +08:00
李通洲 757e5f8174 Bluetooth: support Json printing 2023-09-05 15:29:46 +08:00
李通洲 3669f2aee4 Battery: rename BatteryResult to FFBatteryResult 2023-09-05 15:29:46 +08:00
李通洲 14f26879de Global: init --format json support (#527) 2023-09-05 15:29:46 +08:00
李通洲 2f46a77ff2 TerminalFont: better kitty font detection 2023-09-04 19:19:55 +08:00
李通洲 10853fdf35 Doc: add note for image protocol support of Android 2023-09-03 22:51:28 +08:00
李通洲 591fd558e1 Logo: fix --logo-padding for --logo-separate 2023-09-03 22:39:09 +08:00
李通洲 b863e65ea3 OpenGL: silence warnings 2023-09-03 22:21:53 +08:00
李通洲 fc61f64630 Logo: add --logo-separate true 2023-09-03 22:20:11 +08:00
李通洲 3483673ef7 Terminal (Android): fix termux detection 2023-09-03 20:57:23 +08:00
李通洲 9e839d3b8b Logo: simplify code 2023-09-03 19:55:57 +08:00
李通洲 33f121d7fb JsonSchema: fix the name of property defaultRouteOnly 2023-09-03 19:01:52 +08:00
李通洲 9500ca8f83 Logo: fix poll() timeout or failed error when image is very large
Fix #554
2023-09-03 17:50:20 +08:00
李通洲 4dfbc0f909 Logo: try fixing #553 2023-09-02 22:32:34 +08:00
李通洲 effb685fba Logo: try improving performance for image-raw 2023-09-02 10:08:08 -04:00
李通洲 3692e49e9b TerminalShell: correctly set PATH_MAX on Linux 2023-09-02 10:05:30 -04:00
李通洲 04d56d9b6a IO: fix short read when reading from pipe 2023-09-02 10:04:57 -04:00
李通洲 34417ae692 TerminalFont: support contour 2023-09-02 08:11:21 -04:00
李通洲 67d04a746e Terminal: support contour version detection 2023-09-02 07:40:23 -04:00
李通洲 552e0f84aa Doc: update changelog 2023-09-02 00:47:05 -04:00
李通洲 3e880fedf7 Logo: support kitty-direct / iterm without specifying logo width / height
Fixes #550
2023-09-02 00:46:39 -04:00
李通洲 e5c4a6ed2c Logo (Builtin): update EvolutionOS
Closes #551
2023-09-01 23:29:23 -04:00
李通洲 0bda7d80c2 Doc: update README for image logo on Windows 2023-08-30 22:21:29 +08:00
李通洲 7cb86df48d Logo: improve performance on Windows for iterm protocol 2023-08-30 22:17:51 +08:00
李通洲 21e5df2826 Global: replace cpu-usage to cpuusage 2023-08-29 17:47:20 +08:00
李通洲 a5ee51e156 Global: use FF_LIST_AUTO_DESTROY 2023-08-29 10:49:22 +08:00
李通洲 bddcb4772c DE (FreeBSD): add fast path for xfce4 version detection 2023-08-29 10:47:24 +08:00
Carter Li a3f13bdca9 Merge pull request #545 from fastfetch-cli/dev
Release v2.0.5
2023-08-26 20:31:27 +08:00
李通洲 55444b9c4e Release v2.0.5 2023-08-26 08:16:06 -04:00
李通洲 2f14d7742e Display (Linux): fix memleaks 2023-08-26 05:52:06 -04:00
李通洲 0534882f4e Cursor: Don't print 0px 2023-08-26 05:43:15 -04:00
李通洲 ce2f2f4416 Doc: update changelog 2023-08-26 05:31:00 -04:00
李通洲 5259aeb039 Display: fix segfault when using libxrandr
Fix #544
2023-08-26 05:28:21 -04:00
李通洲 e51999edd1 Doc: update changelog 2023-08-26 13:43:33 +08:00
李通洲 2f96c847b9 Disk: print Read-only 2023-08-26 13:43:33 +08:00
李通洲 32d6436027 Disk: add --disk-show-readonly 2023-08-26 13:43:33 +08:00
李通洲 7358326a13 Disk: add --disk-use-available
fix #543
2023-08-26 13:43:13 +08:00
李通洲 434a879538 Disk: rename FFDiskType to FFDiskVolumeType 2023-08-26 13:40:40 +08:00
487 changed files with 28093 additions and 7155 deletions
+5
View File
@@ -0,0 +1,5 @@
[codespell]
check-filenames =
builtin = clear,rare,usage,informal
skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii
ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,sur,doas
+2 -5
View File
@@ -1,7 +1,7 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: '[BUG] '
labels: bug
assignees: ''
@@ -24,12 +24,9 @@ The content of the configuration file you use (if any)
//paste here
```
Output of `env NO_CONFIG=1 fastfetch --load-config all --show-errors --stat --multithreading false --disable-linewrap false --hide-cursor false`:
Output of `fastfetch -c ci.jsonc --format json`:
<!--
Note that this output will contain you public IP. If it is not relevant for the issue, feel free to remove it before uploading.
If you get the following error: `Error: couldn't find config: [...]`, copy the files in [presets](../../presets/) to `/usr/share/fastfetch/presets/` or `~/.local/share/fastfetch/presets/`.
If this isn't possible (or too much work) for you, post the output of `env NO_CONFIG=1 fastfetch --show-errors --stat --multithreading false --disable-linewrap false --hide-cursor false && fastfetch --version`.
-->
```
+3 -1
View File
@@ -1,12 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: '[FEAT] '
labels: enhancement
assignees: ''
---
<!-- Before requesting a new feature, please try `fastfetch -c all.jsonc` to see if it has been supported -->
# Current state:
# Wanted state:
+3 -3
View File
@@ -1,7 +1,7 @@
---
name: Logo request
about: Request a new logo
title: ''
title: '[LOGO] '
labels: logo request
assignees: ''
@@ -9,10 +9,10 @@ assignees: ''
# OS
```
paste content of /etc/os-release here. If this file doesn't exist, describe a way to identify the distro.
Paste content of /etc/os-release here. If this file doesn't exist, describe a way to identify the distro.
```
# Ascii
```
paste ascii art here. If you leave this empty, i will try to find the logo myself.
Paste ascii art here.
```
+99 -37
View File
@@ -5,6 +5,20 @@ on:
- pull_request
jobs:
spellcheck:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Install codespell
shell: bash
run: sudo apt update && sudo apt install -y codespell
- name: Run Spellchecker
run: codespell
linux-buildtest:
name: Linux build test
permissions:
@@ -13,24 +27,32 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
compiler: [gcc, clang, "musl-gcc"]
compiler: [
{ cc: gcc, cxx: "g++" },
{ cc: clang, cxx: "clang++" },
{ cc: "musl-gcc", cxx: "musl-g++" }
]
enableFeatures: [ON, OFF]
exclude:
# The feature libraries are all build against glibc, so they can't be used with musl
- compiler: "musl-gcc"
- compiler: { cc: "musl-gcc", cxx: "musl-g++" }
enableFeatures: ON
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev
run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev directx-headers-dev libdrm-dev
- name: configure project
env:
CC: ${{ matrix.compiler }}
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_JSONC=${{ matrix.enableFeatures }} .
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_DIRECTX_HEADERS=${{ matrix.enableFeatures }} -DENABLE_DRM=${{ matrix.enableFeatures }} .
- name: build project
run: cmake --build .
@@ -38,11 +60,17 @@ jobs:
- name: run tests
run: ctest
- name: run fastfetch --list-features
run: ./fastfetch --list-features
- name: run fastfetch
run: ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
run: time ./fastfetch -c presets/ci.jsonc
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: run flashfetch
run: ./flashfetch
run: time ./flashfetch
linux:
name: Linux
@@ -54,10 +82,18 @@ jobs:
ffversion: ${{ steps.ffversion.outputs.ffversion }}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev libdrm-dev directx-headers-dev
- name: install linuxbrew packages
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick ddcutil --ignore-dependencies
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -65,10 +101,10 @@ jobs:
languages: c
- name: configure project
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
run: PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
- name: build project
run: cmake --build . --target package
run: cmake --build . --target package --verbose
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
@@ -77,11 +113,17 @@ jobs:
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
run: time ./fastfetch -c presets/ci.jsonc
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: run flashfetch
run: time ./flashfetch
- name: print dependencies
run: ldd fastfetch
- name: run tests
run: ctest
@@ -103,10 +145,15 @@ jobs:
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: install required packages
run: brew install vulkan-loader molten-vk imagemagick chafa
run: |
brew update
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install vulkan-loader vulkan-headers molten-vk imagemagick chafa
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -117,7 +164,7 @@ jobs:
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' .
- name: build project
run: cmake --build . --target package
run: cmake --build . --target package --verbose
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
@@ -126,11 +173,17 @@ jobs:
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
run: time ./fastfetch -c presets/ci.jsonc
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: run flashfetch
run: time ./flashfetch
- name: print dependencies
run: otool -L fastfetch
- name: run tests
run: ctest
@@ -148,19 +201,24 @@ jobs:
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: run VM
uses: vmactions/freebsd-vm@v0
uses: cross-platform-actions/action@v0.21.1
with:
prepare: |
pkg install -y cmake git pkgconf pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd pulseaudio
operating_system: freebsd
version: '13.2'
run: |
uname -a
sudo pkg update
sudo pkg install -y cmake git pkgconf binutils pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd pulseaudio
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
cmake --build . --target package
cmake --build . --target package --verbose
./fastfetch --list-features
time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
time ./fastfetch
time ./fastfetch --format json
time ./flashfetch
ldd fastfetch
ctest
- name: upload artifacts
@@ -180,7 +238,7 @@ jobs:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: setup-msys2
uses: msys2/setup-msys2@v2
@@ -192,19 +250,11 @@ jobs:
- name: print msys version
run: uname -a
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/clang64/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
run: cmake --build . --verbose
- name: copy necessary dlls
run: cp /clang64/bin/{OpenCL,vulkan-1}.dll .
@@ -213,11 +263,17 @@ jobs:
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
run: time ./fastfetch -c presets/ci.jsonc
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: run flashfetch
run: time ./flashfetch
- name: print dependencies
run: ldd fastfetch
- name: run tests
run: ctest
@@ -244,7 +300,7 @@ jobs:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: setup-msys2
uses: msys2/setup-msys2@v2
@@ -265,7 +321,7 @@ jobs:
run: env PKG_CONFIG_PATH=/clang32/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
run: cmake --build . --verbose
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
@@ -274,11 +330,17 @@ jobs:
run: cp /clang32/bin/{OpenCL,vulkan-1}.dll .
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors --no-buffer --load-config presets/all
run: time ./fastfetch -c presets/ci.jsonc
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: run flashfetch
run: time ./flashfetch
- name: print dependencies
run: ldd fastfetch
- name: run tests
run: ctest
+1
View File
@@ -7,3 +7,4 @@
cscope.*
tags
fastfetch.kdev4
*.user
+288 -10
View File
@@ -1,7 +1,285 @@
# 2.4.0
**We are deprecating flags based config files (will be removed in v3.0.0). We suggest you migrate to json based config files.** One may use `-c /path/to/config.conf --gen-config` to migrate existing flag based config files.
Changes:
* All flag based presets are removed
Features:
* Improve performance of detecting rpm and pkg package count (Packages, Linux / FreeBSD)
* Support Apple M3X temperature detection (CPU / GPU, macOS)
* `--ds-force-drm` support a new option `sysfs-only`
* Improve xfce4 version detection
* Detect WM and DE by enumerating running processes (WM / DE, FreeBSD)
* Add a new module `Physical Disk`, which detects product name, full size, serial number and so on.
Bugfixes:
* Fix crashes sometimes when `--logo-padding-top` is not set (Logo)
* Fix memory usage counting algorithm (Memory, macOS)
* Fix the behavior of `--no-buffer` in Windows
* Fix possible segfault in some devices (Display, Linux)
* Fix segfaults on first use of new images with Sixel flag (Image)
Logo:
* Remove unnecessary escaping for Adelie logo
* Add EshanizedOS
# 2.3.4
Bugfixes:
* Fix `--help` doesn't work when built without python
Features:
* Use `MemAvailable` if available (Memory, Linux)
* Improve performance of detecting dpkg package count (Packages, Linux)
# 2.3.3
Bugfixes:
* Fix `--help` doesn't work in Windows and some other platforms
# 2.3.2
Bugfixes:
* Fix fish completion script, and install the script correctly
Logo:
* Fix Xray-OS logo name
# 2.3.1
Bugfixes:
* Fix man page install location
# 2.3.0
**We are deprecating flags based config files (will be removed in v3.0.0). We suggest you migrate to json based config files.**
Config related changes:
* The deprecated flag `--gen-config conf` is removed
* Flag `--gen-config` now does the same thing as `--migrate-config`, which can be used as config migration and default config file generation. Flag `--migrate-config` is removed
* Fastfetch now searches for config files in the order of `fastfetch --list-config-paths`, and won't load other config if one is found.
* The undocumented flag `--load-user-config` is removed. As an alternative, `--config none` can be used to disable loading config files.
* `--config` (previously named `--load-config`) is now supported for command line arguments only. If specified, other config files won't be loaded, which works like other programs.
* Config files will always be loaded before other command line flags being parsed. That is to say, command line flags will always override options defined in config files.
* the value of GPUType `integrated` contained a typo and was fixed. Existing config files may need to be updated.
Features:
* Support Oils and elvish shell version detection (Shell)
* Support Windows Server Core (Windows)
* Better ddcutil 2.x compatibility (Brightness, Linux)
* Add completion support for fish (natively) and nushell (via [carapace-bin](https://github.com/rsteube/carapace-bin))
* Support nix in macOS (Packages, macOS)
* Print module description for `--list-modules`
* Support `alacritty.toml` (TerminalFont)
* Support board detection on macOS. It simplily prints machine model identifier as for now (Board, macOS)
* Add general method to query product name (Host, macOS)
* Use `libdrm` as a better fall back for detecting displays, which correctly detects current mode; supports refresh rate detection and maybe also faster than using `/sys/class/drm` (Display, Linux)
* Support physical disk size detection (DiskIO)
* Support physical disk name and type detection (DiskIO, FreeBSD)
Bugfixes:
* End `va_list` before returning (@VoltrexKeyva)
* Don't use background color when printing blocks (Color)
* Fix lots of typos
* Fix compatibility with Linux containers (Linux)
* Don't report disabled monitors when using DRM (Linux)
* Fix bad performance in some cases when using X11 (Display, Linux)
* Fix some memory leaks
* Fix used swap space detection (Swap, FreeBSD)
* Don't leak fds to child processes (Linux)
* Fix possible issues when reading procfs (Linux, @apocelipes)
Logos:
* Add Adelie, Ironclad
* Update parch
# 2.2.3
Features:
* Update the latest mac models (Host, macOS)
Bugfixes:
* Fix local ips detection on Android. Regression from `2.0.0` (LocalIP, Android)
* Fix terminal detection on NixOS (Terminal)
# 2.2.2
Changes:
* `--percent-type` now defaults to 9 (colored percentage numbers)
* `fastfetch` now prints LocalIp module by default
Features:
* LocalIP module now prints netmask in CIDR format for IPv4 (LocalIP)
* Bios module now detects system firmware type (Bios)
* Improve detection of `Battery`
* Detect cycle count on supported platforms
* Detect temperature on Linux when supported
* Status detection on macOS has been adjusted to be consistent with other platforms
* Linux binaries are built with imagemagick7 support
Bugfixes:
* Fix uninitialized variables (#609)
* Fix spelling of `--preserve-aspect-ratio` (#614)
Logos:
* Update NixOS_small
# 2.2.1
Hotfix release for #606
Bugfixes:
* Fix broken presets due to the breaking changes introduced in 2.2.0
Features:
* Pretty print `fastfetch --help`
# 2.2.0
This release introduces a new option `--migrate-config`, which migrates old flag based config file to new JSONC format
Changes:
* `--pipe` and `--stat` are moved from `general` options to `display` options. This affects cjson configuration.
* Display keys `percent*` and `size*` in JSON config are restructured. e.g. `{ "sizeNdigits": 1 }` is now `{ "size": { "ndigits": 1 } }`
* With the introduction of `--migrate-config`, the old flag based config file is deprecated, and will be removed in 3.0.0 (next major version)
* Support of `--gen-config conf` is deprecated accordingly, and will be removed in 2.3.0 (next minor version)
* The global flag `--allow-slow-operations` is split into some explicit flags in different modules
* `--packages-winget`: control whether `winget` packages count should be detected. Note it's a very slow operation, please enable it with caution.
* `--chassis-use-wmi`: control whether `WMI` query should be used to detect chassis type, which detects more information, but slower. This flag only affects `--chassis-format` and `--format json`.
* `--battery-use-setup-api`: control whether `SetupAPI` should be used on Windows to detect battery info, which supports multi batteries, but slower.
* `--wm-detect-plugin`: control whether WM plugins should be detected. Note it's implemented with global processes enumeration and can report false results.
* `--de-slow-version-detection`: control DE version should be detected with slow operations. It's usually not necessary and only provided as a backup.
* `--localip-default-route-only` and `--netio-default-route-only` defaults to true to avoid large number of results
Features:
* Quirks for MIPS platforms (CPU, Linux)
* Use devicetree path for OBP hosts (Host, Linux)
* Detect `tmux: server` as tmux (Terminal, Linux)
* Support urxvt version detection (Terminal, Linux)
* Support st version detection (Terminal, Linux)
* Support st terminal font detection (TerminalFont, Linux)
* Support xfce4-terminal 1.1.0+ terminal font detection (TerminalFont, Linux)
* Add option `--migrate-config <?target-file-path>`
* Support Nvidia GPU temp and cuda core count detection via nvml. Use `--gpu-use-nvml` to enable it (GPU)
* Try supporting Wifi authentication type detection in macOS Sonoma. Please file a feature request if you get `to be supported (num)` with result of `/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep auth` (Wifi, macOS)
Bugfixes:
* Better GPU memory and type detection (GPU, Windows)
* Don't print display type twice (Display)
* Detect BSSID instead of Wifi MAC address to align with other platforms (Wifi, macOS)
* Remove support of used GPU memory detection, which is not reliable and only supported with `--gpu-force-vulkan`. (GPU)
* Fix flag `--brightness-ddcci-sleep` (Brightness, Linux)
* Fix hanging if a child process prints to both stdout and stderr (Linux)
Logos:
* Add Black Mesa
* Add cycledream
* Add Evolinx
* Add azos
* Add Interix
# 2.1.2
Bugfixes:
* Fix icon detection on Windows. It shows enabled system icons in desktop (`This PC`, `Recycle Bin`, etc) (Icon, Windows)
* Fix compatibility with ddcutil 2.0 (Brightness, Linux)
* Fix a compile warning (CPUUsage, FreeBSD)
# 2.1.1
Features:
* Support opkg (Packages, Linux)
* Support GNOME Console terminal version and font detection (Terminal, Linux)
* Add `--cpu-freq-ndigits` to set number of digits for CPU frequency (CPU)
* New module to detect physical disk I/O usage (DiskIO)
* Add `--cpuusage-separate` to display CPU usage per CPU logical core
* Add `--brightness-ddcci-sleep` to set the sleep times (in ms) when sending DDC/CI requests (Brightness, #580)
Bugfixes:
* Fix possible crashes on Windows 7 (Disk, Windows)
* Fix possible crashes caused by uninitialized strings (Users, Windows)
* Improve support of `--help *-format` and several bugs are found and fixed
* Don't incorrectly print `No active sound devices found` when using a non-controllable sound device (Sound, macOS)
* Fix implementation processes counting (Processes, Linux)
* Work around a issue that SSID cannot be detected on macOS Sonoma (Wifi, macOS)
Logo:
* Add Chimera Linux
* Add EndeavourSmall
* Add Xenia
* Add MainsailOS
* Fix phyOS
# 2.1.0
This release introduces a new output format: JSON result
Changes:
* Users module detects and prints user login time by default. Specifying `--users-compact` to disable it
* Fastfetch now requires yyjson 0.8.0 or later, which is embedded in fastfetch source tree. If you build fastfetch with `-DENABLE_SYSTEM_YYJSON` cmake option, you must upgrade your yyjson package
* Reduced information supported by `--terminal-format`, `--shell-format`
* Some config presets (`devinfo` and `verbose`) are obsolete and removed. They are barely maintained and can be replaced with `--format json` now.
* Custom strings in `--module-key` and `--module-format` are no longer trimmed.
* `/boot` is hidden by default (FreeBSD, Disk)
Features:
* Add `--format json`, which prints system information as JSON format
* Add fast path for xfce4 version detection (DE, FreeBSD)
* Support contour terminal version and font detection (Terminal / TerminalFont)
* Support `kitty-direct` / `iterm` without specifying logo width / height. Note: in this case, the entre screen will be cleared.
* Support new flag `--logo-separate`. If true, print modules at bottom of the logo
* Support Apple Silicon CPU frequency detection (CPU, macOS)
* Support user login time detection (Users)
* Support winget package manager detection, guarded behind `--allow-slow-operations` (Packages, Windows)
* Print monitor type (built-in or external) (Display)
* Support full GPU detection in WSL (Linux, GPU)
* Add `--module-key " "` as a special case for hiding keys
* Support `--title-format`. See `fastfetch --help title-format` for detail
* Support `--colors-key` (Colors)
* Add `-c` as a shortcut of `--load-config`. Note it was used as the shortcut of `--color` before 2.0.5
* Support Windows Service Pack version detection (Kernel, Windows)
* Support Debian point releases detection (OS, Linux)
* Add new module `NetIO` which prints network throughput (usage) of specified interface. Note this module costs about 1 second to finish.
* Use `lscpu` to detect CPU name for ARM CPUs (CPU, Linux)
Bugfixes:
* Fix fastfetch hanging in specific environment (#561)
* Fix short read when reading from stdin (Logo)
* Fix `poll() timeout or failed` error when image is very large (Logo)
* Fix Termux Monet terminal version detection (Terminal)
* Fix zpool volumes detection (Disk, Linux)
* Fix external volumes detection (Disk, Linux)
* Fix snap package number detection on systems other than Ubuntu (Packages, Linux)
* Fix dpkg / apt package number detection (Packages, Linux)
* Fix bluetooth mac address detection (Bluetooth, Windows)
Logo:
* Add Afterglow
* Add Elbrus
* Update EvolutionOS
* Update AOSC OS
* Update Ubuntu_old
* Update Windows 11_small
* Add Amazon Linux
* Add LainOS
* Fix colors of Slackware
# 2.0.5
Bugfixes:
* Fix segfault when using libxrandr (#544, Display, Linux)
* Don't print 0px (#544, Cursor)
Features:
* Add option `--disk-use-available` (#543)
* Add option `--disk-show-readonly`
# 2.0.4
Bugfixes:
* Fix building on 32-bit FreeBSD (Memory, BSD)
* Fix building on 32-bit FreeBSD (Memory, FreeBSD)
* Fix `--file-raw` doesn't work (Logo)
Features:
@@ -22,7 +300,7 @@ Features:
# 2.0.2
Bugfixes:
* Workarund [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows)
* Workaround [a compiler bug of GCC](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282) (Windows)
* Fix presets not detected by file name (#529)
Logo:
@@ -34,7 +312,7 @@ First stable release of Fastfetch V2
Changes:
* Unescape strings only when parsing `.conf` files
* Previously: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\: *`. Note the backslashs are unescaped twice (once by shell and once by fastfetch).
* Previously: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\: *`. Note the backslashes are unescaped twice (once by shell and once by fastfetch).
* Now: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\\: *`
* Remove option shortcut `-c` (alias of `--color`), which is more commonly used as alias of `--config`
* Rename `--recache` to `--logo-recache` (which is used for regenerate image logo cache). Remove option shortcut `-r` (alias of `--recache`).
@@ -90,7 +368,7 @@ Features:
* Better CPU and Host detection for Android (Android)
* Support yakuake terminal version & font detection (Terminal, Linux)
* Add new option `--bright-color` which can be used to disable the default bright color of keys, title and ASCII logo.
* Add module `Monitor` which prints physical parameters (native resolutions and demensions) of connected monitors
* Add module `Monitor` which prints physical parameters (native resolutions and dimensions) of connected monitors
* Support path with environment variables for `--logo-source` and `--load-config`.
Bugfixes:
@@ -178,7 +456,7 @@ Bugfixes:
* Fix Windows drives detection in WSL (Disk)
Changes:
* In order to make Icons module consistant between different platforms, `--icons-format` no longer supports individual GTK / QT icon params.
* In order to make Icons module consistent between different platforms, `--icons-format` no longer supports individual GTK / QT icon params.
* `--theme-format` no longer supports individual GTK / plasma theme params.
* `--local-ip-*` and `--public-ip-*` have been changed to `--localip-*` and `--publicip-*`
* `--localip-compact-type` is no longer supported. Fastfetch now display IPs as `--localip-compat-type multiline` by default, with `--local-compact true` can be set as an alias of `--localip-compact-type oneline`
@@ -201,7 +479,7 @@ Bugfixes:
* Fix iTerm being detected as iTermServer-* sometimes
* Fix sound device volume being incorrectly detected as muted sometimes (Sound)
* Fix memleaks reported by LeakSanitizer (Linux)
* Fix potential memory curruption bug in unicode.c (Windows)
* Fix potential memory corruption bug in unicode.c (Windows)
Logo:
* Update Windows 11 ASCII logo to look more visually consistent (#445)
@@ -237,7 +515,7 @@ Bugfixes:
* Fix compiling errors (Windows)
Improvements:
* Improve preformance (WmTheme amd Font, Windows and macOS)
* Improve performance (WmTheme amd Font, Windows and macOS)
* Enable nonblocking public-ip / weather detection (Android)
# 1.10.2
@@ -282,7 +560,7 @@ Other:
* Simplified wmtheme output format (Windows)
* Improved GPU detection performance on Windows 11
* Lastest Mac model identifier support (macOS)
* Latest Mac model identifier support (macOS)
# 1.9.1
@@ -364,7 +642,7 @@ Bugfixes:
This release introduces Windows support! Fastfetch now fully support all major desktop OSes (Linux, macOS, Windows and FreeBSD)
Notable Changes:
* Bios / Board / Chassis modules are splitted against Host module for performance reasons
* Bios / Board / Chassis modules are split against Host module for performance reasons
* Caching is removed. Option `--nocache` is removed accordingly
Features:
@@ -373,7 +651,7 @@ Features:
* Adds a new flag `--stat`, which prints time usage for individual modules
* Adds Wifi module which supports Windows and macOS
* Adds data source option for logo printing
* Detects Homebrew Cellar and Cask seperately
* Detects Homebrew Cellar and Cask separately
* Detects WSL version
* Detects disk based on mount point
* Exposes more chafa configs
+171 -41
View File
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 2.0.4
VERSION 2.4.0
LANGUAGES C
DESCRIPTION "Fast system information tool"
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
)
@@ -49,6 +49,7 @@ cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR BSD" OFF
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR BSD" OFF)
@@ -67,10 +68,12 @@ cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
cmake_dependent_option(ENABLE_PCI_MEMORY "Enable detecting GPU memory size with libpci" OFF "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embeded) yyjson library" OFF "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF)
option(ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF)
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
@@ -96,12 +99,15 @@ endif()
set(WARNING_FLAGS "-Wall -Wextra -Wconversion -Werror=uninitialized -Werror=return-type")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointer-types -Werror=implicit-function-declaration")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion")
if(WIN32)
if(WIN32 OR ENABLE_DIRECTX_HEADERS)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -fno-exceptions -fno-rtti")
endif()
if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--tsaware -Wl,--build-id -Wl,--subsystem,console:6.1,--major-os-version,6,--minor-os-version,1")
endif()
@@ -112,8 +118,9 @@ if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
endif()
set(FASTFETCH_FLAGS_DEBUG "-fno-omit-frame-pointer")
if(NOT WIN32)
set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address -fsanitize=undefined")
if(ENABLE_ASAN)
message(STATUS "Address sanitizer enabled (DEBUG only)")
set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")
@@ -121,8 +128,8 @@ if(NOT WIN32)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -rdynamic")
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Enabling LTO")
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED)
@@ -198,19 +205,35 @@ endif()
# Text data #
#############
function(fastfetch_load_text FILENAME OUTVAR)
file(READ "${FILENAME}" TEMP)
string(REGEX REPLACE "\n$" "" TEMP "${TEMP}") # Remove trailing newline
function(fastfetch_encode_c_string STR OUTVAR)
string(REGEX REPLACE "\n$" "" TEMP "${STR}") # Remove trailing newline
string(REPLACE "\\" "\\\\" TEMP "${TEMP}") # Escape backslashes
string(REPLACE "\n" "\\n" TEMP "${TEMP}") # Replace newlines with \n
string(REPLACE "\"" "\\\"" TEMP "${TEMP}") # Replace quotes with \"
string(REPLACE "$\\" "" TEMP "${TEMP}") # Remove $\, so we can unescape some things
set("${OUTVAR}" "${TEMP}" PARENT_SCOPE)
set(${OUTVAR} "\"${TEMP}\"" PARENT_SCOPE)
endfunction(fastfetch_encode_c_string)
function(fastfetch_load_text FILENAME OUTVAR)
file(READ "${FILENAME}" TEMP)
fastfetch_encode_c_string("${TEMP}" TEMP)
set(${OUTVAR} "${TEMP}" PARENT_SCOPE)
endfunction(fastfetch_load_text)
find_package(Python)
if(Python_FOUND)
execute_process(COMMAND ${Python_EXECUTABLE} -c "import json,sys;json.dump(json.load(sys.stdin),sys.stdout,separators=(',',':'))"
INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/src/data/help.json"
OUTPUT_VARIABLE DATATEXT_JSON_HELP)
if(DATATEXT_JSON_HELP STREQUAL "")
message(ERROR "DATATEXT_JSON_HELP is empty, which should not happen!")
endif()
else()
message(STATUS "Python3 is not found, 'help.json' will not be minified")
file(READ "src/data/help.json" DATATEXT_JSON_HELP)
endif()
fastfetch_encode_c_string("${DATATEXT_JSON_HELP}" DATATEXT_JSON_HELP)
fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM)
fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER)
fastfetch_load_text(src/data/config_user.jsonc DATATEXT_CONFIG_USER_JSONC)
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT)
@@ -218,27 +241,21 @@ fastfetch_load_text(src/data/help_config.txt DATATEXT_HELP_CONFIG)
configure_file(src/fastfetch_config.h.in fastfetch_config.h @ONLY)
configure_file(src/fastfetch_datatext.h.in fastfetch_datatext.h @ONLY)
if(APPLE)
configure_file(src/util/apple/Info.plist.in Info.plist @ONLY)
endif()
string(TIMESTAMP FASTFETCH_BUILD_DATE "%d %B %Y")
configure_file(doc/fastfetch.1.in fastfetch.1 @ONLY)
####################
# Ascii image data #
####################
function(fastfetch_load_raw_text FILENAME OUTVAR)
file(READ "${FILENAME}" TEMP)
string(REGEX REPLACE "\n$" "" TEMP "${TEMP}") # Remove trailing newline
string(JSON TEMP SET "{}" "${TEMP}" "0") # Encode raw strings using JSON_SET
string(REGEX REPLACE "^\\{[ \t\r\n]*" "" TEMP "${TEMP}") # Remove JSON braces
string(REGEX REPLACE "[ \t\r\n]*:[ \t\r\n]*0[ \t\r\n]*\\}$" "" TEMP "${TEMP}") # Remove trailing ` : 0 }`
if(NOT "${TEMP}" MATCHES "^\"[^\n]*\"")
message(FATAL_ERROR "Internal error: unexpected output: '${TEMP}'")
endif()
set(${OUTVAR} "${TEMP}" PARENT_SCOPE)
endfunction(fastfetch_load_raw_text)
file(GLOB LOGO_FILES "src/logo/ascii/*.txt")
set(LOGO_BUILTIN_H "#pragma once\n\n")
set(LOGO_BUILTIN_H "#pragma once\n#pragma GCC diagnostic ignored \"-Wtrigraphs\"\n\n")
foreach(file ${LOGO_FILES})
fastfetch_load_raw_text("${file}" content)
fastfetch_load_text("${file}" content)
get_filename_component(file "${file}" NAME_WLE)
string(TOUPPER "${file}" file)
string(REGEX REPLACE "\\$\\{c([0-9]+)\\}" "$\\1" content "${content}")
@@ -259,6 +276,7 @@ set(LIBFASTFETCH_SRC
src/common/jsonconfig.c
src/common/library.c
src/common/modules.c
src/common/netif/netif.c
src/common/option.c
src/common/parsing.c
src/common/printing.c
@@ -267,26 +285,28 @@ set(LIBFASTFETCH_SRC
src/detection/chassis/chassis.c
src/detection/cpu/cpu.c
src/detection/cpuusage/cpuusage.c
src/detection/datetime/datetime.c
src/detection/disk/disk.c
src/detection/diskio/diskio.c
src/detection/displayserver/displayserver.c
src/detection/font/font.c
src/detection/gpu/gpu.c
src/detection/locale/locale.c
src/detection/media/media.c
src/detection/netio/netio.c
src/detection/opencl/opencl.c
src/detection/os/os.c
src/detection/packages/packages.c
src/detection/publicip/publicip.c
src/detection/terminalfont/terminalfont.c
src/detection/terminalshell/terminalshell.c
src/detection/version/version.c
src/detection/vulkan/vulkan.c
src/detection/weather/weather.c
src/logo/builtin.c
src/logo/image/im6.c
src/logo/image/im7.c
src/logo/image/image.c
src/logo/logo.c
src/logo/option.c
src/modules/battery/battery.c
src/modules/bios/bios.c
src/modules/bluetooth/bluetooth.c
@@ -303,6 +323,7 @@ set(LIBFASTFETCH_SRC
src/modules/datetime/datetime.c
src/modules/de/de.c
src/modules/disk/disk.c
src/modules/diskio/diskio.c
src/modules/font/font.c
src/modules/gpu/gpu.c
src/modules/host/host.c
@@ -314,10 +335,12 @@ set(LIBFASTFETCH_SRC
src/modules/localip/localip.c
src/modules/memory/memory.c
src/modules/monitor/monitor.c
src/modules/netio/netio.c
src/modules/opencl/opencl.c
src/modules/opengl/opengl.c
src/modules/os/os.c
src/modules/packages/packages.c
src/modules/physicaldisk/physicaldisk.c
src/modules/processes/processes.c
src/modules/player/player.c
src/modules/poweradapter/poweradapter.c
@@ -342,6 +365,11 @@ set(LIBFASTFETCH_SRC
src/modules/wifi/wifi.c
src/modules/wm/wm.c
src/modules/wmtheme/wmtheme.c
src/options/display.c
src/options/modules.c
src/options/logo.c
src/options/general.c
src/options/library.c
src/util/edidHelper.c
src/util/FFlist.c
src/util/FFstrbuf.c
@@ -354,6 +382,7 @@ if(LINUX)
list(APPEND LIBFASTFETCH_SRC
src/common/dbus.c
src/common/io/io_unix.c
src/common/netif/netif_linux.c
src/common/networking_linux.c
src/common/processing_linux.c
src/detection/battery/battery_linux.c
@@ -366,22 +395,28 @@ if(LINUX)
src/detection/cursor/cursor_linux.c
src/detection/bluetooth/bluetooth_linux.c
src/detection/disk/disk_linux.c
src/detection/physicaldisk/physicaldisk_linux.c
src/detection/diskio/diskio_linux.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/drm.c
src/detection/displayserver/linux/wayland.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/font/font_linux.c
src/detection/gpu/gpu_linux.c
src/detection/gpu/gpu_nvidia.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_linux.c
src/detection/icons/icons_linux.c
src/detection/libc/libc_linux.c
src/detection/lm/lm_linux.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_linux.c
src/detection/media/media_linux.c
src/detection/memory/memory_linux.c
src/detection/monitor/monitor_linux.c
src/detection/netio/netio_linux.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
src/detection/packages/packages_linux.c
@@ -399,12 +434,15 @@ if(LINUX)
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_linux.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/util/platform/FFPlatform_unix.c
)
elseif(ANDROID)
list(APPEND LIBFASTFETCH_SRC
src/common/io/io_unix.c
src/common/netif/netif_linux.c
src/common/networking_linux.c
src/common/processing_linux.c
src/detection/battery/battery_android.c
@@ -417,17 +455,21 @@ elseif(ANDROID)
src/detection/cursor/cursor_nosupport.c
src/detection/cpuusage/cpuusage_linux.c
src/detection/disk/disk_linux.c
src/detection/physicaldisk/physicaldisk_linux.c
src/detection/diskio/diskio_linux.c
src/detection/displayserver/displayserver_android.c
src/detection/font/font_nosupport.c
src/detection/gpu/gpu_nosupport.c
src/detection/host/host_android.c
src/detection/icons/icons_nosupport.c
src/detection/libc/libc_android.c
src/detection/lm/lm_nosupport.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_linux.c
src/detection/monitor/monitor_nosupport.c
src/detection/netio/netio_linux.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_android.c
src/detection/packages/packages_linux.c
@@ -444,6 +486,8 @@ elseif(ANDROID)
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_nosupport.c
src/detection/wifi/wifi_android.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_nosupport.c
src/detection/wmtheme/wmtheme_nosupport.c
src/util/platform/FFPlatform_unix.c
)
@@ -451,6 +495,7 @@ elseif(BSD)
list(APPEND LIBFASTFETCH_SRC
src/common/dbus.c
src/common/io/io_unix.c
src/common/netif/netif_bsd.c
src/common/networking_linux.c
src/common/processing_linux.c
src/common/sysctl.c
@@ -464,25 +509,31 @@ elseif(BSD)
src/detection/cpuusage/cpuusage_bsd.c
src/detection/cursor/cursor_linux.c
src/detection/disk/disk_bsd.c
src/detection/physicaldisk/physicaldisk_bsd.c
src/detection/diskio/diskio_bsd.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/drm.c
src/detection/displayserver/linux/wayland.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/font/font_linux.c
src/detection/gpu/gpu_linux.c
src/detection/gpu/gpu_nvidia.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_bsd.c
src/detection/lm/lm_linux.c
src/detection/icons/icons_linux.c
src/detection/libc/libc_bsd.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_bsd.c
src/detection/media/media_linux.c
src/detection/memory/memory_bsd.c
src/detection/monitor/monitor_nosupport.c
src/detection/netio/netio_bsd.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
src/detection/packages/packages_linux.c
src/detection/packages/packages_bsd.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_bsd.c
src/detection/gtk_qt/qt.c
@@ -497,37 +548,43 @@ elseif(BSD)
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_bsd.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/util/platform/FFPlatform_unix.c
)
elseif(APPLE)
list(APPEND LIBFASTFETCH_SRC
src/common/io/io_unix.c
src/common/netif/netif_bsd.c
src/common/networking_linux.c
src/common/processing_linux.c
src/common/sysctl.c
src/detection/battery/battery_apple.c
src/detection/bios/bios_apple.c
src/detection/bluetooth/bluetooth_apple.m
src/detection/board/board_nosupport.c
src/detection/board/board_apple.c
src/detection/brightness/brightness_apple.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_apple.c
src/detection/cpuusage/cpuusage_apple.c
src/detection/cursor/cursor_apple.m
src/detection/disk/disk_apple.m
src/detection/disk/disk_bsd.c
src/detection/physicaldisk/physicaldisk_apple.c
src/detection/diskio/diskio_apple.c
src/detection/displayserver/displayserver_apple.c
src/detection/font/font_apple.m
src/detection/gpu/gpu_apple.c
src/detection/host/host_apple.c
src/detection/lm/lm_nosupport.c
src/detection/icons/icons_nosupport.c
src/detection/libc/libc_apple.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_apple.c
src/detection/media/media_apple.m
src/detection/memory/memory_apple.c
src/detection/monitor/monitor_apple.m
src/detection/netio/netio_bsd.c
src/detection/opengl/opengl_apple.c
src/detection/os/os_apple.m
src/detection/packages/packages_apple.c
@@ -544,6 +601,8 @@ elseif(APPLE)
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_apple.c
src/detection/wifi/wifi_apple.m
src/detection/wm/wm_apple.c
src/detection/de/de_nosupport.c
src/detection/wmtheme/wmtheme_apple.m
src/util/apple/cf_helpers.c
src/util/apple/osascript.m
@@ -552,6 +611,7 @@ elseif(APPLE)
elseif(WIN32)
list(APPEND LIBFASTFETCH_SRC
src/common/io/io_windows.c
src/common/netif/netif_windows.c
src/common/networking_windows.c
src/common/processing_windows.c
src/detection/battery/battery_windows.c
@@ -564,17 +624,22 @@ elseif(WIN32)
src/detection/cpuusage/cpuusage_windows.c
src/detection/cursor/cursor_windows.c
src/detection/disk/disk_windows.c
src/detection/physicaldisk/physicaldisk_windows.c
src/detection/diskio/diskio_windows.c
src/detection/displayserver/displayserver_windows.c
src/detection/font/font_windows.c
src/detection/gpu/gpu_windows.c
src/detection/gpu/gpu_nvidia.c
src/detection/host/host_windows.c
src/detection/icons/icons_windows.c
src/detection/libc/libc_windows.cpp
src/detection/lm/lm_nosupport.c
src/detection/localip/localip_windows.c
src/detection/gamepad/gamepad_windows.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_windows.c
src/detection/monitor/monitor_windows.c
src/detection/netio/netio_windows.c
src/detection/opengl/opengl_windows.c
src/detection/os/os_windows.cpp
src/detection/packages/packages_windows.c
@@ -591,6 +656,8 @@ elseif(WIN32)
src/detection/users/users_windows.c
src/detection/wallpaper/wallpaper_windows.c
src/detection/wifi/wifi_windows.c
src/detection/wm/wm_windows.cpp
src/detection/de/de_nosupport.c
src/detection/wmtheme/wmtheme_windows.c
src/util/windows/getline.c
src/util/windows/com.cpp
@@ -601,6 +668,11 @@ elseif(WIN32)
)
endif()
if(ENABLE_DIRECTX_HEADERS)
message(STATUS "Enabling DirectX headers for WSL")
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_wsl.cpp)
endif()
include(CheckFunctionExists)
check_function_exists(wcwidth HAVE_WCWIDTH)
if(NOT HAVE_WCWIDTH)
@@ -623,14 +695,39 @@ endif()
add_library(libfastfetch OBJECT
${LIBFASTFETCH_SRC}
)
if(yyjson_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_USE_SYSTEM_YYJSON)
target_link_libraries(libfastfetch PRIVATE yyjson)
endif()
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE)
if(LINUX AND EXISTS "/lib/ld-musl-${CMAKE_HOST_SYSTEM_PROCESSOR}.so.1")
execute_process(COMMAND "/lib/ld-musl-${CMAKE_HOST_SYSTEM_PROCESSOR}.so.1"
ERROR_VARIABLE LD_MUSL_RESULT)
if("${LD_MUSL_RESULT}" MATCHES "Version ([0-9]+\\.[0-9]+\\.[0-9]+)")
target_compile_definitions(libfastfetch PUBLIC FF_MUSL_VERSION="${CMAKE_MATCH_1}")
endif()
endif()
if(APPLE AND EXISTS "/usr/bin/otool")
execute_process(COMMAND /usr/bin/otool -L /usr/bin/otool
OUTPUT_VARIABLE OTOOL_OTOOL_RESULT)
if("${OTOOL_OTOOL_RESULT}" MATCHES "libSystem\\.B\\.dylib \\(.*current version ([0-9]+\\.[0-9]+\\.[0-9]+)\\)")
target_compile_definitions(libfastfetch PUBLIC FF_LIBSYSTEM_VERSION="${CMAKE_MATCH_1}")
endif()
endif()
if(BSD AND EXISTS "/usr/local/bin/objdump")
execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'FBSD_[^ )]*' -o | sort -Vru | head -1"
OUTPUT_VARIABLE OBJDUMP_T_RESULT)
if("${OBJDUMP_T_RESULT}" MATCHES "FBSD_([0-9]+\\.[0-9]+)")
target_compile_definitions(libfastfetch PUBLIC FF_FBSD_VERSION="${CMAKE_MATCH_1}")
endif()
endif()
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1)
if(WIN32)
target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1)
elseif(APPLE)
target_compile_definitions(libfastfetch PUBLIC _DARWIN_C_SOURCE)
endif()
if(HAVE_WCWIDTH)
@@ -701,6 +798,10 @@ ff_lib_enable(X11
"x11"
"X11"
)
ff_lib_enable(DRM
"libdrm"
"Libdrm"
)
ff_lib_enable(GIO
"gio-2.0"
"GIO"
@@ -773,6 +874,10 @@ ff_lib_enable(DDCUTIL
"ddcutil"
"Ddcutil"
)
ff_lib_enable(DIRECTX_HEADERS
"DirectX-Headers"
"DirectX-Headers"
)
if(ENABLE_THREADS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS)
@@ -802,31 +907,32 @@ elseif(APPLE)
PRIVATE "-framework OpenCL"
PRIVATE "-framework SystemConfiguration"
PRIVATE "-weak_framework CoreDisplay"
PRIVATE "-weak_framework DisplayServices -F /System/Library/PrivateFrameworks"
PRIVATE "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks"
PRIVATE "-F /System/Library/PrivateFrameworks"
PRIVATE "-weak_framework DisplayServices"
PRIVATE "-weak_framework MediaRemote"
PRIVATE "-weak_framework Apple80211"
)
elseif(WIN32)
target_compile_definitions(libfastfetch PRIVATE -D_WIN32_WINNT=0x0601)
target_link_libraries(libfastfetch
PRIVATE "bthprops"
PRIVATE "dwmapi"
PRIVATE "gdi32"
PRIVATE "iphlpapi"
PRIVATE "ole32"
PRIVATE "oleaut32"
PRIVATE "opengl32"
PRIVATE "ws2_32"
PRIVATE "ntdll"
PRIVATE "version"
PRIVATE "setupapi"
PRIVATE "hid"
PRIVATE "wtsapi32"
PRIVATE "dxva2"
)
elseif(BSD)
target_link_libraries(libfastfetch
PRIVATE "m"
PRIVATE "usbhid"
PRIVATE "geom"
)
elseif(ANDROID)
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
@@ -877,6 +983,12 @@ target_link_libraries(flashfetch
PRIVATE libfastfetch
)
# Prevent fastfetch from linking to libstdc++
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
set_target_properties(fastfetch PROPERTIES LINKER_LANGUAGE C)
set_target_properties(flashfetch PROPERTIES LINKER_LANGUAGE C)
if(WIN32)
set(TARGET_NAME fastfetch)
target_sources(fastfetch
@@ -887,6 +999,13 @@ if(WIN32)
target_sources(flashfetch
PRIVATE src/util/windows/version.rc
)
elseif(APPLE)
target_link_options(fastfetch
PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,Info.plist
)
target_link_options(flashfetch
PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,Info.plist
)
endif()
###################
@@ -930,6 +1049,12 @@ install(
RENAME "${CMAKE_PROJECT_NAME}"
)
install(
FILES "${CMAKE_SOURCE_DIR}/completions/fish"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d"
RENAME "${CMAKE_PROJECT_NAME}.fish"
)
install(
DIRECTORY "${CMAKE_SOURCE_DIR}/presets"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}"
@@ -940,6 +1065,11 @@ install(
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}"
)
install(
FILES "${PROJECT_BINARY_DIR}/fastfetch.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
)
##################
# package target #
##################
+1 -1
View File
@@ -16,7 +16,7 @@ Here i just add things that are easy to forget.
- [ ] ZSH completions
- [ ] Fish completions
- [ ] Make CPU usage detection much faster and more accurate
- [ ] Detect CPU usage in a common detection methode and expose it both to the cpuUsage module and the cpu format string
- [ ] Detect CPU usage in a common detection method and expose it both to the cpuUsage module and the cpu format string
- [ ] Per session caching
### General
+46 -125
View File
@@ -1,13 +1,13 @@
# Fastfetch
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/fastfetch-cli/fastfetch/ci.yml)
![GitHub license](https://img.shields.io/github/license/fastfetch-cli/fastfetch)
![GitHub contributors](https://img.shields.io/github/contributors/fastfetch-cli/fastfetch)
![GitHub top language](https://img.shields.io/github/languages/top/fastfetch-cli/fastfetch?logo=c&label=)
![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/fastfetch-cli/fastfetch)
![homebrew downloads](https://img.shields.io/homebrew/installs/dm/fastfetch?logo=homebrew)
![GitHub all releases](https://img.shields.io/github/downloads/fastfetch-cli/fastfetch/total?logo=github)
![GitHub release (with filter)](https://img.shields.io/github/v/release/fastfetch-cli/fastfetch?logo=github)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/fastfetch-cli/fastfetch/ci.yml)](https://github.com/fastfetch-cli/fastfetch/actions)
[![GitHub license](https://img.shields.io/github/license/fastfetch-cli/fastfetch)](https://github.com/fastfetch-cli/fastfetch/blob/dev/LICENSE)
[![GitHub contributors](https://img.shields.io/github/contributors/fastfetch-cli/fastfetch)](https://github.com/fastfetch-cli/fastfetch/graphs/contributors)
[![GitHub top language](https://img.shields.io/github/languages/top/fastfetch-cli/fastfetch?logo=c&label=)](https://github.com/fastfetch-cli/fastfetch/blob/dev/CMakeLists.txt#L5)
[![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/fastfetch-cli/fastfetch)](https://github.com/fastfetch-cli/fastfetch/commits)
[![homebrew downloads](https://img.shields.io/homebrew/installs/dm/fastfetch?logo=homebrew)](https://formulae.brew.sh/formula/fastfetch#default)
[![GitHub all releases](https://img.shields.io/github/downloads/fastfetch-cli/fastfetch/total?logo=github)](https://github.com/fastfetch-cli/fastfetch/releases)
[![GitHub release (with filter)](https://img.shields.io/github/v/release/fastfetch-cli/fastfetch?logo=github)](https://github.com/fastfetch-cli/fastfetch/releases)
[![latest packaged version(s)](https://repology.org/badge/latest-versions/fastfetch.svg)](https://repology.org/project/fastfetch/versions)
[![Packaging status](https://repology.org/badge/tiny-repos/fastfetch.svg)](https://repology.org/project/fastfetch/versions)
@@ -23,144 +23,53 @@ Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for
There are [screenshots on different platforms](https://github.com/fastfetch-cli/fastfetch/wiki)
## Customization
## Installation
With customization and speed being two competing goals, this project actually builds two executables:
### Linux
* The main one is `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent by modifying `$XDG_CONFIG_HOME/fastfetch/config.conf`. Use `fastfetch --gen-config conf` to generate one. To view the available options, run `fastfetch --help`.
* The second executable is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c).
* Debian / Ubuntu: Download `fastfetch-<version>-Linux.deb` from [Github release page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and `sudo apt install fastfetch-<version>-Linux.deb`
* Arch Linux: `sudo pacman -S fastfetch`
* Fedora: `sudo dnf install fastfetch`
* Gentoo: `sudo emerge --ask app-misc/fastfetch`
Currently, the performance difference is measurable, but too small to be recognizable by humans. But with more options planned, the leap will get bigger over time and on slow machines this might actually make a difference.
There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config <filename>`. They may also serve as a good example for format arguments.
Logos can be heavily customized too; see the [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for more information.
### Customization with new JSONC format
A new, structure based, and user-friendly config file format was introduced in v2.0.0. This format is based on [JSONC](https://jsonc.org/). [See more details in Wiki](https://github.com/fastfetch-cli/fastfetch/wiki/Configuration)
## Dependencies
Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl`, `libm` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most Linux distributions.
The following libraries are used if present at runtime:
### Linux and FreeBSD
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
* [`libvulkan`](https://www.vulkan.org/): Vulkan module & fallback for GPU output.
* [`libxcb-randr`](https://xcb.freedesktop.org/),
[`libXrandr`](https://gitlab.freedesktop.org/xorg/lib/libxrandr),
[`libxcb`](https://xcb.freedesktop.org/),
[`libX11`](https://gitlab.freedesktop.org/xorg/lib/libx11): At least one of them sould be present in X11 sessions for better display detection and faster WM detection. The `*randr` ones provide multi monitor support The `libxcb*` ones usually have better performance.
* [`libwayland-client`](https://wayland.freedesktop.org/): Better display performance and output in wayland sessions. Supports different refresh rates per monitor.
* [`libGIO`](https://developer.gnome.org/gio/unstable/): Needed for values that are only stored GSettings.
* [`libDConf`](https://developer.gnome.org/dconf/unstable/): Needed for values that are only stored in DConf + Fallback for GSettings.
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel or kitty graphics protocol.
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art.
* [`libZ`](https://www.zlib.net/): Faster image output when using kitty graphics protocol.
* [`libDBus`](https://www.freedesktop.org/wiki/Software/dbus): Bluetooth, Player & Media detection.
* [`libEGL`](https://www.khronos.org/registry/EGL/),
[`libGLX`](https://dri.freedesktop.org/wiki/GLX/),
[`libOSMesa`](https://docs.mesa3d.org/osmesa.html): At least one of them is needed by the OpenGL module for gl context creation.
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count.
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
* [`libnm`](https://networkmanager.dev/docs/libnm/latest/): Used for Wifi detection.
* [`libpulse`](https://freedesktop.org/software/pulseaudio/doxygen/): Used for Sound detection.
* [`libddcutil`](https://github.com/rockowitz/ddcutil): Used for brightness detection of external displays
[See also if fastfetch has been packaged for your favorite Linux distro](#Packaging)
### macOS
* [`MediaRemote`](https://iphonedev.wiki/index.php/MediaRemote.framework): Need for Media detection. It's a private framework provided by newer macOS system.
* [`DisplayServices`](https://developer.apple.com/forums/thread/666383#663154022): Need for screen brightness detection. It's a private framework provided by newer macOS system.
* [`MoltenVK`](https://github.com/KhronosGroup/MoltenVK): Vulkan driver for macOS. [`molten-vk`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/molten-vk.rb)
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel graphics protocol. [`imagemagick`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/imagemagick.rb)
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art. [`chafa`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/chafa.rb)
* [`libsqlite3`](https://www.sqlite.org/index.html): Used for fast wallpaper detection ( fallback to AppleScript )
For the image logo, iTerm with iterm image protocol should work. Apple Terminal is not supported.
`brew install fastfetch`
### Windows
* [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection.
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers)
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd)
`scoop install fastfetch`
Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, as fastfetch for Windows targets [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library, [it must be installed manually](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) as UCRT is only pre-installed in Windows 10 and later.
You may also download it directly from [GitHub releases page](https://github.com/fastfetch-cli/fastfetch/releases/latest) and extract the archive.
For the image logo, only chafa is supported due to [a design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not included by default due to the massive dependencies of imagemagick. You must built it yourself.
### FreeBSD
### Android
`pkg install fastfetch`
* [`freetype`](https://www.freetype.org/): Used for Termux font detection. [`freetype`](https://github.com/termux/termux-packages/tree/master/packages/freetype)
* [`libvulkan`](https://www.vulkan.org/): Vulkan module, also used for GPU detection. Usually has been provided by Android system. [`vulkan-loader-android`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-loader-android) [`vulkan-headers`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-headers)
* [`termux-api`](https://github.com/termux/termux-api-package): Used for Wifi / Battery detection. Read [the official doc](https://wiki.termux.com/wiki/Termux:API) for detail or if you hang on these modules (IMPORTANT). [`termux-api`](https://github.com/termux/termux-packages/tree/master/packages/termux-api)
* [`libandroid-wordexp-static`](https://github.com/termux/termux-packages/tree/master/packages/libandroid-wordexp): `wordexp.h` support for Android.
### Android (Termux)
## Support status
All categories not listed here should work without needing a specific implementation.
`pkg install fastfetch`
##### Available Modules
```
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, LM, Locale, LocalIP, Media, Memory, Monitor, OpenCL, OpenGL, OS, Packages, Player, Power Adapter, Processes, PublicIP, Separator, Shell, Sound, Swap, Terminal, Terminal Font, Terminal Size, Theme, Time, Title, Uptime, Version, Vulkan, Wallpaper, Weather, Wifi, WM, WMTheme
```
## Build from source
##### Builtin logos
See Wiki: https://github.com/fastfetch-cli/fastfetch/wiki/Building
<!-- `Content of src/logo/builtin.c`.split('\n').map(x => x.trim()).filter(x => x.startsWith('// ')).map(x => x.slice(3)).filter(x => x != 'LAST').sort((a, b)=>a.toUpperCase().localeCompare(b.toUpperCase())).join(', ') -->
```
AerOS, AIX, AlmaLinux, Alpine, Alpine2Small, AlpineSmall, Alter, Amazon, AmogOS, Anarchy, Android, AndroidSmall, Antergos, Antix, AoscOS, AoscOsRetro, AoscOsRetro_small, Aperture, Apple, AppleSmall, Apricity, Arch, Arch2, ArchBox, Archcraft, Archcraft2, Archlabs, ArchSmall, ArchStrike, ArcoLinux, ArcoLinuxSmall, ArseLinux, Artix, Artix2Small, ArtixSmall, Arya, Asahi, Aster, AsteroidOS, AstOS, Astra, Ataraxia, Athena, Bedrock, BigLinux, Bitrig, BlackArch, BlackPanther, BLAG, BlankOn, BlueLight, Bodhi, Bonsai, BSD, BunsenLabs, CachyOS, CachyOSSmall, Calculate, CalinixOS, CalinixOSSmall, Carbs, CBL-Mariner, CelOS, Center, CentOS, CentOSSmall, Chakra, ChaletOS, Chapeau, ChonkySealOS, Chrom, Cleanjaro, CleanjaroSmall, ClearLinux, ClearOS, Clover, Cobalt, Condres, ContainerLinux, CRUX, CRUXSmall, CrystalLinux, Cucumber, CutefishOS, CuteOS, CyberOS, Dahlia, DarkOS, Debian, DebianSmall, Deepin, DesaOS, Devuan, DevuanSmall, DietPi, DracOS, DragonFly, DragonFlyOld, DragonFlySmall, Drauger, Droidian, Elementary, ElementarySmall, Elive, EncryptOS, Endeavour, Endless, Enso, EuroLinux, EvolutionOS, Exherbo, ExodiaPredator, Fedora, FedoraOld, FedoraSmall, FemboyOS, Feren, Finnix, Floflis, FreeBSD, FreeBSDSmall, FreeMiNT, Frugalware, Funtoo, GalliumOS, Garuda, GarudaDragon, GarudaSmall, Gentoo, GentooSmall, GhostBSD, Glaucus, GNewSense, Gnome, GNU, GoboLinux, GrapheneOS, Grombyang, Guix, GuixSmall, Haiku, HaikuSmall, HamoniKR, HarDClanZ, HardenedBSD, Hash, Huayra, Hybrid, HydroOS, Hyperbola, HyperbolaSmall, Iglunix, InstantOS, IRIX, Itc, Januslinux, Kaisen, Kali, KaliSmall, KaOS, KDENeon, Kibojoe, KISSLinux, Kogaion, Korora, KrassOS, KSLinux, Kubuntu, LangitKetujuh, Laxeros, LEDE, LibreELEC, Linspire, Linux, LinuxLight, LinuxLightSmall, LinuxMint, LinuxMintOld, LinuxMintSmall, LinuxSmall, Live_Raizo, LMDE, Lunar, MacOS, MacOS2, MacOS2Small, MacOSSmall, Mageia, MageiaSmall, MagpieOS, Mandriva, Manjaro, ManjaroSmall, MassOS, MatuusOS, MaUI, Meowix, Mer, Minix, Mint, MintOld, MintSmall, MiracleLinux, MOS, Msys2, MX, MXSmall, Namib, Nekos, Neptune, NetBSD, NetRunner, Nitrux, NixOS, NixOS_small, NixOsOld, NixOsSmall, Nobara, NomadBSD, Nurunner, NuTyX, Obarun, OBRevenge, OmniOS, OpenBSD, OpenBSDSmall, OpenEuler, OpenIndiana, OpenKylin, OpenMamba, OpenMandriva, OpenStage, OpenSuse, OpenSuseLeap, OpenSuseSmall, OpenSuseTumbleweed, OpenWrt, OPNsense, Oracle, Orchid, OrchidSmall, OS_Elbrus, OSMC, OSX, OSXSmall, PacBSD, Panwah, Parabola, ParabolaSmall, Parch, Pardus, Parrot, Parsix, PCBSD, PCLinuxOS, PearOS, Pengwin, Pentoo, Peppermint, PhyOS, Pisi, PNMLinux, Pop, PopSmall, Porteus, PostMarketOS, PostMarketOSSmall, Proxmox, PuffOS, Puppy, PureOS, PureOSSmall, Q4OS, Qubes, Qubyt, Quibian, Radix, Raspbian, RaspbianSmall, RavynOS, Reborn, RebornSmall, RedCore, RedHatEnterpriseLinux, RedHatEnterpriseLinux_old, RedstarOS, Refracted Devuan, Regata, Regolith, RhaymOS, RockyLinux, RockyLinuxSmall, RosaLinux, Sabayon, Sabotage, Sailfish, SalentOS, SalientOS, Salix, SambaBOX, Sasanqua, Scientific, Semc, Septor, Serene, SharkLinux, ShastraOS, Siduction, SkiffOS, Slackel, Slackware, SlackwareSmall, Slitaz, SmartOS, Soda, Solaris, SolarisSmall, Solus, SourceMage, Sparky, Star, SteamOS, StockLinux, Sulin, Suse, SuseSmall, Swagarch, T2, Tails, TeArch, TorizonCore, Trisquel, TuxedoOS, Twister, Ubuntu, Ubuntu2Old, Ubuntu2Small, UbuntuBudgie, UbuntuCinnamon, UbuntuGnome, UbuntuKde, UbuntuKylin, UbuntuMate, UbuntuOld, UbuntuSmall, UbuntuStudio, UbuntuSway, UbuntuTouch, UbuntuUnity, Ultramarine, Univalent, Univention, UOS, UrukOS, Uwuntu, Vanilla, Venom, Vnux, Void, VoidSmall, Vzlinux, WiiLinuxNgx, Windows, Windows11, Windows11Small, Windows8, Windows95, Xferience, YiffOS, Zorin
```
## Usage
Run `fastfetch --print-logos` to print them
* Run it with default configuration: `fastfetch`
* Run it with [all supported modules](https://github.com/fastfetch-cli/fastfetch/wiki/Support+Status#available-modules) and find what you interest: `fastfetch -c all.jsonc`
* Find all data that fastfetch detects: `fastfetch -s <module> --format json`
* Display help messages: `fastfetch --help`
* Generate config file based on command line arguments: `fastfetch --arg1 --arg2 --gen-config`
##### Package managers
```
apk, brew, Chocolatey, dpkg, emerge, eopkg, Flatpak, MacPorts, nix, Pacman, paludis, pkg, pkgtool, rpm, scoop, Snap, xbps
```
## Customization
##### WM themes
```
DWM (Windows), KWin, Marco, Muffin, Mutter, Openbox (LXDE, LXQT & without DE), Quartz Compositor (macOS), XFWM
```
Fastfetch uses the JSONC (or JSON with comments) for configuration. [See Wiki for detail](https://github.com/fastfetch-cli/fastfetch/wiki/Configuration). There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `-c <filename>`. They may also serve as a good example for format arguments.
##### DE versions
```
Budgie, Cinnamon, Gnome, KDE Plasma, LXQt, Mate, XFCE4
```
Logos can be heavily customized too; see the [logo documentation](https://github.com/fastfetch-cli/fastfetch/wiki/Logo-options) for more information.
##### Terminal fonts
```
Alacritty, Apple Terminal, ConEmu, Deepin Terminal, foot, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, MATE Terminal, mintty, QTerminal, Tabby, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal, Yakuake
```
## Building
fastfetch uses [`cmake`](https://cmake.org/) for building. [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) is recommended for better library detection. The simplest steps to build the fastfetch and flashfetch binaries are:
```bash
mkdir -p build
cd build
cmake ..
cmake --build . --target fastfetch --target flashfetch
```
If the build process fails to find the headers for a library listed in [dependencies](#dependencies), fastfetch will simply build without support for that specific feature. This means, it won't look for it at runtime and just act like it isn't available.
### Building on Windows
Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 subsystem (or CLANGARM64 if needed) is suggested (and tested) to build fastfetch. If you need Windows 7 / 8.x support, using MINGW64 is suggested.
1. Install [MSYS2](https://www.msys2.org/#installation)
1. Open `MSYS2 / CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime)
1. Install dependencies
```bash
pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
```
Follow the building instructions of Linux next.
## Packaging
@@ -176,7 +85,19 @@ Follow the building instructions of Linux next.
## FAQ
Q: Why do you need a very performant version of neofetch?
> I like putting neofetch in my ~/.bashrc to have a system overwiew whenever I use the terminal, but the slow speed annoyed me, so I created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
> I like putting neofetch in my ~/.bashrc to have a system overview whenever I use the terminal, but the slow speed annoyed me, so I created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
Q: It does not display [*] correctly for me, what can I do?
> This is most likely because your system is not implemented (yet). At the moment I am focusing more on making the core app better, than adding more configurations. Feel free to open a pull request if you want to add support for your configuration
## Star History
Give it a star to support us!
<a href="https://star-history.com/#fastfetch-cli/fastfetch&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=fastfetch-cli/fastfetch&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=fastfetch-cli/fastfetch&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=fastfetch-cli/fastfetch&type=Date" />
</picture>
</a>
+6 -7
View File
@@ -5,7 +5,7 @@ __fastfetch_complete_help()
local __ff_helps=(
"color"
"format"
"load-config"
"config"
"os-format"
"host-format"
"kernel-format"
@@ -24,7 +24,7 @@ __fastfetch_complete_help()
"terminal-format"
"terminalfont-format"
"cpu-format"
"cpu-usage-format"
"cpuusage-format"
"gpu-format"
"memory-format"
"swap-format"
@@ -66,7 +66,7 @@ __fastfetch_complete_path()
__fastfetch_complete_logo()
{
COMPREPLY=($(compgen -W "$(fastfetch --list-logos-autocompletion)" -- "$CURRENT_WORD"))
COMPREPLY=($(compgen -W "$(fastfetch --list-logos autocompletion)" -- "$CURRENT_WORD"))
}
__fastfetch_complete_logo_type()
@@ -182,7 +182,6 @@ __fastfetch_completion()
"--cpu-temp"
"--gpu-temp"
"--battery-temp"
"--display-detect-name"
"--display-precise-refresh-rate"
"--localip-show-ipv4"
"--localip-show-ipv6"
@@ -218,10 +217,9 @@ __fastfetch_completion()
"--logo-color-6"
"--logo-color-7"
"--logo-color-8"
"--logo-color-9"
"--logo-width"
"--logo-height"
"--logo-color-9"
"-c"
"--color"
"--color-keys"
"--color-title"
@@ -360,7 +358,8 @@ __fastfetch_completion()
)
local FF_OPTIONS_PATH=(
"--load-config"
"-c"
"--config"
"--os-file"
"--lib-pci"
"--lib-vulkan"
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env fish
if not type -q fastfetch
return
end
complete -c fastfetch -f
function __fastfetch_complete_bool
echo -e "true\tBool"
echo -e "false\tBool"
end
function __fastfetch_complete_color
echo -e "black\tColor"
echo -e "red\tColor"
echo -e "green\tColor"
echo -e "yellow\tColor"
echo -e "blue\tColor"
echo -e "magenta\tColor"
echo -e "cyan\tColor"
echo -e "white\tColor"
echo -e "default\tColor"
end
function __fastfetch_complete_command
for line in (fastfetch --list-modules autocompletion)
set -l pair (string split -m 2 : $line)
set -l module (string lower $pair[1])
echo -e "$module-format\tModule format"
end
echo -e "format\tCustom format"
echo -e "color\tColor format"
end
function __fastfetch_complete_config
for line in (fastfetch --list-presets autocompletion)
echo -e "$line\tPreset"
end
echo -e "none\tDisable loading config file"
end
function __fastfetch_complete_logo
for line in (fastfetch --list-logos autocompletion)
echo -e "$line\tBuiltin logo"
end
echo -e "none\tDon't print logo"
echo -e "small\tPrint small ascii logo if available"
end
function __fastfetch_complete_structure
for line in (fastfetch --list-modules autocompletion)
set -l pair (string split -m 2 : $line)
echo -e "$pair[1]\t$pair[2]"
end
end
string match -r -a -g "^###> ?(.*)" < (status -f) | string collect | python3 | source
###> #!/usr/bin/env python3
###>
###> import json, subprocess, sys
###>
###> def main():
###> data: dict[str, list[dict]] = json.loads(subprocess.check_output(['fastfetch', '--help-raw']))
###>
###> for key in data:
###> for flag in data[key]:
###> if flag.get('pseudo', False):
###> continue
###>
###> command_prefix: str = f'complete -c fastfetch -d "{flag["desc"]}" -l "{flag["long"]}"';
###> if 'short' in flag:
###> command_prefix += f' -o "{flag["short"]}"'
###>
###> if 'arg' in flag:
###> type: str = flag['arg']['type'];
###> if type == 'bool':
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_bool)"')
###> elif type == 'color':
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_color)"')
###> elif type == 'command':
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_command)"')
###> elif type == 'config':
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_config)"')
###> elif type == 'enum':
###> temp: str = ' '.join(map(lambda x: f"{x[0]}\\t{x[1]}", flag["arg"]["enum"].items()))
###> print(f'{command_prefix} -x -a "{temp}"')
###> elif type == 'logo':
###> print(f'{command_prefix} -x -a "(__fastfetch_complete_logo)"')
###> elif type == 'structure':
###> print(f'{command_prefix} -x -a "(__fish_complete_list : __fastfetch_complete_structure)"')
###> elif type == 'path':
###> print(f'{command_prefix} -r -F')
###> else:
###> print(f'{command_prefix} -x')
###> else:
###> print(f'{command_prefix} -f')
###>
###> if __name__ == "__main__":
###> try:
###> main()
###> except:
###> sys.exit(1)
###>
+134
View File
@@ -0,0 +1,134 @@
.TH FASTFETCH 1 "@FASTFETCH_BUILD_DATE@" "@CMAKE_PROJECT_NAME@ @CMAKE_PROJECT_VERSION@"
.SH NAME
fastfetch \- a neofetch\-like tool for fetching system information and
displaying them in a pretty way
.SH SYNOPSIS
.B fastfetch
.I [options...]
.SH DESCRIPTION
Fastfetch is a neofetch\-like tool for fetching system information and
displaying them in a pretty way. It is written mainly in C, with performance
and customizability in mind.
Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported.
.SH "EXIT STATUS"
On successful execution, fastfetch returns zero. If any error happened,
the exit code will be non\-zero.
.SH OPTIONS
.SS "Informative Options"
.TP
.B \-h, \-\-help \fI [command]
Show help output, displaying all available options or help for given command
.TP
.B \-v, \-\-version
Show version of fastfetch
.TP
.B \-\-list\-config\-paths
List search paths of config files
.TP
.B \-\-list\-data\-paths
List search paths of presets and logos
.TP
.B \-\-list\-logos
List available logos, they can be loaded with \fI \-\-logo
.TP
.B \-\-list\-modules
List available modules
.TP
.B \-\-list\-presets
List available presets, they can be loaded with \fI \-\-config
.TP
.B \-\-list\-features
List the supported features fastfetch was compiled with
.TP
.B \-\-print\-logos
Print available logos
.TP
.B \-\-print\-structure
Print the default structure
.SS "Display Options"
.TP
.B \-l, \-\-logo \fI <logo>
Set the logo to display
.TP
.B \-s, \-\-structure \fI <structure>
Set the structure of the fetch. For details about the structure,
see the CONFIGURATION section.
.SS "Config Options"
.TP
.B \-c, \-\-config \fI <config>
Use the specified config file or preset. If "none", disable further config
loading. For details about config files, see the CONFIGURATION section
.TP
.B \-\-gen\-config \fI [file]
Generate a config file with options specified on the command line.
If \fI file \fR is specified, the configuration will written to the
file, otherwise it will be written to stdout.
.TP
.B \-\-gen\-config\-force \fI [file]
Same as \fB \-\-gen\-config\fR, but overwrites existing config
.TP
To list all options, use \fB \-\-help\fR this will also print all available module options.
.SH CONFIGURATION
.SS "Fetch Structure"
The structure of a fetch describes the modules that should be included in
the output. It consists of a string of modules, separated by a colon (:).
To list all available modules, use \fB \-\-list\-modules \fR
.SS "Config Files"
fastfetch supports two types of config files. The legacy
configuration files and a JSONC based format.
A JSONC config file is a JSON file that also supports comments with (//). Those
files must have the extension '.jsonc'. You can migrate a legacy config
file to the JSONC format by using \fB\-\-gen\-config\fR.
The specified configuration/preset files are searched in the following order:
1. relative to the current working directory
2. relative to ~/.local/share/fastfetch/presets/
3. relative to /usr/share/fastfetch/presets/
When both a '.jsonc' and a '.conf' file with the same name is found,
the '.jsonc' file is preferred.
Fastfetch provides some default presets. List them with \fB \-\-print\-available\-presets\fR.
.SH "SEE ALSO"
.BR neofetch (1)
.SH BUGS
Please report bugs to:\fI https://github.com/fastfetch\-cli/fastfetch/issues \fR
+621 -224
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1 +0,0 @@
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:Monitor:LM:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:TerminalSize:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Version:Break:Colors
+3
View File
@@ -51,6 +51,9 @@
"sound",
"gamepad",
"weather",
"netio",
"diskio",
"physicaldisk",
"version",
"break",
"colors"
-3
View File
@@ -1,3 +0,0 @@
--logo arch
--os-format "Arch Linux ({12})"
--packages-format "{} (pacman)"
+70
View File
@@ -0,0 +1,70 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"display": {
"stat": true,
"pipe": true,
"showErrors": true,
"noBuffer": true
},
"modules": [
"title",
"separator",
"os",
"host",
"bios",
"board",
"chassis",
"kernel",
"uptime",
"processes",
"packages",
"shell",
"display",
"brightness",
"monitor",
"lm",
"de",
"wm",
"wmtheme",
"theme",
"icons",
"font",
"cursor",
"wallpaper",
"terminal",
"terminalfont",
"terminalsize",
"cpu",
"cpuusage",
"gpu",
"memory",
"swap",
"disk",
"battery",
"poweradapter",
"player",
"media",
"publicip",
"localip",
"wifi",
"datetime",
"locale",
"vulkan",
"opengl",
"opencl",
"users",
"bluetooth",
"sound",
"gamepad",
{
"type": "weather",
"timeout": 1000
},
"netio",
"diskio",
"physicaldisk",
"version",
"break",
"colors"
]
}
-3
View File
@@ -1,3 +0,0 @@
--disable-linewrap false
--multithreading false
--show-errors
-3
View File
@@ -1,3 +0,0 @@
--load-config devinfo
--load-config all
--load-config verbose
-49
View File
@@ -1,49 +0,0 @@
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "builtin",
"source": "arch"
},
"display": {
"disableLinewrap": false,
"showErrors": true
},
"general": {
"multithreading": false
},
"modules": [
"title",
"separator",
{
"type": "os",
"format": "Arch Linux ({12})"
},
"host",
"kernel",
"uptime",
{
"type": "packages",
"format": "{} (pacman)"
},
"shell",
"display",
"de",
"wm",
"wmtheme",
"theme",
"icons",
"font",
"cursor",
"terminal",
"terminalfont",
"cpu",
"gpu",
"memory",
"disk",
"battery",
"poweradapter",
"locale",
"break",
"colors"
]
}
-1
View File
@@ -1 +0,0 @@
# Load with --load-config examples/1
+150
View File
@@ -0,0 +1,150 @@
// Load with --load-config examples/2.jsonc
// Note that you must replace the image path to an existing image to display it.
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"padding": {
"top": 2
}
},
"display": {
"separator": " -> "
},
"modules": [
{
"type": "custom",
"format": "\u001b[90m┌────────────────────────────────────────────────────────────┐"
},
{
"type": "title",
"keyWidth": 10
},
{
"type": "custom",
"format": "\u001b[90m└────────────────────────────────────────────────────────────┘"
},
{
"type": "custom",
"format": " \u001b[90m \u001b[31m \u001b[32m \u001b[33m \u001b[34m \u001b[35m \u001b[36m \u001b[37m \u001b[38m \u001b[39m  \u001b[38m \u001b[37m \u001b[36m \u001b[35m \u001b[34m \u001b[33m \u001b[32m \u001b[31m \u001b[90m"
},
{
"type": "custom",
"format": "\u001b[90m┌────────────────────────────────────────────────────────────┐"
},
{
"type": "os",
"key": " OS",
"keyColor": "yellow"
},
{
"type": "kernel",
"key": "│ ├",
"keyColor": "yellow"
},
{
"type": "packages",
"key": "│ ├󰏖",
"keyColor": "yellow"
},
{
"type": "shell",
"key": "│ └",
"keyColor": "yellow"
},
{
"type": "wm",
"key": " DE/WM",
"keyColor": "blue"
},
{
"type": "lm",
"key": "│ ├󰧨",
"keyColor": "blue"
},
{
"type": "wmtheme",
"key": "│ ├󰉼",
"keyColor": "blue"
},
{
"type": "icons",
"key": "│ ├󰀻",
"keyColor": "blue"
},
{
"type": "terminal",
"key": "│ ├",
"keyColor": "blue"
},
{
"type": "wallpaper",
"key": "│ └󰸉",
"keyColor": "blue"
},
{
"type": "host",
"key": " PC",
"keyColor": "green"
},
{
"type": "cpu",
"key": "│ ├",
"keyColor": "green"
},
{
"type": "gpu",
"key": "│ ├﬙",
"keyColor": "green"
},
{
"type": "disk",
"key": "│ ├",
"keyColor": "green"
},
{
"type": "memory",
"key": "│ ├󰑭",
"keyColor": "green"
},
{
"type": "swap",
"key": "│ ├󰓡",
"keyColor": "green"
},
{
"type": "uptime",
"key": "│ ├󰅐",
"keyColor": "green"
},
{
"type": "display",
"key": "│ └󰍹",
"keyColor": "green"
},
{
"type": "sound",
"key": " SND",
"keyColor": "cyan"
},
{
"type": "player",
"key": "│ ├󰥠",
"keyColor": "cyan"
},
{
"type": "media",
"key": "│ └󰝚",
"keyColor": "cyan"
},
{
"type": "custom",
"format": "\u001b[90m└────────────────────────────────────────────────────────────┘"
},
"break",
{
"type": "custom",
"format": " \u001b[90m \u001b[31m \u001b[32m \u001b[33m \u001b[34m \u001b[35m \u001b[36m \u001b[37m \u001b[38m \u001b[39m  \u001b[38m \u001b[37m \u001b[36m \u001b[35m \u001b[34m \u001b[33m \u001b[32m \u001b[31m \u001b[90m"
}
]
}
+37
View File
@@ -0,0 +1,37 @@
{
"$schema": "file:///C:/msys64/home/zhang/fastfetch/doc/json_schema.json",
"logo": {
"type": "small"
},
"display": {
"separator": "\u001b[31m-> "
},
"modules": [
{
"key": "Distro ",
"type": "os"
},
{
"key": "Shell ",
"type": "shell"
},
{
"key": "Terminal ",
"type": "terminal"
},
{
"key": "Display ",
"type": "display"
},
{
"key": "Backlight ",
"type": "brightness"
},
"break",
{
"type": "colors",
"paddingLeft": 6,
"symbol": "circle"
}
]
}
-24
View File
@@ -1,24 +0,0 @@
# Load with --load-config examples/2
# Note that you must replace the image path to an existing image to display it.
--kitty /home/linus/Bilder/Gentoo.png
--logo-width 28
--separator "  "
--set-keyless HardwareStart=┌───────── \e[1mHardware Information\e[0m ─────────┐
--set-keyless SoftwareStart=├───────── \e[1mSoftware Information\e[0m ─────────┤
--set-keyless InformationEnd=└────────────────────────────────────────┘
--set-keyless Colors= \e[38m \e[37m \e[36m \e[35m \e[34m \e[33m \e[32m \e[31m
--structure HardwareStart:Host:CPU:GPU:SoftwareStart:OS:Kernel:WM:Shell:Terminal:TerminalFont:Packages:InformationEnd:Colors
--host-key " "
--cpu-key " "
--gpu-key " ﬙"
--os-key " "
--kernel-key " "
--wm-key " "
--shell-key " "
--terminal-key " "
--terminalfont-key " "
--packages-key " "
-7
View File
@@ -1,7 +0,0 @@
# Load with --load-config example/3
--logo debian_small
--structure Vulkan:OpenGL:OpenCL:Memory:Disk:LocalIP
--binary-prefix si
--localip-show-loop false
--disk-folders /:/home:/boot:/efi
-7
View File
@@ -1,7 +0,0 @@
# Load with --load-config examples/4
--color blue
--logo arch_small
--logo-padding-right 1
--separator "  "
--structure DateTime:Break:Player:Media
-11
View File
@@ -1,11 +0,0 @@
# Load with --load-config examples/5
--logo none
--color reset_magenta
--structure Theme:Icons:Font:Cursor
--theme-key T
--theme-format {7}
--icons-key I
--icons-format {5}
--font-key F
--cursor-key C
+4 -3
View File
@@ -8,9 +8,10 @@
"color": {
"keys": "magenta"
},
"sizeNdigits": 0,
"sizeMaxPrefix": "MB",
"percentType": 9
"size": {
"ndigits": 0,
"maxPrefix": "MB"
}
},
"modules": [
{
-1
View File
@@ -4,7 +4,6 @@
"type": "small"
},
"display": {
"percentType": 6,
"keyWidth": 11,
"bar": {
"charElapsed": "=",
-4
View File
@@ -1,4 +0,0 @@
--structure Host:Display:CPU:GPU:Memory:Disk:Battery
--memory-format "{?2}{2}{?}"
--disk-format "{?2}{2}{?}"
--battery-format "{?1}{1} {?}{?2}{2} {?}{?3}({3}){?}"
-9
View File
@@ -1,9 +0,0 @@
--structure "Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Terminal:TerminalFont:CPU:GPU:Memory:Break:Colors"
--host-format "{/2}{-}{/}{2}{?3} {3}{?}"
--os-format "{3} {12}"
--display-key Resolution
--display-compact-type original
--de-format "{2} {3}"
--theme-format "{?1}{1}{?3} {3}{?} [Plasma], {?}{7}"
--terminalfont-format "{/2}{-}{/}{2}{?3} {3}{?}"
--memory-format "{/1}{-}{/}{/2}{-}{/}{} / {}"
-5
View File
@@ -1,5 +0,0 @@
--structure Title:Separator:OS:Host:Kernel:Uptime:Battery:Break:Packages:Shell:Display:Terminal:Break:CPU:GPU:Memory:Break:Colors
--host-format "{/2}{-}{/}{2}{?3} {3}{?}"
--battery-format "{/4}{-}{/}{4}%{?5} [{5}]{?}"
--display-key "Display"
--gpu-key "GPU"
-1
View File
@@ -1 +0,0 @@
--structure OS:Kernel:Shell:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont
-31
View File
@@ -1,31 +0,0 @@
--os-format System: {}; Name: {}; Pretty name: {}; ID: {}; ID like: {}; Variant: {}; Variant ID: {}; Version: {}; Version ID: {}; Version codename: {}; Build ID: {}; Architecture: {}
--host-format Family: product_family: {}; product_name: {}; product_version: {}; product_sku: {}; sys_vendor: {}
--kernel-format Sysname: {}; Release: {}; Version: {}
--uptime-format Days: {}; Hours: {}; Minutes: {}; Seconds: {}
--processes-format Count: {}
--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak-system: {}; flatpak-user: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}; pkgtool: {}; paludis {}
--shell-format Process name: {}; Process path: {}; Process exe: {}; Process version: {}; User path: {}; User exe: {}; User version: {}
--display-format Width: {}; Height: {}; Refresh rate: {}; ScaledWith: {}; ScaledHeight: {}
--de-format Process name: {}; Pretty name: {}; Version: {}
--wm-format Process name: {}; Pretty name: {}; Protocol: {}
--wmtheme-format Name: {}
--theme-format Plasma: {}; Plasma colors: {}; Plasma colors pretty: {}; GTK2: {}; GTK3: {}; GTK4: {}; GTK: {}
--icons-format Plasma: {}; GTK2: {}; GTK3: {}; GTK4: {}; GTK: {}
--font-format Font1: {}; Font2: {}; Font3: {}; Font4: {}
--cursor-format Theme: {}; Size: {}
--terminal-format Process: {}; Path: {}; Exe: {}
--terminalfont-format Pretty: {}; Name: {}; Size: {}; Styles: {}
--cpu-format Name: {}, Vendor: {}, CoresPhysical: {}, CoresLogical: {}, CoresOnline: {}, FrequencyMin: {}, FrequencyMax: {}, Temperature: {}
--cpu-usage-format Percentage: {}
--gpu-format Vendor: {}; Name: {}; Driver: {}; Temperature: {}; CoreCount: {}; Type: {}
--memory-format Used: {}; Total: {}; Percentage: {}
--disk-format SizeUsed: {}; SizeTotal: {}; SizePercentage: {}; FilesUsed: {}; FilesTotal: {}; FilesPercentage: {}; External: {}; Hidden: {}; Filesystem: {}; Name: {}
--battery-format Manufactor: {}; Model: {}; Technology: {}; Capacity: {}; Status: {}
--poweradapter-format Watts: {}; Name: {}; Manufactor: {}; Model: {}; Description: {}
--player-format Pretty: {}; Name: {}; Bus: {}; Url: {}
--media-format Pretty: {}; Name: {}; Artist: {}; Album: {}
--datetime-format year: {}; yearShort: {}; month: {}; monthPretty: {}; monthName: {}; monthNameShort: {}; weekNumber: {}; weekday: {}; weekdayShort: {}; dayInYear: {}; dayInMonth: {}; dayInWeek: {}; hour: {}; hourPretty: {}; hour12: {}; hour12Pretty: {}; minute: {}; minutePretty: {}; second: {}; secondPretty: {}
--vulkan-format driver: {}; Api Version: {}; Conformance Version: {}
--opengl-format version: {}; renderer: {}; vendor: {}
--opencl-format version: {}; device: {}; vendor: {}
--bluetooth-format Name: {}; Address: {}; Type: {}; Battery: {}
+10359
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
{
"home": "https://github.com/NVIDIA/nvidia-settings/blob/main/src/nvml.h",
"license": "Embed in source",
"version": "545.23.06",
"author": "NVIDIA Corporation"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"home": "https://github.com/ibireme/yyjson",
"license": "MIT ( embed in source )",
"version": "5e3b26d2659287d31e2f8e10f95f95feb7e5ab3a",
"version": "0.8.0",
"author": "ibireme"
}
+217 -51
View File
@@ -307,6 +307,9 @@ uint32_t yyjson_version(void) {
#define YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE (0x10 * sizeof(yyjson_mut_val))
#define YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE (0x1000000 * sizeof(yyjson_mut_val))
/* The minimum size of the dynamic allocator's chunk. */
#define YYJSON_ALC_DYN_MIN_SIZE 0x1000
/* Default value for compile-time options. */
#ifndef YYJSON_DISABLE_READER
#define YYJSON_DISABLE_READER 0
@@ -966,6 +969,15 @@ static const yyjson_alc YYJSON_DEFAULT_ALC = {
NULL
};
/*==============================================================================
* Null Memory Allocator
*
* This allocator is just a placeholder to ensure that the internal
* malloc/realloc/free function pointers are not null.
*============================================================================*/
static void *null_malloc(void *ctx, usize size) {
return NULL;
}
@@ -989,29 +1001,37 @@ static const yyjson_alc YYJSON_NULL_ALC = {
/*==============================================================================
* Pool Memory Allocator
* This is a simple memory allocator that uses linked list memory chunk.
* The following code will be executed only when the library user creates
* this allocator manually.
*
* This allocator is initialized with a fixed-size buffer.
* The buffer is split into multiple memory chunks for memory allocation.
*============================================================================*/
/** chunk header */
/** memory chunk header */
typedef struct pool_chunk {
usize size; /* chunk memory size (include chunk header) */
struct pool_chunk *next;
usize size; /* chunk memory size, include chunk header */
struct pool_chunk *next; /* linked list, nullable */
/* char mem[]; flexible array member */
} pool_chunk;
/** ctx header */
/** allocator ctx header */
typedef struct pool_ctx {
usize size; /* total memory size (include ctx header) */
pool_chunk *free_list;
usize size; /* total memory size, include ctx header */
pool_chunk *free_list; /* linked list, nullable */
/* pool_chunk chunks[]; flexible array member */
} pool_ctx;
/** align up the input size to chunk size */
static_inline void pool_size_align(usize *size) {
*size = size_align_up(*size, sizeof(pool_chunk)) + sizeof(pool_chunk);
}
static void *pool_malloc(void *ctx_ptr, usize size) {
/* assert(size != 0) */
pool_ctx *ctx = (pool_ctx *)ctx_ptr;
pool_chunk *next, *prev = NULL, *cur = ctx->free_list;
if (unlikely(size == 0 || size >= ctx->size)) return NULL;
size = size_align_up(size, sizeof(pool_chunk)) + sizeof(pool_chunk);
if (unlikely(size >= ctx->size)) return NULL;
pool_size_align(&size);
while (cur) {
if (cur->size < size) {
@@ -1038,6 +1058,7 @@ static void *pool_malloc(void *ctx_ptr, usize size) {
}
static void pool_free(void *ctx_ptr, void *ptr) {
/* assert(ptr != NULL) */
pool_ctx *ctx = (pool_ctx *)ctx_ptr;
pool_chunk *cur = ((pool_chunk *)ptr) - 1;
pool_chunk *prev = NULL, *next = ctx->free_list;
@@ -1064,25 +1085,15 @@ static void pool_free(void *ctx_ptr, void *ptr) {
static void *pool_realloc(void *ctx_ptr, void *ptr,
usize old_size, usize size) {
/* assert(ptr != NULL && size != 0 && old_size < size) */
pool_ctx *ctx = (pool_ctx *)ctx_ptr;
pool_chunk *cur = ((pool_chunk *)ptr) - 1, *prev, *next, *tmp;
usize free_size;
void *new_ptr;
if (unlikely(size == 0 || size >= ctx->size)) return NULL;
size = size_align_up(size, sizeof(pool_chunk)) + sizeof(pool_chunk);
/* reduce size */
if (unlikely(size <= cur->size)) {
free_size = cur->size - size;
if (free_size >= sizeof(pool_chunk) * 2) {
tmp = (pool_chunk *)(void *)((u8 *)cur + cur->size - free_size);
tmp->size = free_size;
pool_free(ctx_ptr, (void *)(tmp + 1));
cur->size -= free_size;
}
return ptr;
}
/* check size */
if (unlikely(size >= ctx->size)) return NULL;
pool_size_align(&old_size);
pool_size_align(&size);
if (unlikely(old_size == size)) return ptr;
/* find next and prev chunk */
prev = NULL;
@@ -1092,10 +1103,9 @@ static void *pool_realloc(void *ctx_ptr, void *ptr,
next = next->next;
}
/* merge to higher chunk if they are contiguous */
if ((u8 *)cur + cur->size == (u8 *)next &&
cur->size + next->size >= size) {
free_size = cur->size + next->size - size;
if ((u8 *)cur + cur->size == (u8 *)next && cur->size + next->size >= size) {
/* merge to higher chunk if they are contiguous */
usize free_size = cur->size + next->size - size;
if (free_size > sizeof(pool_chunk) * 2) {
tmp = (pool_chunk *)(void *)((u8 *)cur + size);
if (prev) prev->next = tmp;
@@ -1109,15 +1119,15 @@ static void *pool_realloc(void *ctx_ptr, void *ptr,
cur->size += next->size;
}
return ptr;
} else {
/* fallback to malloc and memcpy */
void *new_ptr = pool_malloc(ctx_ptr, size - sizeof(pool_chunk));
if (new_ptr) {
memcpy(new_ptr, ptr, cur->size - sizeof(pool_chunk));
pool_free(ctx_ptr, ptr);
}
return new_ptr;
}
/* fallback to malloc and memcpy */
new_ptr = pool_malloc(ctx_ptr, size - sizeof(pool_chunk));
if (new_ptr) {
memcpy(new_ptr, ptr, cur->size - sizeof(pool_chunk));
pool_free(ctx_ptr, ptr);
}
return new_ptr;
}
bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size) {
@@ -1147,6 +1157,161 @@ bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size) {
/*==============================================================================
* Dynamic Memory Allocator
*
* This allocator allocates memory on demand and does not immediately release
* unused memory. Instead, it places the unused memory into a freelist for
* potential reuse in the future. It is only when the entire allocator is
* destroyed that all previously allocated memory is released at once.
*============================================================================*/
/** memory chunk header */
typedef struct dyn_chunk {
usize size; /* chunk size, include header */
struct dyn_chunk *next;
/* char mem[]; flexible array member */
} dyn_chunk;
/** allocator ctx header */
typedef struct {
dyn_chunk free_list; /* dummy header, sorted from small to large */
dyn_chunk used_list; /* dummy header */
} dyn_ctx;
/** align up the input size to chunk size */
static_inline bool dyn_size_align(usize *size) {
usize alc_size = *size + sizeof(dyn_chunk);
alc_size = size_align_up(alc_size, YYJSON_ALC_DYN_MIN_SIZE);
if (unlikely(alc_size < *size)) return false; /* overflow */
*size = alc_size;
return true;
}
/** remove a chunk from list (the chunk must already be in the list) */
static_inline void dyn_chunk_list_remove(dyn_chunk *list, dyn_chunk *chunk) {
dyn_chunk *prev = list, *cur;
for (cur = prev->next; cur; cur = cur->next) {
if (cur == chunk) {
prev->next = cur->next;
cur->next = NULL;
return;
}
prev = cur;
}
}
/** add a chunk to list header (the chunk must not be in the list) */
static_inline void dyn_chunk_list_add(dyn_chunk *list, dyn_chunk *chunk) {
chunk->next = list->next;
list->next = chunk;
}
static void *dyn_malloc(void *ctx_ptr, usize size) {
/* assert(size != 0) */
const yyjson_alc def = YYJSON_DEFAULT_ALC;
dyn_ctx *ctx = (dyn_ctx *)ctx_ptr;
dyn_chunk *chunk, *prev, *next;
if (unlikely(!dyn_size_align(&size))) return NULL;
/* freelist is empty, create new chunk */
if (!ctx->free_list.next) {
chunk = (dyn_chunk *)def.malloc(def.ctx, size);
if (unlikely(!chunk)) return NULL;
chunk->size = size;
chunk->next = NULL;
dyn_chunk_list_add(&ctx->used_list, chunk);
return (void *)(chunk + 1);
}
/* find a large enough chunk, or resize the largest chunk */
prev = &ctx->free_list;
while (true) {
chunk = prev->next;
if (chunk->size >= size) { /* enough size, reuse this chunk */
prev->next = chunk->next;
dyn_chunk_list_add(&ctx->used_list, chunk);
return (void *)(chunk + 1);
}
if (!chunk->next) { /* resize the largest chunk */
chunk = (dyn_chunk *)def.realloc(def.ctx, chunk, chunk->size, size);
if (unlikely(!chunk)) return NULL;
prev->next = NULL;
chunk->size = size;
dyn_chunk_list_add(&ctx->used_list, chunk);
return (void *)(chunk + 1);
}
prev = chunk;
}
}
static void *dyn_realloc(void *ctx_ptr, void *ptr,
usize old_size, usize size) {
/* assert(ptr != NULL && size != 0 && old_size < size) */
const yyjson_alc def = YYJSON_DEFAULT_ALC;
dyn_ctx *ctx = (dyn_ctx *)ctx_ptr;
dyn_chunk *prev, *next, *new_chunk;
dyn_chunk *chunk = (dyn_chunk *)ptr - 1;
if (unlikely(!dyn_size_align(&size))) return NULL;
if (chunk->size >= size) return ptr;
dyn_chunk_list_remove(&ctx->used_list, chunk);
new_chunk = (dyn_chunk *)def.realloc(def.ctx, chunk, chunk->size, size);
if (likely(new_chunk)) {
new_chunk->size = size;
chunk = new_chunk;
}
dyn_chunk_list_add(&ctx->used_list, chunk);
return new_chunk ? (void *)(new_chunk + 1) : NULL;
}
static void dyn_free(void *ctx_ptr, void *ptr) {
/* assert(ptr != NULL) */
dyn_ctx *ctx = (dyn_ctx *)ctx_ptr;
dyn_chunk *chunk = (dyn_chunk *)ptr - 1, *prev;
dyn_chunk_list_remove(&ctx->used_list, chunk);
for (prev = &ctx->free_list; prev; prev = prev->next) {
if (!prev->next || prev->next->size >= chunk->size) {
chunk->next = prev->next;
prev->next = chunk;
break;
}
}
}
yyjson_alc *yyjson_alc_dyn_new(void) {
const yyjson_alc def = YYJSON_DEFAULT_ALC;
usize hdr_len = sizeof(yyjson_alc) + sizeof(dyn_ctx);
yyjson_alc *alc = (yyjson_alc *)def.malloc(def.ctx, hdr_len);
dyn_ctx *ctx = (dyn_ctx *)(void *)(alc + 1);
if (unlikely(!alc)) return NULL;
alc->malloc = dyn_malloc;
alc->realloc = dyn_realloc;
alc->free = dyn_free;
alc->ctx = alc + 1;
memset(ctx, 0, sizeof(*ctx));
return alc;
}
void yyjson_alc_dyn_free(yyjson_alc *alc) {
const yyjson_alc def = YYJSON_DEFAULT_ALC;
dyn_ctx *ctx = (dyn_ctx *)(void *)(alc + 1);
dyn_chunk *chunk, *next;
if (unlikely(!alc)) return;
for (chunk = ctx->free_list.next; chunk; chunk = next) {
next = chunk->next;
def.free(def.ctx, chunk);
}
for (chunk = ctx->used_list.next; chunk; chunk = next) {
next = chunk->next;
def.free(def.ctx, chunk);
}
def.free(def.ctx, alc);
}
/*==============================================================================
* JSON document and value
*============================================================================*/
@@ -1305,7 +1470,6 @@ yyjson_mut_val *yyjson_val_mut_copy(yyjson_mut_doc *m_doc,
We copy them to another contiguous memory as mutable values,
then reconnect the mutable values with the original relationship.
*/
usize i_vals_len;
yyjson_mut_val *m_vals, *m_val;
yyjson_val *i_val, *i_end;
@@ -1375,7 +1539,6 @@ static yyjson_mut_val *unsafe_yyjson_mut_val_mut_copy(yyjson_mut_doc *m_doc,
second to last item, which needs to be linked to the last item to close the
circle.
*/
yyjson_mut_val *m_val = unsafe_yyjson_mut_val(m_doc, 1);
if (unlikely(!m_val)) return NULL;
m_val->tag = m_vals->tag;
@@ -1540,12 +1703,13 @@ static_inline bool unsafe_yyjson_num_equals(void *lhs, void *rhs) {
yyjson_val_uni *runi = &((yyjson_val *)rhs)->uni;
yyjson_subtype lt = unsafe_yyjson_get_subtype(lhs);
yyjson_subtype rt = unsafe_yyjson_get_subtype(rhs);
if (lt == rt)
return luni->u64 == runi->u64;
if (lt == YYJSON_SUBTYPE_SINT && rt == YYJSON_SUBTYPE_UINT)
if (lt == rt) return luni->u64 == runi->u64;
if (lt == YYJSON_SUBTYPE_SINT && rt == YYJSON_SUBTYPE_UINT) {
return luni->i64 >= 0 && luni->u64 == runi->u64;
if (lt == YYJSON_SUBTYPE_UINT && rt == YYJSON_SUBTYPE_SINT)
}
if (lt == YYJSON_SUBTYPE_UINT && rt == YYJSON_SUBTYPE_SINT) {
return runi->i64 >= 0 && luni->u64 == runi->u64;
}
return false;
}
@@ -1571,8 +1735,8 @@ bool unsafe_yyjson_equals(yyjson_val *lhs, yyjson_val *rhs) {
while (len-- > 0) {
rhs = yyjson_obj_iter_getn(&iter, lhs->uni.str,
unsafe_yyjson_get_len(lhs));
if (!rhs || !unsafe_yyjson_equals(lhs + 1, rhs))
return false;
if (!rhs) return false;
if (!unsafe_yyjson_equals(lhs + 1, rhs)) return false;
lhs = unsafe_yyjson_get_next(lhs + 1);
}
}
@@ -1626,8 +1790,8 @@ bool unsafe_yyjson_mut_equals(yyjson_mut_val *lhs, yyjson_mut_val *rhs) {
while (len-- > 0) {
rhs = yyjson_mut_obj_iter_getn(&iter, lhs->uni.str,
unsafe_yyjson_get_len(lhs));
if (!rhs || !unsafe_yyjson_mut_equals(lhs->next, rhs))
return false;
if (!rhs) return false;
if (!unsafe_yyjson_mut_equals(lhs->next, rhs)) return false;
lhs = lhs->next->next;
}
}
@@ -2506,6 +2670,7 @@ yyjson_mut_val *yyjson_merge_patch(yyjson_mut_doc *doc,
builder = yyjson_mut_obj(doc);
if (unlikely(!builder)) return NULL;
memset(&local_orig, 0, sizeof(local_orig));
if (!yyjson_is_obj(orig)) {
orig = &local_orig;
orig->tag = builder->tag;
@@ -2557,6 +2722,7 @@ yyjson_mut_val *yyjson_mut_merge_patch(yyjson_mut_doc *doc,
builder = yyjson_mut_obj(doc);
if (unlikely(!builder)) return NULL;
memset(&local_orig, 0, sizeof(local_orig));
if (!yyjson_mut_is_obj(orig)) {
orig = &local_orig;
orig->tag = builder->tag;
@@ -3318,8 +3484,6 @@ static_inline void pow10_table_get_exp(i32 exp10, i32 *exp2) {
#if !YYJSON_DISABLE_READER
/*==============================================================================
* JSON Character Matcher
*============================================================================*/
@@ -3513,6 +3677,8 @@ static_inline bool digi_is_digit_or_fp(u8 d) {
#if !YYJSON_DISABLE_READER
/*==============================================================================
* Hex Character Reader
* This function is used by JSON reader to read escaped characters.
+85 -21
View File
@@ -527,16 +527,16 @@ extern "C" {
#define YYJSON_VERSION_MAJOR 0
/** The minor version of yyjson. */
#define YYJSON_VERSION_MINOR 7
#define YYJSON_VERSION_MINOR 8
/** The patch version of yyjson. */
#define YYJSON_VERSION_PATCH 0
/** The version of yyjson in hex: `(major << 16) | (minor << 8) | (patch)`. */
#define YYJSON_VERSION_HEX 0x000700
#define YYJSON_VERSION_HEX 0x000800
/** The version string of yyjson. */
#define YYJSON_VERSION_STRING "0.7.0"
#define YYJSON_VERSION_STRING "0.8.0"
/** The version of yyjson in hex, same as `YYJSON_VERSION_HEX`. */
yyjson_api uint32_t yyjson_version(void);
@@ -635,11 +635,11 @@ typedef struct yyjson_alc {
function, but the amount of memory required to write a JSON cannot be directly
calculated.
This is not a general-purpose allocator. If used to read multiple JSON
documents and only some of them are released, it may cause memory
fragmentation, leading to performance degradation and memory waste. Therefore,
it is recommended to use this allocator only for reading or writing a single
JSON document.
This is not a general-purpose allocator. It is designed to handle a single JSON
data at a time. If it is used for overly complex memory tasks, such as parsing
multiple JSON documents using the same allocator but releasing only a few of
them, it may cause memory fragmentation, resulting in performance degradation
and memory waste.
@param alc The allocator to be initialized.
If this parameter is NULL, the function will fail and return false.
@@ -662,9 +662,31 @@ typedef struct yyjson_alc {
yyjson_doc *doc = yyjson_read_opts(json, strlen(json), 0, &alc, NULL);
// the memory of `doc` is on the stack
@endcode
@warning This Allocator is not thread-safe.
*/
yyjson_api bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, size_t size);
/**
A dynamic allocator.
This allocator has a similar usage to the pool allocator above. However, when
there is not enough memory, this allocator will dynamically request more memory
using libc's `malloc` function, and frees it all at once when it is destroyed.
@return A new dynamic allocator, or NULL if memory allocation failed.
@note The returned value should be freed with `yyjson_alc_dyn_free()`.
@warning This Allocator is not thread-safe.
*/
yyjson_api yyjson_alc *yyjson_alc_dyn_new(void);
/**
Free a dynamic allocator which is created by `yyjson_alc_dyn_new()`.
@param alc The dynamic allocator to be destroyed.
*/
yyjson_api void yyjson_alc_dyn_free(yyjson_alc *alc);
/*==============================================================================
@@ -3556,7 +3578,7 @@ yyjson_api_inline bool yyjson_mut_obj_rotate(yyjson_mut_val *obj,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3566,7 +3588,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_null(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3576,7 +3598,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_true(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3586,7 +3608,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_false(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3596,7 +3618,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_bool(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3606,7 +3628,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_uint(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3616,7 +3638,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_sint(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3626,7 +3648,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_int(yyjson_mut_doc *doc,
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3636,7 +3658,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_real(yyjson_mut_doc *doc,
The `key` and `val` should be null-terminated UTF-8 strings.
This function allows duplicated key in one object.
@warning The key/value string are not copied, you should keep these strings
@warning The key/value strings are not copied, you should keep these strings
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3648,7 +3670,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_str(yyjson_mut_doc *doc,
The `len` should be the length of the `val`, in bytes.
This function allows duplicated key in one object.
@warning The key/value string are not copied, you should keep these strings
@warning The key/value strings are not copied, you should keep these strings
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3660,7 +3682,7 @@ yyjson_api_inline bool yyjson_mut_obj_add_strn(yyjson_mut_doc *doc,
The value string is copied.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -3673,18 +3695,44 @@ yyjson_api_inline bool yyjson_mut_obj_add_strcpy(yyjson_mut_doc *doc,
The `len` should be the length of the `val`, in bytes.
This function allows duplicated key in one object.
@warning The key/value string are not copied, you should keep these strings
@warning The key/value strings are not copied, you should keep these strings
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *key,
const char *val, size_t len);
/**
Creates and adds a new array to the target object.
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string is not copied, you should keep these strings
unmodified for the lifetime of this JSON document.
@return The new array, or NULL on error.
*/
yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_arr(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *key);
/**
Creates and adds a new object to the target object.
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string is not copied, you should keep these strings
unmodified for the lifetime of this JSON document.
@return The new object, or NULL on error.
*/
yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_obj(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *key);
/** Adds a JSON value at the end of the object.
The `key` should be a null-terminated UTF-8 string.
This function allows duplicated key in one object.
@warning The key string are not copied, you should keep the string
@warning The key string is not copied, you should keep the string
unmodified for the lifetime of this JSON document. */
yyjson_api_inline bool yyjson_mut_obj_add_val(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
@@ -6920,6 +6968,22 @@ yyjson_api_inline bool yyjson_mut_obj_add_strncpy(yyjson_mut_doc *doc,
});
}
yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_arr(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *_key) {
yyjson_mut_val *key = yyjson_mut_str(doc, _key);
yyjson_mut_val *val = yyjson_mut_arr(doc);
return yyjson_mut_obj_add(obj, key, val) ? val : NULL;
}
yyjson_api_inline yyjson_mut_val *yyjson_mut_obj_add_obj(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *_key) {
yyjson_mut_val *key = yyjson_mut_str(doc, _key);
yyjson_mut_val *val = yyjson_mut_obj(doc);
return yyjson_mut_obj_add(obj, key, val) ? val : NULL;
}
yyjson_api_inline bool yyjson_mut_obj_add_val(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *_key,
+27 -21
View File
@@ -6,15 +6,17 @@ void ffAppendPercentBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
{
assert(green <= 100 && yellow <= 100 && red <= 100);
uint32_t blocksPercent = (uint32_t) (percent / 100.0 * instance.config.barWidth + 0.5);
uint32_t blocksGreen = (uint32_t) (green / 100.0 * instance.config.barWidth + 0.5);
uint32_t blocksYellow = (uint32_t) (yellow / 100.0 * instance.config.barWidth + 0.5);
uint32_t blocksRed = (uint32_t) (red / 100.0 * instance.config.barWidth + 0.5);
assert(blocksPercent <= instance.config.barWidth);
const FFOptionsDisplay* options = &instance.config.display;
if(instance.config.barBorder)
uint32_t blocksPercent = (uint32_t) (percent / 100.0 * options->barWidth + 0.5);
uint32_t blocksGreen = (uint32_t) (green / 100.0 * options->barWidth + 0.5);
uint32_t blocksYellow = (uint32_t) (yellow / 100.0 * options->barWidth + 0.5);
uint32_t blocksRed = (uint32_t) (red / 100.0 * options->barWidth + 0.5);
assert(blocksPercent <= options->barWidth);
if(options->barBorder)
{
if(!instance.config.pipe)
if(!options->pipe)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m[ ");
else
ffStrbufAppendS(buffer, "[ ");
@@ -22,7 +24,7 @@ void ffAppendPercentBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
for (uint32_t i = 0; i < blocksPercent; ++i)
{
if(!instance.config.pipe)
if(!options->pipe)
{
if (i == blocksGreen)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m");
@@ -31,26 +33,26 @@ void ffAppendPercentBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
else if (i == blocksRed)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
}
ffStrbufAppend(buffer, &instance.config.barCharElapsed);
ffStrbufAppend(buffer, &options->barCharElapsed);
}
if (blocksPercent < instance.config.barWidth)
if (blocksPercent < options->barWidth)
{
if(!instance.config.pipe)
if(!options->pipe)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m");
for (uint32_t i = blocksPercent; i < instance.config.barWidth; ++i)
ffStrbufAppend(buffer, &instance.config.barCharTotal);
for (uint32_t i = blocksPercent; i < options->barWidth; ++i)
ffStrbufAppend(buffer, &options->barCharTotal);
}
if(instance.config.barBorder)
if(options->barBorder)
{
if(!instance.config.pipe)
if(!options->pipe)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_WHITE "m ]");
else
ffStrbufAppendS(buffer, " ]");
}
if(!instance.config.pipe)
if(!options->pipe)
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
@@ -67,14 +69,18 @@ void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
{
assert(green <= 100 && yellow <= 100);
bool colored = !!(instance.config.percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT);
const FFOptionsDisplay* options = &instance.config.display;
bool colored = !!(options->percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT);
if (parentheses)
ffStrbufAppendC(buffer, '(');
if (colored && !instance.config.pipe)
if (colored && !options->pipe)
{
if(green < yellow)
if(percent != percent)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m");
else if(green < yellow)
{
if (percent <= green)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_GREEN "m");
@@ -93,9 +99,9 @@ void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_RED "m");
}
}
ffStrbufAppendF(buffer, "%.*f%%", instance.config.percentNdigits, percent);
ffStrbufAppendF(buffer, "%.*f%%", options->percentNdigits, percent);
if (colored && !instance.config.pipe)
if (colored && !options->pipe)
{
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_bar
#define FF_INCLUDED_common_bar
#include "fastfetch.h"
enum
@@ -15,5 +12,3 @@ enum
void ffAppendPercentBar(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, uint8_t red);
void ffAppendPercentNum(FFstrbuf* buffer, double percent, uint8_t green, uint8_t yellow, bool parentheses);
#endif
+168 -16
View File
@@ -1,23 +1,13 @@
#include "commandoption.h"
#include "common/printing.h"
#include "common/time.h"
#include "common/jsonconfig.h"
#include "fastfetch_datatext.h"
#include "modules/modules.h"
#include "util/stringUtils.h"
#include <ctype.h>
bool ffParseModuleCommand(const char* type)
{
if(!isalpha(type[0])) return false;
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(type[0]) - 'A']; *modules; ++modules)
{
FFModuleBaseInfo* baseInfo = *modules;
if (ffStrEqualsIgnCase(type, baseInfo->name))
{
baseInfo->printModule(baseInfo);
return true;
}
}
return false;
}
#include <inttypes.h>
bool ffParseModuleOptions(const char* key, const char* value)
{
@@ -30,3 +20,165 @@ bool ffParseModuleOptions(const char* key, const char* value)
}
return false;
}
void ffPrepareCommandOption(FFdata* data)
{
FFOptionsModules* const options = &instance.config.modules;
//If we don't have a custom structure, use the default one
if(data->structure.length == 0)
ffStrbufAppendS(&data->structure, FASTFETCH_DATATEXT_STRUCTURE);
if(ffStrbufContainIgnCaseS(&data->structure, FF_CPUUSAGE_MODULE_NAME))
ffPrepareCPUUsage();
if(ffStrbufContainIgnCaseS(&data->structure, FF_DISKIO_MODULE_NAME))
ffPrepareDiskIO(&options->diskIo);
if(ffStrbufContainIgnCaseS(&data->structure, FF_NETIO_MODULE_NAME))
ffPrepareNetIO(&options->netIo);
if(instance.config.general.multithreading)
{
if(ffStrbufContainIgnCaseS(&data->structure, FF_PUBLICIP_MODULE_NAME))
ffPreparePublicIp(&options->publicIP);
if(ffStrbufContainIgnCaseS(&data->structure, FF_WEATHER_MODULE_NAME))
ffPrepareWeather(&options->weather);
}
}
static void genJsonConfig(FFModuleBaseInfo* baseInfo, yyjson_mut_doc* doc)
{
yyjson_mut_val* modules = yyjson_mut_obj_get(doc->root, "modules");
if (!modules)
modules = yyjson_mut_obj_add_arr(doc, doc->root, "modules");
yyjson_mut_val* module = yyjson_mut_obj(doc);
FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateS(baseInfo->name);
ffStrbufLowerCase(&type);
yyjson_mut_obj_add_strbuf(doc, module, "type", &type);
if (baseInfo->generateJsonConfig)
baseInfo->generateJsonConfig(baseInfo, doc, module);
if (yyjson_mut_obj_size(module) > 1)
yyjson_mut_arr_add_val(modules, module);
else
yyjson_mut_arr_add_strbuf(doc, modules, &type);
}
static void genJsonResult(FFModuleBaseInfo* baseInfo, yyjson_mut_doc* doc)
{
yyjson_mut_val* module = yyjson_mut_arr_add_obj(doc, doc->root);
yyjson_mut_obj_add_str(doc, module, "type", baseInfo->name);
if (baseInfo->generateJsonResult)
baseInfo->generateJsonResult(baseInfo, doc, module);
else
yyjson_mut_obj_add_str(doc, module, "error", "Unsupported for JSON format");
}
static void parseStructureCommand(
const char* line,
FFlist* customValues,
void (*fn)(FFModuleBaseInfo *baseInfo, yyjson_mut_doc* jsonDoc),
yyjson_mut_doc* jsonDoc
)
{
// handle `--set` and `--set-keyless`
FF_LIST_FOR_EACH(FFCustomValue, customValue, *customValues)
{
if (ffStrbufEqualS(&customValue->key, line))
{
__attribute__((__cleanup__(ffDestroyCustomOptions))) FFCustomOptions options;
ffInitCustomOptions(&options);
if (customValue->printKey)
ffStrbufAppend(&options.moduleArgs.key, &customValue->key);
ffStrbufAppend(&options.moduleArgs.outputFormat, &customValue->value);
if (__builtin_expect(jsonDoc != NULL, false))
fn((FFModuleBaseInfo*) &options, jsonDoc);
else
ffPrintCustom(&options);
return;
}
}
if(isalpha(line[0]))
{
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(line[0]) - 'A']; *modules; ++modules)
{
FFModuleBaseInfo* baseInfo = *modules;
if (ffStrEqualsIgnCase(line, baseInfo->name))
{
if (__builtin_expect(jsonDoc != NULL, false))
fn(baseInfo, jsonDoc);
else
baseInfo->printModule(baseInfo);
return;
}
}
}
ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>");
}
void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc)
{
//Parse the structure and call the modules
uint32_t startIndex = 0;
while (startIndex < data->structure.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':');
data->structure.chars[colonIndex] = '\0';
uint64_t ms = 0;
if(instance.config.display.stat)
ms = ffTimeGetTick();
parseStructureCommand(data->structure.chars + startIndex, &data->customValues, genJsonResult, jsonDoc);
if(instance.config.display.stat)
{
ms = ffTimeGetTick() - ms;
if (jsonDoc)
{
yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root);
yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms);
}
else
{
char str[32];
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms);
if(instance.config.display.pipe)
puts(str);
else
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
}
}
#if defined(_WIN32)
if (!jsonDoc && !instance.config.display.noBuffer) fflush(stdout);
#endif
startIndex = colonIndex + 1;
}
}
void ffMigrateCommandOptionToJsonc(FFdata* data, yyjson_mut_doc* jsonDoc)
{
//If we don't have a custom structure, use the default one
if(data->structure.length == 0)
ffStrbufAppendS(&data->structure, FASTFETCH_DATATEXT_STRUCTURE);
//Parse the structure and call the modules
uint32_t startIndex = 0;
while (startIndex < data->structure.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':');
data->structure.chars[colonIndex] = '\0';
parseStructureCommand(data->structure.chars + startIndex, &data->customValues, genJsonConfig, jsonDoc);
startIndex = colonIndex + 1;
}
}
+18 -6
View File
@@ -1,11 +1,23 @@
#pragma once
#ifndef FF_INCLUDED_common_commandoption
#define FF_INCLUDED_common_commandoption
#include "fastfetch.h"
bool ffParseModuleCommand(const char* type);
bool ffParseModuleOptions(const char* key, const char* value);
typedef struct FFCustomValue
{
bool printKey;
FFstrbuf key;
FFstrbuf value;
} FFCustomValue;
#endif
// Things only needed by fastfetch
typedef struct FFdata
{
FFstrbuf structure;
FFlist customValues; // List of FFCustomValue
bool configLoaded;
} FFdata;
bool ffParseModuleOptions(const char* key, const char* value);
void ffPrepareCommandOption(FFdata* data);
void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc);
void ffMigrateCommandOptionToJsonc(FFdata* data, yyjson_mut_doc* jsonDoc);
+1 -5
View File
@@ -7,7 +7,7 @@
static bool loadLibSymbols(FFDBusLibrary* lib)
{
FF_LIBRARY_LOAD(dbus, &instance.config.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD(dbus, &instance.config.library.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_bus_get, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_new_method_call, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_init, false)
@@ -33,9 +33,6 @@ static const FFDBusLibrary* loadLib(void)
static FFDBusLibrary lib;
static bool loaded = false;
static bool loadSuccess = false;
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
ffThreadMutexLock(&mutex);
if(!loaded)
{
@@ -43,7 +40,6 @@ static const FFDBusLibrary* loadLib(void)
loadSuccess = loadLibSymbols(&lib);
}
ffThreadMutexUnlock(&mutex);
return loadSuccess ? &lib : NULL;
}
-4
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_dbus
#define FF_INCLUDED_common_dbus
#ifdef FF_HAVE_DBUS
#include <dbus/dbus.h>
@@ -54,4 +51,3 @@ DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char
void ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, FFstrbuf* result);
#endif // FF_HAVE_DBUS
#endif // FF_INCLUDED_common_dbus
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_font
#define FF_INCLUDED_common_font
#include "util/FFstrbuf.h"
#include "util/FFlist.h"
@@ -21,5 +18,3 @@ void ffFontInitCopy(FFfont* font, const char* name);
void ffFontInitValues(FFfont* font, const char* name, const char* size);
void ffFontInitWithSpace(FFfont* font, const char* rawName);
void ffFontDestroy(FFfont* font);
#endif
+4 -4
View File
@@ -12,6 +12,8 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
ffStrbufAppendF(buffer, "%i", *(int*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT)
ffStrbufAppendF(buffer, "%" PRIu32, *(uint32_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT64)
ffStrbufAppendF(buffer, "%" PRIu64, *(uint64_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT16)
ffStrbufAppendF(buffer, "%" PRIu16, *(uint16_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT8)
@@ -201,7 +203,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
}
// fastforward to the end of the if without printing the in between
i = ffStrbufNextIndexS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" - 1 because the loop will increament it again directly after continue
i = ffStrbufNextIndexS(formatstr, i, "{?}") + 2; // 2 is the length of "{?}" - 1 because the loop will increment it again directly after continue
continue;
}
@@ -227,7 +229,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
}
// fastforward to the end of the if without printing the in between
i = ffStrbufNextIndexS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" - 1 because the loop will increament it again directly after continue
i = ffStrbufNextIndexS(formatstr, i, "{/}") + 2; // 2 is the length of "{/}" - 1 because the loop will increment it again directly after continue
continue;
}
@@ -254,7 +256,5 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t n
ffFormatAppendFormatArg(buffer, &arguments[index - 1]);
}
ffStrbufTrimRight(buffer, ' ');
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
+1 -5
View File
@@ -1,12 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_common_format
#define FF_INCLUDED_common_format
typedef enum FFformatargtype
{
FF_FORMAT_ARG_TYPE_NULL = 0,
FF_FORMAT_ARG_TYPE_UINT,
FF_FORMAT_ARG_TYPE_UINT64,
FF_FORMAT_ARG_TYPE_UINT16,
FF_FORMAT_ARG_TYPE_UINT8,
FF_FORMAT_ARG_TYPE_INT,
@@ -26,5 +24,3 @@ typedef struct FFformatarg
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
#endif
+28 -249
View File
@@ -15,8 +15,6 @@
#include <signal.h>
#endif
#include "modules/modules.h"
FFinstance instance; // Global singleton
static void initState(FFstate* state)
@@ -27,135 +25,16 @@ static void initState(FFstate* state)
ffPlatformInit(&state->platform);
state->configDoc = NULL;
state->resultDoc = NULL;
}
static void defaultConfig(void)
{
ffInitLogoOptions(&instance.config.logo);
ffStrbufInit(&instance.config.colorKeys);
ffStrbufInit(&instance.config.colorTitle);
instance.config.brightColor = true;
ffStrbufInitStatic(&instance.config.keyValueSeparator, ": ");
instance.config.processingTimeout = 1000;
#if defined(__linux__) || defined(__FreeBSD__)
ffStrbufInit(&instance.config.playerName);
ffStrbufInit(&instance.config.osFile);
instance.config.dsForceDrm = false;
#elif defined(_WIN32)
instance.config.wmiTimeout = 5000;
#endif
instance.config.showErrors = false;
instance.config.allowSlowOperations = false;
instance.config.pipe = !isatty(STDOUT_FILENO);
#ifdef NDEBUG
instance.config.disableLinewrap = !instance.config.pipe;
instance.config.hideCursor = !instance.config.pipe;
#else
instance.config.disableLinewrap = false;
instance.config.hideCursor = false;
#endif
instance.config.escapeBedrock = true;
instance.config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC;
instance.config.sizeNdigits = 2;
instance.config.sizeMaxPrefix = UINT8_MAX;
instance.config.temperatureUnit = FF_TEMPERATURE_UNIT_CELSIUS;
instance.config.multithreading = true;
instance.config.stat = false;
instance.config.noBuffer = false;
instance.config.keyWidth = 0;
ffStrbufInitStatic(&instance.config.barCharElapsed, "");
ffStrbufInitStatic(&instance.config.barCharTotal, "-");
instance.config.barWidth = 10;
instance.config.barBorder = true;
instance.config.percentType = 1;
instance.config.percentNdigits = 0;
ffInitBatteryOptions(&instance.config.battery);
ffInitBiosOptions(&instance.config.bios);
ffInitBluetoothOptions(&instance.config.bluetooth);
ffInitBoardOptions(&instance.config.board);
ffInitBreakOptions(&instance.config.break_);
ffInitBrightnessOptions(&instance.config.brightness);
ffInitCPUOptions(&instance.config.cpu);
ffInitCPUUsageOptions(&instance.config.cpuUsage);
ffInitChassisOptions(&instance.config.chassis);
ffInitColorsOptions(&instance.config.colors);
ffInitCommandOptions(&instance.config.command);
ffInitCursorOptions(&instance.config.cursor);
ffInitCustomOptions(&instance.config.custom);
ffInitDEOptions(&instance.config.de);
ffInitDateTimeOptions(&instance.config.dateTime);
ffInitDiskOptions(&instance.config.disk);
ffInitDisplayOptions(&instance.config.display);
ffInitFontOptions(&instance.config.font);
ffInitGPUOptions(&instance.config.gpu);
ffInitGamepadOptions(&instance.config.gamepad);
ffInitHostOptions(&instance.config.host);
ffInitIconsOptions(&instance.config.icons);
ffInitKernelOptions(&instance.config.kernel);
ffInitLMOptions(&instance.config.lm);
ffInitLocalIpOptions(&instance.config.localIP);
ffInitLocaleOptions(&instance.config.locale);
ffInitMediaOptions(&instance.config.media);
ffInitMemoryOptions(&instance.config.memory);
ffInitMonitorOptions(&instance.config.monitor);
ffInitOSOptions(&instance.config.os);
ffInitOpenCLOptions(&instance.config.openCL);
ffInitOpenGLOptions(&instance.config.openGL);
ffInitPackagesOptions(&instance.config.packages);
ffInitPlayerOptions(&instance.config.player);
ffInitPowerAdapterOptions(&instance.config.powerAdapter);
ffInitProcessesOptions(&instance.config.processes);
ffInitPublicIpOptions(&instance.config.publicIP);
ffInitSeparatorOptions(&instance.config.separator);
ffInitShellOptions(&instance.config.shell);
ffInitSoundOptions(&instance.config.sound);
ffInitSwapOptions(&instance.config.swap);
ffInitTerminalFontOptions(&instance.config.terminalFont);
ffInitTerminalOptions(&instance.config.terminal);
ffInitTerminalSizeOptions(&instance.config.terminalSize);
ffInitThemeOptions(&instance.config.theme);
ffInitTitleOptions(&instance.config.title);
ffInitUptimeOptions(&instance.config.uptime);
ffInitUsersOptions(&instance.config.users);
ffInitVersionOptions(&instance.config.version);
ffInitVulkanOptions(&instance.config.vulkan);
ffInitWMOptions(&instance.config.wm);
ffInitWMThemeOptions(&instance.config.wmTheme);
ffInitWallpaperOptions(&instance.config.wallpaper);
ffInitWeatherOptions(&instance.config.weather);
ffInitWifiOptions(&instance.config.wifi);
ffStrbufInit(&instance.config.libPCI);
ffStrbufInit(&instance.config.libVulkan);
ffStrbufInit(&instance.config.libWayland);
ffStrbufInit(&instance.config.libXcbRandr);
ffStrbufInit(&instance.config.libXcb);
ffStrbufInit(&instance.config.libXrandr);
ffStrbufInit(&instance.config.libX11);
ffStrbufInit(&instance.config.libGIO);
ffStrbufInit(&instance.config.libDConf);
ffStrbufInit(&instance.config.libDBus);
ffStrbufInit(&instance.config.libXFConf);
ffStrbufInit(&instance.config.libSQLite3);
ffStrbufInit(&instance.config.librpm);
ffStrbufInit(&instance.config.libImageMagick);
ffStrbufInit(&instance.config.libZ);
ffStrbufInit(&instance.config.libChafa);
ffStrbufInit(&instance.config.libEGL);
ffStrbufInit(&instance.config.libGLX);
ffStrbufInit(&instance.config.libOSMesa);
ffStrbufInit(&instance.config.libOpenCL);
ffStrbufInit(&instance.config.libfreetype);
ffStrbufInit(&instance.config.libPulse);
ffStrbufInit(&instance.config.libnm);
ffStrbufInit(&instance.config.libDdcutil);
ffOptionsInitLogo(&instance.config.logo);
ffOptionsInitGeneral(&instance.config.general);
ffOptionsInitModules(&instance.config.modules);
ffOptionsInitDisplay(&instance.config.display);
ffOptionsInitLibrary(&instance.config.library);
}
void ffInitInstance(void)
@@ -172,29 +51,6 @@ void ffInitInstance(void)
defaultConfig();
}
#if defined(FF_HAVE_THREADS) && !(defined(__APPLE__) || defined(_WIN32) || defined(__ANDROID__))
#include "detection/gtk_qt/gtk_qt.h"
#define FF_START_DETECTION_THREADS
FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffConnectDisplayServer)
FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectQt)
FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectGTK2)
FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectGTK3)
FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(ffDetectGTK4)
void startDetectionThreads(void)
{
ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, NULL));
ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, NULL));
ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, NULL));
ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, NULL));
ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, NULL));
}
#endif //FF_HAVE_THREADS
static volatile bool ffDisableLinewrap = true;
static volatile bool ffHideCursor = true;
@@ -230,15 +86,18 @@ static void exitSignalHandler(int signal)
void ffStart(void)
{
#ifdef FF_START_DETECTION_THREADS
if(instance.config.multithreading)
if(instance.config.general.multithreading)
startDetectionThreads();
#endif
ffDisableLinewrap = instance.config.disableLinewrap && !instance.config.pipe;
ffHideCursor = instance.config.hideCursor && !instance.config.pipe;
ffDisableLinewrap = instance.config.display.disableLinewrap && !instance.config.display.pipe && !instance.state.resultDoc;
ffHideCursor = instance.config.display.hideCursor && !instance.config.display.pipe && !instance.state.resultDoc;
#ifdef _WIN32
if (!instance.config.noBuffer) setvbuf(stdout, NULL, _IOFBF, 4096);
if (instance.config.display.noBuffer)
setvbuf(stdout, NULL, _IONBF, 0);
else
setvbuf(stdout, NULL, _IOFBF, 4096);
SetConsoleCtrlHandler(consoleHandler, TRUE);
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
@@ -246,7 +105,7 @@ void ffStart(void)
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
SetConsoleOutputCP(CP_UTF8);
#else
if (instance.config.noBuffer) setvbuf(stdout, NULL, _IONBF, 0);
if (instance.config.display.noBuffer) setvbuf(stdout, NULL, _IONBF, 0);
struct sigaction action = { .sa_handler = exitSignalHandler };
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);
@@ -254,7 +113,7 @@ void ffStart(void)
#endif
//reset everything to default before we start printing
if(!instance.config.pipe)
if(!instance.config.display.pipe && !instance.state.resultDoc)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
if(ffHideCursor)
@@ -276,105 +135,19 @@ void ffFinish(void)
static void destroyConfig(void)
{
ffDestroyLogoOptions(&instance.config.logo);
ffStrbufDestroy(&instance.config.colorKeys);
ffStrbufDestroy(&instance.config.colorTitle);
ffStrbufDestroy(&instance.config.keyValueSeparator);
ffStrbufDestroy(&instance.config.barCharElapsed);
ffStrbufDestroy(&instance.config.barCharTotal);
#if defined(__linux__) || defined(__FreeBSD__)
ffStrbufDestroy(&instance.config.playerName);
ffStrbufDestroy(&instance.config.osFile);
#endif
ffDestroyBatteryOptions(&instance.config.battery);
ffDestroyBiosOptions(&instance.config.bios);
ffDestroyBluetoothOptions(&instance.config.bluetooth);
ffDestroyBoardOptions(&instance.config.board);
ffDestroyBreakOptions(&instance.config.break_);
ffDestroyBrightnessOptions(&instance.config.brightness);
ffDestroyCPUOptions(&instance.config.cpu);
ffDestroyCPUUsageOptions(&instance.config.cpuUsage);
ffDestroyChassisOptions(&instance.config.chassis);
ffDestroyColorsOptions(&instance.config.colors);
ffDestroyCommandOptions(&instance.config.command);
ffDestroyCursorOptions(&instance.config.cursor);
ffDestroyCustomOptions(&instance.config.custom);
ffDestroyDEOptions(&instance.config.de);
ffDestroyDateTimeOptions(&instance.config.dateTime);
ffDestroyDiskOptions(&instance.config.disk);
ffDestroyDisplayOptions(&instance.config.display);
ffDestroyFontOptions(&instance.config.font);
ffDestroyGPUOptions(&instance.config.gpu);
ffDestroyGamepadOptions(&instance.config.gamepad);
ffDestroyHostOptions(&instance.config.host);
ffDestroyIconsOptions(&instance.config.icons);
ffDestroyKernelOptions(&instance.config.kernel);
ffDestroyLMOptions(&instance.config.lm);
ffDestroyLocalIpOptions(&instance.config.localIP);
ffDestroyLocaleOptions(&instance.config.locale);
ffDestroyMediaOptions(&instance.config.media);
ffDestroyMemoryOptions(&instance.config.memory);
ffDestroyMonitorOptions(&instance.config.monitor);
ffDestroyOSOptions(&instance.config.os);
ffDestroyOpenCLOptions(&instance.config.openCL);
ffDestroyOpenGLOptions(&instance.config.openGL);
ffDestroyPackagesOptions(&instance.config.packages);
ffDestroyPlayerOptions(&instance.config.player);
ffDestroyPowerAdapterOptions(&instance.config.powerAdapter);
ffDestroyProcessesOptions(&instance.config.processes);
ffDestroyPublicIpOptions(&instance.config.publicIP);
ffDestroySeparatorOptions(&instance.config.separator);
ffDestroyShellOptions(&instance.config.shell);
ffDestroySoundOptions(&instance.config.sound);
ffDestroySwapOptions(&instance.config.swap);
ffDestroyTerminalFontOptions(&instance.config.terminalFont);
ffDestroyTerminalOptions(&instance.config.terminal);
ffDestroyTerminalSizeOptions(&instance.config.terminalSize);
ffDestroyThemeOptions(&instance.config.theme);
ffDestroyTitleOptions(&instance.config.title);
ffDestroyUptimeOptions(&instance.config.uptime);
ffDestroyUsersOptions(&instance.config.users);
ffDestroyVersionOptions(&instance.config.version);
ffDestroyVulkanOptions(&instance.config.vulkan);
ffDestroyWMOptions(&instance.config.wm);
ffDestroyWMThemeOptions(&instance.config.wmTheme);
ffDestroyWallpaperOptions(&instance.config.wallpaper);
ffDestroyWeatherOptions(&instance.config.weather);
ffDestroyWifiOptions(&instance.config.wifi);
ffStrbufDestroy(&instance.config.libPCI);
ffStrbufDestroy(&instance.config.libVulkan);
ffStrbufDestroy(&instance.config.libWayland);
ffStrbufDestroy(&instance.config.libXcbRandr);
ffStrbufDestroy(&instance.config.libXcb);
ffStrbufDestroy(&instance.config.libXrandr);
ffStrbufDestroy(&instance.config.libX11);
ffStrbufDestroy(&instance.config.libGIO);
ffStrbufDestroy(&instance.config.libDConf);
ffStrbufDestroy(&instance.config.libDBus);
ffStrbufDestroy(&instance.config.libXFConf);
ffStrbufDestroy(&instance.config.libSQLite3);
ffStrbufDestroy(&instance.config.librpm);
ffStrbufDestroy(&instance.config.libImageMagick);
ffStrbufDestroy(&instance.config.libZ);
ffStrbufDestroy(&instance.config.libChafa);
ffStrbufDestroy(&instance.config.libEGL);
ffStrbufDestroy(&instance.config.libGLX);
ffStrbufDestroy(&instance.config.libOSMesa);
ffStrbufDestroy(&instance.config.libOpenCL);
ffStrbufDestroy(&instance.config.libfreetype);
ffStrbufDestroy(&instance.config.libPulse);
ffStrbufDestroy(&instance.config.libnm);
ffStrbufDestroy(&instance.config.libDdcutil);
ffOptionsDestroyLogo(&instance.config.logo);
ffOptionsDestroyGeneral(&instance.config.general);
ffOptionsDestroyModules(&instance.config.modules);
ffOptionsDestroyDisplay(&instance.config.display);
ffOptionsDestroyLibrary(&instance.config.library);
}
static void destroyState(void)
{
ffPlatformDestroy(&instance.state.platform);
yyjson_doc_free(instance.state.configDoc);
yyjson_mut_doc_free(instance.state.resultDoc);
ffStrbufDestroy(&instance.state.genConfigPath);
}
void ffDestroyInstance(void)
@@ -411,6 +184,9 @@ void ffListFeatures(void)
#ifdef FF_HAVE_X11
"x11\n"
#endif
#ifdef FF_HAVE_DRM
"drm\n"
#endif
#ifdef FF_HAVE_GIO
"gio\n"
#endif
@@ -465,6 +241,9 @@ void ffListFeatures(void)
#ifdef FF_HAVE_DDCUTIL
"libddcutil\n"
#endif
#ifdef FF_HAVE_DIRECTX_HEADERS
"Directx Headers\n"
#endif
""
, stdout);
}
+68 -14
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_io_io
#define FF_INCLUDED_common_io_io
#include "util/FFstrbuf.h"
#ifdef _WIN32
@@ -12,7 +9,13 @@
typedef HANDLE FFNativeFD;
#else
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
typedef int FFNativeFD;
// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime.
// one safe way to read correct data is reading the whole file in a single read syscall
// 8192 comes from procps-ng: https://gitlab.com/procps-ng/procps/-/blob/master/library/meminfo.c?ref_type=heads#L39
#define PROC_FILE_BUFFSIZ 8192
#endif
static inline FFNativeFD FFUnixFD2NativeFD(int unixfd)
@@ -51,11 +54,11 @@ static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data)
#ifndef _WIN32
return read(fd, data, dataSize);
#else
DWORD readed;
if(!ReadFile(fd, data, (DWORD)dataSize, &readed, NULL))
DWORD bytesRead;
if(!ReadFile(fd, data, (DWORD)dataSize, &bytesRead, NULL))
return -1;
return (ssize_t)readed;
return (ssize_t)bytesRead;
#endif
}
@@ -73,17 +76,49 @@ static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer)
//Bit flags, combine with |
typedef enum FFPathType
{
FF_PATHTYPE_REGULAR = 1,
FF_PATHTYPE_LINK = 2,
FF_PATHTYPE_DIRECTORY = 4
FF_PATHTYPE_FILE = 1 << 0,
FF_PATHTYPE_DIRECTORY = 1 << 1,
FF_PATHTYPE_ANY = FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY,
} FFPathType;
#define FF_PATHTYPE_FILE (FF_PATHTYPE_REGULAR | FF_PATHTYPE_LINK)
#define FF_PATHTYPE_ANY (FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY)
static inline bool ffPathExists(const char* path, FFPathType pathType)
{
#ifdef _WIN32
DWORD attr = GetFileAttributesA(path);
if(attr == INVALID_FILE_ATTRIBUTES)
return false;
if(pathType & FF_PATHTYPE_FILE && !(attr & FILE_ATTRIBUTE_DIRECTORY))
return true;
if(pathType & FF_PATHTYPE_DIRECTORY && (attr & FILE_ATTRIBUTE_DIRECTORY))
return true;
#else
struct stat fileStat;
if(stat(path, &fileStat) != 0)
return false;
unsigned int mode = fileStat.st_mode & S_IFMT;
if(pathType & FF_PATHTYPE_FILE && mode == S_IFREG)
return true;
if(pathType & FF_PATHTYPE_DIRECTORY && mode == S_IFDIR)
return true;
#endif
return false;
}
bool ffPathExists(const char* path, FFPathType pathType);
bool ffPathExpandEnv(const char* in, FFstrbuf* out);
#define FF_IO_TERM_RESP_WAIT_MS 100 // #554
FF_C_SCANF(2, 3)
const char* ffGetTerminalResponse(const char* request, const char* format, ...);
@@ -99,7 +134,7 @@ static inline void ffUnsuppressIO(bool* suppressed)
#define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true)
void ffListFilesRecursively(const char* path);
void ffListFilesRecursively(const char* path, bool pretty);
static inline bool wrapClose(FFNativeFD* pfd)
{
@@ -130,4 +165,23 @@ static inline bool wrapFclose(FILE** pfile)
}
#define FF_AUTO_CLOSE_FILE __attribute__((__cleanup__(wrapFclose)))
#endif // FF_INCLUDED_common_io_io
#ifndef _WIN32
static inline bool wrapClosedir(DIR** pdir)
{
assert(pdir);
if (!*pdir)
return false;
closedir(*pdir);
return true;
}
#else
static inline bool wrapClosedir(HANDLE* pdir)
{
assert(pdir);
if (!*pdir)
return false;
FindClose(*pdir);
return true;
}
#endif
#define FF_AUTO_CLOSE_DIR __attribute__((__cleanup__(wrapClosedir)))
+62 -55
View File
@@ -3,10 +3,10 @@
#include "util/unused.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <termios.h>
#include <poll.h>
#include <dirent.h>
#include <errno.h>
#if __has_include(<wordexp.h>)
#include <wordexp.h>
@@ -16,26 +16,31 @@ static void createSubfolders(const char* fileName)
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
while(*fileName != '\0')
char *token = NULL;
while((token = strchr(fileName, '/')) != NULL)
{
ffStrbufAppendC(&path, *fileName);
if(*fileName == '/')
mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH);
++fileName;
ffStrbufAppendNS(&path, (uint32_t)(token - fileName + 1), fileName);
mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH);
fileName = token + 1;
}
}
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC;
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC;
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
int FF_AUTO_CLOSE_FD fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
{
createSubfolders(fileName);
fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
if (errno == ENOENT)
{
createSubfolders(fileName);
fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
return false;
}
else
return false;
}
@@ -44,39 +49,50 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
{
ssize_t readed = 0;
ssize_t bytesRead = 0;
struct stat fileInfo;
if(fstat(fd, &fileInfo) != 0)
return false;
ffStrbufEnsureFree(buffer, fileInfo.st_size > 0 ? (uint32_t)fileInfo.st_size : 31);
if (fileInfo.st_size > 0)
{
// optimize for files has a fixed length,
// file can be very large, only keep necessary memory to save time and resources.
ffStrbufEnsureFixedLengthFree(buffer, (uint32_t)fileInfo.st_size);
}
else
ffStrbufEnsureFree(buffer, 31);
uint32_t free = ffStrbufGetFree(buffer);
// procfs file's st_size is always zero
// choose a signed int type so that can store a native number
ssize_t remain = fileInfo.st_size;
while(
(readed = read(fd, buffer->chars + buffer->length, free)) > 0 &&
(uint32_t) readed == free
(bytesRead = read(fd, buffer->chars + buffer->length, free)) > 0
) {
buffer->length += (uint32_t) readed;
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
buffer->length += (uint32_t) bytesRead;
// if remain > 0, it means there is some data left in the file.
// if remain == 0, it means reading has completed, no need to grow up the buffer.
// if remain < 0, we are reading a file from procfs/sysfs and its st_size is zero,
// we cannot detect how many data remains in the file, we only can call ffStrbufEnsureFree and read again.
remain -= bytesRead;
if((uint32_t) bytesRead == free && remain != 0)
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
free = ffStrbufGetFree(buffer);
}
// In case of failure, read returns -1. We don't want to substract the length of the buffer.
if(readed > 0)
buffer->length += (uint32_t) readed;
buffer->chars[buffer->length] = '\0';
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
return readed >= 0;
return buffer->length > 0;
}
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
{
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY);
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY | O_CLOEXEC);
if(fd == -1)
return -1;
@@ -85,33 +101,13 @@ ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY);
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY | O_CLOEXEC);
if(fd == -1)
return false;
return ffAppendFDBuffer(fd, buffer);
}
bool ffPathExists(const char* path, FFPathType type)
{
struct stat fileStat;
if(stat(path, &fileStat) != 0)
return false;
int mode = fileStat.st_mode & S_IFMT;
if(type & FF_PATHTYPE_REGULAR && mode == S_IFREG)
return true;
if(type & FF_PATHTYPE_DIRECTORY && mode == S_IFDIR)
return true;
if(type & FF_PATHTYPE_LINK && mode == S_IFLNK)
return true;
return false;
}
bool ffPathExpandEnv(FF_MAYBE_UNUSED const char* in, FF_MAYBE_UNUSED FFstrbuf* out)
{
bool result = false;
@@ -150,21 +146,21 @@ const char* ffGetTerminalResponse(const char* request, const char* format, ...)
fflush(stdout);
//Give the terminal 35ms to respond
if(poll(&(struct pollfd) { .fd = STDIN_FILENO, .events = POLLIN }, 1, 35) <= 0)
if(poll(&(struct pollfd) { .fd = STDIN_FILENO, .events = POLLIN }, 1, FF_IO_TERM_RESP_WAIT_MS) <= 0)
{
tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm);
return "poll() timeout or failed";
}
char buffer[512];
ssize_t readed = read(STDIN_FILENO, buffer, sizeof(buffer) - 1);
ssize_t bytesRead = read(STDIN_FILENO, buffer, sizeof(buffer) - 1);
tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm);
if(readed <= 0)
if(bytesRead <= 0)
return "read(STDIN_FILENO, buffer, sizeof(buffer) - 1) failed";
buffer[readed] = '\0';
buffer[bytesRead] = '\0';
va_list args;
va_start(args, format);
@@ -188,7 +184,7 @@ bool ffSuppressIO(bool suppress)
origOut = dup(STDOUT_FILENO);
origErr = dup(STDERR_FILENO);
nullFile = open("/dev/null", O_WRONLY);
nullFile = open("/dev/null", O_WRONLY | O_CLOEXEC);
init = true;
}
@@ -203,7 +199,7 @@ bool ffSuppressIO(bool suppress)
return true;
}
void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* folderName)
void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indentation, const char* folderName, bool pretty)
{
DIR* dir = opendir(folder->chars);
if(dir == NULL)
@@ -211,8 +207,12 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol
uint32_t folderLength = folder->length;
if(folderName != NULL)
if(pretty && folderName != NULL)
{
for(uint8_t i = 0; i < indentation - 1; i++)
fputs(" | ", stdout);
printf("%s/\n", folderName);
}
struct dirent* entry;
@@ -225,13 +225,20 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol
ffStrbufAppendS(folder, entry->d_name);
ffStrbufAppendC(folder, '/');
listFilesRecursively(folder, (uint8_t) (indentation + 1), entry->d_name);
listFilesRecursively(baseLength, folder, (uint8_t) (indentation + 1), entry->d_name, pretty);
ffStrbufSubstrBefore(folder, folderLength);
continue;
}
for(uint8_t i = 0; i < indentation; i++)
fputs(" | ", stdout);
if (pretty)
{
for(uint8_t i = 0; i < indentation; i++)
fputs(" | ", stdout);
}
else
{
fputs(folder->chars + baseLength, stdout);
}
puts(entry->d_name);
}
@@ -239,9 +246,9 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol
closedir(dir);
}
void ffListFilesRecursively(const char* path)
void ffListFilesRecursively(const char* path, bool pretty)
{
FF_STRBUF_AUTO_DESTROY folder = ffStrbufCreateS(path);
ffStrbufEnsureEndsWithC(&folder, '/');
listFilesRecursively(&folder, 0, NULL);
listFilesRecursively(folder.length, &folder, 0, NULL, pretty);
}
+50 -44
View File
@@ -6,23 +6,28 @@
static void createSubfolders(const char* fileName)
{
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
while(*fileName != '\0')
char *token = NULL;
while((token = strchr(fileName, '/')) != NULL)
{
ffStrbufAppendC(&path, *fileName);
if(*fileName == '/')
CreateDirectoryA(path.chars, NULL);
++fileName;
ffStrbufAppendNS(&path, (uint32_t)(token - fileName + 1), fileName);
CreateDirectoryA(path.chars, NULL);
fileName = token + 1;
}
}
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
if (handle == INVALID_HANDLE_VALUE)
{
createSubfolders(fileName);
handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
if (GetLastError() == ERROR_PATH_NOT_FOUND)
{
createSubfolders(fileName);
handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE)
return false;
}
else
return false;
}
@@ -32,28 +37,35 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
bool ffAppendFDBuffer(HANDLE handle, FFstrbuf* buffer)
{
DWORD readed = 0;
DWORD bytesRead = 0;
LARGE_INTEGER fileSize;
if(!GetFileSizeEx(handle, &fileSize))
fileSize.QuadPart = 0;
ffStrbufEnsureFree(buffer, fileSize.QuadPart > 0 ? (uint32_t)fileSize.QuadPart : 31);
if (fileSize.QuadPart > 0)
{
// optimize for files has a fixed length,
// file can be very large, only keep necessary memory to save time and resources.
ffStrbufEnsureFixedLengthFree(buffer, (uint32_t)fileSize.QuadPart);
}
else
ffStrbufEnsureFree(buffer, 31);
uint32_t free = ffStrbufGetFree(buffer);
ssize_t remain = fileSize.QuadPart;
bool success;
while(
(success = !!ReadFile(handle, buffer->chars + buffer->length, free, &readed, NULL)) &&
(uint32_t) readed == free
(success = !!ReadFile(handle, buffer->chars + buffer->length, free, &bytesRead, NULL)) &&
bytesRead > 0
) {
buffer->length += (uint32_t) readed;
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
buffer->length += (uint32_t) bytesRead;
remain -= (ssize_t)bytesRead;
if((uint32_t) bytesRead == free && remain != 0)
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
free = ffStrbufGetFree(buffer);
}
if(readed > 0)
buffer->length += (uint32_t) readed;
buffer->chars[buffer->length] = '\0';
ffStrbufTrimRight(buffer, '\n');
@@ -80,24 +92,6 @@ bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
return ffAppendFDBuffer(handle, buffer);
}
bool ffPathExists(const char* path, FFPathType type)
{
DWORD attr = GetFileAttributesA(path);
if(attr == INVALID_FILE_ATTRIBUTES)
return false;
if(type & FF_PATHTYPE_REGULAR && !(attr & FILE_ATTRIBUTE_DIRECTORY))
return true;
if(type & FF_PATHTYPE_DIRECTORY && (attr & FILE_ATTRIBUTE_DIRECTORY))
return true;
if(type & FF_PATHTYPE_LINK && (attr & FILE_ATTRIBUTE_REPARSE_POINT))
return true;
return false;
}
bool ffPathExpandEnv(const char* in, FFstrbuf* out)
{
DWORD length = ExpandEnvironmentStringsA(in, NULL, 0);
@@ -116,16 +110,21 @@ bool ffSuppressIO(bool suppress)
return false;
}
void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* folderName)
void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indentation, const char* folderName, bool pretty)
{
uint32_t folderLength = folder->length;
if(folderName != NULL)
if(pretty && folderName != NULL)
{
for(uint8_t i = 0; i < indentation - 1; i++)
fputs(" | ", stdout);
printf("%s/\n", folderName);
}
ffStrbufAppendC(folder, '*');
WIN32_FIND_DATAA entry;
HANDLE hFind = FindFirstFileA(folder->chars, &entry);
ffStrbufTrimRight(folder, '*');
if(hFind == INVALID_HANDLE_VALUE)
return;
@@ -139,24 +138,31 @@ void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* fol
ffStrbufSubstrBefore(folder, folderLength);
ffStrbufAppendS(folder, entry.cFileName);
ffStrbufAppendC(folder, '/');
listFilesRecursively(folder, (uint8_t) (indentation + 1), entry.cFileName);
listFilesRecursively(baseLength, folder, (uint8_t) (indentation + 1), entry.cFileName, pretty);
ffStrbufSubstrBefore(folder, folderLength);
continue;
}
for(uint8_t i = 0; i < indentation; i++)
fputs(" | ", stdout);
if (pretty)
{
for(uint8_t i = 0; i < indentation; i++)
fputs(" | ", stdout);
}
else
{
fputs(folder->chars + baseLength, stdout);
}
puts(entry.cFileName);
} while (FindNextFileA(hFind, &entry));
FindClose(hFind);
}
void ffListFilesRecursively(const char* path)
void ffListFilesRecursively(const char* path, bool pretty)
{
FF_STRBUF_AUTO_DESTROY folder = ffStrbufCreateS(path);
ffStrbufEnsureEndsWithC(&folder, '/');
listFilesRecursively(&folder, 0, NULL);
listFilesRecursively(folder.length, &folder, 0, NULL, pretty);
}
const char* ffGetTerminalResponse(const char* request, const char* format, ...)
@@ -173,7 +179,7 @@ const char* ffGetTerminalResponse(const char* request, const char* format, ...)
while (true)
{
if (WaitForSingleObjectEx(hInput, 35, TRUE) != WAIT_OBJECT_0)
if (WaitForSingleObjectEx(hInput, FF_IO_TERM_RESP_WAIT_MS, TRUE) != WAIT_OBJECT_0)
{
SetConsoleMode(hInput, prev_mode);
return "WaitForSingleObject() failed or timeout";
+78 -283
View File
@@ -35,6 +35,18 @@ bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs*
return false;
}
void ffJsonConfigGenerateModuleArgsConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFModuleArgs* defaultModuleArgs, FFModuleArgs* moduleArgs)
{
if (!ffStrbufEqual(&defaultModuleArgs->key, &moduleArgs->key))
yyjson_mut_obj_add_strbuf(doc, module, "key", &moduleArgs->key);
if (!ffStrbufEqual(&defaultModuleArgs->outputFormat, &moduleArgs->outputFormat))
yyjson_mut_obj_add_strbuf(doc, module, "format", &moduleArgs->outputFormat);
if (!ffStrbufEqual(&defaultModuleArgs->keyColor, &moduleArgs->keyColor))
yyjson_mut_obj_add_strbuf(doc, module, "keyColor", &moduleArgs->keyColor);
if (moduleArgs->keyWidth != defaultModuleArgs->keyWidth)
yyjson_mut_obj_add_uint(doc, module, "keyWidth", moduleArgs->keyWidth);
}
const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[])
{
if (yyjson_is_int(val))
@@ -70,7 +82,17 @@ const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair p
return "Invalid enum value type; must be a string or integer";
}
static bool parseModuleJsonObject(const char* type, yyjson_val* jsonVal)
static inline void genJsonResult(FFModuleBaseInfo* baseInfo, yyjson_mut_doc* doc)
{
yyjson_mut_val* module = yyjson_mut_arr_add_obj(doc, doc->root);
yyjson_mut_obj_add_str(doc, module, "type", baseInfo->name);
if (baseInfo->generateJsonResult)
baseInfo->generateJsonResult(baseInfo, doc, module);
else
yyjson_mut_obj_add_str(doc, module, "error", "Unsupported for JSON format");
}
static bool parseModuleJsonObject(const char* type, yyjson_val* jsonVal, yyjson_mut_doc* jsonDoc)
{
if(!isalpha(type[0])) return false;
@@ -80,7 +102,10 @@ static bool parseModuleJsonObject(const char* type, yyjson_val* jsonVal)
if (ffStrEqualsIgnCase(type, baseInfo->name))
{
if (jsonVal) baseInfo->parseJsonObject(baseInfo, jsonVal);
baseInfo->printModule(baseInfo);
if (__builtin_expect(jsonDoc != NULL, false))
genJsonResult(baseInfo, jsonDoc);
else
baseInfo->printModule(baseInfo);
return true;
}
}
@@ -97,26 +122,42 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module)
ffPrepareCPUUsage();
break;
}
case 'd': case 'D': {
if (ffStrEqualsIgnCase(type, FF_DISKIO_MODULE_NAME))
{
if (module) cfg->modules.diskIo.moduleInfo.parseJsonObject(&cfg->modules.diskIo, module);
ffPrepareDiskIO(&cfg->modules.diskIo);
}
break;
}
case 'n': case 'N': {
if (ffStrEqualsIgnCase(type, FF_NETIO_MODULE_NAME))
{
if (module) cfg->modules.netIo.moduleInfo.parseJsonObject(&cfg->modules.netIo, module);
ffPrepareNetIO(&cfg->modules.netIo);
}
break;
}
case 'p': case 'P': {
if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME))
{
if (module) ffParsePublicIpJsonObject(&cfg->publicIP, module);
ffPreparePublicIp(&cfg->publicIP);
if (module) cfg->modules.publicIP.moduleInfo.parseJsonObject(&cfg->modules.publicIP, module);
ffPreparePublicIp(&cfg->modules.publicIP);
}
break;
}
case 'w': case 'W': {
if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME))
{
if (module) ffParseWeatherJsonObject(&cfg->weather, module);
ffPrepareWeather(&cfg->weather);
if (module) cfg->modules.weather.moduleInfo.parseJsonObject(&cfg->modules.weather, module);
ffPrepareWeather(&cfg->modules.weather);
}
break;
}
}
}
static const char* printJsonConfig(bool prepare)
static const char* printJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc)
{
yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc);
assert(root);
@@ -133,7 +174,7 @@ static const char* printJsonConfig(bool prepare)
yyjson_arr_foreach(modules, idx, max, item)
{
uint64_t ms = 0;
if(!prepare && instance.config.stat)
if(!prepare && instance.config.display.stat)
ms = ffTimeGetTick();
yyjson_val* module = item;
@@ -152,294 +193,48 @@ static const char* printJsonConfig(bool prepare)
if(prepare)
prepareModuleJsonObject(type, module);
else if(!parseModuleJsonObject(type, module))
else if(!parseModuleJsonObject(type, module, jsonDoc))
return "Unknown module type";
if(!prepare && instance.config.stat)
if(!prepare && instance.config.display.stat)
{
char str[32];
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ffTimeGetTick() - ms);
if(instance.config.pipe)
puts(str);
ms = ffTimeGetTick() - ms;
if (jsonDoc)
{
yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root);
yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms);
}
else
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
{
char str[32];
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms);
if(instance.config.display.pipe)
puts(str);
else
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
}
}
#if defined(_WIN32)
if (!instance.config.noBuffer) fflush(stdout);
if (!instance.config.display.noBuffer && !jsonDoc) fflush(stdout);
#endif
}
return NULL;
}
const char* ffParseGeneralJsonConfig(void)
void ffPrintJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc)
{
FFconfig* config = &instance.config;
yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc);
assert(root);
if (!yyjson_is_obj(root))
return "Invalid JSON config format. Root value must be an object";
yyjson_val* object = yyjson_obj_get(root, "general");
if (!object) return NULL;
if (!yyjson_is_obj(object)) return "Property 'general' must be an object";
yyjson_val *key_, *val;
size_t idx, max;
yyjson_obj_foreach(object, idx, max, key_, val)
{
const char* key = yyjson_get_str(key_);
if (ffStrEqualsIgnCase(key, "allowSlowOperations"))
config->allowSlowOperations = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "thread") || ffStrEqualsIgnCase(key, "multithreading"))
config->multithreading = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "stat"))
{
if ((config->stat = yyjson_get_bool(val)))
config->showErrors = true;
}
else if (ffStrEqualsIgnCase(key, "escapeBedrock"))
config->escapeBedrock = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "pipe"))
config->pipe = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "processingTimeout"))
config->processingTimeout = (int32_t) yyjson_get_int(val);
#if defined(__linux__) || defined(__FreeBSD__)
else if (ffStrEqualsIgnCase(key, "playerName"))
ffStrbufSetS(&config->playerName, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "osFile"))
ffStrbufSetS(&config->osFile, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "dsForceDrm"))
config->dsForceDrm = yyjson_get_bool(val);
#elif defined(_WIN32)
else if (ffStrEqualsIgnCase(key, "wmiTimeout"))
config->wmiTimeout = (int32_t) yyjson_get_int(val);
#endif
else
return "Unknown general property";
}
return NULL;
}
const char* ffParseDisplayJsonConfig(void)
{
FFconfig* config = &instance.config;
yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc);
assert(root);
if (!yyjson_is_obj(root))
return "Invalid JSON config format. Root value must be an object";
yyjson_val* object = yyjson_obj_get(root, "display");
if (!object) return NULL;
if (!yyjson_is_obj(object)) return "Property 'display' must be an object";
yyjson_val *key_, *val;
size_t idx, max;
yyjson_obj_foreach(object, idx, max, key_, val)
{
const char* key = yyjson_get_str(key_);
if (ffStrEqualsIgnCase(key, "showErrors"))
config->showErrors = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "disableLinewrap"))
config->disableLinewrap = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "hideCursor"))
config->hideCursor = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "separator"))
ffStrbufSetS(&config->keyValueSeparator, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "color"))
{
if (yyjson_is_str(val))
{
ffOptionParseColor(yyjson_get_str(val), &config->colorKeys);
ffStrbufSet(&config->colorTitle, &config->colorKeys);
}
else if (yyjson_is_obj(val))
{
const char* colorKeys = yyjson_get_str(yyjson_obj_get(val, "keys"));
if (colorKeys)
ffOptionParseColor(colorKeys, &config->colorKeys);
const char* colorTitle = yyjson_get_str(yyjson_obj_get(val, "title"));
if (colorTitle)
ffOptionParseColor(colorTitle, &config->colorTitle);
}
else
return "display.color must be either a string or an object";
}
else if (ffStrEqualsIgnCase(key, "brightColor"))
config->brightColor = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "binaryPrefix"))
{
int value;
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
{ "iec", FF_BINARY_PREFIX_TYPE_IEC },
{ "si", FF_BINARY_PREFIX_TYPE_SI },
{ "jedec", FF_BINARY_PREFIX_TYPE_JEDEC },
{},
});
if (error) return error;
config->binaryPrefixType = (FFBinaryPrefixType) value;
}
else if (ffStrEqualsIgnCase(key, "sizeNdigits"))
config->sizeNdigits = (uint8_t) yyjson_get_uint(val);
else if (ffStrEqualsIgnCase(key, "sizeMaxPrefix"))
{
int value;
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
{ "B", 0 },
{ "kB", 1 },
{ "MB", 2 },
{ "GB", 3 },
{ "TB", 4 },
{ "PB", 5 },
{ "EB", 6 },
{ "ZB", 7 },
{ "YB", 8 },
{}
});
if (error) return error;
config->sizeMaxPrefix = (uint8_t) value;
}
else if (ffStrEqualsIgnCase(key, "temperatureUnit"))
{
int value;
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
{ "CELSIUS", FF_TEMPERATURE_UNIT_CELSIUS },
{ "C", FF_TEMPERATURE_UNIT_CELSIUS },
{ "FAHRENHEIT", FF_TEMPERATURE_UNIT_FAHRENHEIT },
{ "F", FF_TEMPERATURE_UNIT_FAHRENHEIT },
{ "KELVIN", FF_TEMPERATURE_UNIT_KELVIN },
{ "K", FF_TEMPERATURE_UNIT_KELVIN },
{},
});
if (error) return error;
config->temperatureUnit = (FFTemperatureUnit) value;
}
else if (ffStrEqualsIgnCase(key, "percentType"))
config->percentType = (uint8_t) yyjson_get_uint(val);
else if (ffStrEqualsIgnCase(key, "percentNdigits"))
config->percentNdigits = (uint8_t) yyjson_get_uint(val);
else if (ffStrEqualsIgnCase(key, "bar"))
{
if (yyjson_is_obj(val))
{
const char* charElapsed = yyjson_get_str(yyjson_obj_get(val, "charElapsed"));
if (charElapsed)
ffStrbufSetS(&config->barCharElapsed, charElapsed);
const char* charTotal = yyjson_get_str(yyjson_obj_get(val, "charTotal"));
if (charTotal)
ffStrbufSetS(&config->barCharTotal, charTotal);
yyjson_val* border = yyjson_obj_get(val, "border");
if (border)
config->barBorder = yyjson_get_bool(border);
yyjson_val* width = yyjson_obj_get(val, "width");
if (width)
config->barWidth = (uint8_t) yyjson_get_uint(width);
}
else
return "display.bar must be an object";
}
else if (ffStrEqualsIgnCase(key, "noBuffer"))
config->noBuffer = yyjson_get_bool(val);
else if (ffStrEqualsIgnCase(key, "keyWidth"))
config->keyWidth = (uint32_t) yyjson_get_uint(val);
else
return "Unknown display property";
}
return NULL;
}
const char* ffParseLibraryJsonConfig(void)
{
FFconfig* config = &instance.config;
yyjson_val* const root = yyjson_doc_get_root(instance.state.configDoc);
assert(root);
if (!yyjson_is_obj(root))
return "Invalid JSON config format. Root value must be an object";
yyjson_val* object = yyjson_obj_get(root, "library");
if (!object) return NULL;
if (!yyjson_is_obj(object)) return "Property 'library' must be an object";
yyjson_val *key_, *val;
size_t idx, max;
yyjson_obj_foreach(object, idx, max, key_, val)
{
const char* key = yyjson_get_str(key_);
if (ffStrEqualsIgnCase(key, "pci"))
ffStrbufSetS(&config->libPCI, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "vulkan"))
ffStrbufSetS(&config->libVulkan, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "freetype"))
ffStrbufSetS(&config->libfreetype, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "wayland"))
ffStrbufSetS(&config->libWayland, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "xcbRandr"))
ffStrbufSetS(&config->libXcbRandr, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "xcb"))
ffStrbufSetS(&config->libXcb, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "Xrandr"))
ffStrbufSetS(&config->libXrandr, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "X11"))
ffStrbufSetS(&config->libX11, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "gio"))
ffStrbufSetS(&config->libGIO, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "DConf"))
ffStrbufSetS(&config->libDConf, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "dbus"))
ffStrbufSetS(&config->libDBus, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "XFConf"))
ffStrbufSetS(&config->libXFConf, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "sqlite") || ffStrEqualsIgnCase(key, "sqlite3"))
ffStrbufSetS(&config->libSQLite3, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "rpm"))
ffStrbufSetS(&config->librpm, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "imagemagick"))
ffStrbufSetS(&config->libImageMagick, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "z"))
ffStrbufSetS(&config->libZ, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "chafa"))
ffStrbufSetS(&config->libChafa, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "egl"))
ffStrbufSetS(&config->libEGL, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "glx"))
ffStrbufSetS(&config->libGLX, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "osmesa"))
ffStrbufSetS(&config->libOSMesa, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "opencl"))
ffStrbufSetS(&config->libOpenCL, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "pulse"))
ffStrbufSetS(&config->libPulse, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "nm"))
ffStrbufSetS(&config->libnm, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "ddcutil"))
ffStrbufSetS(&config->libDdcutil, yyjson_get_str(val));
else
return "Unknown library property";
}
return NULL;
}
void ffPrintJsonConfig(bool prepare)
{
const char* error = printJsonConfig(prepare);
const char* error = printJsonConfig(prepare, jsonDoc);
if (error)
ffPrintErrorString("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error);
{
if (jsonDoc)
{
yyjson_mut_val* obj = yyjson_mut_obj(jsonDoc);
yyjson_mut_obj_add_str(jsonDoc, obj, "error", error);
yyjson_mut_doc_set_root(jsonDoc, obj);
}
else
ffPrintErrorString("JsonConfig", 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "%s", error);
}
}
+19 -4
View File
@@ -4,7 +4,22 @@
bool ffJsonConfigParseModuleArgs(const char* key, yyjson_val* val, FFModuleArgs* moduleArgs);
const char* ffJsonConfigParseEnum(yyjson_val* val, int* result, FFKeyValuePair pairs[]);
void ffPrintJsonConfig(bool prepare);
const char* ffParseGeneralJsonConfig(void);
const char* ffParseDisplayJsonConfig(void);
const char* ffParseLibraryJsonConfig(void);
void ffPrintJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc);
void ffJsonConfigGenerateModuleArgsConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFModuleArgs* defaultModuleArgs, FFModuleArgs* moduleArgs);
yyjson_api_inline yyjson_mut_val* yyjson_mut_strbuf(yyjson_mut_doc *doc, const FFstrbuf* buf) {
return yyjson_mut_strncpy(doc, buf->chars, buf->length);
}
yyjson_api_inline bool yyjson_mut_obj_add_strbuf(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const char *_key,
const FFstrbuf* buf) {
return yyjson_mut_obj_add_strncpy(doc, obj, _key, buf->chars, buf->length);
}
yyjson_api_inline bool yyjson_mut_arr_add_strbuf(yyjson_mut_doc *doc,
yyjson_mut_val *obj,
const FFstrbuf* buf) {
return yyjson_mut_arr_add_strncpy(doc, obj, buf->chars, buf->length);
}
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_library
#define FF_INCLUDED_common_library
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
@@ -74,5 +71,3 @@ static inline void ffLibraryUnload(void** handle)
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue);
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
#endif
+58 -55
View File
@@ -5,31 +5,32 @@ static FFModuleBaseInfo* A[] = {
};
static FFModuleBaseInfo* B[] = {
(void*) &instance.config.battery,
(void*) &instance.config.bios,
(void*) &instance.config.bluetooth,
(void*) &instance.config.board,
(void*) &instance.config.break_,
(void*) &instance.config.brightness,
(void*) &instance.config.modules.battery,
(void*) &instance.config.modules.bios,
(void*) &instance.config.modules.bluetooth,
(void*) &instance.config.modules.board,
(void*) &instance.config.modules.break_,
(void*) &instance.config.modules.brightness,
NULL,
};
static FFModuleBaseInfo* C[] = {
(void*) &instance.config.chassis,
(void*) &instance.config.command,
(void*) &instance.config.colors,
(void*) &instance.config.cpu,
(void*) &instance.config.cpuUsage,
(void*) &instance.config.cursor,
(void*) &instance.config.custom,
(void*) &instance.config.modules.chassis,
(void*) &instance.config.modules.command,
(void*) &instance.config.modules.colors,
(void*) &instance.config.modules.cpu,
(void*) &instance.config.modules.cpuUsage,
(void*) &instance.config.modules.cursor,
(void*) &instance.config.modules.custom,
NULL,
};
static FFModuleBaseInfo* D[] = {
(void*) &instance.config.dateTime,
(void*) &instance.config.de,
(void*) &instance.config.display,
(void*) &instance.config.disk,
(void*) &instance.config.modules.dateTime,
(void*) &instance.config.modules.de,
(void*) &instance.config.modules.display,
(void*) &instance.config.modules.disk,
(void*) &instance.config.modules.diskIo,
NULL,
};
@@ -38,23 +39,23 @@ static FFModuleBaseInfo* E[] = {
};
static FFModuleBaseInfo* F[] = {
(void*) &instance.config.font,
(void*) &instance.config.modules.font,
NULL,
};
static FFModuleBaseInfo* G[] = {
(void*) &instance.config.gamepad,
(void*) &instance.config.gpu,
(void*) &instance.config.modules.gamepad,
(void*) &instance.config.modules.gpu,
NULL,
};
static FFModuleBaseInfo* H[] = {
(void*) &instance.config.host,
(void*) &instance.config.modules.host,
NULL,
};
static FFModuleBaseInfo* I[] = {
(void*) &instance.config.icons,
(void*) &instance.config.modules.icons,
NULL,
};
@@ -63,41 +64,43 @@ static FFModuleBaseInfo* J[] = {
};
static FFModuleBaseInfo* K[] = {
(void*) &instance.config.kernel,
(void*) &instance.config.modules.kernel,
NULL,
};
static FFModuleBaseInfo* L[] = {
(void*) &instance.config.lm,
(void*) &instance.config.locale,
(void*) &instance.config.localIP,
(void*) &instance.config.modules.lm,
(void*) &instance.config.modules.locale,
(void*) &instance.config.modules.localIP,
NULL,
};
static FFModuleBaseInfo* M[] = {
(void*) &instance.config.media,
(void*) &instance.config.memory,
(void*) &instance.config.monitor,
(void*) &instance.config.modules.media,
(void*) &instance.config.modules.memory,
(void*) &instance.config.modules.monitor,
NULL,
};
static FFModuleBaseInfo* N[] = {
(void*) &instance.config.modules.netIo,
NULL,
};
static FFModuleBaseInfo* O[] = {
(void*) &instance.config.openCL,
(void*) &instance.config.openGL,
(void*) &instance.config.os,
(void*) &instance.config.modules.openCL,
(void*) &instance.config.modules.openGL,
(void*) &instance.config.modules.os,
NULL,
};
static FFModuleBaseInfo* P[] = {
(void*) &instance.config.packages,
(void*) &instance.config.player,
(void*) &instance.config.powerAdapter,
(void*) &instance.config.processes,
(void*) &instance.config.publicIP,
(void*) &instance.config.modules.packages,
(void*) &instance.config.modules.physicalDisk,
(void*) &instance.config.modules.player,
(void*) &instance.config.modules.powerAdapter,
(void*) &instance.config.modules.processes,
(void*) &instance.config.modules.publicIP,
NULL,
};
@@ -110,40 +113,40 @@ static FFModuleBaseInfo* R[] = {
};
static FFModuleBaseInfo* S[] = {
(void*) &instance.config.separator,
(void*) &instance.config.shell,
(void*) &instance.config.sound,
(void*) &instance.config.swap,
(void*) &instance.config.modules.separator,
(void*) &instance.config.modules.shell,
(void*) &instance.config.modules.sound,
(void*) &instance.config.modules.swap,
NULL,
};
static FFModuleBaseInfo* T[] = {
(void*) &instance.config.terminal,
(void*) &instance.config.terminalFont,
(void*) &instance.config.terminalSize,
(void*) &instance.config.title,
(void*) &instance.config.theme,
(void*) &instance.config.modules.terminal,
(void*) &instance.config.modules.terminalFont,
(void*) &instance.config.modules.terminalSize,
(void*) &instance.config.modules.title,
(void*) &instance.config.modules.theme,
NULL,
};
static FFModuleBaseInfo* U[] = {
(void*) &instance.config.uptime,
(void*) &instance.config.users,
(void*) &instance.config.modules.uptime,
(void*) &instance.config.modules.users,
NULL,
};
static FFModuleBaseInfo* V[] = {
(void*) &instance.config.version,
(void*) &instance.config.vulkan,
(void*) &instance.config.modules.version,
(void*) &instance.config.modules.vulkan,
NULL,
};
static FFModuleBaseInfo* W[] = {
(void*) &instance.config.wallpaper,
(void*) &instance.config.weather,
(void*) &instance.config.wm,
(void*) &instance.config.wifi,
(void*) &instance.config.wmTheme,
(void*) &instance.config.modules.wallpaper,
(void*) &instance.config.modules.weather,
(void*) &instance.config.modules.wm,
(void*) &instance.config.modules.wifi,
(void*) &instance.config.modules.wmTheme,
NULL,
};
+30
View File
@@ -0,0 +1,30 @@
#include "netif.h"
#ifndef _WIN32
#include <net/if.h>
#else
#define IF_NAMESIZE 16
#endif
bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex);
enum { IF_INDEX_UNINITIALIZED = (uint32_t) -1, IF_INDEX_INVALID = (uint32_t) -2 };
static uint32_t ifIndex = IF_INDEX_UNINITIALIZED;
static char ifName[IF_NAMESIZE + 1];
static inline void init()
{
if (ifIndex == (uint32_t) IF_INDEX_UNINITIALIZED && !ffNetifGetDefaultRouteImpl(ifName, &ifIndex))
ifIndex = (uint32_t) IF_INDEX_INVALID;
}
const char* ffNetifGetDefaultRouteIfName()
{
init();
return ifName;
}
uint32_t ffNetifGetDefaultRouteIfIndex()
{
init();
return ifIndex;
}
+9
View File
@@ -0,0 +1,9 @@
#pragma once
#include "fastfetch.h"
#ifndef _WIN32
const char* ffNetifGetDefaultRouteIfName();
#endif
uint32_t ffNetifGetDefaultRouteIfIndex();
+98
View File
@@ -0,0 +1,98 @@
#include "netif.h"
#include "common/io/io.h"
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n))
#if defined(__APPLE__)
# define ROUNDUP(a) ROUNDUP2((a), sizeof(int))
#elif defined(__NetBSD__)
# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t))
#elif defined(__FreeBSD__)
# define ROUNDUP(a) ROUNDUP2((a), sizeof(int))
#elif defined(__OpenBSD__)
# define ROUNDUP(a) ROUNDUP2((a), sizeof(int))
#else
# error unknown platform
#endif
static struct sockaddr *
get_rt_address(struct rt_msghdr *rtm, int desired)
{
struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
for (int i = 0; i < RTAX_MAX; i++)
{
if (rtm->rtm_addrs & (1 << i))
{
if ((1 <<i ) == desired)
return sa;
sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa);
}
}
return NULL;
}
bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex)
{
//https://github.com/hashPirate/copenheimer-masscan-fork/blob/36f1ed9f7b751a7dccd5ed27874e2e703db7d481/src/rawsock-getif.c#L104
FF_AUTO_CLOSE_FD int pfRoute = socket(PF_ROUTE, SOCK_RAW, AF_INET);
if (pfRoute < 0)
return false;
{
struct timeval timeout = {1, 0};
setsockopt(pfRoute, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
setsockopt(pfRoute, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
}
int pid = getpid();
struct {
struct rt_msghdr hdr;
struct sockaddr_in dst;
uint8_t data[512];
} rtmsg = {
.hdr = {
.rtm_type = RTM_GET,
.rtm_flags = RTF_UP | RTF_GATEWAY,
.rtm_version = RTM_VERSION,
.rtm_addrs = RTA_DST | RTA_IFP,
.rtm_msglen = sizeof(rtmsg.hdr) + sizeof(rtmsg.dst),
.rtm_pid = pid,
.rtm_seq = 1,
},
.dst = {
.sin_family = AF_INET,
.sin_len = sizeof(rtmsg.dst),
},
};
if (write(pfRoute, &rtmsg, rtmsg.hdr.rtm_msglen) != rtmsg.hdr.rtm_msglen)
return false;
while (read(pfRoute, &rtmsg, sizeof(rtmsg)) > 0)
{
if (rtmsg.hdr.rtm_seq == 1 && rtmsg.hdr.rtm_pid == pid)
{
struct sockaddr_dl* sdl = (struct sockaddr_dl *)get_rt_address(&rtmsg.hdr, RTA_IFP);
if (sdl)
{
assert(sdl->sdl_nlen <= IF_NAMESIZE);
memcpy(iface, sdl->sdl_data, sdl->sdl_nlen);
iface[sdl->sdl_nlen] = '\0';
*ifIndex = sdl->sdl_index;
return true;
}
return false;
}
}
return false;
}
+28
View File
@@ -0,0 +1,28 @@
#include "netif.h"
#include "common/io/io.h"
#include <net/if.h>
#include <stdio.h>
#define FF_STR_INDIR(x) #x
#define FF_STR(x) FF_STR_INDIR(x)
bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex)
{
FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r");
if (!netRoute) return false;
// skip first line
flockfile(netRoute);
while (getc_unlocked(netRoute) != '\n');
funlockfile(netRoute);
unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu,
while (fscanf(netRoute, "%" FF_STR(IF_NAMESIZE) "s%llx%*[^\n]", iface, &destination) == 2)
{
if (destination != 0) continue;
*ifIndex = if_nametoindex(iface);
return true;
}
return false;
}
+27
View File
@@ -0,0 +1,27 @@
#include "netif.h"
#include "util/mallocHelper.h"
#include <iphlpapi.h>
bool ffNetifGetDefaultRouteImpl(FF_MAYBE_UNUSED char* iface/* unsupported */, uint32_t* ifIndex)
{
ULONG size = 0;
if (GetIpForwardTable(NULL, &size, TRUE) != ERROR_INSUFFICIENT_BUFFER)
return false;
FF_AUTO_FREE MIB_IPFORWARDTABLE* pIpForwardTable = (MIB_IPFORWARDTABLE*) malloc(size);
if (GetIpForwardTable(pIpForwardTable, &size, TRUE) != ERROR_SUCCESS)
return false;
for (uint32_t i = 0; i < pIpForwardTable->dwNumEntries; ++i)
{
MIB_IPFORWARDROW* ipForwardRow = &pIpForwardTable->table[i];
if (ipForwardRow->dwForwardDest == 0 && ipForwardRow->dwForwardMask == 0)
{
*ifIndex = ipForwardRow->dwForwardIfIndex;
break;
}
}
return true;
}
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_networking
#define FF_INCLUDED_common_networking
#include "common/thread.h"
#include "util/FFstrbuf.h"
@@ -35,5 +32,3 @@ static inline bool ffNetworkingGetHttp(const char* host, const char* path, uint3
return ffNetworkingRecvHttpResponse(&state, buffer, timeout);
return false;
}
#endif
+4 -3
View File
@@ -77,7 +77,8 @@ bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, con
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout)
{
#ifdef FF_HAVE_THREADS
ffThreadJoin(state->thread);
if (!ffThreadJoin(state->thread, timeout))
return false;
#endif
if(state->sockfd == -1)
return false;
@@ -85,8 +86,8 @@ bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, ui
if(timeout > 0)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = (__typeof__(timev.tv_usec)) (timeout * 1000); //milliseconds to microseconds
timev.tv_sec = timeout / 1000;
timev.tv_usec = (__typeof__(timev.tv_usec)) ((timeout % 1000) * 1000); //milliseconds to microseconds
setsockopt(state->sockfd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
}
+19 -1
View File
@@ -3,28 +3,46 @@
#include "util/FFstrbuf.h"
struct yyjson_val;
struct yyjson_mut_doc;
struct yyjson_mut_val;
// Must be the first field of FFModuleOptions
typedef struct FFModuleBaseInfo
{
const char* name;
const char* description;
// A dirty polymorphic implementation in C.
// This is UB, because `void*` is not compatible with `FF*Options*`.
// However we can't do it better unless we move to C++, so that `option` becomes a `this` pointer
// https://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type
bool (*parseCommandOptions)(void* options, const char* key, const char* value);
void (*parseJsonObject)(void* options, struct yyjson_val *module);
void (*printModule)(void* options);
void (*generateJsonResult)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* module);
void (*printHelpFormat)(void);
void (*generateJsonConfig)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* obj);
} FFModuleBaseInfo;
static inline void ffOptionInitModuleBaseInfo(
FFModuleBaseInfo* baseInfo,
const char* name,
const char* description,
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
void* printModule // void (*const printModule)(void* options)
void* printModule, // void (*const printModule)(void* options)
void* generateJsonResult, // void (*const generateJsonResult)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj)
void (*printHelpFormat)(void),
void* generateJsonConfig // void (*const generateJsonConfig)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj)
)
{
baseInfo->name = name;
baseInfo->description = description;
baseInfo->parseCommandOptions = (__typeof__(baseInfo->parseCommandOptions)) parseCommandOptions;
baseInfo->parseJsonObject = (__typeof__(baseInfo->parseJsonObject)) parseJsonObject;
baseInfo->printModule = (__typeof__(baseInfo->printModule)) printModule;
baseInfo->generateJsonResult = (__typeof__(baseInfo->generateJsonResult)) generateJsonResult;
baseInfo->printHelpFormat = printHelpFormat;
baseInfo->generateJsonConfig = (__typeof__(baseInfo->generateJsonConfig)) generateJsonConfig;
}
typedef struct FFModuleArgs
+4 -4
View File
@@ -65,7 +65,7 @@ static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, const cha
double size = (double) bytes;
uint8_t counter = 0;
while(size >= base && counter < instance.config.sizeMaxPrefix && prefixes[counter + 1])
while(size >= base && counter < instance.config.display.sizeMaxPrefix && prefixes[counter + 1])
{
size /= base;
counter++;
@@ -74,12 +74,12 @@ static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, const cha
if(counter == 0)
ffStrbufAppendF(result, "%"PRIu64" %s", bytes, prefixes[0]);
else
ffStrbufAppendF(result, "%.*f %s", instance.config.sizeNdigits, size, prefixes[counter]);
ffStrbufAppendF(result, "%.*f %s", instance.config.display.sizeNdigits, size, prefixes[counter]);
}
void ffParseSize(uint64_t bytes, FFstrbuf* result)
{
switch (instance.config.binaryPrefixType)
switch (instance.config.display.binaryPrefixType)
{
case FF_BINARY_PREFIX_TYPE_IEC:
parseSize(result, bytes, 1024, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", NULL});
@@ -98,7 +98,7 @@ void ffParseSize(uint64_t bytes, FFstrbuf* result)
void ffParseTemperature(double celsius, FFstrbuf* buffer)
{
switch (instance.config.temperatureUnit)
switch (instance.config.display.temperatureUnit)
{
case FF_TEMPERATURE_UNIT_CELSIUS:
ffStrbufAppendF(buffer, "%.1f°C", celsius);
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_parsing_h
#define FF_INCLUDED_parsing_h
#include "fastfetch.h"
#include <stdint.h>
@@ -24,5 +21,3 @@ int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
void ffParseSize(uint64_t bytes, FFstrbuf* result);
void ffParseTemperature(double celsius, FFstrbuf* buffer);
#endif
+32 -15
View File
@@ -6,20 +6,24 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
{
ffLogoPrintLine();
//This is used by --set-keyless, in this case we wan't neither the module name nor the separator
//This is used by --set-keyless, in this case we want neither the module name nor the separator
if(moduleName == NULL)
return;
if(!instance.config.pipe)
//This is used as a magic value for hiding keys
if(moduleArgs && ffStrbufEqualS(&moduleArgs->key, " "))
return;
if(!instance.config.display.pipe)
{
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
if (instance.config.brightColor)
if (instance.config.display.brightColor)
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
if(moduleArgs && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR) && moduleArgs->keyColor.length > 0)
ffPrintColor(&moduleArgs->keyColor);
else
ffPrintColor(&instance.config.colorKeys);
ffPrintColor(&instance.config.display.colorKeys);
}
//NULL check is required for modules with custom keys, e.g. disk with the folder path
@@ -39,18 +43,18 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
ffStrbufWriteTo(&key, stdout);
}
if(!instance.config.pipe)
if(!instance.config.display.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
ffStrbufWriteTo(&instance.config.keyValueSeparator, stdout);
ffStrbufWriteTo(&instance.config.display.keyValueSeparator, stdout);
if(!instance.config.pipe)
if(!instance.config.display.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
if (!instance.config.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
if (!instance.config.display.pipe && !(printType & FF_PRINT_TYPE_NO_CUSTOM_KEY_WIDTH))
{
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.keyWidth;
uint32_t keyWidth = moduleArgs && moduleArgs->keyWidth > 0 ? moduleArgs->keyWidth : instance.config.display.keyWidth;
if (keyWidth > 0)
printf("\e[%uG", (unsigned) (keyWidth + instance.state.logoWidth));
}
@@ -73,17 +77,17 @@ void ffPrintFormatString(const char* moduleName, uint8_t moduleIndex, const FFMo
static void printError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, va_list arguments)
{
if(!instance.config.showErrors)
if(!instance.config.display.showErrors)
return;
ffPrintLogoAndKey(moduleName, moduleIndex, moduleArgs, printType);
if(!instance.config.pipe)
if(!instance.config.display.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout);
vprintf(message, arguments);
if(!instance.config.pipe)
if(!instance.config.display.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
putchar('\n');
@@ -112,9 +116,7 @@ void ffPrintColor(const FFstrbuf* colorValue)
if(colorValue->length == 0)
return;
fputs("\033[", stdout);
ffStrbufWriteTo(colorValue, stdout);
fputc('m', stdout);
printf("\e[%sm", colorValue->chars);
}
void ffPrintCharTimes(char c, uint32_t times)
@@ -130,3 +132,18 @@ void ffPrintCharTimes(char c, uint32_t times)
if(remaining > 0)
fwrite(str, 1, remaining, stdout);
}
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[])
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateS(name);
ffStrbufLowerCase(&buffer);
printf("--%s-format:\n", buffer.chars);
printf("Sets the format string for %s output.\n", name);
puts("To see how a format string is constructed, take a look at \"fastfetch --help format\".");
puts("The following values are passed:");
for(unsigned i = 0; i < numArgs; i++)
printf(" {%u}: %s\n", i + 1, args[i]);
printf("The default is something similar to \"%s\".\n", def);
}
+1 -4
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_printing
#define FF_INCLUDED_common_printing
#include "fastfetch.h"
#include "common/format.h"
@@ -25,4 +22,4 @@ FF_C_PRINTF(4, 5) void ffPrintError(const char* moduleName, uint8_t moduleIndex,
void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times);
#endif
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]);
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_processing
#define FF_INCLUDED_common_processing
#include "util/FFstrbuf.h"
const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr);
@@ -28,5 +25,3 @@ static inline const char* ffProcessAppendStdErr(FFstrbuf* buffer, char* const ar
}
return error;
}
#endif
+36 -25
View File
@@ -11,47 +11,62 @@
#include <errno.h>
#include <sys/wait.h>
enum { FF_PIPE_BUFSIZ = 4096 };
enum { FF_PIPE_BUFSIZ = 8192 };
static inline void waitpid_wrapper(pid_t* pid)
static inline void waitpid_wrapper(const pid_t* pid)
{
// remove zombie processes
if (*pid > 0)
waitpid(*pid, NULL, 0);
}
static inline int ffPipe2(int *fds, int flags)
{
#ifdef __APPLE__
if(pipe(fds) == -1)
return -1;
fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
fcntl(fds[1], F_SETFL, fcntl(fds[1], F_GETFL) | flags);
return 0;
#else
return pipe2(fds, flags);
#endif
}
const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr)
{
int pipes[2];
const int timeout = instance.config.general.processingTimeout;
if(pipe(pipes) == -1)
if(ffPipe2(pipes, O_CLOEXEC) == -1)
return "pipe() failed";
__attribute__((__cleanup__(waitpid_wrapper))) pid_t childPid = fork();
if(childPid == -1)
{
close(pipes[0]);
close(pipes[1]);
return "fork() failed";
}
//Child
if(childPid == 0)
{
int nullFile = open("/dev/null", O_WRONLY | O_CLOEXEC);
dup2(pipes[1], useStdErr ? STDERR_FILENO : STDOUT_FILENO);
close(pipes[0]);
close(pipes[1]);
close(useStdErr ? STDOUT_FILENO : STDERR_FILENO);
dup2(nullFile, useStdErr ? STDOUT_FILENO : STDERR_FILENO);
setenv("LANG", "C", 1);
execvp(argv[0], argv);
exit(901);
_exit(127);
}
//Parent
close(pipes[1]);
int FF_AUTO_CLOSE_FD childPipeFd = pipes[0];
char str[FF_PIPE_BUFSIZ];
int timeout = instance.config.processingTimeout;
if (timeout >= 0)
fcntl(childPipeFd, F_SETFL, fcntl(childPipeFd, F_GETFL) | O_NONBLOCK);
do
while(1)
{
if (timeout >= 0)
{
@@ -68,18 +83,14 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
}
}
char str[FF_PIPE_BUFSIZ];
while (true)
{
ssize_t nRead = read(childPipeFd, str, FF_PIPE_BUFSIZ);
if (nRead > 0)
ffStrbufAppendNS(buffer, (uint32_t) nRead, str);
else if (nRead == 0)
return NULL;
else if (nRead < 0)
break;
}
} while (errno == EAGAIN);
ssize_t nRead = read(childPipeFd, str, FF_PIPE_BUFSIZ);
if (nRead > 0)
ffStrbufAppendNS(buffer, (uint32_t) nRead, str);
else if (nRead == 0)
return NULL;
else if (nRead < 0)
break;
};
return NULL;
return "read(childPipeFd, str, FF_PIPE_BUFSIZ) failed";
}
+2 -2
View File
@@ -4,11 +4,11 @@
#include <Windows.h>
enum { FF_PIPE_BUFSIZ = 4096 };
enum { FF_PIPE_BUFSIZ = 8192 };
const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool useStdErr)
{
int timeout = instance.config.processingTimeout;
int timeout = instance.config.general.processingTimeout;
FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = CreateNamedPipeW(
L"\\\\.\\pipe\\LOCAL\\",
+1 -1
View File
@@ -91,7 +91,7 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer)
// The following functions return true if the file was found, independently if start was found
// Buffers which already contain content are not overwritten
// The last occurence of start in the first file will be the one used
// The last occurrence of start in the first file will be the one used
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
{
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_properties
#define FF_INCLUDED_common_properties
#include "fastfetch.h"
typedef struct FFpropquery
@@ -51,5 +48,3 @@ static inline bool ffParsePropFileData(const char* relativeFile, const char* sta
{
return ffParsePropFileDataValues(relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
#endif
+4 -11
View File
@@ -15,18 +15,14 @@ typedef enum FFInitState
#define FF_LIBRARY_DATA_LOAD_INIT(dataObject, userLibraryName, ...) \
static dataObject data; \
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; \
static FFInitState initState = FF_INITSTATE_UNINITIALIZED; \
ffThreadMutexLock(&mutex); \
if(initState != FF_INITSTATE_UNINITIALIZED) {\
ffThreadMutexUnlock(&mutex); \
return initState == FF_INITSTATE_SUCCESSFUL ? &data : NULL; \
} \
initState = FF_INITSTATE_SUCCESSFUL; \
void* libraryHandle = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL); \
if(libraryHandle == NULL) { \
initState = FF_INITSTATE_FAILED; \
ffThreadMutexUnlock(&mutex); \
return NULL; \
} \
@@ -35,20 +31,17 @@ typedef enum FFInitState
if(data.ff ## symbolName == NULL) { \
dlclose(libraryHandle); \
initState = FF_INITSTATE_FAILED; \
ffThreadMutexUnlock(&mutex); \
return NULL; \
}
#define FF_LIBRARY_DATA_LOAD_RETURN \
initState = FF_INITSTATE_SUCCESSFUL; \
ffThreadMutexUnlock(&mutex); \
return &data;
#define FF_LIBRARY_DATA_LOAD_ERROR \
{ \
dlclose(libraryHandle); \
initState = FF_INITSTATE_FAILED; \
ffThreadMutexUnlock(&mutex); \
return NULL; \
}
@@ -99,7 +92,7 @@ typedef struct GSettingsData
static const GSettingsData* getGSettingsData(void)
{
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance.config.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance.config.library.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_lookup)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_has_key)
@@ -172,7 +165,7 @@ typedef struct DConfData
static const DConfData* getDConfData(void)
{
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance.config.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2);
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance.config.library.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2);
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_read_full)
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_new)
@@ -243,7 +236,7 @@ typedef struct XFConfData
static const XFConfData* getXFConfData(void)
{
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance.config.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance.config.library.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get)
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_has_property)
@@ -305,7 +298,7 @@ typedef struct SQLiteData
static const SQLiteData* getSQLiteData(void)
{
FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance.config.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance.config.library.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_open_v2)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_prepare_v2)
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_settings
#define FF_INCLUDED_common_settings
#include "fastfetch.h"
typedef enum FFvarianttype
@@ -38,5 +35,3 @@ bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
#elif defined(__FreeBSD__)
bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result);
#endif
#endif
-5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_sysctl
#define FF_INCLUDED_common_sysctl
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
@@ -13,5 +10,3 @@ const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
#endif
+38 -7
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_common_thread
#define FF_INCLUDED_common_thread
#include "fastfetch.h"
#ifdef FF_HAVE_THREADS
@@ -10,6 +7,7 @@
#include <handleapi.h>
#include <synchapi.h>
#include <process.h>
#include <processthreadsapi.h>
#define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
typedef SRWLOCK FFThreadMutex;
typedef HANDLE FFThreadType;
@@ -21,9 +19,23 @@
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; }
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) static __stdcall unsigned fn ## ThreadMain () { fn(); return 0; }
static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); }
static inline void ffThreadJoin(FFThreadType thread) { WaitForSingleObject(thread, 0xffffffff /*INFINITE*/); }
static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout)
{
if (WaitForSingleObject(thread, timeout == 0 ? (DWORD) -1 : timeout) != 0 /*WAIT_OBJECT_0*/)
{
TerminateThread(thread, (DWORD) -1);
CloseHandle(thread);
return false;
}
CloseHandle(thread);
return true;
}
#else
#include <pthread.h>
#include <signal.h>
#if __has_include(<pthread_np.h>)
#include <pthread_np.h>
#endif
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
typedef pthread_mutex_t FFThreadMutex;
typedef pthread_t FFThreadType;
@@ -37,7 +49,28 @@
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static void* fn ## ThreadMain (void* data) { fn((paramType)data); return NULL; }
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) static void* fn ## ThreadMain () { fn(); return NULL; }
static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); }
static inline void ffThreadJoin(FFThreadType thread) { pthread_join(thread, NULL); }
static inline bool ffThreadJoin(FFThreadType thread, FF_MAYBE_UNUSED uint32_t timeout)
{
#if (defined(__linux__) && !defined(__ANDROID__)) || __has_include(<pthread_np.h>)
if (timeout > 0)
{
struct timespec ts;
if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
{
ts.tv_sec += ts.tv_sec / 1000;
ts.tv_nsec += (ts.tv_nsec % 1000) * 1000000;
if (pthread_timedjoin_np(thread, NULL, &ts) != 0)
{
pthread_kill(thread, SIGTERM);
return false;
}
return true;
}
}
#endif
pthread_join(thread, NULL);
return true;
}
#endif
#else //FF_HAVE_THREADS
#define FF_THREAD_MUTEX_INITIALIZER 0
@@ -46,5 +79,3 @@
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { FF_UNUSED(mutex) }
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
#endif //FF_HAVE_THREADS
#endif
+14 -5
View File
@@ -1,12 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_common_time
#define FF_INCLUDED_common_time
#include <stdint.h>
#ifdef _WIN32
#include <synchapi.h>
#include <profileapi.h>
#include <sysinfoapi.h>
#else
#include <time.h>
#endif
@@ -26,6 +24,19 @@ static inline uint64_t ffTimeGetTick() //In msec
#endif
}
static inline uint64_t ffTimeGetNow()
{
#ifdef _WIN32
uint64_t timeNow;
GetSystemTimeAsFileTime((FILETIME*) &timeNow);
return (timeNow - 116444736000000000ull) / 10000ull;
#else
struct timespec timeNow;
clock_gettime(CLOCK_REALTIME, &timeNow);
return (uint64_t)((timeNow.tv_sec * 1000) + (timeNow.tv_nsec / 1000000));
#endif
}
static inline void ffTimeSleep(uint32_t msec)
{
#ifdef _WIN32
@@ -34,5 +45,3 @@ static inline void ffTimeSleep(uint32_t msec)
nanosleep(&(struct timespec){ msec / 1000, (msec % 1000) * 1000000 }, NULL);
#endif
}
#endif
-16
View File
@@ -1,16 +0,0 @@
# Fastfetch system configuration
# This file sets the default config for all users of the system.
# For more information about how configuration files work,
# see ~/.config/fastfetch/config.conf, generated during first run.
# All options that can be put there (or passed as argument) can be put here too.
# Use fastfetch --print-config-system > /etc/fastfetch/config.conf
# to overwrite this file with the current default file.
# User config option
# Sets if fastfetch should load user provided configuration.
# If this is off, fastfetch ignores the user config file and any passed arguments
# Must be true or false
# Default is true.
#--load-user-config true
-43
View File
@@ -1,43 +0,0 @@
// ~/.config/fastfetch/config.jsonc
// See https://github.com/fastfetch-cli/fastfetch/wiki/Configuration for more details
// See *.jsonc in https://github.com/fastfetch-cli/fastfetch/tree/dev/presets/examples for more examples
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"padding": {
"top": 2
}
},
"display": {
"percentType": 9 // colored percent number
},
"modules": [
"title",
"separator",
"os",
"host",
"kernel",
"uptime",
"packages",
"shell",
"display",
"de",
"wm",
"wmtheme",
"theme",
"icons",
"font",
"cursor",
"terminal",
"terminalfont",
"cpu",
"gpu",
"memory",
"disk",
"battery",
"poweradapter",
"locale",
"break",
"colors"
]
}
-514
View File
@@ -1,514 +0,0 @@
# Fastfetch configuration
# Write every argument in different lines.
# Direct arguments will overwrite the corresponding ones in this file.
# Argument keys are not case sensitive.
# Whitespaces are trimmed at the beginning and the end.
# Empty lines or lines starting with # are ignored.
# This file was shipped with $" FASTFETCH_PROJECT_VERSION $".
# Use fastfetch --gen-config-force to overwrite this file with the current defaults
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
# Of course all of them can be made persistent here too.
# Config option:
# Load additional config files.
# Some are shipped with fastfetch, list them with "fastfetch --list-presets".
# Must be a path to a config file or the name of a shipped preset.
# The config file is completely loaded before continuing in the current file, so the placement of this option matters, as later options overwrite already set ones.
# Can be used multiple times to load multiple config files / presets.
#--load-config /path/to/config.txt
# Structure option:
# Sets the modules to use and their order.
# Must be a list of module names, separated by colons.
# List available modules with "fastfetch --list-modules".
# Get the default structure with "fastfetch --print-structure".
#--structure $" FASTFETCH_DATATEXT_STRUCTURE $"
# Multithreading option:
# Sets if fastfetch should use multiple threads to detect the values.
# Must be true or false.
# Default is true.
#--multithreading true
# Print stat option:
# Sets if fastfetch should print time usage (in ms) for individual modules
# If true, it will also enable --show-errors
# Must be true or false.
# Default is false.
#--stat true
# Slow operations option:
# Sets if fastfetch is allowed to use known slow operations to detect more / better values.
# Must be true or false.
# Default is false.
#--allow-slow-operations false
# Linewrap option:
# Sets if fastfetch should disable linewrap during the run.
# Must be true or false.
# Default is true.
#--disable-linewrap true
# Cursor option:
# Sets if fastfetch should hide the console cursor during the run.
# Must be true or false.
# Default is true.
#--hide-cursor true
# Processing timeout option:
# Sets the timeout (ms) when waiting for child processes
# Must be an integer.
# Default is 1000
#--processing-timeout 1000
# WMI timeout option:
# Sets the timeout (ms) for WMI queries. Windows only
# Must be an integer.
# Default is 5000
#--wmi-timeout 5000
# Logo option:
# Sets the logo to use.
# List available logos with "fastfetch --list-logos".
# Print available logos with "fastfetch --print-logos".
# Must be the name of an available logo or a path to a text file containing a custom logo.
# Default is the current distribution.
#--logo arch
# Logo type option:
# Sets the logo type to use.
# Must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty or chafa.
# Default is auto.
#--logo-type auto
# Logo width option:
# Sets the width of the logo (in characters) if the logo is an image.
# Must be a positive integer.
# Default is 65.
#--logo-width 65
# Logo height option:
# Sets the height of the logo (in characters) if the logo is an image.
# Must be a positive integer.
# Default is 0 (keeps aspect ration).
#--logo-height 0
# Logo color options:
# Overwrite a color in the logo. Also works for user provided logos.
# In the user logo, they replace $[1-9]. Use $$ to print a single $ sign.
# Must be linux console color codes or the name of a color.
# Default is the one specified by the logo.
# Use "fastfetch --help color" to learn more and see examples.
# Valid index range is [1-9].
#--logo-color-1 red
#--logo-color-2 32
# [...]
#--logo-color-9 yellow
# Logo padding option:
# Adds a padding to the left and the right side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding 0
# Logo padding left option:
# Adds a padding to the left side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding-left 0
# Logo padding right option:
# Adds a padding to the right side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding-right 0
# Logo padding top option:
# Adds a padding to the top side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding-top 0
# Logo print remaining option:
# Sets if the remaining logo should be printed, it is has more lines than modules to show.
# Must be true or false.
# Default is true.
#--logo-print-remaining true
# Color keys option:
# Sets the color of the keys.
# Must be linux console color codes or the name of a color.
# Default is the key color of the logo.
# Use "fastfetch --help color" to learn more and see examples.
#--color-keys magenta
# Color title option:
# Sets the color of the title.
# Must be linux console color codes or the name of a color.
# Default is the title color of the logo.
# Use "fastfetch --help color" to learn more and see examples.
#--color-title magenta
# Binary prefix option:
# Sets the binary prefix to use.
# Must be a IEC, SI or JEDEC.
# Default is IEC.
#--binary-prefix IEC
# Size number of digits option:
# Sets the number of digits to keep after the decimal point when formatting sizes.
# Must be an possitive integer.
# Default is 2.
#--size-ndigits 2
# Size max prefix option:
# Sets the largest binary prefix to use when formatting sizes.
# Must be one of B, kB, MB, GB, TB, PB, EB, ZB, YB
# Default is YB.
#--size-max-prefix YB
# Disable output buffer option:
# Sets if the stdout application buffer should be disabled.
# Must be true or false.
# Default is false.
#--no-buffer false
# Title FQDN option:
# Sets if the title should use the fully qualified domain name.
# Must be true or false.
# Default is false.
#--title-fqdn false
# Title user color option:
# Sets color of the user name (left part).
# Default is empty (use color of `--color-title`).
#--title-color-user
# Title at color option:
# Sets color of the @ symbol (middle part).
# Default is empty (use color of `--color-title`).
#--title-color-at
# Title host color option:
# Sets color of the host name (right part).
# Default is empty (use color of `--color-title`).
#--title-color-host
# Separator option:
# Sets the string placed between a key and its value.
# Can be any string.
# Default is ": ".
#--separator ": "
# Separator string option:
# Sets the string printed by the "separator" module (usually between title and rest of output)
# Must be any string. It is repated / cut to fit perfectly.
# Default is "-"
#--separator-string -
# Public IP URL option:
# Sets the URL of public IP detection server to be used.
# Only HTTP protocol is supported, and the value should not contain "http://" prefix.
# Default is "ipinfo.io/ip".
#--publicip-url "ipinfo.io/ip"
# Public IP timeout option:
# Sets the time to wait for the public ip server to respond.
# Must be a positive integer.
# Default is 0 (disabled).
#--publicip-timeout 0
# Weather location option:
# Sets the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`).
# Default is empty (guessing by public IP)
#--weather-location "Location"
# Weather output format option:
# Sets the weather format to be used. It must be URI encoded.
# See: https://github.com/chubin/wttr.in#one-line-output
# Default is "%t+-+%C+(%l)".
#--weather-output-format "%t+-+%C+(%l)"
# Weather timeout option:
# Sets the time to wait for the weather server (wttr.in) to respond.
# Must be a positive integer.
# Default is 0 (disabled).
#--weather-timeout 0
# OS file option
# Sets the path to the file containing the operating system information.
# Should be a valid path to an existing file.
# Default is /etc/os-release.
#--os-file /etc/os-release
# Player name option
# Sets the name of the player. This is also used in song detection
# Must be the exact name of the player or a dbus address (e.g. org.mpris.MediaPlayer2.spotify)
# Default is the first match starting with org.mpris.MediaPlayer2.
#--player-name spotify
# Display server force DRM option
# Sets if fastfetch should only use `/sys/class/drm` to detect displays if you get issues with the default behavior.
# Note DRM doesn't support refresh rate or scaled resolution detection.
# Only supported on Linux.
# Must be true or false.
# Default is false.
#--ds-force-drm false
# Escape bedrock option
# Sets if fastfetch should escape the bedrock jail, if it detectes that it is running in one
# Must be true or false.
# Default is true.
#--escape-bedrock true
# OpenGL option
# Sets with opengl context creation library to use
# Must be either auto, egl, glx or osmesa
# Default is auto.
#--opengl-library auto
# GPU hide options
# Sets whether to hide certain gpu types
# Must be either true or false
# Default is false.
#--gpu-hide-integrated
#--gpu-hide-discrete
# GPU detection options
# Forces using vulkan to detect GPUs
# which support video memory usage detection with `--allow-slow-operations`
# Must be either true or false
# Default is false.
#--gpu-force-vulkan
# Disk show options
# Sets if certain types of disk should be printed
# Must be either true or false
# Default is false except for --disk-show-external.
#--disk-show-external true
#--disk-show-hidden false
#--disk-show-subvolumes false
#--disk-show-unknown false
# Disk option
# A colon (semicolon on Windows) separated list of folder paths for the disk output
# This option override `--disk-show-*` options above
# Must be a string
# Default is "/:/home" ("C:\\;D:\\ ..." on Windows).
#--disk-folders /:/home
# Bluetooth show disconnected option
# Sets if disconnected bluetooth devices should be printed
# Must be either true or false
# Default is false.
#--bluetooth-show-disconnected false
# Display compact output option
# Sets if all displays should be printed in one line
# Must be either original (print pixel resolution) or scaled (print scaled resolution)
# Default is none.
#--display-compact-type none
# Display detect name option
# Sets if display name should be detected and printed (if supported)
# Must be either true of false
# Default is false.
#--display-detect-name none
# Display precise refresh rate option
# Sets if decimal refresh rates should not be rounded into integers when printing
# Must be either true (keep decimals) of false (round into integers)
# Default is false.
#--display-precise-refresh-rate false
# Sound show all option
# Sets if all sound devices should be printed
# Must be either main, active or all. Default is main
# Default is main.
#--sound-type main
# Percentage output type option
# Applies to all modules that prints percentage values. Currently memory, swap, disk, battery and CPU usage are supported.
# Only works with default format ( without --module-format option ).
# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar; 6: prints bar and hide other texts; 9: prints colored number
#--percent-type 1
# Key options:
# Sets the displayed key of a module
# Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help.
#--os-key OS
#--host-key Host
#--chassis-key Chassis
#--kernel-key Kernel
#--uptime-key Uptime
#--processes-key Processes
#--packages-key Packages
#--shell-key Shell
#--display-key Display {1}
#--brightness-key Brightness ({1})
#--monitor-key Monitor
#--de-key DE
#--wm-key WM
#--wmtheme-key WM Theme
#--theme-key Theme
#--icons-key Icons
#--font-key Font
#--cursor-key Cursor
#--terminal-key Terminal
#--terminalfont-key Terminal Font
#--cpu-key CPU
#--cpu-usage-key CPU Usage
#--gpu-key GPU {1}
#--memory-key Memory
#--swap-key Swap
#--disk-key Disk ({1})
#--battery-key Battery {1}
#--poweradapter-key Power Adapter {1}
#--lm-key LM
#--locale-key Locale
#--localip-key Local IP ({1})
#--publicip-key Public IP
#--wifi-key Wifi
#--weather-key Weather
#--player-key Media Player
#--media-key Media
#--datetime-key Date Time
#--version-key Version
#--vulkan-key Vulkan
#--opengl-key OpenGL
#--opencl-key OpenCL
#--users-key Users
#--bluetooth-key Bluetooth
#--sound-key Sound
#--gamepad-key Gamepad
#--wallpaper-key Wallpaper
# Format options:
# Sets the format string for module values.
# For information on format strings, see "fastfetch --help format".
# To see the parameter they take and their default value, see "fastfetch --help *-format", e.g. "fastfetch --help os-format".
# An empty format string (As they are currently below) will behave as if it was not set.
#--os-format
#--host-format
#--chassis-format
#--kernel-format
#--uptime-format
#--processes-format
#--packages-format
#--shell-format
#--display-format
#--brightness-format
#--de-format
#--wm-format
#--wmtheme-format
#--theme-format
#--icons-format
#--font-format
#--cursor-format
#--terminal-format
#--terminalfont-format
#--cpu-format
#--cpu-usage-format
#--gpu-format
#--memory-format
#--swap-format
#--disk-format
#--battery-format
#--poweradapter-format
#--lm-format
#--locale-format
#--localip-format
#--publicip-format
#--weather-format
#--monitor-format
#--player-format
#--media-format
#--datetime-format
#--version-format
#--vulkan-format
#--opengl-format
#--opencl-format
#--users-format
#--bluetooth-format
#--sound-format
#--gamepad-format
#--wallpaper-format
# Key color options:
# Overrides the global `--color-keys` for one specified module
#--os-key-color
#--host-key-color
#--chassis-key-color
#--kernel-key-color
#--uptime-key-color
#--processes-key-color
#--packages-key-color
#--shell-key-color
#--display-key-color
#--brightness-key-color
#--de-key-color
#--wm-key-color
#--wmtheme-key-color
#--theme-key-color
#--icons-key-color
#--font-key-color
#--cursor-key-color
#--terminal-key-color
#--terminalfont-key-color
#--cpu-key-color
#--cpu-usage-key-color
#--gpu-key-color
#--memory-key-color
#--swap-key-color
#--disk-key-color
#--battery-key-color
#--poweradapter-key-color
#--lm-key-color
#--locale-key-color
#--localip-key-color
#--publicip-key-color
#--weather-key-color
#--monitor-key-color
#--player-key-color
#--media-key-color
#--datetime-key-color
#--version-key-color
#--vulkan-key-color
#--opengl-key-color
#--opencl-key-color
#--users-key-color
#--bluetooth-key-color
#--sound-key-color
#--gamepad-key-color
#--wallpaper-key-color
# Library options:
# Sets an user specific path to a library to load.
# Must be a valid path to a library.
#--lib-PCI /usr/lib/libpci.so
#--lib-vulkan /usr/lib/libvulkan.so (libMoltenVK.dylib on macOS)
#--lib-wayland /usr/lib/libwayland-client.so
#--lib-xcb-randr /usr/lib/libxcb-randr.so
#--lib-xcb /usr/lib/libxcb.so
#--lib-Xrandr /usr/lib/libXrandr.so
#--lib-X11 /usr/lib/libX11.so
#--lib-gio /usr/lib/libgio-2.0.so
#--lib-DConf /usr/lib/libdconf.so
#--lib-DBus /usr/lib/libdbus-1.so
#--lib-XFConf /usr/lib/libxfconf-0.so
#--lib-sqlite3 /usr/lib/libsqlite3.so
#--lib-rpm /usr/lib/librpm.so
#--lib-imagemagick /usr/lib/libMagickCore-7.Q16HDRI.so
#--lib-z /usr/lib/libz.so
#--lib-chafa /usr/lib/libchafa.so
#--lib-egl /usr/lib/libEGL.so
#--lib-glx /usr/lib/libGLX.so
#--lib-osmesa /usr/lib/libOSMesa.so
#--lib-opencl /usr/lib/libOpenCL.so
#--lib-freetype /data/data/com.termux/files/usr/lib
#--lib-pulse /usr/lib/libpulse.so
#--lib-ddcutil /usr/lib/libddcutil.so
#--lib-nm /usr/lib/libnm.so
+1366
View File
File diff suppressed because it is too large Load Diff
+3 -166
View File
@@ -1,167 +1,4 @@
Usage: fastfetch <options>
Informative options:
-h,--help: Show this message
-h,--help <command>: Show help for a specific command
-v,--version: Show the version of fastfetch
--list-config-paths: List search paths of config files
--list-data-paths: List search paths of presets and logos
--list-logos: List available logos
--list-modules: List available modules
--list-presets: List presets fastfetch knows about; they can be loaded with --load-config (+)
--list-features: List the supported features fastfetch was compiled with (mainly for development)
--print-logos: Print available logos
--print-config-system: Print the default system config
--print-config-user: Print the default user config
--print-structure: Print the default structure
--gen-config <?type>: Generate a sample config file in the default path. Param `type` can be `jsonc` or `conf`
--gen-config-force <?type>: Generate a sample config file in the default path. Overwrite the existing one
General options:
--load-config <file>: Load a config file or preset (+)
--config <file>: Alias of --load-config (+)
--multithreading <?value>: Use multiple threads to detect values
--stat <?value>: Show time usage (in ms) for individual modules
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
--escape-bedrock <?value>: On Bedrock Linux, whether to escape the bedrock jail
--pipe <?value>: Disable logo and all escape sequences
--wmi-timeout <num>: Set the timeout (ms) for WMI queries. Windows only. Default is 5000
--processing-timeout <num>: Set the timeout (ms) when waiting for child processes. Default is 1000
--ds-force-drm <?value>: Set if only DRM should be used to detect displays. Default is false
Logo options:
-l,--logo <logo>: Set the logo; if default, the name of a builtin logo or a path to a file
--logo-type <type>: Set the type of the logo given; must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty, iterm or chafa
--logo-width <width>: Set the width of the logo (in characters), if it is an image. Required for iTerm image protocol
--logo-height <height>: Set the height of the logo (in characters), if it is an image. Required for iTerm image protocol
--logo-preserve-aspect-radio <?value>: Set if the logo should fill the specified width and height as much as possible without stretching. Supported by iTerm image protocol
--logo-color-[1-9] <color>: Overwrite a color in the logo
--logo-padding <padding>: Set the padding on the left and the right of the logo
--logo-padding-left <padding>: Set the padding on the left of the logo
--logo-padding-right <padding>: Set the padding on the right of the logo
--logo-padding-top <padding>: Set the padding on the top of the logo
--logo-print-remaining <?value>: Whether to print the remaining logo, if it has more lines than modules to display
--logo-recache <?value>: If true, regenerate image logo cache
--file <file>: Short for --logo-type file --logo <file>
--file-raw <file>: Short for --logo-type file-raw --logo <file>
--data <data>: Short for --logo-type data --logo <data>
--data-raw <data>: Short for --logo-type data-raw --logo <data>
--sixel <file>: Short for --logo-type sixel --logo <file>
--kitty <file>: Short for --logo-type kitty --logo <file>
--iterm <file>: Short for --logo-type iterm --logo <file>
--chafa <file>: Short for --logo-type chafa --logo <file>
--chafa-fg-only <?value>: Produce character-cell output using foreground colors only. See chafa document for detail
--chafa-symbols <str>: Specify character symbols to employ in final output. See chafa document for detail
--chafa-canvas-mode <value>: Determine how colors are used in the output. This value maps the int value of enum ChafaCanvasMode. See chafa document for detail
--chafa-color-space <value>: Set color space used for quantization. 0 for RGB; 1 for DIN99d. See chafa document for detail
--chafa-dither-mode <value>: Set output dither mode (No effect with 24-bit color). This value maps the int value of enum ChafaDitherMode. See chafa document for detail
Display options:
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
--color-keys <color>: Set the color of the keys
--color-title <color>: Set the color of the title
--color <color>: Set the color of both the keys and title
--key-width <num>: Align the width of keys to <num> characters
--bright-color <?value>: Set if the keys, title and ASCII logo should be printed in bright color. Default is true
--separator <str>: Set the separator between key and value. Default is a colon with a space
--set <key=value>: Hard set the value of a key
--set-keyless <key=value>: Hard set the value of a key, but don't print the key or the separator
--show-errors <?value>: Print occurring errors
--disable-linewrap <?value>: Whether to disable line wrap during the run
--hide-cursor <?value>: Whether to hide the cursor during the run
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1
--percent-ndigits <value>: Set the number of digits to keep after the decimal point when formatting percentage numbers. Default is 0
--bar-char-elapsed <str>: Set the character to use in elapsed part. Default is '■'
--bar-char-total <str>: Set the character to use in total part. Default is '-'
--bar-width <?num>: Set the width of the bar, in number of characters. Default is 10
--bar-border <?value>: Whether to show a border around the bar. Default is true
--no-buffer <?value>: Set if the stdout application buffer should be disabled. Default is false
--size-ndigits <value>: Set the number of digits to keep after the decimal point when formatting sizes
--size-max-prefix <value>: Set the largest binary prefix to use when formatting sizes. Default is YB
--temperature-unit <value>: Set the unit of the temperature. Must be one of C, F and K. Default is C
General module options:
--<module>-format <format>: Set the format string to use for each specific module.
To see how a format string works, use fastfetch --help format.
To see help about a specific format string, use fastfetch --help <module>-format.
--<module>-key <key>: Set the key to use for each specific module.
For modules which print multiple lines, the string is parsed as a format string with the index as first character.
--<module>-key-color <format>: Override the global `--color-keys` option for each specific module.
--<module>-key-width <num>: Override the global `--key-width` option for each specific module.
Library options: Set the path of a library to load
--lib-PCI <path>
--lib-vulkan <path>
--lib-wayland <path>
--lib-xcb-randr <path>
--lib-xcb <path>
--lib-Xrandr <path>
--lib-X11 <path>
--lib-gio <path>
--lib-DConf <path>
--lib-DBus <path>
--lib-XFConf <path>
--lib-sqlite3 <path>
--lib-rpm <path>
--lib-imagemagick <path>
--lib-z <path>
--lib-chafa <path>
--lib-egl <path>
--lib-glx <path>
--lib-osmesa <path>
--lib-opencl <path>
--lib-pulse <path>
--lib-freetype <path>
--lib-ddcutil <path>
Module specific options:
--title-fqdn <?value>: Set if the title should use fully qualified domain name. Default is false
--title-color-user <color>: Set color of the user name (left part). Default is empty (use color of `--color-title`).
--title-color-at <color>: Set color of the @ symbol (middle part). Default is empty (use color of `--color-title`)
--title-color-host <color>: Set color of the host name (right part). Default is empty (use color of `--color-title`)
--separator-string <str>: Set the string printed by the separator module
--os-file <path>: Set the path to the file containing OS information
--disk-folders <folders>: A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows)
--disk-show-regular <?value>: Set if regular volume should be printed. Default is true
--disk-show-external <?value>: Set if external volume should be printed. Default is true
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
--bluetooth-show-disconnected: <?value>: Set if disconnected bluetooth devices should be printed. Default is false
--display-compact-type: <?string>: Set if all displays should be printed in one line. Default is none
--display-detect-name: <?value>: Set if display name should be detected and printed (if supported). Default is false
--display-precise-refresh-rate: <?value>:Set if decimal refresh rates should not be rounded into integers when printing. Default is true
--sound-type: <value>: Set what type of sound devices should be printed. Should be either main, active or all. Default is main
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--gpu-force-vulkan <?value>: Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false
--gpu-hide-type <?value>: Specify the type of GPUs should not be printed. Must be `integrated`, `discrete` or `none`. Default is none
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
--localip-show-ipv4 <?value>: Show IPv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show IPv6 addresses in local ip module. Default is false
--localip-show-mac <?value>: Show mac addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--localip-name-prefix <str>: Show IPs with given name prefix only. Default is empty
--localip-default-route-only <?value>: Show ips that are used for default routing only. Default is false
--localip-compact <?value>: Show all IPs in one line. Default is false
--publicip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--publicip-url: The URL of public IP detection server to be used.
--weather-location: Set the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`).
--weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0)
--weather-output-format: The output weather format to be used. It must be URI encoded.
--player-name: The name of the player to use
--opengl-library <value>: Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
--command-shell <str>: Set the shell program to execute the command text. Default is cmd for Windows, /bin/sh for *nix
--command-key <str>: Set the module key to display
--command-text <str>: Set the command text to be executed
--colors-symbol <str>: Set the symbol to be printed by Colors module. Default is block
--colors-padding-left <value>: Set the number of white spaces to print before the symbol. Default is 0
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
If a value starts with a ?, it is optional. "true" will be used if not set.
A (+) at the end indicates that more help can be printed with --help <option>
All options can be made permanent in $XDG_CONFIG_HOME/fastfetch/config.conf
If a value starts with a ?, it is optional. An optional boolean value defaults to true if not specified.
More detailed help messages for each options can be printed with "-h <option_without_dash_prefix>"
All options can be made permanent with command "fastfetch <options> --gen-config"
+3 -3
View File
@@ -1,9 +1,9 @@
usage: fastfetch --color <color>
Usage: fastfetch --color <color>
<color> must be a color encoding for linux terminals. It is inserted between "ESC[" and "m".
<color> must be a color encoding as ANSI escape sequences. It is inserted between "ESC[" and "m".
Infos about them can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.
Examples:
--color 35: sets the color to pink
--color 35: sets the color to magenta. `--color magenta` is also supported
--color 4;92: sets the color to bright Green with underline
--color 5;104: blinking text on a blue background
If no color is set, the main color of the logo will be used.
+2 -3
View File
@@ -1,9 +1,8 @@
usage: fastfetch --load-config <file>
Usage: fastfetch -c <file>
Loads a config file. A config file contains one flag per line. Empty lines or lines starting with # are ignored.
If the file is relative it looks in the following order:
- relative to the current working directory
- relative to ~/.local/share/fastfetch/presets/
- relative to /usr/share/fastfetch/presets/
Fastfetch provides some default presets. List them with --print-available-presets.
Note that this will only print presets fastfetch knows about and not every possible one.
Fastfetch provides some default presets. List them with "fastfetch --list-presets".
+2 -2
View File
@@ -1,7 +1,7 @@
A format string is a string that contains placeholders for values.
These placeholders begin with a '{', containing the index of the value, and end with a '}'.
For example the format string "Values: {1} ({2})", with the values "First" and "My second val", will produce
The format string can contain placeholders in any order and have multiple occurences.
The format string can contain placeholders in any order and have multiple occurrences.
To include spaces when setting from the command line, surround the whole string with double quotes (").
If the value index is missing, meaning the placeholder is "{}", an internal counter sets the value index.
@@ -22,7 +22,7 @@ For example to print a fallback for a second value if it is not set, use "{?2}{2
To stop formatting at any point in the format string, use "{-}".
To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.
"\\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
"\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
A "{#}" is equivalent to a "{#0}" and resets everything to normal.
For example to print something pink and underline, use "{#4;35}...{#}".
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Sele
+1 -1
View File
@@ -1 +1 @@
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:PowerAdapter:Locale:Break:Colors
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Swap:Disk:LocalIp:Battery:PowerAdapter:Locale:Break:Colors
+3 -7
View File
@@ -1,13 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_detection_battery_battery
#define FF_INCLUDED_detection_battery_battery
#include "fastfetch.h"
#define FF_BATTERY_TEMP_UNSET (0/0.0)
typedef struct BatteryResult
typedef struct FFBatteryResult
{
FFstrbuf manufacturer;
FFstrbuf modelName;
@@ -15,8 +12,7 @@ typedef struct BatteryResult
double capacity;
FFstrbuf status;
double temperature;
} BatteryResult;
uint32_t cycleCount;
} FFBatteryResult;
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results);
#endif
+4 -3
View File
@@ -33,8 +33,9 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results)
if (!yyjson_is_obj(root))
return "Battery info result is not a JSON object";
BatteryResult* battery = ffListAdd(results);
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
@@ -68,7 +69,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results)
return NULL;
ffStrbufClear(&temp);
BatteryResult* battery = ffListAdd(results);
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
@@ -78,7 +79,7 @@ static const char* parseDumpsys(FFBatteryOptions* options, FFlist* results)
if (ffParsePropLines(start, "AC powered: ", &temp) && ffStrbufEqualS(&temp, "true"))
ffStrbufAppendS(&battery->status, "AC powered");
ffStrbufClear(&temp);
if (ffParsePropLines(start, "USB powered: ", &temp) && ffStrbufEqualS(&temp, "true"))
{
if (battery->status.length) ffStrbufAppendS(&battery->status, ", ");
+32 -35
View File
@@ -5,30 +5,16 @@
#include <IOKit/IOKitLib.h>
static double detectBatteryTemp(void)
{
double result = 0;
if(ffDetectCoreTemps(FF_TEMP_BATTERY, &result))
return FF_BATTERY_TEMP_UNSET;
return result;
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
{
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery");
if (matchDict == NULL)
return "IOServiceMatching(\"AppleSmartBattery\") failed";
io_iterator_t iterator;
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("AppleSmartBattery"), &iterator) != kIOReturnSuccess)
return "IOServiceGetMatchingServices() failed";
io_registry_entry_t registryEntry;
while((registryEntry = IOIteratorNext(iterator)) != 0)
{
CFMutableDictionaryRef properties;
FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef properties = NULL;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
{
IOObjectRelease(registryEntry);
@@ -38,8 +24,14 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
bool boolValue;
const char* error;
BatteryResult* battery = ffListAdd(results);
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->capacity = 0.0/0.0;
int currentCapacity, maxCapacity;
if ((error = ffCfDictGetInt(properties, CFSTR("MaxCapacity"), &maxCapacity)))
@@ -54,33 +46,38 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
battery->capacity = currentCapacity * 100.0 / maxCapacity;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->technology);
ffCfDictGetString(properties, CFSTR("DeviceName"), &battery->modelName);
if (!ffCfDictGetBool(properties, CFSTR("built-in"), &boolValue) && boolValue)
{
ffStrbufAppendS(&battery->manufacturer, "Apple Inc.");
ffStrbufAppendS(&battery->modelName, "Builtin");
ffStrbufAppendS(&battery->technology, "Lithium");
if (!battery->modelName.length)
ffStrbufAppendS(&battery->modelName, "Built-in");
}
ffCfDictGetInt(properties, CFSTR("CycleCount"), (int32_t*) &battery->cycleCount);
if (!ffCfDictGetBool(properties, CFSTR("ExternalConnected"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "AC connected, ");
else
ffStrbufAppendS(&battery->status, "Discharging, ");
if (!ffCfDictGetBool(properties, CFSTR("IsCharging"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Charging, ");
if (!ffCfDictGetBool(properties, CFSTR("AtCriticalLevel"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
if (options->temp)
{
ffStrbufAppendS(&battery->manufacturer, "Unknown");
ffStrbufAppendS(&battery->modelName, "Unknown");
ffStrbufAppendS(&battery->technology, "Unknown");
int64_t temp;
if (!ffCfDictGetInt64(properties, CFSTR("Temperature"), &temp))
battery->temperature = (double) temp / 10 - 273.15;
else
ffDetectCoreTemps(FF_TEMP_BATTERY, &battery->temperature);
}
ffStrbufInit(&battery->status);
if (!ffCfDictGetBool(properties, CFSTR("FullyCharged"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Fully charged");
else if (!ffCfDictGetBool(properties, CFSTR("IsCharging"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Charging");
else
ffStrbufAppendS(&battery->status, "");
battery->temperature = options->temp ? detectBatteryTemp() : FF_BATTERY_TEMP_UNSET;
CFRelease(properties);
IOObjectRelease(registryEntry);
}
+4 -3
View File
@@ -20,9 +20,9 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
if(units == 0)
return NULL;
FF_AUTO_CLOSE_FD int acpifd = open("/dev/acpi", O_RDONLY);
FF_AUTO_CLOSE_FD int acpifd = open("/dev/acpi", O_RDONLY | O_CLOEXEC);
if(acpifd < 0)
return "open(\"/dev/acpi\", O_RDONLY) failed";
return "open(\"/dev/acpi\", O_RDONLY | O_CLOEXEC) failed";
for(int i = 0; i < units; ++i)
{
@@ -32,8 +32,9 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
if(ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) < 0 || (battio.battinfo.state == ACPI_BATT_STAT_NOT_PRESENT))
continue;
BatteryResult* battery = ffListAdd(results);
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
+25 -8
View File
@@ -1,11 +1,11 @@
#include "fastfetch.h"
#include "common/io/io.h"
#include "battery.h"
#include "common/io/io.h"
#include "detection/temps/temps_linux.h"
#include "util/stringUtils.h"
#include <dirent.h>
static void parseBattery(FFstrbuf* dir, FFlist* results)
static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* options, FFlist* results)
{
uint32_t dirLength = dir->length;
@@ -27,7 +27,7 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
return;
BatteryResult* result = ffListAdd(results);
FFBatteryResult* result = ffListAdd(results);
//capacity must exist and be not empty
ffStrbufAppendS(dir, "/capacity");
@@ -65,7 +65,26 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
ffReadFileBuffer(dir->chars, &result->status);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufAppendS(dir, "/cycle_count");
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(dir->length)
result->cycleCount = (uint32_t) ffStrbufToUInt(&testBatteryBuffer, 0);
result->temperature = FF_BATTERY_TEMP_UNSET;
if (options->temp)
{
const FFlist* tempsResult = ffDetectTemps();
FF_LIST_FOR_EACH(FFTempValue, value, *tempsResult)
{
if (ffStrbufEqualS(&value->name, id))
{
result->temperature = value->value;
break;
}
}
}
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
@@ -84,7 +103,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
uint32_t baseDirLength = baseDir.length;
DIR* dirp = opendir(baseDir.chars);
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir.chars);
if(dirp == NULL)
return "opendir(batteryDir) == NULL";
@@ -95,12 +114,10 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
continue;
ffStrbufAppendS(&baseDir, entry->d_name);
parseBattery(&baseDir, results);
parseBattery(&baseDir, entry->d_name, options, results);
ffStrbufSubstrBefore(&baseDir, baseDirLength);
}
closedir(dirp);
if(results->length == 0)
return "batteryDir doesn't contain any battery folder";
+133 -124
View File
@@ -30,137 +30,146 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
SetupDiDestroyDeviceInfoList(*hdev);
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results)
{
if(instance.config.allowSlowOperations)
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(hdev == INVALID_HANDLE_VALUE)
return "SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY) failed";
SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) };
for(DWORD idev = 0; SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did); idev++)
{
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(hdev == INVALID_HANDLE_VALUE)
return "SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY) failed";
DWORD cbRequired = 0;
SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer
SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired);
if(!pdidd)
break; //Out of memory
pdidd->cbSize = sizeof(*pdidd);
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
continue;
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
DWORD dwWait = 0;
DWORD dwOut;
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_TAG, &dwWait, sizeof(dwWait), &bqi.BatteryTag, sizeof(bqi.BatteryTag), &dwOut, NULL) && bqi.BatteryTag)
continue;
BATTERY_INFORMATION bi = {0};
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL))
continue;
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
continue;
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
ffStrbufInitS(&battery->technology, "Lead Acid");
else if(memcmp(bi.Chemistry, "LION", 4) == 0 || memcmp(bi.Chemistry, "Li-I", 4) == 0)
ffStrbufInitS(&battery->technology, "Lithium Ion");
else if(memcmp(bi.Chemistry, "NiCd", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Cadmium");
else if(memcmp(bi.Chemistry, "NiMH", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Metal Hydride");
else if(memcmp(bi.Chemistry, "NiZn", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Zinc");
else if(memcmp(bi.Chemistry, "RAM\0", 4) == 0)
ffStrbufInitS(&battery->technology, "Rechargeable Alkaline-Manganese");
else
ffStrbufInitS(&battery->technology, "Unknown");
SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) };
for(DWORD idev = 0; SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did); idev++)
{
DWORD cbRequired = 0;
SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer
SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired);
if(!pdidd)
break; //Out of memory
pdidd->cbSize = sizeof(*pdidd);
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
continue;
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
DWORD dwWait = 0;
DWORD dwOut;
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_TAG, &dwWait, sizeof(dwWait), &bqi.BatteryTag, sizeof(bqi.BatteryTag), &dwOut, NULL) && bqi.BatteryTag)
continue;
BATTERY_INFORMATION bi = {0};
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL))
continue;
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
continue;
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
ffStrbufInitS(&battery->technology, "Lead Acid");
else if(memcmp(bi.Chemistry, "LION", 4) == 0 || memcmp(bi.Chemistry, "Li-I", 4) == 0)
ffStrbufInitS(&battery->technology, "Lithium Ion");
else if(memcmp(bi.Chemistry, "NiCd", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Cadmium");
else if(memcmp(bi.Chemistry, "NiMH", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Metal Hydride");
else if(memcmp(bi.Chemistry, "NiZn", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Zinc");
else if(memcmp(bi.Chemistry, "RAM\0", 4) == 0)
ffStrbufInitS(&battery->technology, "Rechargeable Alkaline-Manganese");
else
ffStrbufInitS(&battery->technology, "Unknown");
{
ffStrbufInit(&battery->modelName);
bqi.InformationLevel = BatteryDeviceName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->modelName, name);
}
{
ffStrbufInit(&battery->manufacturer);
bqi.InformationLevel = BatteryManufactureName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->manufacturer, name);
}
battery->temperature = 0.0/0.0;
if(options->temp)
{
bqi.InformationLevel = BatteryTemperature;
ULONG temp;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &temp, sizeof(temp), &dwOut, NULL))
battery->temperature = temp;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY)
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
else
battery->capacity = 0;
ffStrbufInit(&battery->status);
if(bs.PowerState & BATTERY_POWER_ON_LINE)
ffStrbufAppendS(&battery->status, "AC Connected, ");
if(bs.PowerState & BATTERY_DISCHARGING)
ffStrbufAppendS(&battery->status, "Discharging, ");
if(bs.PowerState & BATTERY_CHARGING)
ffStrbufAppendS(&battery->status, "Charging");
if(bs.PowerState & BATTERY_CRITICAL)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
}
else
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->temperature = 0.0/0.0;
bqi.InformationLevel = BatteryDeviceName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->modelName, name);
}
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
{
ffStrbufAppendS(&battery->status, "AC Connected");
if(info.Charging)
ffStrbufAppendS(&battery->status, ", Charging");
}
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
{
ffStrbufInit(&battery->manufacturer);
bqi.InformationLevel = BatteryManufactureName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->manufacturer, name);
}
battery->cycleCount = bi.CycleCount;
battery->temperature = 0.0/0.0;
if(options->temp)
{
bqi.InformationLevel = BatteryTemperature;
ULONG temp;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &temp, sizeof(temp), &dwOut, NULL))
battery->temperature = temp;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY)
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
else
battery->capacity = 0;
ffStrbufInit(&battery->status);
if(bs.PowerState & BATTERY_POWER_ON_LINE)
ffStrbufAppendS(&battery->status, "AC Connected, ");
if(bs.PowerState & BATTERY_DISCHARGING)
ffStrbufAppendS(&battery->status, "Discharging, ");
if(bs.PowerState & BATTERY_CHARGING)
ffStrbufAppendS(&battery->status, "Charging, ");
if(bs.PowerState & BATTERY_CRITICAL)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
return NULL;
}
static const char* detectWithNtApi(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results)
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->temperature = 0.0/0.0;
battery->cycleCount = 0;
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
{
ffStrbufAppendS(&battery->status, "AC Connected");
if(info.Charging)
ffStrbufAppendS(&battery->status, ", Charging");
}
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
return NULL;
}
return "NtPowerInformation(SystemBatteryState) failed";
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
{
return true
? detectWithSetupApi(options, results)
: detectWithNtApi(options, results);
}
+1 -5
View File
@@ -1,8 +1,5 @@
#pragma once
#ifndef FF_INCLUDED_detection_bios_bios
#define FF_INCLUDED_detection_bios_bios
#include "fastfetch.h"
typedef struct FFBiosResult
@@ -11,8 +8,7 @@ typedef struct FFBiosResult
FFstrbuf release;
FFstrbuf vendor;
FFstrbuf version;
FFstrbuf type;
} FFBiosResult;
const char* ffDetectBios(FFBiosResult* bios);
#endif
+2
View File
@@ -9,5 +9,7 @@ const char* ffDetectBios(FFBiosResult* bios)
if (ffStrbufIgnCaseEqualS(&bios->version, "unknown"))
ffStrbufClear(&bios->version);
ffStrbufSetStatic(&bios->type, "Bootloader");
return NULL;
}
+3 -3
View File
@@ -23,7 +23,7 @@ const char* ffDetectBios(FFBiosResult* bios)
ffCfDictGetString(properties, CFSTR("vendor"), &bios->vendor);
ffCfDictGetString(properties, CFSTR("version"), &bios->version);
ffCfDictGetString(properties, CFSTR("release-date"), &bios->date);
ffStrbufAppendS(&bios->release, "Efi");
ffStrbufSetStatic(&bios->type, "UEFI");
CFRelease(properties);
IOObjectRelease(registryEntry);
@@ -54,12 +54,12 @@ const char* ffDetectBios(FFBiosResult* bios)
uint32_t index = ffStrbufFirstIndexC(&bios->version, '-');
if (index != bios->version.length)
{
ffStrbufAppendNS(&bios->release, index, bios->version.chars);
ffStrbufAppendNS(&bios->type, index, bios->version.chars);
ffStrbufRemoveSubstr(&bios->version, 0, index + 1);
}
else
{
ffStrbufAppendS(&bios->release, "iBoot");
ffStrbufSetStatic(&bios->type, "iBoot");
}
CFRelease(properties);
}
+2
View File
@@ -1,6 +1,7 @@
#include "bios.h"
#include "common/settings.h"
#include "common/sysctl.h"
#include "util/smbiosHelper.h"
const char* ffDetectBios(FFBiosResult* result)
@@ -13,5 +14,6 @@ const char* ffDetectBios(FFBiosResult* result)
ffCleanUpSmbiosValue(&result->vendor);
ffSettingsGetFreeBSDKenv("smbios.bios.version", &result->version);
ffCleanUpSmbiosValue(&result->version);
ffSysctlGetString("machdep.bootmethod", &result->type);
return NULL;
}
+4
View File
@@ -23,5 +23,9 @@ const char* ffDetectBios(FFBiosResult* bios)
getSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->release);
getSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->vendor);
getSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->version);
if (ffPathExists("/sys/firmware/efi", FF_PATHTYPE_DIRECTORY) || ffPathExists("/sys/firmware/acpi/tables/UEFI", FF_PATHTYPE_FILE))
ffStrbufSetStatic(&bios->type, "UEFI");
else
ffStrbufSetStatic(&bios->type, "BIOS");
return NULL;
}
+37
View File
@@ -2,6 +2,30 @@
#include "util/windows/registry.h"
#include "util/smbiosHelper.h"
#include <ntstatus.h>
#include <winternl.h>
typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION
{
GUID BootIdentifier;
FIRMWARE_TYPE FirmwareType;
union
{
ULONGLONG BootFlags;
struct
{
ULONGLONG DbgMenuOsSelection : 1; // REDSTONE4
ULONGLONG DbgHiberBoot : 1;
ULONGLONG DbgSoftBoot : 1;
ULONGLONG DbgMeasuredLaunch : 1;
ULONGLONG DbgMeasuredLaunchCapable : 1; // 19H1
ULONGLONG DbgSystemHiveReplace : 1;
ULONGLONG DbgMeasuredLaunchSmmProtections : 1;
ULONGLONG DbgMeasuredLaunchSmmLevel : 7; // 20H1
};
};
} SYSTEM_BOOT_ENVIRONMENT_INFORMATION;
const char* ffDetectBios(FFBiosResult* bios)
{
FF_HKEY_AUTO_DESTROY hKey = NULL;
@@ -24,5 +48,18 @@ const char* ffDetectBios(FFBiosResult* bios)
)
ffStrbufAppendF(&bios->release, "%u.%u", (unsigned)major, (unsigned)minor);
// Same as GetFirmwareType, but support (?) Windows 7
// https://ntdoc.m417z.com/system_information_class
SYSTEM_BOOT_ENVIRONMENT_INFORMATION sbei;
if (NT_SUCCESS(NtQuerySystemInformation(90 /*SystemBootEnvironmentInformation*/, &sbei, sizeof(sbei), NULL)))
{
switch (sbei.FirmwareType)
{
case FirmwareTypeBios: ffStrbufSetStatic(&bios->type, "BIOS"); break;
case FirmwareTypeUefi: ffStrbufSetStatic(&bios->type, "UEFI"); break;
default: break;
}
}
return NULL;
}

Some files were not shown because too many files have changed in this diff Show More