Compare commits

...

763 Commits

Author SHA1 Message Date
Carter Li 17bb3fd238 CI (macOS): optimises benchmark charts 2026-10-14 15:28:42 +08:00
Carter Li 1d8bbeb89f CI (macOS / Windows): reduces deps; builds universal darwin binary 2026-10-14 14:06:54 +08:00
Carter Li 939bfbb844 Merge pull request #2652 from fastfetch-cli/dev
Release v2.70.0
2026-10-14 10:42:20 +08:00
Carter Li fdd4a60d9d Packages (macOS): tidy [ci skip] 2026-10-14 10:37:58 +08:00
Carter Li 6eb3a8148b Packages (macOS): falls back to pkgsrc's standard package database path
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-10-13 21:35:50 -05:00
Carter Li 4f6a329ea3 Gamepad (Windows): ensures cancelled read completion is fully awaited
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-10-13 21:29:52 -05:00
Carter Li cb73fdcfc9 CI (macOS): installs the latest MacPorts release 2026-10-13 23:53:53 +08:00
Carter Li 8a0c1d2f6c Wifi (Android): fixes Android 17 support
Fixes the Wifi transmit link speed being read from a field a vendor writes in front of it, rather than from the transmit speed itself
2026-10-13 20:53:11 +08:00
Carter Li 2aa053a904 Sound (Android): adds new bluetooth device type
the Bluetooth LE hearing aid, the two Bluetooth peripheral-mode paths and the proxy endpoint.
2026-10-13 20:47:58 +08:00
Carter Li a9ee641bd6 Display (Android): fixes Android display detection reporting nothing on Android 11 2026-10-13 19:20:51 +08:00
李通洲 f93ffed57a Disk: fix Windows quota affecting free space and unify disk size calculation
- Windows: use FILE_FS_FULL_SIZE_INFORMATION_EX on Windows 10 1809+ (Build >= 17763) when calcType != AVAILABLE to get ActualTotalAllocationUnits/ActualAvailableAllocationUnits (ignoring per-user disk quotas). Fall back to legacy FILE_FS_FULL_SIZE_INFORMATION with CallerAvailableAllocationUnits when calcType is AVAILABLE or EX is unavailable.
- Unix-like: respect --disk-calc-type. Use f_bfree for FREE, f_bavail for AVAILABLE (Linux/BSD/SunOS). Haiku currently always uses free_blocks.
- Refactor FFDisk: remove bytesUsed and bytesAvailable; compute used = total - free in disk module.
- Disk module: update custom format (remove `size-available`, add `bytes-used` and `bytes-total`); update JSON output (remove `bytes.available`, `bytes.used`).
- Disk detection: stop computing used in common path; let each platform set bytesFree by chosen semantics.

Fixes #2651
2026-10-13 15:35:12 +08:00
Carter Li 73ebe95120 GPU (Pci): hardens the parser; adds tests 2026-10-13 09:17:26 +08:00
Carter Li b7bc8ca99d Display (Android): adds cmd display get-displays back
and updates changelog
2026-10-12 14:40:09 +08:00
Carter Li 1bab113d25 Display (Android): be compatible with Android 17 2026-10-12 14:20:21 +08:00
Carter Li 3b042d26ab Sound (Linux): adds ALSA backend as a fallback 2026-10-12 00:22:02 +08:00
Carter Li 29567e1674 Chore: eliminates compiler warnings 2026-10-11 23:54:08 +08:00
Carter Li 1e8b4eb974 Gamepad (Windows): tidy 2026-10-11 14:53:32 +08:00
Carter Li 3453de61f8 CI (Android): tries to fix building 2026-10-11 11:37:48 +08:00
Carter Li ad1d12ed38 Terminal (Android): reports real app display name instead of hard coding Termux 2026-10-11 10:42:42 +08:00
Carter Li ab6ec4c3f5 Media (Android): adds app uid support 2026-10-11 10:42:41 +08:00
İhsan Deniz 3ccaf2d7dd L10n (TR): proofreads Turkish module names (#2648)
- Host: "Ana Bilgisayar" -> "Cihaz". The module reports the machine
  model; "ana bilgisayar" reads as a mainframe in Turkish.
- Login Manager: "Oturum Açma Yöneticisi" -> "Giriş Yöneticisi".
  Shorter, and the common Turkish term.
- Top: "En yoğun işlemler" -> "En Yoğun Süreçler". Title case like the
  other Turkish names, and "Süreçler" to match the Processes module.
- Bluetooth Radio: "Bluetooth Radyosu" -> "Bluetooth Adaptörü". "Radyo"
  reads as an FM radio; "Adaptör" matches Power Adapter ("Güç Adaptörü").

Related to #2526
2026-10-11 07:50:31 +08:00
Carter Li 1f32e0bcb2 Display (Android): removes old detection methods 2026-10-11 00:44:15 +08:00
Carter Li d7b66c8677 Common (Android): unifies dex parsers 2026-10-10 23:55:38 +08:00
Carter Li 7f9faeb720 Display (Android): detects via binder 2026-10-10 22:57:48 +08:00
Carter Li cc435d2b70 Platform (OpenBSD): uses getexecpath(3) if available
Fixes https://github.com/fastfetch-cli/fastfetch/issues/2195#issuecomment-6095513342
2026-10-10 18:33:09 +08:00
Carter Li e0361fdcf6 Doc: updates changelog 2026-10-10 16:32:41 +08:00
Carter Li 124f474f81 Media (macOS): don't spawn child process 2026-10-10 16:32:09 +08:00
Carter Li 068d86ef13 Sound (Linux): updates comments 2026-10-10 15:44:04 +08:00
Carter Li 10d6b3a3d7 Display: fixes missing a lang option 2026-10-10 15:43:38 +08:00
Carter Li 62617a35de Common (Debug): fixes possible errno lost 2026-10-10 15:43:20 +08:00
Carter Li 10379d600d Packages (Linux): hardens getdents64 usage 2026-10-10 15:42:41 +08:00
Carter Li de414b7250 Common (Zlib): don't #define Z_LARGE64 2026-10-10 15:41:07 +08:00
Carter Li be51ba9f15 command not found 2026-10-10 15:40:29 +08:00
Carter Li 132e69b580 Percent: clamps bar width to 0% ~ 100% 2026-10-10 14:00:30 +08:00
Carter Li 07a7211526 Command: extends useStdErr to useOutput 2026-10-10 14:00:30 +08:00
李通洲 0806145f4d Command (Windows): detects command not found error (WIP) 2026-10-10 14:00:30 +08:00
李通洲 a7e19308cc Processing (Windows): handles ERROR_PATH_NOT_FOUND 2026-10-10 14:00:30 +08:00
Carter Li 262a8ca4d3 Processing: adds more debug info 2026-10-09 23:03:20 +08:00
Carter Li 30d6fb542b LocalIP (macOS): fixes MAC address reporting 20:00:00:00:00:00 on macOS 27 2026-10-09 23:02:44 +08:00
Dmitry Marakasov 1e0ec1004a Doc: fixes repology URLs (#2643) [ci skip] 2026-10-07 23:25:55 +08:00
Carter Li 35a35f066c Android: fixes binaries built via NDK running on Termux 2026-10-07 14:29:42 +08:00
Carter Li 9859b248ff Platform: prefers the passwd shell over $SHELL 2026-10-07 14:06:56 +08:00
Carter Li 66709ccc77 CI: adds android 2026-10-07 08:47:46 +08:00
Carter Li 10ca4f171e Global (Android): fixes building on old API level 2026-10-07 01:45:49 +08:00
Carter Li 04a5c2d9d3 Camera (Android): tidy 2026-10-07 00:35:45 +08:00
Carter Li 4909ac0d52 OpenBSD: eliminates some compiler warnings 2026-10-06 09:34:49 +08:00
Carter Li fb89af3d84 Common: adds zlib helpers 2026-10-06 09:31:58 +08:00
Carter Li 2bcd49c106 Networking: removes unused decls 2026-10-06 01:09:14 +08:00
Mohd Quamar Tyagi 3a069b2331 Packages (macOS): adds pkgsrc detection on macOS (#2627)
* feat(packages): add pkgsrc detection on macOS

* Simplify pkgsrc directory retrieval logic

Removed fallback logic for pkgsrc directory retrieval.

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-10-05 00:07:02 -05:00
dependabot[bot] d5e50ee30c CI: Bump the github-actions group across 1 directory with 5 updates (#2637)
Bumps the github-actions group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [uraimo/run-on-arch-action](https://github.com/uraimo/run-on-arch-action) | `3.2.0` | `3.2.1` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.38.1` | `4.38.2` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.38.1` | `4.38.2` |
| [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) | `1.4.0` | `1.4.1` |
| [msys2/setup-msys2](https://github.com/msys2/setup-msys2) | `2.32.0` | `2.33.0` |



Updates `uraimo/run-on-arch-action` from 3.2.0 to 3.2.1
- [Release notes](https://github.com/uraimo/run-on-arch-action/releases)
- [Commits](https://github.com/uraimo/run-on-arch-action/compare/460cb8e6d9f726a588fc9b5e681c8a6cab09ae41...fa1f3e7de95534497266c7265950b5188355fbfb)

Updates `github/codeql-action/init` from 4.38.1 to 4.38.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/1c5b675653bb5c22dbe9b12b556ec555138e09fd...2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2)

Updates `github/codeql-action/analyze` from 4.38.1 to 4.38.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/1c5b675653bb5c22dbe9b12b556ec555138e09fd...2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2)

Updates `vmactions/solaris-vm` from 1.4.0 to 1.4.1
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](https://github.com/vmactions/solaris-vm/compare/a11f407d3720a3717673d4194f19ee63b284977e...87d3c436511cef802cd1637f86f73b1a97715c8c)

Updates `msys2/setup-msys2` from 2.32.0 to 2.33.0
- [Release notes](https://github.com/msys2/setup-msys2/releases)
- [Changelog](https://github.com/msys2/setup-msys2/blob/main/CHANGELOG.md)
- [Commits](https://github.com/msys2/setup-msys2/compare/66cd2cce69caa17b53920067426061ca1de3a884...ec48f7c5447b3140e2b088413ae3a55687bccb6e)

---
updated-dependencies:
- dependency-name: uraimo/run-on-arch-action
  dependency-version: 3.2.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.38.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.38.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: vmactions/solaris-vm
  dependency-version: 1.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: msys2/setup-msys2
  dependency-version: 2.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-04 23:49:45 -05:00
dependabot[bot] 845d5983aa CI: Bump the github-actions group with 6 updates (#2636)
* CI: Bump the github-actions group with 6 updates

Bumps the github-actions group with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [uraimo/run-on-arch-action](https://github.com/uraimo/run-on-arch-action) | `3.2.0` | `3.2.1` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.38.1` | `4.38.2` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.38.1` | `4.38.2` |
| [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) | `1.4.0` | `1.4.1` |
| [msys2/setup-msys2](https://github.com/msys2/setup-msys2) | `2.32.0` | `2.33.0` |
| [signpath/github-action-submit-signing-request](https://github.com/signpath/github-action-submit-signing-request) | `2.3` | `3.0` |


Updates `uraimo/run-on-arch-action` from 3.2.0 to 3.2.1
- [Release notes](https://github.com/uraimo/run-on-arch-action/releases)
- [Commits](https://github.com/uraimo/run-on-arch-action/compare/460cb8e6d9f726a588fc9b5e681c8a6cab09ae41...fa1f3e7de95534497266c7265950b5188355fbfb)

Updates `github/codeql-action/init` from 4.38.1 to 4.38.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/1c5b675653bb5c22dbe9b12b556ec555138e09fd...2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2)

Updates `github/codeql-action/analyze` from 4.38.1 to 4.38.2
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/1c5b675653bb5c22dbe9b12b556ec555138e09fd...2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2)

Updates `vmactions/solaris-vm` from 1.4.0 to 1.4.1
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](https://github.com/vmactions/solaris-vm/compare/a11f407d3720a3717673d4194f19ee63b284977e...87d3c436511cef802cd1637f86f73b1a97715c8c)

Updates `msys2/setup-msys2` from 2.32.0 to 2.33.0
- [Release notes](https://github.com/msys2/setup-msys2/releases)
- [Changelog](https://github.com/msys2/setup-msys2/blob/main/CHANGELOG.md)
- [Commits](https://github.com/msys2/setup-msys2/compare/66cd2cce69caa17b53920067426061ca1de3a884...ec48f7c5447b3140e2b088413ae3a55687bccb6e)

Updates `signpath/github-action-submit-signing-request` from 2.3 to 3.0
- [Release notes](https://github.com/signpath/github-action-submit-signing-request/releases)
- [Commits](https://github.com/signpath/github-action-submit-signing-request/compare/c92b958760219087e01f8d67a1669ed57afe2627...f6d04783b4569d051e0c80105fe66e82819d0092)

---
updated-dependencies:
- dependency-name: uraimo/run-on-arch-action
  dependency-version: 3.2.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.38.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.38.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: vmactions/solaris-vm
  dependency-version: 1.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: msys2/setup-msys2
  dependency-version: 2.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: signpath/github-action-submit-signing-request
  dependency-version: '3.0'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update SignPath action version in workflow

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-10-04 23:44:38 -05:00
Carter Li 1989c6f549 Codec (Linux): eliminates a compiler warning [ci skip] 2026-10-05 12:16:36 +08:00
Carter Li 6e2a25759d Networking: removes compression support 2026-10-04 17:36:05 +08:00
Carter Li 460a715901 Logo (Image): fixes a possible building failure 2026-10-04 12:40:35 +08:00
Carter Li 9ac3822105 CI: removes codespell 2026-10-03 18:47:22 +08:00
Carter Li e02e44f673 Global: fixes compiling 2026-10-03 18:39:47 +08:00
Carter Li 0f712b4eaf CMake (macOS): fixes a linker warning 2026-10-03 18:36:47 +08:00
Ashed 995d172d3e Global: Added Finnish support (#2633)
* Global: Added fi support

* Remove a random space i accidentally added

* Fix more spaces
2026-10-03 18:35:56 +08:00
Carter Li 8102478f2f Global: prefers gnu::cleanup 2026-10-03 18:09:17 +08:00
Carter Li 537ffac39c Chore: forces eol=lf 2026-10-03 18:09:17 +08:00
Carter Li 95bcc4da5b Common: adds more FF_DEBUG 2026-10-03 18:09:17 +08:00
Carter Li 1b3594f600 Global: adds more FF_DEBUG 2026-10-03 18:09:17 +08:00
Carter Li ae1288d087 Global (Windows): adds more FF_DEBUG 2026-10-03 12:29:52 +08:00
Carter Li b201fd2db9 Common: improves reliability of FF_DEBUG 2026-10-03 10:53:21 +08:00
Carter Li 7f458b03e8 CMake: moves no-pie config to CI configs 2026-10-03 08:32:49 +08:00
Carter Li 5f65515c3c CMake: reduces binary size 2026-10-03 01:36:12 +08:00
Carter Li 3d0747b56d Common (Windows): optimises ico generation 2026-10-03 01:34:55 +08:00
Carter Li 68c5dd31f5 Global: marks ffGenerate*JsonConfig as [[gnu::cold]] 2026-10-03 01:32:02 +08:00
Carter Li a57ebe992a Battery (Windows): eliminates a compiler warning [ci skip] 2026-10-02 23:40:59 +08:00
Carter Li 54dcb1b6f9 Wifi (SunOS): eliminates a maybe-uninitialized warning 2026-10-02 23:25:06 +08:00
dependabot[bot] 39d667d1d5 CI: Bump the github-actions group with 5 updates (#2623)
* CI: Bump the github-actions group with 5 updates

Bumps the github-actions group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [benchmark-action/github-action-benchmark](https://github.com/benchmark-action/github-action-benchmark) | `1.22.1` | `1.22.2` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.38.0` | `4.38.1` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.38.0` | `4.38.1` |
| [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) | `4.3.0` | `4.4.0` |
| [signpath/github-action-submit-signing-request](https://github.com/signpath/github-action-submit-signing-request) | `2.3` | `3.0` |


Updates `benchmark-action/github-action-benchmark` from 1.22.1 to 1.22.2
- [Release notes](https://github.com/benchmark-action/github-action-benchmark/releases)
- [Changelog](https://github.com/benchmark-action/github-action-benchmark/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benchmark-action/github-action-benchmark/compare/52576c92bccf6ac60c8223ec7eb2565637cae9ba...4322e5726e6334590d251fc4f92bec0efafc45dc)

Updates `github/codeql-action/init` from 4.38.0 to 4.38.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/b96794f015dfd88f77b49b1c93e0fa7110f94c63...1c5b675653bb5c22dbe9b12b556ec555138e09fd)

Updates `github/codeql-action/analyze` from 4.38.0 to 4.38.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/b96794f015dfd88f77b49b1c93e0fa7110f94c63...1c5b675653bb5c22dbe9b12b556ec555138e09fd)

Updates `docker/setup-qemu-action` from 4.3.0 to 4.4.0
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/1f40c72289eff860ee54a304f1438e3cff362e0a...99012661954931238ded8c8b007157a8430204e1)

Updates `signpath/github-action-submit-signing-request` from 2.3 to 3.0
- [Release notes](https://github.com/signpath/github-action-submit-signing-request/releases)
- [Commits](https://github.com/signpath/github-action-submit-signing-request/compare/c92b958760219087e01f8d67a1669ed57afe2627...f6d04783b4569d051e0c80105fe66e82819d0092)

---
updated-dependencies:
- dependency-name: benchmark-action/github-action-benchmark
  dependency-version: 1.22.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.38.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.38.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: docker/setup-qemu-action
  dependency-version: 4.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: signpath/github-action-submit-signing-request
  dependency-version: '3.0'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update build-windows-hosts.yml

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-10-02 23:18:48 +08:00
Carter Li 7099964530 Release: v2.70.0 2026-10-02 22:22:44 +08:00
Carter Li ae4cbcbdba Global: removes quickjs-ng completely 2026-10-02 22:16:51 +08:00
Carter Li cee27354ba Battery (Android): removes dumpsys path 2026-10-02 22:04:29 +08:00
Carter Li 109644ec77 Disk (Haiku): fixes /boot being removed by hideFolders 2026-10-02 21:18:20 +08:00
Carter Li 782b7b8fd1 Display (macOS): don't read CGDisplayModeRef's private layout 2026-10-02 20:08:01 +08:00
Kashie w a9bf53b4a1 Logo: add filled Artix logo to match filled Arch logo (#2631) 2026-10-02 20:07:21 +08:00
Carter Li ab200636f1 Battery (Android): adds temperature and remaining time detection 2026-10-01 20:59:13 +08:00
Carter Li 4d8d6a5fe9 Brightness (Linux): removes ddcutil dep 2026-09-30 10:36:27 +08:00
Carter Li ef853fe858 Brightness (Linux): adds a native impl 2026-09-30 10:35:55 +08:00
Carter Li 47fbfcb0e9 Media (Android): fixes the descriptors a media session reply delivered being closed from a reply that had already gone out of scope, which closed a descriptor that was not theirs and leaked the ones that were 2026-09-30 00:40:57 +08:00
Carter Li c88ec3bcc3 Android: improves performance of dex parsing 2026-09-29 23:58:44 +08:00
Carter Li 2838dccbfd Sound (Android): adds support via /dev/binder 2026-09-29 23:58:02 +08:00
Carter Li f0d8c996e6 Sound (Linux): uses raw pulseaudio protocol
Also removes libpulse dependency
2026-09-29 18:22:03 +08:00
Carter Li 6ff7925f45 Packages (macOS): prefers getdirentries64 2026-09-29 13:36:32 +08:00
Achill Gilgenast ffbf4ec7ac Logo (Builtin): rename postmarketos to nura (#2626)
We changed our os-release ID in https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/9638
2026-09-29 00:28:10 -05:00
Jami Kettunen a3f46d9742 CPU (Linux): make Snapdragon X1/X2 detection more correct (#2625)
Use the previously discussed soc_id which have public values in EDK2.

The so far used toplevel devicetree compatible values weren't as precise
and some logic (x1, x2p, x2e) simply was dead code.

Also drops the CPU test due to reading soc_id sysfs file, could be
adapted if still wanted around.
2026-09-28 21:06:21 -05:00
Carter Li 4fb57bb39b Global (Windows): eliminates SHGetKnownFolderPath 2026-09-28 23:02:34 +08:00
Carter Li cdbe8f54c6 TerminalFont (Linux): uses ffFontInitXft to parse foot terminal font
Fixes #2624
2026-09-28 09:13:16 +08:00
李通洲 80632920bb Doc: uses the temp domain of repology [ci skip] 2026-09-27 09:04:10 +08:00
李通洲 5246f149eb Doc: updates info about image logo on Windows 2026-09-27 09:03:44 +08:00
Joshua Rogers f00a021e27 Completion (Bash): fixes --config/-c path completion splitting on spaces (#2621) [ci skip]
Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-09-27 09:00:11 +08:00
İhsan Deniz 676dbcfee2 Vulkan: fixes driver name concatenation on multi-GPU systems (#2620)
* Vulkan: fixes driver name concatenation on multi-GPU systems

applyDriverName appended to the result buffer without clearing it. When
a later device reported a higher API version, its driver name was
appended to the name of the earlier device instead of replacing it, as
the comment in detectVulkan intends.

* CHANGELOG: moves the #2615 entry to Unreleased

#2616 was opened after 2.69.0 had been released, but its entry was
written under 2.69.0 Bugfixes, so the changelog listed the fix as part
of 2.69.0.
2026-09-27 08:35:20 +08:00
İhsan Deniz 9801d89316 Brightness (Linux): fixes random built-in flag and stdout leak in DDC/CI detection (#2616)
DDC/CI results never set `builtin`, and FF_LIST_ADD does not zero the new
element, so external monitors were reported as built-in or external at
random. Set it to false, as the BSD DDC/CI backend does.

FF_SUPPRESS_IO() was declared inside the `if (ffddca_init)` block, so its
cleanup restored stdout before display detection ran and libddcutil trace
lines could reach the output, ahead of `--format json` too. Declare it at
function scope so it covers the whole detection, including the
FF_DISABLE_DLOPEN build.

Closes #2615
2026-09-26 18:18:43 +08:00
Carter Li fb52d32452 Packages (Linux): uses getdirent64(2) directly 2026-09-26 14:18:00 +08:00
李通洲 36dc82e926 Bootmgr: cleans code 2026-09-26 14:17:24 +08:00
李通洲 7fdd1d8e93 LocalIP / NetIO / DNS (Windows): improves performance
Fixes #2614
2026-09-26 14:17:24 +08:00
Carter Li 0c3b852bf7 Merge pull request #2613 from fastfetch-cli/dev
Release v2.69.0
2026-09-25 18:46:15 +08:00
李通洲 866c5e89c8 Global: fixes several issues found by AI 2026-09-25 17:28:44 +08:00
Carter Li a1edf7316c GPU: adds more debug log 2026-09-25 12:27:58 +08:00
Carter Li c3164d15e1 TerminalShell: hardens version detection code 2026-09-25 11:34:13 +08:00
Carter Li a2eda0090a Shell (Linux): supports more ksh variants 2026-09-25 11:33:46 +08:00
Carter Li d8797ae314 Shell (Windows): fixes possible buffer overflow 2026-09-25 11:32:56 +08:00
Carter Li 93175aea1d TerminalShell: clears version buffer if detection failed 2026-09-25 10:58:27 +08:00
Carter Li 537635cd9c Logo: adds option logo.position: auto 2026-09-25 09:51:34 +08:00
Carter Li c68bedd9bf CMake: adds a missing test 2026-09-25 08:46:41 +08:00
Carter Li 80a931a87f CPU (Linux): fixes Snapdragon X2 series model detection
Fixes #2611
2026-09-25 08:46:13 +08:00
李通洲 d223b04ad8 Media (Android): adds support 2026-09-25 01:55:23 +08:00
李通洲 0e04ebdf63 Wallpaper (Android): adds support 2026-09-24 23:42:27 +08:00
李通洲 bba45429ae Global: fixes issues found by AI 2026-09-24 21:27:51 +08:00
Carter Li 00ccd8be12 Doc: simplifies changelog 2026-09-24 17:44:48 +08:00
Carter Li 42e4fe3085 General: adds general.preload.lua option 2026-09-24 15:55:23 +08:00
Carter Li fb5622215b Common (Format): fixes lua error message trimming 2026-09-24 15:32:15 +08:00
Carter Li ccf1dcfa6d CMake: disables quickjs by default 2026-09-24 14:17:55 +08:00
Carter Li 0c6a9d6e98 CI: fixes build 2026-09-24 14:11:05 +08:00
Carter Li b6b5dabd54 Packages (Windows): disables winget again 2026-09-24 14:09:41 +08:00
Carter Li fdbaaea962 CMake (macOS): uses lazy_framework if applicate
It's said deprecated. Let's see if it still works.
2026-09-24 13:52:29 +08:00
Carter Li add2339c9c chore: removes doc/wiki
Github doesn't support it
2026-09-24 13:51:28 +08:00
Carter Li e1e2de0929 Gamepad (macOS): adds battery level detection support 2026-09-24 11:15:28 +08:00
Carter Li 59f0f533e7 Doc: removes outdated info [ci skip] 2026-09-24 10:11:59 +08:00
李通洲 28f4f6464b Common (Windows): simplifies winrt helper 2026-09-24 10:09:02 +08:00
李通洲 982313063d Gamepad (Windows): fixes battery level detection 2026-09-24 00:02:27 +08:00
Carter Li 1e7386788f Logo (Sixel): adds modification notice
for 3a9595e121
2026-09-23 23:00:00 +08:00
minnnjuuu 3a9595e121 Logo (Sixel): fixes allocator leak on output allocation failure (#2610) 2026-09-23 22:50:22 +08:00
Carter Li f8df95d146 Common (Lua): don't segfault when formating a null string
Fixes #2608
2026-09-23 22:29:39 +08:00
Carter Li 592ef68d60 Bluetooth (Linux): adds comments about LE device support of BlueZ 2026-09-23 18:04:46 +08:00
Carter Li 0bf6c8df74 Doc: adds wiki to docs as a submodule 2026-09-23 18:04:08 +08:00
Carter Li be15a0942c Chore: fixes building 2026-09-23 15:18:56 +08:00
Carter Li 4a97cc6825 Bluetooth: adds option showType 2026-09-23 15:11:06 +08:00
Carter Li a78d2a7737 Bluetooth (Windows / macOS): adds Bluetooth LE device detection 2026-09-23 14:02:08 +08:00
Carter Li 3930759007 Common (Windows): adds a WinRT helper 2026-09-23 13:33:35 +08:00
李通洲 e21530551d Common (Percent): adds ffRssiToSignalQuality 2026-09-23 13:33:35 +08:00
Carter Li c26bace3c2 Global: fixes a lot bugs found by AI 2026-09-22 22:09:26 +08:00
Carter Li fe49a9624e Host (macOS): adds new models 2026-09-22 09:47:45 +08:00
李通洲 7f3209181e Global: adds general cache layer 2026-09-22 00:45:40 +08:00
李通洲 2f74d6be4d Networking (Linux): fixes possible memleaks 2026-09-21 20:13:56 +08:00
李通洲 256c6a4257 PublicIP / Weather: fixes possible can only be used once due to internal limitations error 2026-09-21 20:08:11 +08:00
Carter Li aaa9153f5a CI (Windows): fixes build
Partially reverts f26795826c
2026-09-21 14:55:12 +08:00
dependabot[bot] f26795826c CI: Bump the github-actions group with 5 updates (#2598)
Bumps the github-actions group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [cross-platform-actions/action](https://github.com/cross-platform-actions/action) | `1.5.0` | `1.6.0` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.37.9` | `4.38.0` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.37.9` | `4.38.0` |
| [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) | `1.3.9` | `1.4.0` |
| [signpath/github-action-submit-signing-request](https://github.com/signpath/github-action-submit-signing-request) | `2.3` | `3.0` |


Updates `cross-platform-actions/action` from 1.5.0 to 1.6.0
- [Release notes](https://github.com/cross-platform-actions/action/releases)
- [Changelog](https://github.com/cross-platform-actions/action/blob/master/changelog.md)
- [Commits](https://github.com/cross-platform-actions/action/compare/faa0c6197e94aacf1c5956460152c8380d3560a5...e0b9770014ba65d5e0815f15b74031c3a635f641)

Updates `github/codeql-action/init` from 4.37.9 to 4.38.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/cdf488f595d80d6e07e03d4674febd5ab45fa938...b96794f015dfd88f77b49b1c93e0fa7110f94c63)

Updates `github/codeql-action/analyze` from 4.37.9 to 4.38.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/cdf488f595d80d6e07e03d4674febd5ab45fa938...b96794f015dfd88f77b49b1c93e0fa7110f94c63)

Updates `vmactions/solaris-vm` from 1.3.9 to 1.4.0
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](https://github.com/vmactions/solaris-vm/compare/96d8d976f9e67d82ec6c7e8ce9c1060731f9e21c...a11f407d3720a3717673d4194f19ee63b284977e)

Updates `signpath/github-action-submit-signing-request` from 2.3 to 3.0
- [Release notes](https://github.com/signpath/github-action-submit-signing-request/releases)
- [Commits](https://github.com/signpath/github-action-submit-signing-request/compare/c92b958760219087e01f8d67a1669ed57afe2627...f6d04783b4569d051e0c80105fe66e82819d0092)

---
updated-dependencies:
- dependency-name: cross-platform-actions/action
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: vmactions/solaris-vm
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: signpath/github-action-submit-signing-request
  dependency-version: '3.0'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-21 01:37:15 -05:00
Carter Li 18b31ca875 Doc: fixes json_schema 2026-09-21 14:29:10 +08:00
Carter Li 17b98007b4 Logo (Image): improves compatibility for iTerm when printing gif logo 2026-09-21 14:26:29 +08:00
Carter Li 1023388d60 Doc: adds missing command flags 2026-09-21 14:22:14 +08:00
Carter Li 6842ae0757 Common (Format): fixes module format strings mishandling a value that carries more than one leading ANSI escape sequence 2026-09-21 14:22:14 +08:00
Carter Li b726ee5a85 Chore: fixes a comment [ci skip] 2026-09-21 14:22:14 +08:00
Piotr Kubaj fd08fdb9df Global (FreeBSD): fixes build when libc defines memrchr as a macro (#2599)
FreeBSD 16.0-CURRENT's <string.h> now provides C23-style
qualifier-preserving wrappers for the string search functions.  Besides
the prototype, `memrchr` (like `memchr`, `strchr`, `strstr`, `memmem`,
...) is also defined as a function-like macro built on `_Generic`:

    #define memrchr(b, c, n) __qualsel((b), \
        (const void *)(memrchr)((b), (c), (n)), (memrchr)((b), (c), (n)))

`common/memrchr.h` redeclares the function unconditionally.  When
<string.h> has already been included, that declaration is expanded by
the macro and every translation unit fails with:

    src/common/memrchr.h:11:7: error: expected identifier or '('
       11 | void* memrchr(const void* s, int c, size_t n);

A libc that defines `memrchr` as a macro has necessarily declared the
function it wraps, so skip our declaration in that case.  Nothing
changes on platforms where `memrchr` is not a macro, and the fallback
implementation is still selected by `check_function_exists`.
2026-09-21 01:21:57 -05:00
Natsu 203ccb31fa Packages (Linux): detects rum overlay packages (#2597) 2026-09-21 00:30:25 -05:00
Carter Li 3503facd68 Doc: update changelog [ci skip] 2026-09-21 09:43:09 +08:00
Carter Li b2d48a1908 JsonSchema: updates moduleFormat 2026-09-21 09:25:35 +08:00
Carter Li b803d1ac82 Logo (Image): tidy 2026-09-21 09:25:35 +08:00
李通洲 eda38a37ba Battery (Android): adds debug output 2026-09-21 00:01:45 +08:00
李通洲 0b76d33f07 Wifi(Android): fixes errors when location permission is not granted
Security detection support is also added
2026-09-20 23:49:39 +08:00
李通洲 39564acde4 Platform: replaces pageSize for pageSizeShift 2026-09-20 20:56:42 +08:00
李通洲 3bfc4ec674 Terminal (Windows): uses $SSH_TTY if available 2026-09-20 19:23:35 +08:00
李通洲 fea55b276e Terminal (Windows): ignores services; fixes ssh env detection 2026-09-20 16:25:52 +08:00
李通洲 bc51f1ba0c Brightness (Windows): fixes debug messages 2026-09-20 16:25:14 +08:00
李通洲 38e4ba290d OS (Windows): adds comments 2026-09-20 14:21:25 +08:00
李通洲 24fb73e9b4 CI: eliminates codespell errors 2026-09-20 14:21:03 +08:00
李通洲 f96a290f3b Packages (Windows): caches winget packages count; enables winget by default 2026-09-20 13:05:09 +08:00
李通洲 67da836a27 Top: reduces waitTime to 250ms 2026-09-20 11:24:25 +08:00
李通洲 15e4bc998a Global (Android): code cleanup 2026-09-20 09:23:32 +08:00
李通洲 f9f368c1fb Battery (Android): uses dumpsys if available 2026-09-20 08:13:11 +08:00
李通洲 4a33a2c410 Player (Windows): improves player name detection 2026-09-20 00:50:01 +08:00
李通洲 34639b61b3 Presets: updates examples/25 [ci skip]
Fixes #2595
2026-09-19 18:55:30 +08:00
Carter Li efbfda9cf8 Doc: updates changelog [ci skip] 2026-09-19 18:34:32 +08:00
Carter Li 6142077656 Chore: eliminates a compiler warning 2026-09-19 18:34:32 +08:00
李通洲 58692adabc Common (Networking): fixes a non-pure function marked as pure
Fixes CI
2026-09-19 07:58:59 +08:00
李通洲 665c472482 Wifi (Android): rewrites impl via /dev/binder 2026-09-19 00:39:25 +08:00
李通洲 2594c01fc1 Common: renames androidApi.h for android/api.h 2026-09-18 20:25:46 +08:00
李通洲 e1d7360453 Display (Android): adds richer information and adds detectWithGetprop back 2026-09-18 20:22:16 +08:00
李通洲 873a881dab Battery (Android): rewrites impl via /dev/binder 2026-09-18 20:22:16 +08:00
李通洲 ecbf218d6e Chore: fixes compiling errors 2026-09-18 15:01:11 +08:00
李通洲 2fb7fabc4d CI (Haiku): don't reboot after installing deps 2026-09-18 15:01:11 +08:00
李通洲 811e634dc8 Display (Android): adds real support via /system/bin/cmd 2026-09-18 15:01:10 +08:00
李通洲 098b501d0e Camera (Android): uses NDK instead of the unstable termux-api 2026-09-18 15:01:10 +08:00
李通洲 7baaae166f DE (Android): improves Android ROM detection
Fixes #2541
2026-09-18 15:01:10 +08:00
Ian Ribeiro 560a9f419d WM (Linux): supports Umbriel version detection (#2594) 2026-09-18 11:42:19 +08:00
李通洲 70d2dd37a6 Image (Logo): uses native image decoder on Android
Codec (Android): uses `availability` feature test
2026-09-18 01:17:28 +08:00
李通洲 97ac94eb44 Common: adds more gcc constrants 2026-09-17 21:00:36 +08:00
李通洲 6ff7f2772b Tests: adds more UTs 2026-09-17 20:11:25 +08:00
李通洲 f8fd708423 Global: addresses Copilot's review comments 2026-09-17 19:19:25 +08:00
Carter Li c23c98a85a Logo (Image): supports transparent background of sixel logos 2026-09-17 16:39:19 +08:00
Carter Li 43988a8d41 Release: v2.69.0 2026-09-17 14:37:17 +08:00
Carter Li 1b7cc1cd30 CPU (Linux): adds SoC name of MacBook Neo 2026-09-17 14:02:29 +08:00
Carter Li 59e33150dd CPU (Android): updates the marketing name of Dimensity 9600 Pro 2026-09-17 14:01:13 +08:00
Carter Li e004c97ee0 CMake: adds option -DENABLE_IMAGE_LOGO=<BOOL> 2026-09-17 13:50:07 +08:00
李通洲 9bac273165 NetIO / DiskIO: reduces waitTime & improves accurency 2026-09-17 00:33:47 +08:00
李通洲 d1b747192f Logo (Image): adds animation (gif / apng) support 2026-09-16 20:48:02 +08:00
李通洲 b96d7e7bec Networking: supports chunked response & custom port number 2026-09-16 14:49:50 +08:00
李通洲 7b28ad07d7 Chore: updates gitignore 2026-09-15 22:41:47 +08:00
李通洲 02dc6a4428 Modules: adds * to format args which are available in key format 2026-09-15 22:24:18 +08:00
李通洲 53e868667a Logo (Image): fixes a copy-paste error 2026-09-15 20:11:36 +08:00
Carter Li fbf79ac6fe FFstrbuf: improves empty-string handling
for ffStrbufMatchSeparatedNS and ffStrbufSeparatedContainNS

Fixes #2585
2026-09-15 10:43:25 +08:00
Carter Li 416715a505 Presets: fixes neofetch keys
Fixes #2588
2026-09-15 10:43:25 +08:00
Carter Li ff3360e036 Logo (Image): fixes potencial memleaks 2026-09-15 08:50:47 +08:00
Carter Li 98ec0a674c IO: increases FF_IO_TERM_RESP_WAIT_MS 2026-09-15 08:45:48 +08:00
李通洲 6178256404 Logo (Icat): adds logo-padding support 2026-09-15 00:44:02 +08:00
李通洲 129bb7309e Logo (Icat): adds --stdin=no so icat doesn't try to read stdin 2026-09-15 00:13:06 +08:00
李通洲 464adb3540 Logo (Image): migrates recache to cache: bool|regen 2026-09-14 23:45:28 +08:00
李通洲 3d7ea720fb Logo (Image): improves caching logic; takes mtime into account 2026-09-14 22:43:19 +08:00
李通洲 a90ae0249d IO (Windows): prefers unicode APIs 2026-09-14 22:42:16 +08:00
李通洲 375d0c6b25 Common (IO): adds ffPathGetMtime and uses it 2026-09-14 22:21:49 +08:00
李通洲 e3b3b5dfc6 Packages: fixes a copy-paste bug 2026-09-14 19:25:10 +08:00
Carter Li 35ffdb3995 Logo (Image): drops IM in favor of ImageIO on macOS 2026-09-14 19:02:50 +08:00
李通洲 e8350a0d6e Logo (Image): drops IM in favor of WIC on Windows 2026-09-14 19:02:50 +08:00
李通洲 98e9b6eef1 3rdparty: embeds libsixel 2026-09-14 19:02:50 +08:00
dependabot[bot] d796945604 CI: Bump docker/setup-qemu-action in the github-actions group (#2583)
Bumps the github-actions group with 1 update: [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action).


Updates `docker/setup-qemu-action` from 4.2.0 to 4.3.0
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/96fe6ef7f33517b61c61be40b68a1882f3264fb8...1f40c72289eff860ee54a304f1438e3cff362e0a)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-14 18:49:44 +08:00
Carter Li cd5a2def9a DE (Linux): uses COSMIC_VERSION if available
https://github.com/pop-os/cosmic-comp/issues/2425#issuecomment-5652401962
2026-09-13 17:33:15 +08:00
Carter Li 8334035927 Logo: small optimizations 2026-09-13 12:27:17 +08:00
Carter Li 1ee8528f10 Format: makes {#title} and {#key} honors brightColor config 2026-09-13 12:26:57 +08:00
Carter Li ced49ab2a4 Chore: dont let clang-format break my code style 2026-09-13 12:05:07 +08:00
Carter Li ec8b9be354 Packages: opens SQLite DB in immutable mode
.. to avoid `SQLITE_READONLY` errors
2026-09-13 11:13:33 +08:00
李通洲 19725cd2f7 Packages (Windows): adds --source winget to improve performance of winget package detection 2026-09-13 08:39:45 +08:00
李通洲 20c155e5b4 TerminalFont (Windows): honors JSON fragment
Fixes #2573
2026-09-13 08:39:45 +08:00
dependabot[bot] 61e3f6108c CI: Bump the github-actions group with 3 updates (#2569)
Bumps the github-actions group with 3 updates: [github/codeql-action/init](https://github.com/github/codeql-action), [github/codeql-action/analyze](https://github.com/github/codeql-action) and [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm).


Updates `github/codeql-action/init` from 4.37.8 to 4.37.9
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28...cdf488f595d80d6e07e03d4674febd5ab45fa938)

Updates `github/codeql-action/analyze` from 4.37.8 to 4.37.9
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28...cdf488f595d80d6e07e03d4674febd5ab45fa938)

Updates `vmactions/solaris-vm` from 1.3.8 to 1.3.9
- [Release notes](https://github.com/vmactions/solaris-vm/releases)
- [Commits](https://github.com/vmactions/solaris-vm/compare/315163f088b66e55bbcc45928bd224d4973b2312...96d8d976f9e67d82ec6c7e8ce9c1060731f9e21c)

---
updated-dependencies:
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: vmactions/solaris-vm
  dependency-version: 1.3.9
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-12 23:38:17 +08:00
李通洲 eff8514536 CI (macOS): builds Intel version with macport 2026-09-12 00:08:16 +08:00
李通洲 f37a5a2543 OpenBSD: removes kvm dep 2026-09-11 23:38:10 +08:00
Carter Li 9a9f82b59e Processes (macOS): adds a comment 2026-09-11 10:40:44 +08:00
Carter Li 29818d2dca Top (macOS): improves performance and accuracy‌ of process name 2026-09-11 10:36:16 +08:00
Carter Li 222fe7e3f9 3rdparty (yyjson): upgrades to 0.13.0 2026-09-09 13:49:56 +08:00
Stian Halseth 7d0256fb85 CPU (Linux): adds SPARC support (#2572)
/proc/cpuinfo on sparc has none of the fields the generic fallback looks
for, so the module printed "Unknown (64)". The name is in "cpu", and the
frequency in "Cpu<n>ClkTck" -- in Hz, hex on sparc64, decimal on sparc32.
2026-09-08 20:31:55 +08:00
Carter Li a70c37fdaf Logo (Builtin): removes Zerene
Distro discontinued #2567
2026-09-07 10:58:46 +08:00
Sultaniiazov David 66e9e38f28 Logo (Builtin): adds ALT Atomic (#2549)
Co-authored-by: Vladimir Romanov <rirusha@altlinux.org>
2026-09-06 23:29:42 +08:00
李通洲 5d290cc3d5 Common (CommandOption): find module configuration from JSON config file 2026-09-05 20:14:58 +08:00
Guiorgy 2e542bea64 CMake: bumps min version to 3.21 (#2565)
C_STANDARD C17 and C23 were only introduced in CMake 3.21
2026-09-05 13:43:05 +08:00
李通洲 c708b6f5cd CPU (Linux): adds apple code of M5x 2026-09-05 00:32:58 +08:00
李通洲 6a275da8b1 Sound: removes an unused file 2026-09-05 00:32:31 +08:00
李通洲 ecee5694fb Global: uses strtoull for uint64_t
Fixes #2563 #2564
2026-09-04 19:35:26 +08:00
Matt Housh 4e78f1b703 Packages (Linux): adds support for package detection for CRUX linux 2026-09-04 18:14:21 +08:00
李通洲 62f78ca60c Processes (Windows): uses SystemHandleCountInformation if available 2026-09-03 15:27:40 +08:00
李通洲 00af2d1df2 WM: uses SystemBasicProcessInformation if available 2026-09-03 10:04:55 +08:00
李通洲 1128a75d8c InitSystem: uses SystemBasicProcessInformation if available 2026-09-03 10:04:55 +08:00
Carter Li ce61783c4b Wallpaper (macOS): extracts image path from NSData Configuration field
Also moves NSWorkspace method to the last method to try

Fixes #2559
2026-09-03 09:57:08 +08:00
Piotr Kubaj 20597bff00 Logo (image): also try unsuffixed ImageMagick library names
FreeBSD (and other systems that build ImageMagick without encoding the
quantum depth into the library name) install libMagickCore-7.so and
libMagickCore-6.so without a .Q16HDRI / .Q16 suffix.  dlopen currently
only tries the suffixed names, so image logos always fall back to ASCII
art with "Image Magick library not found" even when ImageMagick is
installed.  Append the plain library names as a last resort.
2026-09-02 17:06:16 +08:00
Carter Li caf64f5e4d Packaging: updates debian stuff [ci skip] 2026-09-02 10:52:57 +08:00
Carter Li 90a6e90b19 Processes (macOS): eliminates a compiler warning 2026-09-02 10:45:52 +08:00
Carter Li e9f719f37a Doc: update CONTRIBUTING.md [ci skip] 2026-09-02 10:44:47 +08:00
Carter Li 8c98bf1953 CMake: discovers module file automatically 2026-09-02 10:44:47 +08:00
Carter Li 1c1136ebd1 Merge pull request #2555 from fastfetch-cli/dev
Release: v2.68.1
2026-09-01 19:44:59 +08:00
李通洲 2787d97973 Release: v2.68.1 2026-09-01 19:21:56 +08:00
李通洲 2e06a73102 Modules: exposes localized module name in custom key format as {module-name} 2026-09-01 19:18:02 +08:00
Carter Li 37c198d997 Revert "CMAKE: bumps minimum CMake version to 3.21.0 (#2517)" (#2554)
I don't know why bumping minimal CMake version changes the behavior of cpack, but it does.

Fixes #2553

This reverts commit 233c481f7a.
2026-09-01 18:58:08 +08:00
Carter Li 37afe5a79d Packaging: updates debian stuff [ci skip] 2026-09-01 16:35:30 +08:00
Carter Li 0ebf09754b Merge pull request #2551 from fastfetch-cli/dev
Release: v2.68.0
2026-09-01 16:20:15 +08:00
Carter Li 0b1bc5b527 CI: upgrades deps; reenables Haiku 2026-09-01 14:14:14 +08:00
Carter Li 3d107764fa Wifi (Linux): fixes compatibility with old kernel headers 2026-09-01 14:14:14 +08:00
李通洲 4863a173e4 Wifi (linux): enables netlink on big-endian platforms 2026-09-01 00:34:55 +08:00
李通洲 8ea4468eec Common (Endian): adds new header 2026-09-01 00:20:40 +08:00
李通洲 b0ba084b5e Global: address review comments v2 2026-08-31 22:03:06 +08:00
李通洲 43d01f26ea Top: handle unknown process names gracefully in output 2026-08-31 20:38:20 +08:00
李通洲 b5ffc32b80 Top / Processes (Windows): improves detection of system / kernel processes detection 2026-08-31 20:37:31 +08:00
李通洲 4ff931c06f Top: adds thread count detection 2026-08-31 20:37:31 +08:00
李通洲 6eef800ea2 Top: supports sorting by start-time 2026-08-31 19:47:14 +08:00
李通洲 b9e4d04d65 Global: addresses review comments generated by CI 2026-08-31 19:10:27 +08:00
Carter Li 9c791b2c12 Doc: adds CONTRIBUTING.md 2026-08-31 15:31:45 +08:00
Carter Li 76b6768141 JsonSchema: regenerates moduleFormat 2026-08-31 15:31:45 +08:00
Carter Li 42002a6240 CPU (Linux): supports more Snapdragon X SoCs 2026-08-31 15:31:45 +08:00
Carter Li ef7f5aeac3 CPU (Android): adds pretty names of new SoCs 2026-08-31 14:26:16 +08:00
Carter Li d5214af189 Global: fixes British spellings and typos found by AI 2026-08-31 13:44:19 +08:00
Carter Li a33d6326f1 CMake: enables CONFIGURE_DEPENDS to FF_MODULE_DIRS globbing 2026-08-31 13:31:21 +08:00
Carter Li df99241424 L10n (gl): adds missing missing Galician translations 2026-08-31 13:11:00 +08:00
dependabot[bot] 5b1ad1008d CI: Bump the github-actions group with 3 updates
Bumps the github-actions group with 3 updates: [uraimo/run-on-arch-action](https://github.com/uraimo/run-on-arch-action), [github/codeql-action/init](https://github.com/github/codeql-action) and [github/codeql-action/analyze](https://github.com/github/codeql-action).


Updates `uraimo/run-on-arch-action` from 3.1.0 to 3.2.0
- [Release notes](https://github.com/uraimo/run-on-arch-action/releases)
- [Commits](https://github.com/uraimo/run-on-arch-action/compare/f9b26e3a1a408d5fd530d20c17b9f3f4428ff8d9...460cb8e6d9f726a588fc9b5e681c8a6cab09ae41)

Updates `github/codeql-action/init` from 4.37.7 to 4.37.8
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd...db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28)

Updates `github/codeql-action/analyze` from 4.37.7 to 4.37.8
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd...db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28)

---
updated-dependencies:
- dependency-name: uraimo/run-on-arch-action
  dependency-version: 3.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-31 08:41:25 +08:00
李通洲 39024abae9 Processes (Haiku): honors options->countKprocs 2026-08-30 19:54:58 +08:00
Carter Li 4dba32aabb WM (macOS): improves reliability of WM plugin detection 2026-08-30 19:04:09 +08:00
李通洲 753ddec3c5 Memory (Windows): prefers NQSI 2026-08-29 20:09:48 +08:00
Carter Li b04587e0cb Presets: moves top to the bottom of running modules [ci skip] 2026-08-29 13:03:49 +08:00
Carter Li 3abcf4195f Processes: corrects the structure of JSON result 2026-08-29 12:14:09 +08:00
李通洲 af8a42270c Top (Hurd): reports startTime; uses time_value64_t 2026-08-29 12:09:40 +08:00
李通洲 1c9e521775 Top: disables FF_TOP_TYPE_DISK on Hurd and Haiku 2026-08-29 12:09:31 +08:00
Carter Li 7fe08bddd0 Processes: adds option countKprocs 2026-08-29 00:58:15 +08:00
Carter Li 41da49f579 Top (SunOS / Hurd): skips kernel tasks 2026-08-29 00:40:08 +08:00
Carter Li f169165599 Top (Linux): improves performance of stat parsing 2026-08-28 18:45:30 +08:00
Carter Li 2c4caf8e0d Top: removes realloc retries 2026-08-28 16:22:33 +08:00
Carter Li 51b370a105 Processes: adds total thread count detection 2026-08-28 15:46:23 +08:00
Carter Li 14cf6bfdc1 Top (macOS): adds comments 2026-08-28 15:46:23 +08:00
Carter Li 4d00dc6802 Logo (Builtin): adds omarchy 2026-08-28 09:49:48 +08:00
Carter Li d7de7c41ca CI: disables fail on alert 2026-08-27 15:28:18 +08:00
Carter Li d80fe3f004 Logo (Builtin): adds macOS_old 2026-08-27 14:58:32 +08:00
Carter Li dcce4ccdb0 CI: moves benchmark-index to /.github as required by the script 2026-08-27 14:57:22 +08:00
Carter Li 191c5f2ef5 Doc: updates README 2026-08-27 14:29:17 +08:00
Carter Li 1dc794fac0 Doc: updates changelog [ci skip] 2026-08-27 14:23:16 +08:00
Carter Li 5936c1cef4 CI: adds benchmark job 2026-08-27 14:23:16 +08:00
Carter Li 04f26a29eb CI: enables bluetooth module on platforms other than macOS 2026-08-27 09:45:58 +08:00
Carter Li c9ad429a1b Global: introduces global macro FF_PATH_PKG_BASE to replace _PATH_LOCALBASE 2026-08-26 23:12:25 +08:00
李通洲 2b42db58da LM (OpenBSD): adds support 2026-08-26 17:43:25 +08:00
Carter Li 32757b0e43 LM (Windows): adds support 2026-08-26 17:43:25 +08:00
Carter Li c5598d2361 LM (macOS): adds support 2026-08-26 17:43:25 +08:00
Carter Li 203cd7cbcf LM (Linux): adds pretty name 2026-08-26 17:43:25 +08:00
Carter Li fb309134b5 LM (Linux): queries systemd session info via dbus 2026-08-26 17:43:25 +08:00
Carter Li 8b162e89de WMDE: improves performance 2026-08-26 14:14:24 +08:00
Carter Li 9670b585fb LM: detects LM from processes list if systemd is not available
2. removes type field
3. small optimizations
2026-08-26 14:12:08 +08:00
Carter Li 3b76ade662 Shell: fixes the fast path of ash version detection 2026-08-26 08:50:08 +08:00
李通洲 1b1df2e731 Common (Settings): tidy 2026-08-25 23:27:36 +08:00
李通洲 6c19a8b4ec Top (DragonFly): fixes building 2026-08-25 23:27:24 +08:00
李通洲 71728247ab Common (Sysctl): handle varying data lengths in integer retrieval functions 2026-08-25 23:24:31 +08:00
李通洲 4344aa2ff1 Top: adds option showType: <cpu|mem|disk> 2026-08-25 20:48:34 +08:00
李通洲 b7d8c12015 CI: adds top module 2026-08-25 18:24:32 +08:00
Carter Li 63d16ca854 Top: removes option kernelTask (never implemented) 2026-08-25 16:30:04 +08:00
Carter Li f15a1e96ce Top (Linux): don't error out when reading /proc/pid/io fails 2026-08-25 16:27:53 +08:00
Carter Li 55bfcd6d86 Top (Android): fixes building 2026-08-25 13:35:32 +08:00
Carter Li 880284fa9c DisplayServer (Android): enables Wayland support
Fixes #2530
2026-08-25 13:32:28 +08:00
Carter Li 143939f19b DE (Android): adds asus zenfone support
Fixes #2541
2026-08-25 09:08:35 +08:00
dependabot[bot] a979d8ae81 CI: Bump the github-actions group with 4 updates
Bumps the github-actions group with 4 updates: [cross-platform-actions/action](https://github.com/cross-platform-actions/action), [github/codeql-action/init](https://github.com/github/codeql-action), [github/codeql-action/analyze](https://github.com/github/codeql-action) and [signpath/github-action-submit-signing-request](https://github.com/signpath/github-action-submit-signing-request).


Updates `cross-platform-actions/action` from 1.3.0 to 1.4.0
- [Release notes](https://github.com/cross-platform-actions/action/releases)
- [Changelog](https://github.com/cross-platform-actions/action/blob/master/changelog.md)
- [Commits](https://github.com/cross-platform-actions/action/compare/5ea7e8e4677bd726033a10b094ba1c5762b15dee...24ef01df165c76df1ed2b9f9e9212e78dc2fc963)

Updates `github/codeql-action/init` from 4.37.6 to 4.37.7
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/5595ccaf912efad79be6eef63a5619ff05969be3...ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd)

Updates `github/codeql-action/analyze` from 4.37.6 to 4.37.7
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/5595ccaf912efad79be6eef63a5619ff05969be3...ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd)

Updates `signpath/github-action-submit-signing-request` from 2.2 to 2.3
- [Release notes](https://github.com/signpath/github-action-submit-signing-request/releases)
- [Commits](https://github.com/signpath/github-action-submit-signing-request/compare/b9d91eadd323de506c0c81cf0c7fe7438f3360fd...c92b958760219087e01f8d67a1669ed57afe2627)

---
updated-dependencies:
- dependency-name: cross-platform-actions/action
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.37.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.37.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: signpath/github-action-submit-signing-request
  dependency-version: '2.3'
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-24 11:31:38 -05:00
Carter Li b5897f784f Processes (GNU): uses native impl 2026-08-25 00:05:49 +08:00
Carter Li 83cc7a94a4 Top: adds new module 2026-08-25 00:05:49 +08:00
李通洲 5edda068f2 PhysicalDisk (DragonFly): eliminates‌ compiler warnings 2026-08-24 20:58:50 +08:00
Carter Li 6d5cb520ed Logo (Builtin): adds artix2 in 2026-08-24 13:21:25 +08:00
Carter Li e7ecba4460 Doc: updates README [ci skip] 2026-08-21 10:40:50 +08:00
Carter Li e0c239729b L10n: adds cs id tr uk vi
Assisted-By: LLM
2026-08-21 10:19:06 +08:00
Samuel Torres 6570a7accc L10n (ES): fixes Spanish translations (#2537) 2026-08-21 08:31:42 +08:00
Samuel Torres 0c4ec62cac L10n: (gl) Added Galician Support 2026-08-21 00:25:32 +08:00
Carter Li 5d11b65d53 TerminalFont (Android): adds font size detection 2026-08-20 16:18:07 +08:00
Carter Li 8b40117c08 Wifi (OpenBSD): fortifies detection and adds channel to frequency helper 2026-08-20 16:04:00 +08:00
Carter Li b1f2bf3526 WM: uses full name in EN, as DE and LM modules do 2026-08-20 15:23:21 +08:00
Carter Li d8452f71ed Wifi (SunOS): fortifies code 2026-08-20 15:05:18 +08:00
Carter Li 2a269bfd4c Wifi: removes driver detection support 2026-08-19 23:28:23 +08:00
Carter Li cafe82b462 Battery (SunOS): adds basic detection impl 2026-08-19 13:24:05 +08:00
Carter Li db8ee8159d Wifi (Haiku): adds basic Wifi detection impl 2026-08-19 11:05:35 +08:00
Carter Li f0765b1a13 Wifi (SunOS): adds basic Wifi detection impl 2026-08-19 10:43:34 +08:00
Carter Li 93566cb73c Wifi (Android / OpenBSD): inits unsupported properties 2026-08-19 10:16:30 +08:00
Carter Li 6d0d093d62 Wifi (NetBSD): adds channel width detection 2026-08-19 10:15:30 +08:00
Carter Li 54fe4ffece Wifi (FreeBSD): adds channel width detection 2026-08-19 09:40:23 +08:00
Carter Li 124bbb06f9 Wifi (macOS): fixes compatibility for old Intel MBP 2026-08-19 09:17:12 +08:00
Carter Li f04a53337d Wifi (macOS): adds channel width, accurate channel frequency and device driver detection 2026-08-18 19:32:01 +08:00
李通洲 514efab8eb Wifi (Windows): adds channel width and device driver detection 2026-08-18 19:32:01 +08:00
Carter Li 232cd6659b Wifi (Linux): adds channel width and device driver detection 2026-08-18 19:32:01 +08:00
Carter Li 7c93f9c82a GPU (macOS): removes useless @available tests 2026-08-18 19:32:01 +08:00
Wehrwolfmann e5b6e3612a L10n: falls back to English when the auto-detected locale is unsupported
--key-language with an empty value (and "language": null in the config)
asks for the system locale, not for a specific language. When that locale
has no translation, fastfetch aborted with exit 477 instead of printing
anything, so the same config broke on every locale outside the twelve
supported ones, and under LC_ALL=C variants such as POSIX.

Auto-detected locales now fall back to English. An explicitly requested
language still errors out, so typos and zh are still reported.
2026-08-17 20:14:39 -05:00
Carter Li 6cb15885c7 L10n: don't use ffStrbufCreateStatic for buffers that will be modified later 2026-08-18 09:11:50 +08:00
Carter Li e6d90c2081 L10n (Zh): uses a different name for Monitor 2026-08-17 14:20:46 +08:00
Carter Li 679d868b4a L10n (Zh): clarifies Disk actually detects Disk partitions 2026-08-17 13:57:23 +08:00
Carter Li 72d240f325 L10n (Zh): clarifies Bluetooth actually detects Bluetooth devices 2026-08-17 13:42:30 +08:00
Carter Li 2ca7e037ef L10n (Zh): translates shell 2026-08-17 13:36:09 +08:00
Carter Li 5e9c31ac31 Completion (Fish): prints enum description [ci skip] 2026-08-17 10:42:24 +08:00
Wehrwolfmann bcb48774a0 Modules: proofreads Russian l10n strings 2026-08-16 12:01:42 -05:00
Wehrwolfmann 9ff7969acf Bluetooth / BluetoothRadio: keeps the brand name in Latin script in Russian keys 2026-08-16 12:01:42 -05:00
李通洲 7fbd06a135 Doc: updates README.md [ci skip] 2026-08-16 22:16:56 +08:00
Hashing bbb906ba10 L10n (Pt): matches all Portuguese locales, not only bare pt (#2521)
359cb0a79a renamed the key from `pt_BR` to
`pt` but kept the exact-match guard, so only the literal string `pt`
matched. Every real Portuguese locale (`pt_BR`, `pt_PT` and their charset
and modifier variants) fell through to `goto error` and aborted.

Return the offset unconditionally, matching every other two-letter case.
2026-08-16 02:15:39 -05:00
李通洲 2de674ec9a L10n (Ar / He): adds support
Fixes #2520
2026-08-16 10:52:23 +08:00
李通洲 b700d9ded5 L10n (Ru): changes Блютус to Блютуз
Ref: https://github.com/fastfetch-cli/fastfetch/issues/2503#issuecomment-5304614812
2026-08-16 10:52:23 +08:00
李通洲 359cb0a79a L10n (Pt): renames pt_BR to pt 2026-08-16 10:52:14 +08:00
李通洲 45f9de6cd2 L10n: improves performance 2026-08-16 10:36:33 +08:00
Guiorgy 233c481f7a CMAKE: bumps minimum CMake version to 3.21.0 (#2517)
C_STANDARD 23 was added in 3.21
2026-08-15 09:15:03 +08:00
Carter Li b677f1e902 Theme: improves GTK theme/icons/font detection on standalone WMs (Hyprland, sway, niri, i3)
Fixes #2504
2026-08-15 09:08:29 +08:00
Carter Li 8d82eedaef DiskIO / NetIO: updates default value of waitTime to reduce latency
Also corrects docs.
2026-08-15 08:53:00 +08:00
Carter Li 4dc27b365f DiskIO / NetIO: fixes I/O rate calculation precision, prevent div-by-zero 2026-08-15 08:51:45 +08:00
李通洲 e5c3fa4023 CI: fixes compiling errors 2026-08-15 00:00:27 +08:00
李通洲 bdba78c45c CI: silences codespell errors 2026-08-14 23:56:29 +08:00
Carter Li f95167e907 Global: adds option key-language
Fixes #2503
2026-08-14 23:33:54 +08:00
Carter Li 3908c39ce2 Modules: adds l10n strings 2026-08-14 22:47:24 +08:00
李通洲 858d3749f4 FFstrbuf: adds FF_STRBUF_STATIC 2026-08-14 18:27:53 +08:00
李通洲 51f36fa4b4 FFstrbuf: adds comments [ci skip] 2026-08-14 17:54:36 +08:00
李通洲 bfe30eec79 Doc: updates changelog [ci skip] 2026-08-14 17:05:06 +08:00
Carter Li 4dd2f2d34b Merge pull request #2516 from fastfetch-cli/dev 2026-08-14 01:20:28 -05:00
Carter Li 60431c0321 Doc: update changelog [ci skip] 2026-08-14 13:50:22 +08:00
李通洲 7b2b3405ae Locale (Windows): reports the code page used by the console 2026-08-14 13:38:14 +08:00
Carter Li 965ed4ba79 Library (Windows): don't assume DataTableEntry->FullDllName is null-terminated 2026-08-14 09:41:30 +08:00
李通洲 00603357ea Processing (Windows): improves performance of environement string creation 2026-08-14 09:41:30 +08:00
OctoBored 5ea299a8d2 Doc: restores Star History in README.md
The Star History chart was removed in 8df0a1c9 (Fixes #2508) because the previous chart was broken due to GitHub stargazer API restrictions. This restores it at the same location using a working data source that requires no API token, so the chart renders correctly again.
2026-08-13 05:43:43 -05:00
Carter Li 368a4c5a73 Release v2.67.1 2026-08-13 11:02:18 +08:00
Carter Li 8df0a1c97e Doc: removes Star History in README.md
Fixes #2508
2026-08-13 10:44:35 +08:00
Carter Li 7098cd86cb Display: fixes bright colours incorrectly active in light theme
Fixes #2509
2026-08-13 10:44:35 +08:00
njk 681749ed54 TerminalFont (Ghostty): fixes font-family fallback order (#2510) 2026-08-12 20:04:19 -05:00
李通洲 c4695b8cf1 Processing (Windows): sets LANG=C when spawning child processes 2026-08-12 13:54:32 +08:00
李通洲 1d12003555 Locale (Windows): uses $LANG if available e.g. MSYS2 2026-08-12 10:19:22 +08:00
Carter Li 16b10c162b Revert "Locale (macOS): queries system-wide locale preference"
This reverts commit 8b8efcdcce.
2026-08-12 10:07:34 +08:00
Carter Li 51cfd4b5ed OS (Android): optimises code 2026-08-12 09:52:31 +08:00
JunaidQrysh a0452b8323 Logo (Image): don't block images support in zellij 2026-08-11 17:41:45 +08:00
Carter Li ebf38e829d OS (Android): reports real code names 2026-08-11 11:02:20 +08:00
HashimAbdulaziz 4c2af4071c TerminalFont (Alacritty): fix font size never being parsed from config
The query array gained a third entry in
dd30c82b83 but numQueries stayed at 2, so
`size =` was never queried and every Alacritty user silently got the
hardcoded 11.25 fallback.
2026-08-09 02:23:17 -05:00
李通洲 e3b8e94055 Wallpaper (macOS): uses the official API if possible 2026-08-09 11:33:58 +08:00
李通洲 1d4b0236ac WMTheme (macOS): migrates impl to pure C using CoreFoundation 2026-08-09 10:25:13 +08:00
李通洲 da42108732 Cursor (macOS): migrates impl to pure C using CoreFoundation 2026-08-09 10:22:21 +08:00
李通洲 8b8efcdcce Locale (macOS): queries system-wide locale preference 2026-08-09 10:12:37 +08:00
李通洲 8bc4464b64 Library: makes ffLibraryIterateDynamicLibs return false on failure 2026-08-09 10:11:25 +08:00
Carter Li 4361c5e787 Library: adds function ffLibraryIterateDynamicLibs 2026-08-09 01:07:19 +08:00
李通洲 558a90d4e0 Loadavg (Haiku): adds support on R1B6 2026-08-09 01:07:19 +08:00
Carter Li 881730d0bd TerminalFont: improves Ghostty config loading with fallback support
Fixes: #2500
2026-08-08 22:40:34 +08:00
Carter Li ac8fc63c28 Doc: updates changelog [ci skip] 2026-08-07 16:39:23 +08:00
Yelninei 8686820c1a CMake (Hurd): Define O_PATH to O_NORW.
This is a noop because O_RW is 0 but O_NORW is the correct constant to
open a file without read/write permissions.
2026-08-07 02:23:29 -05:00
Carter Li 39b3dc001a CMake: adds C23 feature detection and compatibility workarounds for Apple clang 17 2026-08-07 11:00:12 +08:00
Carter Li ba60d7975c Camera (macOS): simplifies code 2026-08-07 09:37:39 +08:00
Carter Li 51a4f34bb5 Codec (macOS): fixes a symbol not found error when running on 10.15 2026-08-07 09:37:39 +08:00
Carter Li 01bb73b9e8 Packaging: updates debian stuff [ci skip] 2026-08-06 16:40:38 +08:00
Carter Li 56da8f8110 Merge pull request #2497 from fastfetch-cli/dev 2026-08-06 03:07:26 -05:00
dependabot[bot] 6d6302e327 CI: Bump the github-actions group with 2 updates
Bumps the github-actions group with 2 updates: [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) and [signpath/github-action-submit-signing-request](https://github.com/signpath/github-action-submit-signing-request).


Updates `docker/setup-qemu-action` from 4.1.0 to 4.2.0
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/06116385d9baf250c9f4dcb4858b16962ea869c3...96fe6ef7f33517b61c61be40b68a1882f3264fb8)

Updates `signpath/github-action-submit-signing-request` from 1.3 to 2.2
- [Release notes](https://github.com/signpath/github-action-submit-signing-request/releases)
- [Commits](https://github.com/signpath/github-action-submit-signing-request/compare/ced31329c0317e779dad2eec2a7c3bb46ea1343e...b9d91eadd323de506c0c81cf0c7fe7438f3360fd)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-version: 4.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: signpath/github-action-submit-signing-request
  dependency-version: '2.2'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-05 21:28:37 -05:00
Carter Li 20277b9ee9 CI: adds dependabot.yml 2026-08-06 10:17:14 +08:00
Thibaud-Vdb b6d95a0ce5 CI: declares least-privilege token permissions
Jobs without a permissions block get the repository's default token
scope, and reusable workflow calls pass the caller's grants straight
through. Scopes are now derived from what each workflow actually does
with the token:

- every build workflow declares contents: read; none of them writes
  through the GITHUB_TOKEN.
- build-linux-hosts.yml keeps security-events: write for the CodeQL
  upload; the other callers had that grant too but never upload
  scanning results, so they drop it.
- build-windows-hosts.yml gets actions: read, which the SignPath
  action documents needing to read job details and download the
  unsigned artifact.
- build-release.yml declares contents: write, matching the grant its
  caller already makes for creating the release.

Runs that execute pull request code now hold a token that can do
nothing but read the repository.
2026-08-05 20:59:02 -05:00
Thibaud-Vdb daf5421be7 CI: passes only the secret each reusable workflow needs
Every reusable workflow call used 'secrets: inherit', which hands the
caller's whole secret set to the called workflow, but the only secret
any of them reads is SIGNPATH_API_TOKEN in build-windows-hosts.yml.
Passing that one secret explicitly and dropping inherit everywhere else
means a compromised step in, say, a BSD build VM has no signing token
to steal, and the workflow files now show exactly which secret flows
where.

The secret is declared optional in the reusable workflow so runs
without it (pull requests, forks) behave as before; the signing step
is already guarded to upstream push events.
2026-08-05 20:59:02 -05:00
Thibaud-Vdb b739dfee0b CI: pins actions to commit SHAs
A version tag like @v1 or a branch like @master is a movable pointer:
whoever controls the action repository can re-point it, and the next
run executes whatever it points at. Several of these actions run in
jobs whose outputs ship to users: build-release.yml creates the GitHub
release with the downloadable binaries, and build-windows-hosts.yml
holds the SignPath signing token, so a re-pointed tag there could ship
a tampered or wrongly signed release. This is exactly how the
tj-actions/changed-files compromise propagated (CVE-2025-30066).

Pinning by full commit SHA makes the reviewed code the code that runs,
the same way docker/setup-qemu-action is already pinned in
build-linux-vms.yml. Refs that pointed at master (cross-platform-actions,
setup-alpine, get-latest-release) are pinned to their latest release
tag. Every pin keeps a version comment, and each SHA was resolved from
the upstream repository and cross-checked against its release tag.
2026-08-05 20:59:02 -05:00
Carter Li 80101a5803 GenConfig: simplifes code 2026-08-05 15:47:42 +08:00
Carter Li cf33bef128 CI: fixes building 2026-08-05 15:30:32 +08:00
Carter Li 7e786bee31 GenConfig: optimises code 2026-08-05 15:21:39 +08:00
Carter Li cbea6c3cb1 Presets (neofetch): shows board name as host name
... when the real host name is not available
2026-08-05 15:02:47 +08:00
Carter Li 48a234d742 GenConfig: removes unused fflush 2026-08-05 14:49:29 +08:00
Carter Li c271708f7d GenConfig: don't use Unicode string when drawing options 2026-08-05 14:36:42 +08:00
Carter Li b42f11442c GenConfig: improves visibility on light-background terminal 2026-08-05 14:28:49 +08:00
Carter Li 73918956d7 GenConfig: prefers macros instead of hard coded ANSI string 2026-08-05 14:28:49 +08:00
Carter Li 6559c7f42d GenConfig: don't use Unicode chars on niche platforms 2026-08-05 14:28:11 +08:00
Carter Li 56950e790f Merge pull request #2490 from fastfetch-cli/dev
Release v2.67.0
2026-08-04 20:05:50 -05:00
Carter Li e7642ea3a2 GenConfig: honors -s set by users 2026-08-04 23:34:15 +08:00
李通洲 a88ef86ce3 InitSystem (Windows): fixes logic of assertions 2026-08-04 21:15:34 +08:00
李通洲 fcf4aca3b7 Shell: fixes a potencial out-of-bound read 2026-08-04 21:14:48 +08:00
李通洲 3f8d141313 GenConfig: disables the feature on Win 8.1; improves redraw logic 2026-08-04 21:05:07 +08:00
李通洲 97a9be27b9 GenConfig: fixes arrow keys not working in Haiku 2026-08-04 20:17:05 +08:00
李通洲 dc46ecbcac GenConfig: code cleanup 2026-08-04 19:34:14 +08:00
李通洲 984fadf70f Revert "Global: first step to full C++ project"
This reverts commit 241ddb79b0.
2026-08-04 19:19:37 +08:00
李通洲 1a42cbe1cf Common (Format): format 2026-08-04 19:18:23 +08:00
Carter Li 9c7cfb864f Release: v2.67.0 2026-08-04 16:28:33 +08:00
Carter Li 6d795a3572 Fastfetch: adds interactive --gen-config mode
removes `--gen-config-*` flags (merged into `--gen-config`)
2026-08-04 15:32:44 +08:00
Carter Li 2af56232a4 FFlist: adds FF_LIST_INSERT_AT and FF_LIST_REMOVE_AT 2026-08-04 15:08:50 +08:00
Carter Li 3196f5efaa chore: adds defaultOrder to every module's definition 2026-08-04 09:58:31 +08:00
aldahiiir 1626ced83c OS (Linux): detects Ubuntu Studio installed with core mode
The minimal (core) installation ships the `ubuntustudio-desktop-core`
metapackage instead of `ubuntustudio-desktop`, so the existing check
missed it and the system was reported as Kubuntu.

Fixes #2485
2026-08-03 20:01:47 +08:00
李通洲 241ddb79b0 Global: first step to full C++ project 2026-08-03 20:00:27 +08:00
李通洲 66ce39e3fc Shell (Windows): fixes incompatibility with the newest fish version 2026-08-02 22:02:54 +08:00
李通洲 3fae9e0274 Libc (Windows): simplifies code 2026-07-31 23:12:10 +08:00
李通洲 5eaf98ecd2 Common: forces optionBuf to be 8-byte aligned 2026-07-29 20:15:54 +08:00
Carter Li 00b7c5b56c Netif (Hurd): fixes a compiler warning 2026-07-28 23:42:08 +08:00
李通洲 305ab14e7b DisplayServer (Linux): don't assume the monitor has only one preferred mode
Fixes #2481
2026-07-28 23:41:07 +08:00
Carter Li a58fc4f77d CI: disable Haiku
Ref: https://github.com/haikuports/haikuports/issues/14445
2026-07-28 15:21:28 +08:00
Carter Li b653ef730d General: removes general.preRun due to security concerns 2026-07-28 15:16:30 +08:00
Carter Li dc464d6efe FFstrbuf: prefers ffStrbufEnsureFree 2026-07-28 14:51:54 +08:00
Carter Li 1c3f0eb7c0 FFstrbuf: adds integer overflow checks to EnsureFreeNoCheck and EnsureFixedLengthFree 2026-07-28 14:51:37 +08:00
Carter Li 476cd67345 Networking: adds Content-Length size limit to prevent excessive memory allocation and potential attacks 2026-07-28 13:29:47 +08:00
Carter Li 2c736697d2 Watch: adds -w/--watch as a seconds-based alias for --dynamic-interval
Closes #2478
2026-07-28 10:52:04 +08:00
Carter Li 738ad59f54 Revert "Weather: replaces aggressive exit(1) with proper error handling (#2474)"
This reverts commit c5a8950ad4.
2026-07-28 10:40:33 +08:00
Carter Li 5476e01407 Revert "PublicIP: replaces exit(1) with proper error status"
This reverts commit 18eef29d0a.
2026-07-28 10:38:53 +08:00
Carter Li 4f0b00116e PublicIP: fixes invalid URL parser 2026-07-28 10:37:36 +08:00
Carter Li 6490e2707f Networking: relaxes accepted response format 2026-07-28 10:31:32 +08:00
tru3 ccf3909372 Separator: fixes memory leakes
- Add missing ffStrbufDestroy(&options->outputColor) in ffDestroySeparatorOptions
  to prevent memory leak when outputColor is set via JSON config
- Replace two exit(1) calls in ffPreparePublicIp with proper error status
  propagation, matching the pattern used in the weather module
2026-07-24 08:50:59 +08:00
tru3 18eef29d0a PublicIP: replaces exit(1) with proper error status
- Add missing ffStrbufDestroy(&options->outputColor) in ffDestroySeparatorOptions
  to prevent memory leak when outputColor is set via JSON config
- Replace two exit(1) calls in ffPreparePublicIp with proper error status
  propagation, matching the pattern used in the weather module
2026-07-24 08:50:59 +08:00
h4sht f6c25667fe Display: adds missing ffStrbufDestroy calls in ffOptionsDestroyDisplay (#2476)
13 FFstrbuf fields were initialized but never destroyed, potentially
leaking memory when configured via JSON or command-line:
- barBorderLeft, barBorderRight
- barBorderLeftElapsed, barBorderRightElapsed
- barColorElapsed, barColorTotal, barColorBorder
- tempColorGreen, tempColorYellow, tempColorRed
- percentColorGreen, percentColorYellow, percentColorRed

Co-authored-by: tru3 <tru3@tru3.com>
2026-07-24 08:43:31 +08:00
h4sht 97fa52fef0 FFstrbuf: removes dead code in ffStrbufSubstrBefore (#2475)
The redundant `if (index < strbuf->length)` check inside the static string
branch is always true since `strbuf->length <= index` is already checked
at the top of the function and returns false. Remove this dead code for clarity.

Co-authored-by: tru3 <tru3@tru3.com>
2026-07-24 08:41:54 +08:00
h4sht c5a8950ad4 Weather: fixes memory leak and replace aggressive exit(1) with proper error handling (#2474)
- Add missing ffStrbufDestroy(&options->location) in ffDestroyWeatherOptions
  to prevent memory leak when location is set via config
- Replace exit(1) in ffPrepareWeather with setting status to an error string,
  allowing the error to be properly propagated through the existing error mechanism

Co-authored-by: tru3 <tru3@tru3.com>
2026-07-24 08:39:07 +08:00
Carter Li 111c1bab75 Codec (macOS): fixes detection for VP9 2026-07-23 09:55:31 +08:00
Carter Li 47dfd8a271 Common (macOS): adds M5x temp detection support 2026-07-22 11:08:17 +08:00
Carter Li bc1d305aaa Logo (Builtin): removes hypros
Ref: #1178 #2460
2026-07-22 09:29:36 +08:00
徐晓伟 dda39f0c67 CI (Linux): adds loong64 build workflow (#2469)
* CI: add loong64 build workflow

Add reusable workflow for building fastfetch on LoongArch 64-bit
architecture using QEMU user-mode emulation + Docker container
(lcr.loongnix.cn/debian:14). Integrate into CI pipeline and
release dependencies.

* CI (loong64): pin docker/setup-qemu-action to full commit SHA

Pin to 06116385d9baf250c9f4dcb4858b16962ea869c3 (v4.1.0) for
immutable action reference as required by Codacy.
2026-07-21 21:14:38 +08:00
李通洲 0b72c9b083 Networking (Windows): simplifies code 2026-07-21 21:12:16 +08:00
李通洲 69f3d9ae33 CI (FreeBSD): fixes building 2026-07-20 16:06:22 +08:00
Carter Li db46e06f2e Common (Base64): unifies the code of endian testing 2026-07-20 15:36:57 +08:00
Carlos Milán Figueredo 7223803a76 Common (Base64): corrects byte order on big-endian hosts (#2470)
ffBase64EncodeRaw unconditionally byte-swapped the input word via
__builtin_bswap32, which only produces the intended big-endian byte
layout on little-endian hosts. On big-endian hosts the word is already
in the correct order, so the swap corrupted the encoded output.

Guard the swap with __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ so the
encoder is correct on both endiannesses.
2026-07-20 02:29:59 -05:00
李通洲 9db4ec82fd Version (macOS): siliences a compiler warning 2026-07-19 18:06:00 +08:00
李通洲 62180366fc Theme (Windows): reports basic is DWM is disabled 2026-07-17 23:00:31 +08:00
Carter Li 0feec933ea Camera: removes unused #includes 2026-07-17 10:40:48 +08:00
Carter Li 6c03db8be9 Codec (macOS): fixes a memory leak 2026-07-17 10:35:30 +08:00
Carter Li f0564fb9a7 Camera: adds missing ffStrbufDestroy 2026-07-17 10:34:56 +08:00
李通洲 8bf1aca7fc GPU (Windows): correctly report virtual GPUs
Fixes #2461
2026-07-16 19:27:39 +08:00
李通洲 445311978e Logo: silence GCC warnings by unsilencing CLANG warnings 2026-07-16 19:14:22 +08:00
Carter Li d9f5e006b5 Logo (Builtin): removes MagpieOS
Dead years ago: https://github.com/magpie-linux
2026-07-16 10:48:12 +08:00
Carter Li 21fbf14fb8 Logo (Builtin): removes Furreto, EmperorOS and Magix
Ref: #2460
2026-07-16 10:46:57 +08:00
Carter Li bc8ce39193 Doc: update logo_request template [ci skip]
Ref: #2460
2026-07-16 10:30:56 +08:00
Carter Li ac3fc219cf Doc: updates README [ci skip] 2026-07-15 09:40:51 +08:00
Carter Li dd30c82b83 TerminalFont: supports both syntax for alacritty 2026-07-15 09:16:03 +08:00
李通洲 b41cdb0ca6 Chore: siliences more compiler warnings 2026-07-14 18:58:00 +08:00
李通洲 2b03bacb28 Global: further code cleanups 2026-07-14 15:07:30 +08:00
李通洲 7dcc7d40d5 InitSystem (Windows): adds support
Note: Windows doesn't have a unix-like init system process, but it does have the first userland process, which is `smss.exe`
2026-07-14 15:04:29 +08:00
Carter Li a0fd59d869 DisplayServer (Linux): don't try to inline functions with variable arguments 2026-07-14 11:05:17 +08:00
Carter Li 1c352bb4de DisplayServer (Linux): removes an old hack 2026-07-14 11:03:00 +08:00
Carter Li 29d626f41d DisplayServer (Linux): wait for delayed Wayland output events
Ref: #2451
2026-07-14 10:56:44 +08:00
Carter Li 8ca6bb084d Common (Library): adds FF_LIBRARY_LOAD_SYMBOL_VAR_LAZY 2026-07-14 10:50:36 +08:00
Carter Li 0b3ef5d35c CMake: adds comments 2026-07-13 10:35:03 +08:00
Carter Li 98c8c5b344 CMake (Linux): detects MUSL automatically 2026-07-13 10:32:12 +08:00
Carter Li eeae601924 Global: silences compiler warnings 2026-07-13 10:03:30 +08:00
Carter Li 773e3ea497 TerminalFont: small code cleanups 2026-07-13 10:03:30 +08:00
clice lee 317c0cfb86 TerminalFont (Ghostty): parse config files statically instead of exec'ing ghostty +show-config (#2122) 2026-07-12 20:59:10 -05:00
李通洲 e0c31be9d5 Battery: changes battery status to array type in custom format 2026-07-11 15:23:24 +08:00
李通洲 75f00af98d Global: replaces __auto_type to auto 2026-07-11 11:23:41 +08:00
李通洲 9d6bb7d717 Global: replaces __typeof__ to typeof 2026-07-11 11:12:23 +08:00
李通洲 2ae9c3da33 CI (Linux): removes armv6li
Doesn't have gcc13+
2026-07-11 08:14:25 +08:00
Carter Li bf1af71d03 Shell (Linux): fixes a potiential fish version detection error 2026-07-11 08:14:25 +08:00
李通洲 61656a1a7a Global: replaces __attribute__ to C23 [[attribute]] 2026-07-11 08:14:21 +08:00
李通洲 ba18705d2e Global: replaces NULL to nullptr 2026-07-10 18:10:09 +08:00
Carter Li 873454191f Global: uses typed enums 2026-07-10 18:09:46 +08:00
Carter Li f8908b9a36 Global: upgrades to C23 2026-07-10 18:09:46 +08:00
Carter Li 8ca551cccc Packaging: updates debian stuff [ci skip] 2026-07-10 15:16:11 +08:00
Carter Li 0869809857 Merge pull request #2446 from fastfetch-cli/dev
Release: v2.66.0
2026-07-10 02:04:09 -05:00
Carter Li c31779e99d CI: ensures CMAKE_BUILD_TYPE is correctly set 2026-07-10 14:44:39 +08:00
Carter Li 89ad35d8a1 GPU (BSD): fixes building when DRM is not enabled 2026-07-10 13:41:13 +08:00
Carter Li d651f3de43 Common (Tracer): updates comments [ci skip] 2026-07-10 13:11:17 +08:00
Carter Li c34c3e5aae Release: v2.66.0 2026-07-10 10:21:45 +08:00
Carter Li c5c61584d9 CPU / GPU (macOS): fixes operator priority bug 2026-07-10 10:12:00 +08:00
Carter Li 48c3b4f980 CPU (Linux): removes ARM core count in CPU name 2026-07-10 08:32:42 +08:00
Carter Li 93bca8d480 CPU (Linux): disables printing package count by default
The detection code is problematic. Let's hide the package count before we can find the root cause.
2026-07-10 08:32:42 +08:00
Carter Li c690fe5aa9 BluetoothRadio: fixes memleaks 2026-07-10 08:32:42 +08:00
Carter Li 55e674e1cb GPU: code cleanups and bug fixes 2026-07-09 20:40:49 +08:00
Carter Li 0495c47909 GPU (Linux): fixes GPU core counting on Asahi Linux 2026-07-09 20:04:11 +08:00
Marvin Hinz 2f79c39f62 OS (Linux): adds support for proxmox backup server detection (#2443)
* add support for proxmox backup server detection

* Update Proxmox identifiers and pretty names

* Simplify Proxmox logo names in p.inc

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-07-09 19:05:22 +08:00
Carter Li 44056f1c85 GPU (Linux): fixes accurate AMD GPU names are not queried in driverSpecific mode 2026-07-08 18:14:06 +08:00
李通洲 6358bd7844 FFstrbuf: optimises ffStrbufEnsureFreeNoCheck 2026-07-07 19:15:36 +08:00
Carter Li 11d77e0d09 Logo (Builtin): updates linuxmint_small 2026-07-06 17:27:33 +08:00
李通洲 ec25659503 Presets: uses the builtin icons in examples/10 to avoid inconsistency [ci skip]
Fixes #2438
2026-07-05 08:16:55 +08:00
Carter Li 35dbcb2588 CI: updates scripts 2026-07-04 18:49:00 +08:00
Carter Li 8b6a74f2ec Doc: update changelog 2026-07-03 16:18:01 +08:00
Carter Li 2ea6c3767e Logo (Builtin): cleanup a lot of distro names 2026-07-03 16:15:58 +08:00
Carter Li 827bc26b0a Trace: removes useless empty lines 2026-07-03 15:40:32 +08:00
Carter Li e12f3631d4 OS (Linux): fixes potencial issue 2026-07-03 15:37:38 +08:00
Carter Li 52c9730542 Tracer: query tid only when threading is enabled 2026-07-03 15:36:41 +08:00
Carter Li 225d9e7771 Release: v2.65.3 2026-07-03 14:50:59 +08:00
Carter Li d031d6c20f FFPlatform (Windows): hard codes i686 CPU arch 2026-07-03 14:36:18 +08:00
李通洲 35af768d92 Shell (Windows): improves performance of Windows PowerShell version detection 2026-07-03 11:07:15 +08:00
Carter Li 22c4620345 Logo (Builtin): adds Azure Linux
Fixes #2435
2026-07-03 09:45:34 +08:00
Carter Li 81738aa303 WM (Linux): fixes compatibility with WSL 2.9.3+ 2026-07-02 17:34:43 +08:00
Carter Li 113f7d34d8 OS (Linux): Add Astra Linux version detection
Fixes #2427
2026-07-01 10:57:01 +08:00
Carter Li 62513004c8 Logo (Builtin): adds Flatcar 2026-07-01 10:29:47 +08:00
Carter Li 1b36c3cd5f Logo (Builtin): updates c.inc 2026-07-01 10:29:47 +08:00
eepy 78874ae583 Logo: add chimera2, parabola2_small, postmarketos2, qubes_small (#2430)
* Logo: add chimera2, parabola2_small, postmarketos2, qubes_small

* Logo: add types to chimera2, parabola2_small, postmarketos2, qubes_small, remove "parabola-gnulinux"

* Change logo names to use capital letters

---------

Co-authored-by: v_v <circlepuller@inbox.lv>
Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-06-30 21:29:39 -05:00
李通洲 a447928853 FFstrbuf: don't try to inline functions with varargs 2026-06-30 19:35:34 +08:00
李通洲 9f446bdad7 Common (Library): adds fast path for loading only one lib 2026-06-30 19:35:34 +08:00
李通洲 4cf060eb27 Logo (Image): improves performance of DLL searching on WIndows 2026-06-30 19:35:34 +08:00
Carter Li 08d419d75c Global: adds a simple tracer 2026-06-30 16:19:57 +08:00
Carter Li 3ae1bfdc24 Media (macOS): uses perl for faster startup 2026-06-30 15:22:19 +08:00
李通洲 0e257f25c2 Platform (Windows): one less syscall 2026-06-30 09:03:00 +08:00
Carter Li 195e148cc1 Common: inlines more functions 2026-06-30 09:03:00 +08:00
Carter Li 5ab192ee05 Common (Thread): adds ffThreadGetCurrentId 2026-06-30 00:39:36 +08:00
weedygmd 4897152af6 Logo: adds chimera linux small logo (#2426)
* added small chimera linux logo

* Add logo type for Chimera_small

---------

Co-authored-by: Weed <weedygmd>
Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-06-29 00:36:10 -05:00
Carter Li 69418cb527 Packaging: updates debian stuff [ci skip] 2026-06-29 10:12:54 +08:00
李通洲 0e90f3a7d4 GPU (Windows): fixes typo 2026-06-28 17:07:48 +08:00
Carter Li 1a663e72da Release: v2.65.2 (#2425) 2026-06-28 03:55:56 -05:00
李通洲 e0ae1ac1a2 GPU (Intel): adds comments 2026-06-28 16:26:00 +08:00
李通洲 e0d141ecf6 Memory (BSD): adds underflow protection (should not happen) 2026-06-28 16:25:08 +08:00
李通洲 29eb8bb57d Chore: fixes typos 2026-06-28 16:25:07 +08:00
李通洲 bc1f240558 Memory (Linux): uses strtoull to avoid overflow in 32-bit systems 2026-06-28 16:25:07 +08:00
李通洲 3e15a2591a Release: v2.65.2 2026-06-28 16:25:07 +08:00
李通洲 0ec9443de5 Logo (Builtin): adds Turkish
Fixes #2421
2026-06-28 16:25:07 +08:00
李通洲 4a4ca9a4a8 Memory (NetBSD): takes ZFS arc bytes into account
Used logic from FreeBSD
2026-06-28 16:25:07 +08:00
李通洲 acf76e565a Memory (FreeBSD): don't query c_min if querying size fails 2026-06-28 16:25:07 +08:00
李通洲 778aa21192 Memory (SunOS): takes ZFS arc bytes into account 2026-06-28 16:25:07 +08:00
Carter Li dfdc7284a2 Memory (Linux): takes ZFS arc bytes into account
Fixes #1995
2026-06-28 16:25:07 +08:00
Carter Li 231d7fcd4d Memory (FreeBSD): takes ZFS arc bytes into account
Fixes #2418
2026-06-28 16:25:07 +08:00
Carter Li a3184601dc GPU: detects PCIe speed only in driverSpecific mode
Fixes #2419
2026-06-28 16:25:07 +08:00
李通洲 e3dfeeb8db GPU (MT): adds PCIe speed detection support 2026-06-27 09:46:30 +08:00
Carter Li ccdcd6ab6f Codec (Linux): fixes crashing on AMD GPUs
Ref: https://github.com/fastfetch-cli/fastfetch/issues/2419#issuecomment-4812121503
2026-06-27 08:12:22 +08:00
Carter Li 64d205628e Common (Settings): adds SQLITE_OPEN_NOMUTEX fiag when opening sqlite db 2026-06-26 22:52:59 +08:00
Carter Li ff13adf1b4 Logo (Builtin): updates CachyOS 2026-06-26 00:18:08 +08:00
iinsert c38fd9ec10 Chore: adds Catnap repo link to attribution comments in examples 13-16 (#2417) 2026-06-25 23:07:49 +08:00
Carter Li 96793ec604 Packaging: updates debian stuff [ci skip] 2026-06-24 14:28:35 +08:00
Carter Li b79a336576 Release: 2.65.1
Revision to make github happy
2026-06-24 10:21:03 +08:00
Carter Li d36e3a793b Merge pull request #2410 from fastfetch-cli/dev
Release v2.65.0
2026-06-23 20:39:21 -05:00
Carter Li d48bb48e4f Codec (Linux): fixes potential memleaks 2026-06-24 08:45:45 +08:00
李通洲 835001eb2f Doc: updates changelog 2026-06-23 15:51:42 +08:00
李通洲 5647703e4d WM (Linux): adds weston detection support 2026-06-23 15:51:42 +08:00
李通洲 eff0108bb5 Codec (Linux): adds va-x11 method 2026-06-23 15:33:58 +08:00
Carter Li 31c1431ac6 Release: v2.65.0 2026-06-23 13:16:49 +08:00
Carter Li fa2c56cb9f Global: fixes bugs found by CI
The code quality is to be improved...
2026-06-23 13:16:49 +08:00
Carter Li 104b33c1f7 Display: defaults disableLinewrap to false 2026-06-23 11:05:11 +08:00
Gretagen ZETA cb4502dacc Logo (Builtin): adds Zerene OS mainline (#2404)
* Create zerene.txt

* Update z.inc

* Fixed z.inc

Changed the problematic line mismatch

* Update z.inc

* Update z.inc

more fixes to z.inc

* Remove duplicate name entry for Zerene logo

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
2026-06-22 20:24:55 +08:00
Carter Li 3dc86391ab Doc: update changelog [ci skip] 2026-06-22 16:11:44 +08:00
Carter Li f5a67b25f4 Packages (Linux): cleanups install-release package count code 2026-06-22 13:28:18 +08:00
Jess d8be61411e Packages (Linux): add install-release package count support (#2342)
* feat: add install-release package count support

* Apply suggestion from @codacy-production[bot]

Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>

* Fix formatting of ffParsePropFileValues call

---------

Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
2026-06-22 00:23:21 -05:00
Carter Li 61968ca95c Chore: tidy 2026-06-22 13:18:27 +08:00
Carter Li 9f190b46c9 DisplayServer (macOS): detects string serial number for Apple Silicon 2026-06-22 13:18:27 +08:00
Kerem Gökcek a6aac70a5e Packages (Linux): Improve emerge detection speed (#2406)
* Packages (Linux): Improve emerge detection speed

* Fix code styling
2026-06-21 21:56:01 -05:00
yabobay 3aa43212ff Packages (Linux): support porg 2026-06-22 10:45:08 +08:00
李通洲 7c39b64fb4 CMake: extracts package managers from source code 2026-06-20 19:24:19 +08:00
Carter Li e1963e41be Networking (Linux): don't use MSG_DONTWAIT to send HTTP request
Ref #2401
2026-06-20 10:17:04 +08:00
Carter Li a1d4cbf67f DisplayServer (Wayland): correctly reports platform api 2026-06-20 08:59:31 +08:00
Carter Li f5b9e09d91 DisplayServer (macOS): detects string serial number 2026-06-20 01:21:39 +08:00
Carter Li 9742dda795 Wifi (FreeBSD): adds WPA version detection support 2026-06-19 23:30:01 +08:00
Carter Li 677c213397 Codec (Linux): fixes bug in ffDetectCodecByVdpau 2026-06-19 23:02:13 +08:00
李通洲 8f0a12323b Doc: updates changelog 2026-06-19 20:30:32 +08:00
李通洲 b49f0b3d9c Fastfetch: improves error message for config errors 2026-06-19 20:19:50 +08:00
李通洲 bc686b2c84 Logo: improves error message for chafa options 2026-06-19 20:14:58 +08:00
Carter Li 7c2f7fa4f2 DisplayServer (Linux): detects preferred resolution from EDID 2026-06-19 19:21:00 +08:00
Carter Li 5fd059827d Display: fetch text serial if available instead of the 4-byte integer 2026-06-19 18:56:08 +08:00
Carter Li 240928138e GPU: adds egl-ext detection method 2026-06-18 21:03:28 +08:00
Carter Li 508a50f803 OpenGL (EGL): optimises code 2026-06-18 21:03:28 +08:00
Carter Li bd40d8756e GPU (FreeBSD): adds a missing var-init 2026-06-18 19:33:40 +08:00
Carter Li b732e0c6d7 Codec (Linux): fixes a crash 2026-06-18 18:11:48 +08:00
Carter Li 96685b7ebe Global: cleanups FF_HAVE_DRM macro 2026-06-18 17:45:19 +08:00
Carter Li 49a1e42efd CI: updates spellcheck 2026-06-18 13:39:56 +08:00
Carter Li b0fd11fcbd Global: simplifies code 2026-06-18 10:59:36 +08:00
Carter Li b6127ff2c9 Codec (Linux): removes usage of libdrm 2026-06-18 10:56:28 +08:00
Carter Li f3babe3187 Codec (Linux): fixes memleaks 2026-06-18 10:44:11 +08:00
Carter Li e9c0d886d1 DisplayServer (Linux): be compatible with KDE 6.7
This PR also removes usage of `kde-output-order-v1-protocol`, which disables detection of primary monitor for old KDE versions
2026-06-18 10:31:37 +08:00
Carter Li d6a4946511 DisplayServer (Linux): fixes memleaks 2026-06-18 10:06:52 +08:00
Carter Li 43e0cc22ff GPU: initializes pcieSpeed everywhere 2026-06-18 08:44:01 +08:00
Carter Li c42ea6eeea DisplayServer (Linux): adds HDR detection support
Fixes #2356
2026-06-17 20:07:37 +08:00
Carter Li fe7962d5d2 DisplayServer (Linux): embeds definitions of wl-output-* 2026-06-17 15:32:27 +08:00
Carter Li e84195bca0 Linux (Wayland): drops zwlr-output.c
It doesn't expose much more functions than `wl-output`
2026-06-17 15:10:24 +08:00
Carter Li bf0133fe60 Packaging: updates debian stuff [ci skip] 2026-06-17 15:06:15 +08:00
李通洲 942c15b7b0 CPU (X86): fixes detection for AMD Carrizo
Ref: https://github.com/anrieff/libcpuid/commit/b0c4959cf4a8b8351ab33add3f83ee0dcf37faf1
2026-06-15 18:41:48 +08:00
Carter Li 61a0bbcc8d GPU (Linux): fixes building for old kernel headers 2026-06-14 19:51:30 +08:00
Carter Li 8b3673eb38 GPU (Nvidia): replaces deprecated API nvmlDeviceGetTemperature with suggested one 2026-06-14 19:51:30 +08:00
Carter Li 22f9948497 GPU: detect current pcie link speed 2026-06-14 19:51:30 +08:00
李通洲 107f39eb15 JsonSchema: update moduleFormat 2026-06-14 19:51:30 +08:00
Carter Li 4e44c0520b GPU: detects max PCI gen & link width 2026-06-14 19:51:29 +08:00
Carter Li 55eb3c59d4 GPU (Linux): replaces amdgpu library with raw ioctl calls 2026-06-14 19:51:29 +08:00
Carter Li 878ccf1375 DisplayServer (Linux): use kernel headers if libdrm is not available 2026-06-13 12:29:51 +08:00
Carter Li ebb0cf77bd CMake: checks linux kernel headers 2026-06-13 12:29:51 +08:00
Carter Li 17914dc29e Global: unifies FF_STR macro 2026-06-13 12:29:51 +08:00
李通洲 14dfe171fb GPU (OpenBSD): adds DRM method 2026-06-13 12:29:51 +08:00
Carter Li 265c334399 GPU (FreeBSD): moves DRM detection to global space for OpenBSD use 2026-06-13 12:29:51 +08:00
Carter Li fc303c58db GPU: adds unified ffGPUFillVendorByDeviceName 2026-06-13 12:29:51 +08:00
Carter Li 01e7503263 GPU (BSD): uses direct ioctl calls (WIP) 2026-06-13 12:29:50 +08:00
Carter Li ffd0455fe3 DisplayServer (Linux): rewrites libdrm calls with plain ioctls 2026-06-12 14:34:36 +08:00
Carter Li 7df2ed2251 Packages: reorders package variables in custom format 2026-06-12 14:34:36 +08:00
Carter Li 2edc41dd9a CI (OpenBSD): updates packages 2026-06-11 15:14:39 +08:00
Carter Li cada77163e Chore: update .gitignore 2026-06-11 15:07:47 +08:00
Carter Li 7cecdb0e6d DisplayServer (Linux): don't return success if no devices are successfully connected 2026-06-11 10:49:07 +08:00
Carter Li 420a9e9d7b TerminalFont (Linux): adds kmscon support
Fixes #2393
2026-06-11 10:49:00 +08:00
Carter Li b96d8ad00b Terminal (Linux): adds kmscon version detection support 2026-06-11 10:15:50 +08:00
Carter Li 52970e2d13 Processing (Linux): don't use /proc/pid/exe as exePath when the file is not executable (no permission) 2026-06-11 10:15:50 +08:00
Carter Li 4594734b66 CI (OpenBSD): updates OS version 2026-06-09 16:07:56 +08:00
Carter Li eb54c89b4a OS (macOS): adds the code name of macOS 27 2026-06-09 14:05:23 +08:00
Carter Li 43301afc47 CPU: enables showPeCoreCount by default 2026-06-09 14:04:54 +08:00
Carter Li 09e28451ec CPU (Linux): simplifies code of frequency detection 2026-06-09 13:38:49 +08:00
Carter Li 35c2f8c924 CPU (Linux): fixes physical core detection on non-x86 2026-06-09 13:09:58 +08:00
李通洲 3ec7e94b47 CPU (Windows): uses a better way to fetch core types 2026-06-08 19:03:23 +08:00
Carter Li a720e1f945 Fastfetch (Windows): moves SetConsoleMode and SetConsoleOutputCP to the start of process
Fixes #2383
2026-06-08 10:58:14 +08:00
Carter Li 70061625f7 Chore: adds FF_A_COLD 2026-06-08 10:38:28 +08:00
李通洲 5cd4316f98 CPU (X86): uses normalized cpu brand name for pattern matching 2026-06-08 00:41:08 +08:00
李通洲 e946861eb0 Codec (Windows): fixes compatibility of Win 8.1 2026-06-08 00:41:01 +08:00
李通洲 f09aebecd5 CPU (X86): updates comments 2026-06-07 16:48:15 +08:00
李通洲 8f266eb2a7 Chore: don't check spelling in cpu_x86.c 2026-06-07 16:41:59 +08:00
李通洲 8ee08d0067 CI: don't run heavy tests if the light one failed 2026-06-07 16:40:40 +08:00
李通洲 e936ddef6b CPU (X86): adds code name and tech detection
Fixes #1501
2026-06-07 10:46:37 +08:00
李通洲 c706201282 Global: adds some always_inline 2026-06-06 23:01:18 +08:00
李通洲 e24e3b6b29 Global: returns false when an error is printed 2026-06-05 22:34:53 +08:00
李通洲 135547fd50 Logo: don't accept chafa options when chafa is disabled 2026-06-05 22:19:35 +08:00
李通洲 da05bed32f CMake: exposes pre-defined macros to fastfetch.c to avoid imcompatiblity with libfastfetch 2026-06-05 22:19:35 +08:00
Carter Li 636471c366 Merge pull request #2375 from fastfetch-cli/dev
Release v2.64.2
2026-06-05 18:36:58 +08:00
李通洲 cbc84fda6c Common (Lua): addresses AI's feedback 2026-06-05 18:21:28 +08:00
李通洲 fc7a0a8484 Codec (Linux): supports BINARY_LINK_TYPE=dynamic 2026-06-05 18:05:54 +08:00
李通洲 4d3b6c3b1b Common (QJS): supports BINARY_LINK_TYPE=dynamic 2026-06-05 17:49:49 +08:00
李通洲 70e67177fe Common (Lua): supports BINARY_LINK_TYPE=dynamic 2026-06-05 17:22:16 +08:00
李通洲 9fe7d6dbfa Logo: addresses review comments of AI 2026-06-05 16:34:02 +08:00
Carter Li a139a8c4a5 Doc: updates changelog [ci skip] 2026-06-05 16:22:04 +08:00
Valeriy Kosikhin da568c986e Logo (Builtin): update OpenWrt logo
Update the large logo for OpenWrt based on the official branding.
Add a small logo version.
Keep the old logo as openwrt_old.txt

Signed-off-by: Valeriy Kosikhin <vkosikhin@gmail.com>
2026-06-05 16:15:46 +08:00
Carter Li 727fbc0276 Doc: updates changelog 2026-06-05 15:29:00 +08:00
Carter Li 20aabdfd78 Global: resets keysHeight after every refresh 2026-06-05 15:27:25 +08:00
Carter Li e79aaf5ce1 Global: don't clear line in --logo-position right 2026-06-05 15:27:15 +08:00
Carter Li 53c2d07161 Release: v2.64.2 2026-06-05 14:51:50 +08:00
Carter Li 6b9f594620 Global: prevents ascii logo from being overwritten in --dynamic-interval mode 2026-06-05 14:47:01 +08:00
Carter Li ba3968784f Logo (Image): fixes image renders but quickly gets wiped
Regression from v2.64.0

Fixes: #2374
2026-06-05 13:12:07 +08:00
Carter Li 021ece1681 Merge pull request #2370 from fastfetch-cli/dev
Release: v2.64.1
2026-06-04 23:45:19 +08:00
李通洲 9787b56460 Release: v2.64.1 2026-06-04 20:15:54 +08:00
李通洲 54792e61ff Common (Lua): detects circular reference in encode_json 2026-06-04 20:15:54 +08:00
Carter Li b34e2a4055 Common (Base64): adds static to internal functions 2026-06-04 17:22:24 +08:00
Carter Li 3b56200ee4 Packages: adds option PACKAGES_REMOVE_DISABLED to remove disabled package managers from the build entirely 2026-06-04 17:22:24 +08:00
Carter Li de95a62e2f Codec (macOS): removes usage of JPEG XL; replaces enums with raw constants 2026-06-04 10:48:01 +08:00
Carter Li 72cb64a500 Common (Lua): optimises code; fixes incompatibility against lua 5.3 2026-06-04 10:48:01 +08:00
Carter Li d48bd733f0 Merge pull request #2368 from fastfetch-cli/dev
Release v2.64.0
2026-06-03 19:18:31 +08:00
李通洲 0585ea7797 Doc: update changelog 2026-06-03 18:34:09 +08:00
李通洲 794035f8d9 Shell: sets pretty name of busybox to ash 2026-06-03 18:29:33 +08:00
李通洲 723552f68b Shell: be more robust on busybox version detection 2026-06-03 18:29:10 +08:00
Carter Li 8dd38f5744 Release: v2.64.0 2026-06-03 16:04:00 +08:00
Carter Li 616a5c7aea Codec (Vulkan): be compatible with old Vulkan headers
Fixes #2367
2026-06-03 15:23:42 +08:00
Carter Li 5e1e94473e Bootmgr (macOS): don't hard-code the firmware name 2026-06-03 15:23:42 +08:00
CicaDATA 4eae8ac244 Logo (Builtin): updates NurOS logo and colors (#2366) 2026-06-03 02:21:23 -05:00
李通洲 8aeb7c2f10 Shell (Linux): improves performance of busybox (ash) version detection 2026-06-02 17:44:55 +08:00
Carter Li c20b532c7a Common (Format): adds | for center aligning 2026-06-02 16:03:04 +08:00
Carter Li 3c59161aca Common (Format): handles ANSI escapes when padding/truncating variable strings
Fixes #2364
2026-06-02 15:55:10 +08:00
Carter Li bd454632c3 FFstrbuf: inlines more functions 2026-06-02 15:42:40 +08:00
Carter Li e73adc27a0 Common: fixes wcwidth handling 2026-06-02 15:05:13 +08:00
Carter Li 15c6014c04 Common: don't inline ffUtf8CharLenWidth 2026-06-02 14:01:59 +08:00
Carter Li 54f18982ac Common: renames arrayUtil to arrutil 2026-06-02 10:59:18 +08:00
Carter Li 99c2f2a2c8 JsonSchema: adds codec 2026-06-02 10:58:57 +08:00
Carter Li 45f35b1c4d Library (Linux): adds simple debug log 2026-06-02 09:27:38 +08:00
Carter Li 428c05b9de Codec (Linux): optimises code 2026-06-02 09:10:55 +08:00
李通洲 23ca6d94ab CI: run codec module 2026-06-02 00:15:42 +08:00
李通洲 9e4e0cb838 Codec (Linux): removes VAEntrypointEncPicture 2026-06-01 23:45:17 +08:00
李通洲 95a370e5a2 Codec (macOS): fixes building 2026-06-01 20:48:59 +08:00
李通洲 e013005f34 Code (Vulkan): fixes compiling 2026-06-01 20:16:30 +08:00
李通洲 92b86f7cbb Codec: shows types only specifed by showType 2026-06-01 19:27:37 +08:00
李通洲 2e4b7baf44 Codec (Android): adds showType support 2026-06-01 19:27:37 +08:00
李通洲 a47ff0b2dc Codec (macOS): adds showType support 2026-06-01 19:27:37 +08:00
李通洲 1f13f6c8f5 Codec (Windows): adds showType support 2026-06-01 19:27:37 +08:00
李通洲 b0bb6fb58e Codec: don't show Unknown 2026-06-01 19:27:37 +08:00
Carter Li 37029dbbe3 Codec (Vulkan): adds showType support 2026-06-01 19:27:37 +08:00
Carter Li 35428606e7 Codec (Linux): adds FFCodecShowOptions; code cleanup 2026-06-01 19:27:37 +08:00
Carter Li 2c65eee00f Common (Lua): adds json_encode 2026-06-01 19:27:37 +08:00
Carter Li a1bf014352 Codec: normalizes platformApi string 2026-06-01 10:34:17 +08:00
Carter Li 412fc94dab WM (Linux): fixes possible segfault when detecting sway version
Fixes #2360
2026-06-01 10:16:26 +08:00
Carter Li b65de28805 Logo (Builtin): adds Quasar
Fixes #2338 #2323
2026-06-01 09:34:32 +08:00
李通洲 bc86c66cdd Codec (Windows): detects encoders detection support via MFT on Win10 or older 2026-06-01 09:16:22 +08:00
李通洲 9afa01812d Codec (Vulkan): disables impl if the vulkan headers are too old to use 2026-06-01 00:15:27 +08:00
李通洲 30a8a94cd2 Chore (Haiku): silences compiler warnings 2026-05-31 23:56:45 +08:00
李通洲 3a54617196 Codec: adds vulkan support 2026-05-31 23:45:20 +08:00
李通洲 3e3a03a233 Codec (Android): adds support 2026-05-31 23:37:50 +08:00
李通洲 b407669b69 JsonSchema: update 2026-05-31 23:37:49 +08:00
李通洲 e14ea926a5 Codec (macOS): adds platformApi 2026-05-31 23:37:49 +08:00
李通洲 9d8f794cb9 Codec (Windows): detects encoder support via d3d12va 2026-05-31 23:37:49 +08:00
Carter Li 825b8b8715 Codec (Linux): adds vdpau fallback impl 2026-05-31 23:37:49 +08:00
Carter Li 0c94fd87db Codec: updates default format 2026-05-31 23:37:49 +08:00
Carter Li 473a08d85c Decoder: renames to Codec and adds encoders detection support 2026-05-31 23:37:49 +08:00
Carter Li ae5132c388 Decoder (macOS): adds support 2026-05-31 23:37:49 +08:00
李通洲 1addcec7a2 Decoder (Linux): adds *nix support 2026-05-31 23:37:49 +08:00
李通洲 e75c37c101 Decoder (Windows): adds support 2026-05-31 23:37:49 +08:00
李通洲 b9ab823f77 Decoder: inits module 2026-05-31 23:37:48 +08:00
François Revol a63d854681 OS (Haiku): Fix warnings 2026-05-31 23:37:35 +08:00
François Revol 576548b15e WMTheme (Haiku): implement 2026-05-31 23:37:35 +08:00
François Revol 3043971259 Brightness (Haiku): Implement 2026-05-31 23:37:35 +08:00
François Revol ccf4f22f8b Bootmgr (Haiku): Preliminary implementation 2026-05-31 23:37:35 +08:00
LibereCode f932db713c Logo (Builtin): Minor tweak NixOS_small logo (#2357)
* [fix]: markdown-link to wiki

* [fix]: fix color at 1 spot

* [fix]: fix color at 1 spot, again

* Revert "[fix]: markdown-link to wiki"

This reverts commit 72f4d11c90.

"Remove unrelated changes"
2026-05-31 01:11:53 +08:00
李通洲 d2e8a8fd9e CMake: renames DISABLE_MODULE_* for MODULE_DISABLE_* to align with PACKAGE_DISABLE_* 2026-05-30 18:37:42 +08:00
李通洲 4c1f7c114a Chore: reports if embedded wcwidth is enabled 2026-05-30 18:27:17 +08:00
SirSputnikWiki 90bbfe195f Terminal (Linux): improves terminal name detection for nix packages (#2352)
* Improved terminal name detection for nix packages

* Improved terminal name detection for nix packages

* Update terminalshell_linux.c

Move ffStrbufStartsWithC(&result->processName, '.') before string comparation, as it's much cheaper.
2026-05-30 10:16:12 +08:00
Carter Li 1689fc81e9 Logo (Builtin): adds Origami and Origami_small
Fixes #2321 #2322
2026-05-29 16:05:53 +08:00
Carter Li 4190dd5a6e Logo (Builtin): adds BerserkArch
Fixes #2324 #2310
2026-05-29 16:05:52 +08:00
Carter Li 074f882d7e Wallpaper (Linux): adds COSMIC support 2026-05-29 15:40:27 +08:00
Carter Li 53102380b8 WMTheme (Linux): adds COSMIC support 2026-05-29 15:40:02 +08:00
李通洲 822bc158ba CMake: changes FF_MODULE_XX to FF_DISABLE_MODULE_XX 2026-05-28 23:14:49 +08:00
李通洲 8fbc29a70c Common (strutil): fixes unit tests 2026-05-28 22:41:47 +08:00
李通洲 0ef677a98c Logo (Builtin): add NixOS2
Fixes #2346
2026-05-28 20:12:46 +08:00
Carter Li 10b0d0ca3e CPU (Android): adds Exynos 2600 2026-05-28 19:20:21 +08:00
Carter Li ec4e820e92 Logo: exports ffLogoPrintDetected 2026-05-28 19:18:35 +08:00
Carter Li 6c09fe49e4 Logo (Builtin): warps logo definitions into #ifdef blocks 2026-05-28 18:42:10 +08:00
Carter Li 1ce6398391 Logo (Builtin): splits built-in logos into individual files 2026-05-28 18:42:10 +08:00
Carter Li d1bf208a92 Chore: renames stringUtils to strutil 2026-05-28 15:58:08 +08:00
Carter Li 7ce1e553b8 CMake: makes default structure configurable via CMake 2026-05-28 15:55:43 +08:00
Carter Li 9c878b6943 Chore: moves /src/data/help.json to /doc 2026-05-28 15:54:17 +08:00
Carter Li 6b9a6fd103 CMake: adds MODULE_<module> options to disable modules 2026-05-28 15:41:14 +08:00
Carter Li 896fe60461 CMake: adds option FF_ENABLE_WCWIDTH 2026-05-28 14:47:09 +08:00
Carter Li dadcccdf26 TerminalShell: code refactor 2026-05-28 10:31:35 +08:00
李通洲 0746af7549 Wifi (Linux): adds comments [ci skip] 2026-05-27 17:11:59 +08:00
Carter Li 88c3b7d118 Common (stringUtil): adds ffUtf8CharLenWidth 2026-05-26 16:11:30 +08:00
Carter Li 173d9695b6 Common: removes using of built-in wcwidth, which is locale-dependent 2026-05-26 16:10:01 +08:00
Carter Li 4b265cd56a Common: adds Attr FF_A_ALWAYS_INLINE 2026-05-26 15:37:17 +08:00
李通洲 1f211cf8d1 Brightness: adds ddcciSleep: null to skip DDC/CI detection 2026-05-24 10:58:10 +08:00
李通洲 bac60357c6 Logo: fixes paddingLeft not working with position: top 2026-05-24 08:39:25 +08:00
李通洲 3a0e188570 CMake (Windows): disables usage of WinRT on GCC
Fixes #2341
2026-05-23 22:49:04 +08:00
李通洲 9d5b40686b Global: really prints --stat at the right border 2026-05-23 09:50:49 +08:00
李通洲 a321cd877e Logo: resets color state after printing logo line 2026-05-23 09:44:03 +08:00
李通洲 5f810de1e0 Logo: overrides the auto detected max-width with the configured width, if set 2026-05-23 09:33:58 +08:00
李通洲 3f0a93d057 Logo: reworks position: top; adds a new option --logo-padding-bottom 2026-05-22 20:26:18 +08:00
Carter Li cbca6a965c Logo: prints ASCII logo line by line 2026-05-22 19:09:34 +08:00
Carter Li fde1195c27 TerminalFont (macOS): fixes fallback font detection of Ghostty; adds Muxy terminal support 2026-05-22 14:20:39 +08:00
Carter Li 9856d97bd1 Common (macOS): unifies AppBundle version detection code 2026-05-22 13:37:48 +08:00
Carter Li 2751737ebe CI: builds with quickjs-ng support 2026-05-22 10:24:25 +08:00
Carter Li 834292df29 Brightness (DFBSD): fixes compiling 2026-05-22 10:09:39 +08:00
Carter Li a9a29869a4 Format: tidy 2026-05-22 10:09:39 +08:00
Carter Li 242fb50461 Format: traits undefined result as an error 2026-05-22 09:26:52 +08:00
Carter Li b5c4ffcc85 Format (Lua): simplifies error messages 2026-05-21 09:25:41 +08:00
李通洲 2c3628c630 Format (QJS): converts UINT64 to double and drops usage of BigInt 2026-05-20 23:01:28 +08:00
李通洲 4cca9bf198 Presets: removes invalid comments 2026-05-20 18:40:36 +08:00
李通洲 0ed27d9700 Format: fixes a possible OOB read 2026-05-20 18:40:20 +08:00
李通洲 9bca4eb48f Format: normalizes arg name before pass to script language 2026-05-20 18:39:12 +08:00
李通洲 462b80fc36 CMake: corrects the package name of quickjs-ng 2026-05-20 18:17:38 +08:00
Carter Li f49620a95b CMake: hardens Lua handling 2026-05-20 16:18:50 +08:00
Carter Li 6e0949c739 CMake: fixes finding quickjs 2026-05-20 09:32:02 +08:00
Carter Li 4b18ab0de7 Brightness (macOS): fixes building 2026-05-20 09:31:35 +08:00
Carter Li 8abd75a746 Brightness: refactor 2026-05-20 00:09:09 +08:00
Carter Li d5b215e074 Brightness (FreeBSD): improves DDC/CI handling 2026-05-20 00:07:20 +08:00
Carter Li 0b22427091 WM (Linux): fixes swayfx version detection on NixOS 2026-05-19 17:20:56 +08:00
Carter Li aa34910b6c CMake: actually compiles with quickjs-ng definitions 2026-05-19 15:52:01 +08:00
李通洲 52972ed833 CI (Windows): bundles dlls of lua & qjs 2026-05-18 11:06:30 +08:00
李通洲 68e75effab CMake: adds comments [ci skip] 2026-05-18 11:01:37 +08:00
Carter Li bb79370d03 Brightness (FreeBSD): adds ddc-ci detection support (WIP) 2026-05-18 10:08:31 +08:00
李通洲 9613cdd146 CI: builds with quickjs support 2026-05-18 01:42:13 +08:00
李通洲 724b816252 CI: builds with lua support 2026-05-17 23:21:49 +08:00
李通洲 7c89a10add Common: adds Lua script support for custom format 2026-05-17 20:12:03 +08:00
李通洲 fb5ec76eb3 Global: skips module if format buffer is empty 2026-05-17 19:55:30 +08:00
Carter Li 7141214f95 WM (Linux): fixes swayfx version detection 2026-05-17 09:51:19 +08:00
Carter Li 7d6074968f Packaging: update debian stuff [ci skip] 2026-05-15 09:40:40 +08:00
Carter Li 3bd380802b Merge remote-tracking branch 'origin/master' into dev 2026-05-15 09:40:24 +08:00
李通洲 ec1200dc06 Media (Windows): removes using of C++20 std::bind_front 2026-05-14 19:50:38 +08:00
Carter Li 5c18c061b3 GPU (Linux): silences a warning in Release mode 2026-05-14 09:39:17 +08:00
Carter Li acf610416c Merge pull request #2331 from fastfetch-cli/dev
Release: v2.63.1
2026-05-13 19:54:48 +08:00
Carter Li 90d3b3d49f Release: v2.63.1 2026-05-13 19:41:21 +08:00
Carter Li bbc5b4de98 Wifi (Linux): disables usage of Netlink on big-endian platforms
Until some can confirm it works
2026-05-13 19:29:33 +08:00
Carter Li 7f9b6187a6 CommandOption: fixes segfault with unknown module 2026-05-13 19:28:36 +08:00
Carter Li 8067e43631 Media (Linux): be compatible with signed media length
Fixes Chrome support
2026-05-13 19:07:14 +08:00
Carter Li 61dba1ea05 Packaging: update debian stuff [ci skip] 2026-05-13 16:04:51 +08:00
1400 changed files with 68498 additions and 19072 deletions
-5
View File
@@ -1,5 +0,0 @@
[codespell]
check-filenames =
builtin = clear,rare,usage,informal
skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii,./src/detection/gpu/asahi_drm.h
ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,slave,sur,doas,conexant,ags,bu
+13
View File
@@ -1,2 +1,15 @@
# Normalise text files to LF in the repository and check them out with LF, so a CRLF
# never enters an object and never shows up as a whole-file diff on Windows.
* text=auto eol=lf
# The vendored AMD Display Library SDK ships with CRLF endings of its own. Leaving it
# alone keeps `Dep (3rdparty): upgrades display-library` from carrying a 7000-line
# whitespace diff, and a re-vendor will not fight the rule above.
src/3rdparty/display-library/** -text
# The logo fixtures store the exact bytes fastfetch prints, ANSI escapes included.
# They are demo data rather than text, and are not read by any test.
*.fflogo -text
*.h linguist-language=c
*.c linguist-language=c
+32 -7
View File
@@ -6,16 +6,31 @@ body:
- type: markdown
attributes:
value: |
Tip: You can display a logo in fastfetch without adding it to fastfetch's official repo.
> [!WARNING]
> **NB:** If your logo request does not meet the basic requirements outlined in this template, the issue may be closed at any time without any further explanation.
**Tip:** You can display a logo in fastfetch without adding it to fastfetch's official repo.
For highly customized, personal logos, we recommend keeping them locally.
Please refer to https://github.com/fastfetch-cli/fastfetch/wiki/Migrate-Neofetch-Logo-To-Fastfetch
You can test your logo locally using:
`fastfetch -l /path/to/logo.txt --logo-color-1 white --logo-color-2 red`
Please refer to the [Migration Guide](https://github.com/fastfetch-cli/fastfetch/wiki/Migrate-Neofetch-Logo-To-Fastfetch) for details on color placeholders (`$1`, `$2`, etc.).
- type: textarea
attributes:
label: OS
description: Paste the contents of `/etc/os-release` and `/etc/lsb-release` here. If neither file exists, describe how to identify the distro.
description: Paste the contents of `/etc/os-release` (specifically the `ID` and `PRETTY_NAME` fields). If neither file exists, describe how to identify the distro.
placeholder: cat /etc/os-release
validations:
required: true
- type: input
attributes:
label: Public repository URL
description: A public repository is required to verify the request. Please provide a link to the repository where the distro is developed.
placeholder: https://github.com/example/distro
validations:
required: true
- type: input
attributes:
label: Distro Website
@@ -23,25 +38,35 @@ body:
placeholder: https://example.com
validations:
required: true
- type: textarea
attributes:
label: ASCII Art
description: The ASCII logo should not take up too much space (smaller than 50x20 characters, W x H). Please also include the color codes if they are not available in `os-release`.
placeholder: Paste ASCII art here
description: |
The ASCII logo should not take up too much space (smaller than 50x20 characters, W x H).
**Important:** Fastfetch uses `$1`, `$2`, `$3` etc. for color placeholders. Do NOT use hardcoded ANSI escape codes (like `\033[38;2...m`) or Neofetch's `${c1}` syntax.
Take <https://github.com/fastfetch-cli/fastfetch/tree/dev/src/logo/ascii> as examples.
placeholder: Paste ASCII art with $1, $2 placeholders here
validations:
required: true
- type: input
attributes:
label: Original Image URL
description: If the ASCII art is based on an image, please provide a link to the original image file.
placeholder: Image URL from the distro website mentioned above
- type: checkboxes
attributes:
label: Checklist
options:
- label: My distro has reached a stable state (out of beta, alpha, RC).
required: true
- label: The ASCII art is smaller than 50x20 characters (W x H).
required: true
- label: The ASCII art includes color codes, or the color codes are available in `os-release`.
- label: The ASCII art uses `$N` color placeholders (or colors are natively available in `os-release`).
required: true
- label: The ASCII art has no internal padding (spaces at the start and/or end of lines).
- label: The ASCII art has no unnecessary trailing spaces at the end of lines.
required: true
- label: I promise that I will send a removal request if the distro is discontinued.
required: true
+424
View File
@@ -0,0 +1,424 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fastfetch · Benchmark</title>
<style>
:root {
color-scheme: light;
--page: #f5f7fb;
--card: #fff;
--text: #172033;
--muted: #64748b;
--border: #dbe3ef;
--accent: #2563eb;
--accent-soft: #dbeafe;
--chart-text: #334155;
--chart-grid: #cbd5e1;
}
:root[data-theme="dark"] {
color-scheme: dark;
--page: #0f172a; --card: #172033; --text: #e5edf8; --muted: #9aabc1; --border: #334155; --accent-soft: #1e3a8a;
--chart-text: #f1f5f9;
--chart-grid: #475569;
}
* { box-sizing: border-box; }
body { max-width: 1440px; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; background: var(--page); color: var(--text); font: 16px/1.5 system-ui, -apple-system, sans-serif; }
header { margin-bottom: 1.75rem; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.04em; }
h2 { margin: 0; font-size: 1.25rem; }
p { color: var(--muted); }
.intro { margin: .6rem 0 1rem; }
.links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.theme-toggle, .fullscreen { border: 1px solid var(--border); border-radius: .55rem; padding: .5rem .8rem; background: var(--card); color: var(--text); cursor: pointer; font: inherit; font-weight: 600; }
.theme-toggle:hover, .fullscreen:hover { border-color: var(--accent); color: var(--accent); }
.tabs { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.5rem 0; padding: .35rem; border: 1px solid var(--border); border-radius: .8rem; background: var(--card); }
.tab { border: 0; border-radius: .55rem; padding: .65rem 1.15rem; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-weight: 700; }
.tab:hover, .tab[aria-selected="true"] { background: var(--accent); color: #fff; }
.tab-panel[hidden] { display: none; }
.platform-title { display: flex; align-items: center; gap: .65rem; margin: 1.5rem 0 1rem; }
.platform-title::before { content: ''; width: .35rem; height: 1.4rem; border-radius: 1rem; background: var(--accent); }
.charts { display: flex; flex-direction: column; gap: 1.25rem; }
.chart { min-width: 0; padding: 1.25rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); box-shadow: 0 8px 28px #0f172a0c; }
.chart:fullscreen { overflow: auto; padding: 2rem; background: var(--page); }
.chart:fullscreen .canvas-wrap { height: calc(100vh - 13rem); }
.chart-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.chart-header span { color: var(--muted); font-size: .85rem; }
.canvas-wrap { position: relative; height: 360px; }
.chart-actions { display: flex; align-items: center; gap: .75rem; }
.legend-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.legend-action { border: 1px solid var(--border); border-radius: .45rem; padding: .35rem .6rem; background: var(--card); color: var(--muted); cursor: pointer; font: inherit; font-size: .8rem; }
.legend-action:hover { border-color: var(--accent); color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: 1rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; border: 0; padding: .15rem 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; font-size: .85rem; }
.legend-item.is-hidden { color: var(--muted); }
.legend-swatch { width: .75rem; height: .75rem; border-radius: 50%; }
.legend-item.is-hidden .legend-swatch { opacity: .35; }
.chart-tooltip { position: fixed; z-index: 1000; pointer-events: none; width: min(90vw, 900px); max-height: calc(100vh - 24px); overflow: hidden; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: .6rem; background: var(--card); color: var(--text); box-shadow: 0 10px 30px #0f172a33; font-size: .8rem; opacity: 0; transition: opacity .1s ease; }
.chart-tooltip-title { margin-bottom: .35rem; font-weight: 700; white-space: normal; overflow-wrap: anywhere; }
.chart-tooltip-message { margin-bottom: .35rem; color: var(--muted); font-weight: 400; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.chart-tooltip-body { max-height: calc(100vh - 76px); overflow: auto; columns: 220px auto; column-gap: 1.5rem; }
.chart-tooltip-row { display: flex; align-items: center; gap: .45rem; break-inside: avoid; white-space: nowrap; }
.chart-tooltip-swatch { width: .55rem; height: .55rem; border-radius: 50%; flex: 0 0 auto; }
.empty { padding: 2rem 0; color: var(--muted); }
</style>
<script src="data.js"></script>
<script src="https://unpkg.com/chart.js@latest/dist/chart.umd.min.js"></script>
</head>
<body>
<header>
<div class="header-row">
<h1>Fastfetch Benchmark</h1>
<button id="theme-toggle" class="theme-toggle" type="button"></button>
</div>
<p class="intro">Performance history grouped by CPU family. Each chart contains all modules and the total process time for one operating system and architecture. All metric series are shown by default except total process time, module Weather, and module PublicIp — toggle any series from the legend below the chart.</p>
<p class="links"><a href="data.js">Download raw benchmark data</a></p>
</header>
<nav id="tabs" class="tabs" aria-label="CPU architecture"></nav>
<main id="panels"><p class="empty">Loading charts…</p></main>
<script>
(() => {
const benchmarkData = window.BENCHMARK_DATA || {};
const entries = Object.values(benchmarkData.entries || {}).flat();
const groups = new Map();
function architectureFamily(arch) {
const normalized = arch.toLowerCase();
if (/^(amd64|x86_64|x86|i[3-6]86)$/.test(normalized)) return 'Intel';
if (/^(aarch64|arm64|armv[5-8].*|arm)$/.test(normalized)) return 'ARM';
return 'Other';
}
function parseName(name) {
let match = name.match(/^fastfetch (linux|macos|windows) ([^ ]+) (module .+|total process time)$/i);
if (match) {
return { platform: match[1].toLowerCase(), arch: match[2], metric: match[3] };
}
// Keep older macOS records visible while new records use the platform field.
match = name.match(/^fastfetch ([^ ]+) (module .+|total process time)$/i);
return match ? { platform: 'macos', arch: match[1], metric: match[2] } : null;
}
function entryMetadata(entry) {
const raw = entry.commit?.timestamp ?? entry.date;
const date = new Date(raw);
return {
date: Number.isNaN(date.valueOf()) ? String(entry.date ?? '') : date.toISOString(),
sha: entry.commit?.id ?? 'unknown',
message: entry.commit?.message?.trim() ?? ''
};
}
for (const entry of entries) {
const metricsByGroup = new Map();
for (const bench of entry.benches || []) {
const parsed = parseName(bench.name);
if (!parsed) continue;
const key = `${parsed.platform} ${parsed.arch}`;
if (!metricsByGroup.has(key)) metricsByGroup.set(key, new Map());
metricsByGroup.get(key).set(parsed.metric, bench.value);
}
for (const [key, metrics] of metricsByGroup) {
if (!groups.has(key)) groups.set(key, []);
groups.get(key).push({ ...entryMetadata(entry), metrics });
}
}
const colors = [
'#2563eb', '#dc2626', '#16a34a', '#9333ea', '#ea580c', '#0891b2',
'#db2777', '#65a30d', '#4f46e5', '#ca8a04', '#0f766e', '#be123c'
];
// Series hidden on first render; every other metric is shown by default.
const hiddenByDefault = new Set(['total process time', 'module Weather', 'module PublicIp']);
const tabs = document.getElementById('tabs');
const panels = document.getElementById('panels');
const root = document.documentElement;
const themeToggle = document.getElementById('theme-toggle');
const savedTheme = localStorage.getItem('fastfetch-benchmark-theme');
let theme = savedTheme || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
const chartsByInstance = [];
if (!window.Chart) {
tabs.hidden = true;
panels.innerHTML = '<p class="empty">Failed to load Chart.js.</p>';
return;
}
panels.replaceChildren();
function chartColors() {
const styles = getComputedStyle(root);
return {
text: styles.getPropertyValue('--chart-text').trim(),
grid: styles.getPropertyValue('--chart-grid').trim()
};
}
function externalTooltipHandler(context) {
const { chart, tooltip } = context;
let tooltipElement = chart.canvas.parentNode.querySelector('.chart-tooltip');
if (!tooltipElement) {
tooltipElement = document.createElement('div');
tooltipElement.className = 'chart-tooltip';
chart.canvas.parentNode.appendChild(tooltipElement);
}
if (tooltip.opacity === 0) {
tooltipElement.style.opacity = '0';
return;
}
tooltipElement.replaceChildren();
const title = document.createElement('div');
title.className = 'chart-tooltip-title';
const row = chart._benchmarkRows[tooltip.dataPoints[0].dataIndex];
title.textContent = `${new Date(row.date).toLocaleString()} · ${row.sha}`;
tooltipElement.appendChild(title);
if (row.message) {
const message = document.createElement('div');
message.className = 'chart-tooltip-message';
message.textContent = row.message;
tooltipElement.appendChild(message);
}
const bodyElement = document.createElement('div');
bodyElement.className = 'chart-tooltip-body';
for (const body of [...tooltip.dataPoints].sort((a, b) => b.parsed.y - a.parsed.y)) {
const item = document.createElement('div');
item.className = 'chart-tooltip-row';
const swatch = document.createElement('span');
swatch.className = 'chart-tooltip-swatch';
swatch.style.background = body.dataset.borderColor;
const value = document.createElement('span');
value.textContent = `${body.dataset.label}: ${body.formattedValue} ms`;
item.append(swatch, value);
bodyElement.appendChild(item);
}
tooltipElement.appendChild(bodyElement);
const canvasRect = chart.canvas.getBoundingClientRect();
const margin = 12;
let left = canvasRect.left + tooltip.caretX + margin;
let top = canvasRect.top + tooltip.caretY + margin;
tooltipElement.style.left = `${left}px`;
tooltipElement.style.top = `${top}px`;
tooltipElement.style.opacity = '0';
const tooltipRect = tooltipElement.getBoundingClientRect();
if (left + tooltipRect.width > window.innerWidth - margin) left = canvasRect.left + tooltip.caretX - tooltipRect.width - margin;
if (top + tooltipRect.height > window.innerHeight - margin) top = canvasRect.top + tooltip.caretY - tooltipRect.height - margin;
tooltipElement.style.left = `${Math.max(margin, left)}px`;
tooltipElement.style.top = `${Math.max(margin, top)}px`;
tooltipElement.style.opacity = '1';
}
function updateTheme() {
root.dataset.theme = theme;
themeToggle.textContent = theme === 'dark' ? '☀ Light mode' : '☾ Dark mode';
themeToggle.setAttribute('aria-label', `Switch to ${theme === 'dark' ? 'light' : 'dark'} mode`);
const colors = chartColors();
Chart.defaults.color = colors.text;
Chart.defaults.borderColor = colors.grid;
for (const chart of chartsByInstance) {
chart.options.scales.x.title.color = colors.text;
chart.options.scales.x.ticks.color = colors.text;
chart.options.scales.x.grid.color = colors.grid;
chart.options.scales.y.title.color = colors.text;
chart.options.scales.y.ticks.color = colors.text;
chart.options.scales.y.grid.color = colors.grid;
chart.update();
}
}
themeToggle.addEventListener('click', () => {
theme = theme === 'dark' ? 'light' : 'dark';
localStorage.setItem('fastfetch-benchmark-theme', theme);
updateTheme();
});
updateTheme();
const families = new Map();
for (const [key, rows] of groups) {
const arch = key.slice(key.lastIndexOf(' ') + 1);
const family = architectureFamily(arch);
if (!families.has(family)) families.set(family, []);
families.get(family).push({ key, rows });
}
// 'Other' is intentionally not rendered: it only catches stray series (e.g. the retired
// 'macos universal' records) that should not show up as their own tab
const familyOrder = ['Intel', 'ARM'];
const availableFamilies = familyOrder.filter(family => families.has(family));
for (const [index, family] of availableFamilies.entries()) {
const tab = document.createElement('button');
const panelId = `panel-${family.toLowerCase()}`;
tab.className = 'tab';
tab.type = 'button';
tab.id = `tab-${family.toLowerCase()}`;
tab.setAttribute('role', 'tab');
tab.textContent = family;
tab.setAttribute('aria-controls', panelId);
tab.setAttribute('aria-selected', index === 0 ? 'true' : 'false');
tabs.appendChild(tab);
const panel = document.createElement('section');
panel.className = 'tab-panel';
panel.id = panelId;
panel.setAttribute('role', 'tabpanel');
panel.hidden = index !== 0;
panel.setAttribute('aria-labelledby', tab.id);
const title = document.createElement('h2');
title.className = 'platform-title';
title.textContent = `${family} processors`;
panel.appendChild(title);
const chartGrid = document.createElement('div');
chartGrid.className = 'charts';
panel.appendChild(chartGrid);
panels.appendChild(panel);
tab.addEventListener('click', () => {
for (const otherTab of tabs.children) otherTab.setAttribute('aria-selected', otherTab === tab ? 'true' : 'false');
for (const otherPanel of panels.children) otherPanel.hidden = otherPanel !== panel;
});
for (const { key, rows } of families.get(family).sort((a, b) => a.key.localeCompare(b.key))) {
rows.sort((a, b) => a.date.localeCompare(b.date));
const metrics = [...new Set(rows.flatMap(row => [...row.metrics.keys()]))].sort((a, b) => {
if (a === 'total process time') return -1;
if (b === 'total process time') return 1;
return a.localeCompare(b);
});
const section = document.createElement('article');
section.className = 'chart';
const chartHeader = document.createElement('div');
chartHeader.className = 'chart-header';
const chartTitle = document.createElement('h2');
chartTitle.textContent = key;
const chartActions = document.createElement('div');
chartActions.className = 'chart-actions';
const chartHint = document.createElement('span');
chartHint.textContent = `${rows.length} run${rows.length === 1 ? '' : 's'}`;
const fullscreen = document.createElement('button');
fullscreen.className = 'fullscreen';
fullscreen.type = 'button';
fullscreen.textContent = '⛶ Fullscreen';
fullscreen.addEventListener('click', () => {
if (document.fullscreenElement) document.exitFullscreen();
else section.requestFullscreen();
});
chartActions.append(chartHint, fullscreen);
chartHeader.append(chartTitle, chartActions);
const canvasWrap = document.createElement('div');
canvasWrap.className = 'canvas-wrap';
const canvas = document.createElement('canvas');
canvasWrap.appendChild(canvas);
section.append(chartHeader, canvasWrap);
chartGrid.appendChild(section);
const colorsForChart = chartColors();
const chart = new Chart(canvas, {
type: 'line',
data: {
labels: rows.map(row => row.sha.slice(0, 7)),
datasets: metrics.map((metric, index) => ({
label: metric,
data: rows.map(row => row.metrics.has(metric) ? row.metrics.get(metric) : null),
borderColor: colors[index % colors.length],
backgroundColor: colors[index % colors.length],
pointRadius: 3,
tension: 0.2,
spanGaps: true,
hidden: hiddenByDefault.has(metric)
}))
},
options: {
responsive: true,
maintainAspectRatio: false,
interaction: { mode: 'index', intersect: false },
plugins: {
legend: { display: false },
tooltip: {
enabled: false,
external: externalTooltipHandler,
callbacks: {
title: tooltipItems => {
const row = rows[tooltipItems[0].dataIndex];
return `${row.date} · ${row.sha}`;
}
}
}
},
scales: {
x: { title: { display: true, text: 'Date', color: colorsForChart.text }, ticks: { color: colorsForChart.text }, grid: { color: colorsForChart.grid } },
y: { beginAtZero: true, title: { display: true, text: 'Milliseconds', color: colorsForChart.text }, ticks: { color: colorsForChart.text }, grid: { color: colorsForChart.grid } }
}
}
});
chart._benchmarkRows = rows;
chartsByInstance.push(chart);
const legendActions = document.createElement('div');
legendActions.className = 'legend-actions';
const legend = document.createElement('div');
legend.className = 'legend';
const legendItems = [];
function refreshLegend() {
legendItems.forEach((item, metricIndex) => {
item.classList.toggle('is-hidden', !chart.isDatasetVisible(metricIndex));
});
}
function setAllLegends(visible) {
metrics.forEach((metric, metricIndex) => chart.setDatasetVisibility(metricIndex, visible));
refreshLegend();
chart.update();
}
function addLegendAction(label, action) {
const button = document.createElement('button');
button.className = 'legend-action';
button.type = 'button';
button.textContent = label;
button.addEventListener('click', action);
legendActions.appendChild(button);
}
addLegendAction('Show all', () => setAllLegends(true));
addLegendAction('Toggle all', () => {
metrics.forEach((metric, metricIndex) => chart.setDatasetVisibility(metricIndex, !chart.isDatasetVisible(metricIndex)));
refreshLegend();
chart.update();
});
addLegendAction('Reset', () => {
metrics.forEach((metric, metricIndex) => chart.setDatasetVisibility(metricIndex, !hiddenByDefault.has(metric)));
refreshLegend();
chart.update();
});
metrics.forEach((metric, metricIndex) => {
const item = document.createElement('button');
item.className = `legend-item${chart.isDatasetVisible(metricIndex) ? '' : ' is-hidden'}`;
item.type = 'button';
item.innerHTML = `<span class="legend-swatch" style="background:${colors[metricIndex % colors.length]}"></span>${metric}`;
item.addEventListener('click', () => {
chart.setDatasetVisibility(metricIndex, !chart.isDatasetVisible(metricIndex));
item.classList.toggle('is-hidden', !chart.isDatasetVisible(metricIndex));
chart.update();
});
legendItems.push(item);
legend.appendChild(item);
});
section.append(legendActions, legend);
}
}
if (!availableFamilies.length) {
tabs.hidden = true;
panels.innerHTML = '<p class="empty">No benchmark data available.</p>';
}
})();
</script>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
cooldown:
default-days: 7
open-pull-requests-limit: 10
commit-message:
prefix: "CI"
labels:
- "ci"
groups:
github-actions:
patterns:
- "*"
+163
View File
@@ -0,0 +1,163 @@
name: Reusable Android
on:
workflow_call:
inputs:
abi:
required: true
type: string
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: uname -a
run: uname -a
# The NDK comes with the runner image, so nothing is downloaded here. The image is pinned to
# ubuntu-24.04 rather than ubuntu-latest because which NDK a build used is part of what it is.
#
# The image's *latest* NDK, not its default one: the default is r27d (clang 18), while fastfetch
# is built and shipped on Termux with clang 21. Testing three majors behind the compiler the
# supported path uses buys nothing and rejects code clang 21 accepts.
- name: print NDK version
run: |
echo "default: ${ANDROID_NDK_HOME}"
echo "latest: ${ANDROID_NDK_LATEST_HOME}"
test -f "${ANDROID_NDK_LATEST_HOME}/build/cmake/android.toolchain.cmake"
cat "${ANDROID_NDK_LATEST_HOME}/source.properties"
"${ANDROID_NDK_LATEST_HOME}"/toolchains/llvm/prebuilt/*/bin/clang --version
# freetype is the one library this build wants that the NDK does not ship: its headers are not
# in the sysroot and the runner image has no libfreetype-dev, so without this step
# ff_lib_enable(FREETYPE ...) prints "Library: missing: FREETYPE" and
# src/detection/terminalfont/terminalfont_android.c compiles only its #else branch. That is the
# branch the shipped Termux build never takes, so the freetype code would rot untested here.
#
# Handing it the host's copy is sound, for two reasons. fastfetch never links freetype --
# BINARY_LINK_TYPE is dlopen, so ff_lib_enable skips its target_link_libraries and only the
# include path and FF_HAVE_FREETYPE are needed. And freetype's public headers carry no host
# assumptions: FT_SIZEOF_LONG and FT_SIZEOF_INT in freetype/config/integer-types.h are derived
# from FT_ULONG_MAX/FT_UINT_MAX, which come from the *target's* <limits.h>, so the same copy
# describes FT_FaceRec -- and the offset of the family_name that terminalfont_android.c reads --
# correctly for aarch64, armv7 and x86_64 alike.
#
# pkg-config is the only route that can find it: the NDK toolchain leaves PKG_CONFIG_PATH,
# PKG_CONFIG_LIBDIR and PKG_CONFIG_SYSROOT_DIR untouched, so the ordinary host search path is
# what gets used.
#
# The .pc is written here rather than taken from libfreetype-dev, whose own copy carries
# `Requires.private: zlib, bzip2, libpng, harfbuzz, libbrotlidec`. pkgconf -- which is what
# `pkg-config` has been on Ubuntu since 22.10 -- fails outright on a private requirement it
# cannot resolve, even for --exists, and libfreetype-dev only pulls in libpng-dev and
# zlib1g-dev. Nothing is linked, so the include directory is the whole contract. A Version
# field is mandatory (pkgconf treats a .pc without one as not found), hence the sed.
- name: install freetype headers
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends libfreetype-dev
test -f /usr/include/freetype2/ft2build.h
VERSION=$(awk '/^#define FREETYPE_(MAJOR|MINOR|PATCH)/ {printf "%s%s", sep, $3; sep="."}' /usr/include/freetype2/freetype/freetype.h)
test -n "${VERSION}"
mkdir -p freetype-pc
cat > freetype-pc/freetype2.pc <<'EOF'
prefix=/usr
includedir=${prefix}/include
Name: FreeType 2
Description: A free, high-quality, and portable font engine.
Version: 0
Cflags: -I${includedir}/freetype2
EOF
sed -i "s/^Version: .*/Version: ${VERSION}/" freetype-pc/freetype2.pc
PKG_CONFIG_PATH="$PWD/freetype-pc" pkg-config --cflags freetype2
# android-24 (Android 7.0) is Termux's own floor, and it is the floor for a second, independent
# reason: libcamera2ndk.so only exists from API 24, fastfetch links it unconditionally, and the
# NDK has no such thing as a weak *library* reference -- a build aimed lower would fail to load
# on exactly the devices it was aimed at. The level is also what makes this job check anything:
# at 24 the NDK marks AImageDecoder_* / AndroidBitmap_compress (30) and AMediaCodec_getName /
# AMediaCodec_releaseName (28) unavailable, which is what CMakeLists.txt's
# -D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__ -Werror=unguarded-availability pair is built on.
# Building against a newer platform would quietly stop enforcing it.
#
# BUILD_TESTS stays off. The test binaries are host programs, there is no device here to run
# them on, and `ctest` therefore cannot follow -- unlike every other job in this workflow set.
# The platform branch of the build is what this job covers.
- name: configure project
env:
# Picks up the freetype2.pc written by the step above. The rest of the search path is left
# alone, so zlib and every other host .pc file is still found exactly as before.
PKG_CONFIG_PATH: ${{ github.workspace }}/freetype-pc
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=Off -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_LATEST_HOME}/build/cmake/android.toolchain.cmake" -DANDROID_ABI=${{ inputs.abi }} -DANDROID_PLATFORM=android-24 -DCMAKE_INSTALL_PREFIX=/data/data/com.termux/files/usr .
# A silent regression back to "Library: missing: FREETYPE" would look exactly like a passing
# build -- the module would simply stop being compiled, and the only trace would be a line in
# the configure log nobody diffs. Assert that the define actually reached the compile line.
- name: check freetype was detected
run: |
grep -q -- '-DFF_HAVE_FREETYPE=1' CMakeFiles/libfastfetch.dir/flags.make || {
echo "::error::freetype was not detected, so terminalfont_android.c compiled its #else branch only"
grep -o -- '-DFF_HAVE_[A-Z0-9_]*' CMakeFiles/libfastfetch.dir/flags.make | sort -u
exit 1
}
- name: build project
run: cmake --build . --target package --verbose -j4
- name: print ELF header
run: readelf --wide -h fastfetch
- name: print dynamic dependencies
run: readelf --wide -d fastfetch
# libjnigraphics.so, libmediandk.so and libcamera2ndk.so are what provide the entry points
# CMakeLists.txt weakens. A weak reference resolves to null instead of failing the load, and
# FF_ANDROID_API_AT_LEAST() reads the platform level rather than the symbol -- so a library
# dropped from the link line still passes the guard on a device new enough, and the call goes
# through a null pointer. DT_NEEDED is the only place that mistake is visible.
- name: check linked libraries
run: |
for lib in libjnigraphics.so libmediandk.so libcamera2ndk.so; do
readelf --wide -d fastfetch | grep -q "NEEDED.*\[${lib}\]" || { echo "::error::${lib} is not in DT_NEEDED"; exit 1; }
done
# Every reference to an entry point the NDK marks unavailable at API 24 has to be weak: a strong
# one turns a device below API 28/30 into a load failure instead of a graceful downgrade, which
# is the entire reason those three files are compiled with -D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__.
# `nm -D` prints a weak undefined symbol as `w` and a strong undefined one as `U`.
#
# The families are whole prefixes on purpose: every AImageDecoder* entry point is API 30 or 31,
# but the frame-info and header-info ones spell the prefix AImageDecoderFrameInfo / HeaderInfo
# without an underscore, and matching only `AImageDecoder_` would leave them unchecked. The
# AMediaCodec ones are named one by one because the rest of that API -- createDecoderByType,
# createEncoderByType, delete -- is API 21 and is correctly a strong reference.
- name: check weak references
run: |
nm -D fastfetch | grep -E ' (AImageDecoder|AndroidBitmap_compress|AMediaCodec_getName$|AMediaCodec_releaseName$)' > weak.txt
cat weak.txt
test -s weak.txt || { echo "::error::none of these entry points is referenced any more -- if the last use is gone on purpose, this check and the -Werror=unguarded-availability pair it guards should go with it"; exit 1; }
if grep -qv '^ *w ' weak.txt; then
echo "::error::expected every one of these to be a weak reference:"
grep -v '^ *w ' weak.txt
exit 1
fi
- name: print size
run: |
file fastfetch
ls -l fastfetch
- name: upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-android-${{ inputs.abi }}
path: ./fastfetch-*.*
+55
View File
@@ -0,0 +1,55 @@
name: Reusable Benchmark
on:
workflow_call:
permissions:
contents: write
jobs:
benchmark:
runs-on: ubuntu-latest
concurrency:
group: benchmark
cancel-in-progress: false
steps:
- name: checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: download benchmark data
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: benchmark-*
path: benchmarks
- name: merge benchmark data
run: jq -s 'add' benchmarks/*/benchmark.json > benchmark.json
- name: save benchmark dashboard
run: cp .github/benchmark-index.html "$RUNNER_TEMP/benchmark-index.html"
- name: store benchmark result
uses: benchmark-action/github-action-benchmark@4322e5726e6334590d251fc4f92bec0efafc45dc # v1.22.2
with:
name: Fastfetch
tool: customSmallerIsBetter
output-file-path: benchmark.json
github-token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.sha }}
auto-push: true
summary-always: true
benchmark-data-dir-path: dev/bench
- name: publish benchmark dashboard
run: |
git fetch origin gh-pages
git switch --force-create gh-pages FETCH_HEAD
mkdir -p dev/bench
cp "$RUNNER_TEMP/benchmark-index.html" dev/bench/index.html
git config user.name github-action-benchmark
git config user.email github@users.noreply.github.com
git add dev/bench/index.html
if ! git diff --cached --quiet; then
git commit -m "Update benchmark dashboard"
git push origin gh-pages
fi
+47 -21
View File
@@ -3,38 +3,64 @@ name: Reusable DragonFly amd64
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: cpa.sh {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: vmactions/dragonflybsd-vm@v1
- name: Start VM
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641 # v1.6.0
with:
usesh: yes
envs: 'CMAKE_BUILD_TYPE'
prepare: |
uname -a
pkg update
pkg install -y llvm cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl egl opencl ocl-icd v4l_compat chafa libelf
operating_system: dragonflybsd
version: '6.4.2'
shell: bash
cpu_count: 4
run: |
env CC=clang cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
- name: Show system info
run: |
uname -a
pkg --version
- name: Update and install dependencies
run: |
sudo pkg update
sudo pkg install -y llvm cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl egl opencl ocl-icd v4l_compat chafa libelf lua54 libva libvdpau
- name: CMake configuration
run: env CC=clang cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_BUILD_TYPE=${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: CMake build
run: cmake --build . --target package --verbose -j4
- name: List features
run: ./fastfetch --list-features
- name: Run normal
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: Run json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: Run flashfetch
run: time ./flashfetch
- name: Run ldd
run: ldd fastfetch
- name: Run tests
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-dragonfly-amd64
path: ./fastfetch-*.*
+47 -22
View File
@@ -3,40 +3,65 @@ name: Reusable FreeBSD amd64
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: cpa.sh {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: cross-platform-actions/action@master
- name: Start VM
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641 # v1.6.0
with:
operating_system: freebsd
architecture: x86-64
cpu_count: 4
version: '15.1'
shell: bash
version: '15.0'
environment_variables: 'CMAKE_BUILD_TYPE'
run: |
uname -a
sudo pkg update
sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3-tcl egl opencl ocl-icd v4l_compat chafa
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
cpu_count: 4
- name: Show system info
run: |
uname -a
freebsd-version
pkg -v
- name: Update and install dependencies
run: |
sudo pkg update
sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm glib dconf dbus sqlite3 egl opencl ocl-icd v4l_compat chafa lua54 libva libvdpau
- name: CMake configuration
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_BUILD_TYPE=${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: CMake build
run: cmake --build . --target package --verbose -j4
- name: List features
run: ./fastfetch --list-features
- name: Run normal
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: Run json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: Run flashfetch
run: time ./flashfetch
- name: Run ldd
run: ldd fastfetch
- name: Run tests
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-freebsd-amd64
path: ./fastfetch-*.*
+39 -20
View File
@@ -3,38 +3,57 @@ name: Reusable Haiku amd64
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: cpa.sh {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: cross-platform-actions/action@master
- name: Start VM
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641 # v1.6.0
with:
operating_system: haiku
version: 'r1beta5'
architecture: x86-64
cpu_count: 4
version: 'r1beta6'
shell: bash
environment_variables: 'CMAKE_BUILD_TYPE'
run: |
uname -a
pkgman install -y git dbus_devel mesa_devel libelf_devel imagemagick_devel opencl_headers ocl_icd_devel vulkan_devel zlib_devel chafa_devel cmake gcc make pkgconfig python3.10 || pkgman install -y git dbus_devel mesa_devel libelf_devel imagemagick_devel opencl_headers ocl_icd_devel vulkan_devel zlib_devel chafa_devel cmake gcc make pkgconfig python3.10
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ctest --output-on-failure
cpu_count: 4
- name: Show system info
run: uname -a
- name: Install dependencies
run: pkgman install -y git dbus_devel mesa_devel libelf_devel imagemagick_devel opencl_headers ocl_icd_devel vulkan_devel zlib_devel chafa_devel cmake llvm22_clang ninja pkgconfig python3.10 lua || pkgman install -y git dbus_devel mesa_devel libelf_devel imagemagick_devel opencl_headers ocl_icd_devel vulkan_devel zlib_devel chafa_devel cmake llvm22_clang ninja pkgconfig python3.10 lua
- name: CMake configuration
run: CC=clang CXX=clang++ cmake -GNinja -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_BUILD_TYPE=${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} .
- name: CMake build
run: cmake --build . --target package --verbose -j4
- name: List features
run: ./fastfetch --list-features
- name: Run normal
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: Run json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: Run flashfetch
run: time ./flashfetch
- name: Run tests
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-haiku-amd64
path: ./fastfetch-*.*
-40
View File
@@ -1,40 +0,0 @@
name: Reusable Linux armv6l
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v6
- name: run VM
uses: uraimo/run-on-arch-action@v3
id: runcmd
with:
arch: armv6
distro: bookworm
githubToken: ${{ github.token }}
run: |
uname -a
apt-get update && apt-get install -y wget
apt-get install -y cmake make gcc libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev libefl-all-dev rpm
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
with:
name: fastfetch-linux-armv6l
path: ./fastfetch-*.*
+8 -5
View File
@@ -3,6 +3,9 @@ name: Reusable Linux armv7l
on:
workflow_call:
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -11,10 +14,10 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: uraimo/run-on-arch-action@v3
uses: uraimo/run-on-arch-action@fa1f3e7de95534497266c7265950b5188355fbfb # v3.2.1
id: runcmd
with:
arch: armv7
@@ -27,8 +30,8 @@ jobs:
curl -L https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null
echo -e 'Acquire::https::Verify-Peer "false";\nAcquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/99ignore-certificates
apt-get update && apt-get install -y cmake make gcc-13 libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev libefl-all-dev rpm
CC=gcc-13 cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
apt-get update && apt-get install -y cmake make gcc-13 libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libefl-all-dev liblua5.4-dev libvdpau-dev libva-dev rpm
CC=gcc-13 cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
@@ -38,7 +41,7 @@ jobs:
ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-linux-armv7l
path: ./fastfetch-*.*
+40 -8
View File
@@ -14,6 +14,10 @@ on:
description: fastfetch version from linux host build
value: ${{ jobs.build.outputs.ffversion }}
permissions:
security-events: write
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -24,7 +28,7 @@ jobs:
ffversion: ${{ steps.ffversion.outputs.ffversion }}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: uname -a
run: uname -a
@@ -39,28 +43,28 @@ jobs:
run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y gcc-13 libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev libddcutil-dev libefl-all-dev libunwind-dev rpm ninja-build
run: sudo apt-get update && sudo apt-get install -y gcc-13 jq libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libefl-all-dev libunwind-dev liblua5.4-dev libvdpau-dev libva-dev rpm ninja-build
- 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 chafa --ignore-dependencies
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick chafa quickjs-ng --ignore-dependencies
- name: Initialize CodeQL
if: inputs.arch == 'amd64'
uses: github/codeql-action/init@v4
uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
with:
languages: c
- name: configure project
run: CC=gcc-13 PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -GNinja -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_INSTALL_PREFIX=/usr .
run: CC=gcc-13 CMAKE_PREFIX_PATH=/home/linuxbrew/.linuxbrew PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -GNinja -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: build project
run: cmake --build . --target package --verbose -j4
- name: perform CodeQL analysis
if: inputs.arch == 'amd64'
uses: github/codeql-action/analyze@v4
uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
- name: list features
run: ./fastfetch --list-features
@@ -69,7 +73,29 @@ jobs:
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
run: |
{ time -p ./fastfetch -c presets/ci.jsonc --format json > fastfetch.raw.json 2> fastfetch.error; } 2> fastfetch.time
sed -n '/^[[:space:]]*\[/,$p' fastfetch.raw.json > fastfetch.json
cat fastfetch.json
cat fastfetch.error >&2
cat fastfetch.time >&2
- name: prepare benchmark data
run: |
real_seconds=$(awk '$1 == "real" { print $2 }' fastfetch.time)
jq -e 'type == "array"' fastfetch.json > /dev/null
jq --arg platform "linux" --arg arch "${{ inputs.arch }}" --argjson real_seconds "$real_seconds" '
map(select(.stat | type == "number") | {
name: ("fastfetch " + $platform + " " + $arch + " module " + .type),
unit: "ms",
value: .stat
}) + [{
name: ("fastfetch " + $platform + " " + $arch + " total process time"),
unit: "ms",
value: ($real_seconds * 1000)
}]
' fastfetch.json > benchmark.json
cat benchmark.json
- name: run flashfetch
run: time ./flashfetch
@@ -97,7 +123,13 @@ jobs:
cpack -V
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-linux-${{ inputs.arch }}
path: ./fastfetch-*.*
- name: upload benchmark data
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-linux-${{ inputs.arch }}
path: benchmark.json
+8 -5
View File
@@ -3,6 +3,9 @@ name: Reusable Linux i686
on:
workflow_call:
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -11,7 +14,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: uname -a
run: uname -a
@@ -26,18 +29,18 @@ jobs:
run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y gcc-13 gcc-13-multilib libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libelf-dev libddcutil-dev libefl-all-dev libunwind-dev rpm ninja-build
run: sudo apt-get update && sudo apt-get install -y gcc-13 gcc-13-multilib libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libefl-all-dev libunwind-dev liblua5.4-dev libvdpau-dev libva-dev rpm ninja-build
- 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 chafa --ignore-dependencies
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick chafa quickjs-ng --ignore-dependencies
- name: cmake version
run: cmake --version
- name: configure project
run: CC=gcc-13 PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DCMAKE_C_FLAGS="-m32 -march=i686 -mtune=i686" -DCMAKE_SYSTEM_PROCESSOR_OVERRIDE=i686 -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=i386 -GNinja -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_INSTALL_PREFIX=/usr .
run: CC=gcc-13 CMAKE_PREFIX_PATH=/home/linuxbrew/.linuxbrew PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DCMAKE_C_FLAGS="-m32 -march=i686 -mtune=i686 -fno-pie" -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_VERSION=5.10.0 -DCMAKE_SYSTEM_PROCESSOR=i686 -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=i386 -GNinja -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: build project
run: cmake --build . --target package --verbose -j4
@@ -64,7 +67,7 @@ jobs:
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-linux-i686
path: ./fastfetch-*.*
+60
View File
@@ -0,0 +1,60 @@
name: Reusable Linux loong64
on:
workflow_call:
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: set up QEMU for loong64
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- name: build in loong64 container
run: |
docker run --rm --platform linux/loong64 \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
lcr.loongnix.cn/debian:14 \
bash -c '
set -e
uname -a
cat /etc/os-release || true
apt-get update
apt-get install -y --no-install-recommends \
cmake make gcc g++ \
libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev \
libdconf-dev libdbus-1-dev libmagickcore-dev \
libsqlite3-dev librpm-dev \
libegl-dev libglx-dev ocl-icd-opencl-dev \
libdrm-dev \
libelf-dev libefl-all-dev \
liblua5.4-dev \
libvdpau-dev libva-dev \
rpm
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
cmake --build . --target package --verbose -j$(nproc)
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
'
- name: upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-linux-loong64
path: ./fastfetch-*.*
+8 -5
View File
@@ -7,6 +7,9 @@ on:
required: true
type: string
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -15,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: uraimo/run-on-arch-action@v3
uses: uraimo/run-on-arch-action@fa1f3e7de95534497266c7265950b5188355fbfb # v3.2.1
id: runcmd
with:
arch: ${{ inputs.arch }}
@@ -28,8 +31,8 @@ jobs:
uname -a
apt-get update && apt-get install -y software-properties-common
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get update && apt-get install -y cmake make gcc-13 libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libpulse-dev libdrm-dev libchafa-dev libelf-dev libefl-all-dev rpm
CC=gcc-13 cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
apt-get update && apt-get install -y cmake make gcc-13 libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libchafa-dev libelf-dev libefl-all-dev liblua5.4-dev libvdpau-dev libva-dev rpm
CC=gcc-13 cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
@@ -39,7 +42,7 @@ jobs:
ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-linux-${{ inputs.arch }}
path: ./fastfetch-*.*
+45 -17
View File
@@ -1,46 +1,68 @@
name: Reusable macOS Hosts
name: Reusable macOS Universal
on:
workflow_call:
inputs:
arch:
required: true
type: string
runs-on:
required: true
type: string
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
jobs:
build:
runs-on: ${{ inputs.runs-on }}
runs-on: macos-latest
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: uname -a
run: uname -a
- name: install required packages
- name: install required packages with Homebrew
run: |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install --overwrite vulkan-loader vulkan-headers molten-vk imagemagick chafa
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew update
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install --overwrite vulkan-loader vulkan-headers molten-vk chafa lua jq
- name: configure project
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
run: cmake -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build . --target package --verbose -j4
- name: verify universal binary
run: lipo -archs fastfetch
- name: list features
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch -c presets/ci.jsonc --structure-disabled vulkan --stat false
run: time ./fastfetch -c presets/ci.jsonc --structure-disabled vulkan:bluetooth:bluetoothradio --stat false
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --structure-disabled vulkan --format json
run: |
{ time -p ./fastfetch -c presets/ci.jsonc --structure-disabled vulkan:bluetooth:bluetoothradio --format json > fastfetch.raw.json 2> fastfetch.error; } 2> fastfetch.time
sed -n '/^[[:space:]]*\[/,$p' fastfetch.raw.json > fastfetch.json
cat fastfetch.json
cat fastfetch.error >&2
cat fastfetch.time >&2
- name: prepare benchmark data
run: |
real_seconds=$(awk '$1 == "real" { print $2 }' fastfetch.time)
jq -e 'type == "array"' fastfetch.json > /dev/null
jq --arg platform "macos" --arg arch "aarch64" --argjson real_seconds "$real_seconds" '
map(select(.stat | type == "number") | {
name: ("fastfetch " + $platform + " " + $arch + " module " + .type),
unit: "ms",
value: .stat
}) + [{
name: ("fastfetch " + $platform + " " + $arch + " total process time"),
unit: "ms",
value: ($real_seconds * 1000)
}]
' fastfetch.json > benchmark.json
cat benchmark.json
- name: run flashfetch
run: time ./flashfetch
@@ -52,7 +74,13 @@ jobs:
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-macos-${{ inputs.arch }}
name: fastfetch-macos-universal
path: ./fastfetch-*.*
- name: upload benchmark data
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-macos-universal
path: benchmark.json
+10 -5
View File
@@ -3,6 +3,9 @@ name: Reusable Musl amd64
on:
workflow_call:
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -10,21 +13,23 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: setup alpine linux
uses: jirutka/setup-alpine@master
uses: jirutka/setup-alpine@ae3b3ddba35054804fc4a3507b519fa7e8152050 # v1.4.1
with:
branch: edge
- name: install dependencies
run: |
cat /etc/alpine-release
uname -a
apk add cmake samurai vulkan-loader-dev libxcb-dev libxrandr-dev rpm-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev sqlite-dev networkmanager-dev pulseaudio-dev ddcutil-dev elfutils-dev gcc g++
apk add cmake samurai vulkan-loader-dev libxcb-dev libxrandr-dev rpm-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev sqlite-dev networkmanager-dev elfutils-dev lua5.4-dev quickjs-ng-dev libvdpau-dev libva-dev gcc g++
shell: alpine.sh --root {0}
- name: build
run: |
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DIS_MUSL=ON -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -GNinja .
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DIS_MUSL=ON -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" -GNinja .
cmake --build . --target package --verbose -j4
shell: alpine.sh {0}
@@ -39,7 +44,7 @@ jobs:
shell: alpine.sh {0}
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-musl-amd64
path: ./fastfetch-*.*
+45 -21
View File
@@ -3,39 +3,63 @@ name: Reusable NetBSD amd64
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: cpa.sh {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: cross-platform-actions/action@master
- name: Start VM
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641 # v1.6.0
with:
operating_system: netbsd
architecture: x86-64
cpu_count: 4
shell: bash
version: '10.1'
environment_variables: 'CMAKE_BUILD_TYPE'
run: |
uname -a
sudo pkgin -y install clang cmake git pkgconf wayland vulkan-headers dconf dbus sqlite3 ImageMagick
CC=clang cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
shell: bash
cpu_count: 4
- name: Show system info
run: |
uname -a
pkgin -v
- name: Update and install dependencies
run: |
sudo pkgin -y install clang cmake git pkgconf wayland vulkan-headers dconf dbus sqlite3 ImageMagick libva libvdpau
- name: CMake configuration
run: CC=clang cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_BUILD_TYPE=${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: CMake build
run: cmake --build . --target package --verbose -j4
- name: List features
run: ./fastfetch --list-features
- name: Run normal
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: Run json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: Run flashfetch
run: time ./flashfetch
- name: Run ldd
run: ldd fastfetch
- name: Run tests
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-netbsd-amd64
path: ./fastfetch-*.*
+5 -2
View File
@@ -3,6 +3,9 @@ name: Reusable No Features Test
on:
workflow_call:
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -12,13 +15,13 @@ jobs:
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: uname -a
run: uname -a
- name: configure project
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_DRM_AMDGPU=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_PULSE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_ELF=OFF -DENABLE_EET=OFF -DENABLE_THREADS=OFF
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_DRM_AMDGPU=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_ELF=OFF -DENABLE_EET=OFF -DENABLE_THREADS=OFF -DENABLE_IMAGE_LOGO=OFF
- name: build project
run: cmake --build . --target package --verbose -j4
+51 -23
View File
@@ -3,40 +3,68 @@ name: Reusable OmniOS amd64
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: cpa.sh {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: vmactions/omnios-vm@v1
- name: Start VM
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641 # v1.6.0
with:
usesh: true
envs: 'CMAKE_BUILD_TYPE'
prepare: |
uname -a
pkg update --accept || true
pkg install gcc14 cmake git pkg-config glib2 dbus sqlite-3 imagemagick ninja
operating_system: omnios
version: 'r151058'
shell: bash
cpu_count: 4
run: |
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -GNinja .
cmake --build . --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
echo 'set(CPACK_PACKAGE_FILE_NAME "fastfetch-omnios-amd64")' >> CPackConfig.cmake
cpack -V
- name: Show system info
run: |
uname -a
- name: Update and install dependencies
run: |
sudo pkg update --accept || true
sudo pkg install gcc14 cmake git pkg-config glib2 dbus sqlite-3 imagemagick ninja
- name: CMake configuration
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -GNinja -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_BUILD_TYPE=${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: CMake build
run: cmake --build . --verbose -j4
- name: List features
run: ./fastfetch --list-features
- name: Run normal
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: Run json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: Run flashfetch
run: time ./flashfetch
- name: Run ldd
run: ldd fastfetch
- name: Run tests
run: ctest --output-on-failure
- name: Package
run: |
echo 'set(CPACK_PACKAGE_FILE_NAME "fastfetch-omnios-amd64")' >> CPackConfig.cmake
cpack -V
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-omnios-amd64
path: ./fastfetch-*.*
+45 -22
View File
@@ -3,40 +3,63 @@ name: Reusable OpenBSD amd64
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: cpa.sh {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: cross-platform-actions/action@master
- name: Start VM
uses: cross-platform-actions/action@e0b9770014ba65d5e0815f15b74031c3a635f641 # v1.6.0
with:
operating_system: openbsd
architecture: x86-64
cpu_count: 4
version: '7.9'
shell: bash
version: '7.8'
environment_variables: 'CMAKE_BUILD_TYPE'
run: |
uname -a
sudo pkg_add -u
sudo pkg_add -r llvm-21.1.2p0 cmake git pkgconf wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 imagemagick chafa
CC=clang-21 cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
time ./fastfetch -c presets/ci.jsonc --format json
time ./flashfetch
ldd fastfetch
ctest --output-on-failure
cpu_count: 4
- name: Show system info
run: |
uname -a
- name: Update and install dependencies
run: |
sudo pkg_add -u
sudo pkg_add -r llvm-21.1.8p4 cmake git wayland vulkan-headers vulkan-loader glib2 dconf dbus sqlite3 imagemagick chafa lua-5.4.8p0 # pkg-config is preinstalled
- name: CMake configuration
run: CC=clang-21 cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_EMBEDDED_PCIIDS=On -DENABLE_EMBEDDED_AMDGPUIDS=On -DCMAKE_BUILD_TYPE=${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }} -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
- name: CMake build
run: cmake --build . --target package --verbose -j4
- name: List features
run: ./fastfetch --list-features
- name: Run normal
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: Run json
run: time ./fastfetch -c presets/ci.jsonc --format json
- name: Run flashfetch
run: time ./flashfetch
- name: Run ldd
run: ldd fastfetch
- name: Run tests
run: ctest --output-on-failure
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-openbsd-amd64
path: ./fastfetch-*.*
+7 -4
View File
@@ -7,23 +7,26 @@ on:
required: true
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: get latest release version
id: get_version_release
uses: pozetroninc/github-action-get-latest-release@master
uses: pozetroninc/github-action-get-latest-release@2a61c339ea7ef0a336d1daa35ef0cb1418e7676c # v0.8.0
with:
repository: ${{ github.repository }}
- name: download artifacts
if: inputs.ffversion != steps.get_version_release.outputs.release
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- name: create release
if: inputs.ffversion != steps.get_version_release.outputs.release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
tag: ${{ inputs.ffversion }}
commit: ${{ github.sha }}
@@ -50,7 +53,7 @@ jobs:
- name: update release body
if: inputs.ffversion != steps.get_version_release.outputs.release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
tag: ${{ inputs.ffversion }}
commit: ${{ github.sha }}
+8 -5
View File
@@ -3,6 +3,9 @@ name: Reusable Solaris amd64
on:
workflow_call:
permissions:
contents: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -11,21 +14,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: run VM
uses: vmactions/solaris-vm@v1
uses: vmactions/solaris-vm@87d3c436511cef802cd1637f86f73b1a97715c8c # v1.4.1
with:
usesh: true
envs: 'CMAKE_BUILD_TYPE'
release: "11.4-gcc-14"
prepare: |
uname -a
pkg install cmake git pkg-config glib2 dbus sqlite-3 imagemagick ninja dconf mesa
pkg install cmake git pkg-config glib2 dbus sqlite-3 imagemagick ninja dconf mesa lua
run: |
export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -GNinja .
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -GNinja -DCMAKE_C_FLAGS="-fno-pie" -DCMAKE_EXE_LINKER_FLAGS="-no-pie" .
cmake --build . --verbose -j4
./fastfetch --list-features
time ./fastfetch -c presets/ci.jsonc --stat false
@@ -37,7 +40,7 @@ jobs:
cpack -V
- name: upload artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-solaris-amd64
path: ./fastfetch-*.*
-24
View File
@@ -1,24 +0,0 @@
name: Reusable Spellcheck
on:
workflow_call:
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
jobs:
spellcheck:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v6
- name: Install codespell
shell: bash
run: |
sudo apt-get update || true
sudo apt-get install -y codespell
- name: Run Spellchecker
run: codespell
+49 -8
View File
@@ -18,6 +18,18 @@ on:
msys-arch:
required: true
type: string
secrets:
SIGNPATH_API_TOKEN:
description: SignPath REST API token used to submit the signing request
# Optional so that runs without the secret (pull requests, forks)
# still work; the signing step is skipped there anyway.
required: false
permissions:
contents: read
# The SignPath action reads job details and downloads the unsigned
# artifact with the workflow token.
actions: read
env:
CMAKE_BUILD_TYPE: ${{ vars.CMAKE_BUILD_TYPE || 'RelWithDebInfo' }}
@@ -30,14 +42,14 @@ jobs:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: setup-msys2
uses: msys2/setup-msys2@v2
uses: msys2/setup-msys2@ec48f7c5447b3140e2b088413ae3a55687bccb6e # v2.33.0
with:
msystem: ${{ inputs.msystem }}
update: true
install: git mingw-w64-clang-${{ inputs.msys-arch }}-7zip mingw-w64-clang-${{ inputs.msys-arch }}-cmake mingw-w64-clang-${{ inputs.msys-arch }}-clang mingw-w64-clang-${{ inputs.msys-arch }}-vulkan-loader mingw-w64-clang-${{ inputs.msys-arch }}-vulkan-headers mingw-w64-clang-${{ inputs.msys-arch }}-opencl-icd mingw-w64-clang-${{ inputs.msys-arch }}-opencl-headers mingw-w64-clang-${{ inputs.msys-arch }}-cppwinrt mingw-w64-clang-${{ inputs.msys-arch }}-imagemagick mingw-w64-clang-${{ inputs.msys-arch }}-chafa mingw-w64-clang-${{ inputs.msys-arch }}-directx-headers
install: git mingw-w64-clang-${{ inputs.msys-arch }}-7zip mingw-w64-clang-${{ inputs.msys-arch }}-cmake mingw-w64-clang-${{ inputs.msys-arch }}-clang mingw-w64-clang-${{ inputs.msys-arch }}-jq mingw-w64-clang-${{ inputs.msys-arch }}-vulkan-loader mingw-w64-clang-${{ inputs.msys-arch }}-vulkan-headers mingw-w64-clang-${{ inputs.msys-arch }}-opencl-icd mingw-w64-clang-${{ inputs.msys-arch }}-opencl-headers mingw-w64-clang-${{ inputs.msys-arch }}-cppwinrt mingw-w64-clang-${{ inputs.msys-arch }}-chafa mingw-w64-clang-${{ inputs.msys-arch }}-lua mingw-w64-clang-${{ inputs.msys-arch }}-directx-headers
- name: print msys version
run: uname -a
@@ -49,7 +61,7 @@ jobs:
run: cmake --build . --verbose -j4
- name: copy necessary dlls
run: cp /${{ inputs.msystem-lower }}/bin/{OpenCL,vulkan-1}.dll .
run: cp /${{ inputs.msystem-lower }}/bin/lua55.dll .
- name: list features
run: ./fastfetch --list-features
@@ -58,7 +70,29 @@ jobs:
run: time ./fastfetch -c presets/ci.jsonc --stat false
- name: run fastfetch --format json
run: time ./fastfetch -c presets/ci.jsonc --format json
run: |
{ time -p ./fastfetch -c presets/ci.jsonc --format json > fastfetch.raw.json 2> fastfetch.error; } 2> fastfetch.time
sed -n '/^[[:space:]]*\[/,$p' fastfetch.raw.json > fastfetch.json
cat fastfetch.json
cat fastfetch.error >&2
cat fastfetch.time >&2
- name: prepare benchmark data
run: |
real_seconds=$(awk '$1 == "real" { print $2 }' fastfetch.time)
jq -e 'type == "array"' fastfetch.json > /dev/null
jq --arg platform "windows" --arg arch "${{ inputs.arch }}" --argjson real_seconds "$real_seconds" '
map(select(.stat | type == "number") | {
name: ("fastfetch " + $platform + " " + $arch + " module " + .type),
unit: "ms",
value: .stat
}) + [{
name: ("fastfetch " + $platform + " " + $arch + " total process time"),
unit: "ms",
value: ($real_seconds * 1000)
}]
' fastfetch.json > benchmark.json
cat benchmark.json
- name: run flashfetch
run: time ./flashfetch
@@ -72,7 +106,7 @@ jobs:
- if: github.event_name == 'push' && github.repository == 'fastfetch-cli/fastfetch'
id: upload-unsigned-artifact
name: upload artifacts for signing
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-windows-${{ inputs.arch }}
path: |
@@ -82,7 +116,8 @@ jobs:
- if: github.event_name == 'push' && github.repository == 'fastfetch-cli/fastfetch'
name: submit signing request
uses: signpath/github-action-submit-signing-request@v1
# https://github.com/SignPath/github-action-submit-signing-request/issues/18
uses: signpath/github-action-submit-signing-request@c92b958760219087e01f8d67a1669ed57afe2627 # v2.3
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '${{ vars.SIGNPATH_ORG_ID }}'
@@ -99,8 +134,14 @@ jobs:
run: 7z a -t7z -mx9 -bd -y fastfetch-windows-${{ inputs.arch }}.7z LICENSE *.dll fastfetch.exe flashfetch.exe presets
- name: upload true artifacts
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fastfetch-windows-${{ inputs.arch }}
path: ./fastfetch-windows-${{ inputs.arch }}.*
overwrite: true
- name: upload benchmark data
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-windows-${{ inputs.arch }}
path: benchmark.json
+59 -48
View File
@@ -5,18 +5,14 @@ on:
- pull_request
jobs:
spellcheck:
uses: ./.github/workflows/build-spellcheck.yml
no-features-test:
name: No-features-test
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-no-features-test.yml
secrets: inherit
linux-hosts:
needs: no-features-test
name: Linux-${{ matrix.arch }}
permissions:
security-events: write
@@ -32,36 +28,32 @@ jobs:
with:
arch: ${{ matrix.arch }}
runs-on: ${{ matrix.runs-on }}
secrets: inherit
linux-i686:
needs: no-features-test
name: Linux-i686
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-linux-i686.yml
secrets: inherit
linux-armv7l:
needs: no-features-test
name: Linux-armv7l
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-linux-armv7l.yml
secrets: inherit
linux-armv6l:
name: Linux-armv6l
linux-loong64:
needs: no-features-test
name: Linux-loong64
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-linux-armv6l.yml
secrets: inherit
uses: ./.github/workflows/build-linux-loong64.yml
linux-vms:
needs: no-features-test
name: Linux-${{ matrix.arch }}
permissions:
security-events: write
contents: read
strategy:
matrix:
@@ -72,86 +64,93 @@ jobs:
uses: ./.github/workflows/build-linux-vms.yml
with:
arch: ${{ matrix.arch }}
secrets: inherit
musl-amd64:
needs: no-features-test
name: Musl-amd64
uses: ./.github/workflows/build-musl-amd64.yml
secrets: inherit
macos-hosts:
name: macOS-${{ matrix.arch }}
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-musl-amd64.yml
android:
needs: no-features-test
name: Android-${{ matrix.abi }}
permissions:
contents: read
strategy:
matrix:
include:
- arch: amd64
runs-on: macos-15-intel
- arch: aarch64
runs-on: macos-latest
uses: ./.github/workflows/build-macos-hosts.yml
abi:
- arm64-v8a
- armeabi-v7a
- x86_64
uses: ./.github/workflows/build-android.yml
with:
arch: ${{ matrix.arch }}
runs-on: ${{ matrix.runs-on }}
secrets: inherit
abi: ${{ matrix.abi }}
macos-hosts:
needs: no-features-test
name: macOS-universal
permissions:
contents: read
uses: ./.github/workflows/build-macos-hosts.yml
omnios-amd64:
needs: no-features-test
name: OmniOS-amd64
permissions:
contents: read
uses: ./.github/workflows/build-omnios-amd64.yml
secrets: inherit
solaris-amd64:
needs: no-features-test
name: Solaris-amd64
permissions:
contents: read
uses: ./.github/workflows/build-solaris-amd64.yml
secrets: inherit
freebsd-amd64:
needs: no-features-test
name: FreeBSD-amd64
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-freebsd-amd64.yml
secrets: inherit
openbsd-amd64:
needs: no-features-test
name: OpenBSD-amd64
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-openbsd-amd64.yml
secrets: inherit
netbsd-amd64:
needs: no-features-test
name: NetBSD-amd64
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-netbsd-amd64.yml
secrets: inherit
dragonfly-amd64:
needs: no-features-test
name: DragonFly-amd64
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-dragonfly-amd64.yml
secrets: inherit
haiku-amd64:
needs: no-features-test
name: Haiku-amd64
permissions:
security-events: write
contents: read
uses: ./.github/workflows/build-haiku-amd64.yml
secrets: inherit
windows-hosts:
needs: no-features-test
name: Windows-${{ matrix.arch }}
permissions:
security-events: write
contents: read
# The SignPath action reads job details and downloads the unsigned
# artifact with the workflow token.
actions: read
strategy:
matrix:
include:
@@ -172,7 +171,19 @@ jobs:
msystem: ${{ matrix.msystem }}
msystem-lower: ${{ matrix.msystem-lower }}
msys-arch: ${{ matrix.msys-arch }}
secrets: inherit
secrets:
SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }}
benchmark:
if: github.event_name == 'push' && github.ref == 'refs/heads/dev' && github.repository == 'fastfetch-cli/fastfetch'
name: Benchmark
needs:
- linux-hosts
- macos-hosts
- windows-hosts
permissions:
contents: write
uses: ./.github/workflows/build-benchmark.yml
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'fastfetch-cli/fastfetch'
@@ -181,9 +192,10 @@ jobs:
- linux-hosts
- linux-i686
- linux-armv7l
- linux-armv6l
- linux-loong64
- linux-vms
- musl-amd64
- android
- macos-hosts
- freebsd-amd64
- openbsd-amd64
@@ -198,4 +210,3 @@ jobs:
uses: ./.github/workflows/build-release.yml
with:
ffversion: ${{ needs.linux-hosts.outputs.ffversion }}
secrets: inherit
+12 -5
View File
@@ -1,8 +1,10 @@
build/
.vs/
.vscode/
.cache/
.kdev4/
/build/
/build_*/
/build-*/
/.vs/
/.vscode/
/.cache/
/.kdev4/
.DS_Store
cscope.*
tags
@@ -10,3 +12,8 @@ fastfetch.kdev4
*.user
*.user.*
*.swp
*.log
/*.zh.md
/.work*
/doc/*.md
/fastfetch.wiki
+400 -5
View File
@@ -1,7 +1,401 @@
# 2.70.0
Changes:
* LocalIP flags on Windows now describe the interface itself — its operational status, its media connection state and its type, for example `ETHERNET_CSMACD`, `IEEE80211` or `SOFTWARE_LOOPBACK` — instead of the `IP_ADAPTER_*` bits.
* Interfaces that carry no unicast address are no longer reported, since both the addresses and the interface properties are now enumerated from the unicast address table. (LocalIP, Windows)
* libpulse and libddcutil are no longer used on Linux. Package managers should remove them from their fastfetch package.
* QuickJS format scripting has been removed (deprecated in v2.69.0). Migrate scripts to Lua if necessary. (General)
* The Command module option `useStdErr` has been replaced with `useOutput`, which selects which of the command's output streams to capture: `"stdout"`, `"stderr"` or `"both"`.
* It defaults to `"both"`, so a command that logs to stderr now has that output captured instead of discarded.
* Set it to `"stdout"` or `"stderr"` to restore the old single-stream behavior. (Command)
* The Shell module now reports the shell from the password database (`/etc/passwd`) instead of the `$SHELL` environment variable, which may differ when the login shell was changed after the session started. (Title)
* The Disk custom format no longer provides `{size-available}`. `{size-free}` now reports whichever of the two the `disk.useAvailable` option selects, and the raw byte counts are available as `{bytes-used}` and `{bytes-total}`. (Disk)
* This also means `{size-free}` now changes with `disk.useAvailable`; it used to always report the file system's free size.
* The Disk JSON output no longer includes `bytes.available` and `bytes.used`. (Disk)
* `bytes.free` and `bytes.total` are unchanged; the used size can be derived as `total - free`.
Features:
* Added Sound detection on Android. (Sound, Android)
* Added display detection on Android over binder, which needs neither a child process nor a permission. (Display, Android)
* Added battery temperature, remaining time and charger type (AC / USB / wireless) detection on Android. (Battery, Android)
* Added media detection on Android when fastfetch runs as an app UID. (Media, Android)
* Requires `Notification access` permission
* Added app display-name detection on Android, so the media module names the player the way the app names itself instead of by its package name, and the terminal module reports the label Termux is installed under. (Media, Terminal, Android)
* Performance improvements & internal cleanups
* Added Finnish language support. (General)
* Added pkgsrc package detection on macOS. (#2627, Packages, Apple)
* Added an ALSA fallback to Sound on Linux, so a machine that runs no sound server reports its output device and volume instead of an error. (Sound, Linux)
Bugfixes:
* Fixed `--config`/`-c` bash completion offering one candidate per word instead of one candidate per file for paths containing spaces. (Completion, Bash)
* Fixed external monitors detected via DDC/CI being randomly reported as built-in on Linux. (#2615, Brightness, Linux)
* Fixed the Vulkan driver name being concatenated with the name of a previously enumerated device on multi-GPU systems. (#2619, Vulkan)
* Fixed the foot terminal font size not being parsed when written as `Font Name-size`, e.g. `Berkeley Mono-12`. (#2624, TerminalFont, Linux)
* Fixed `/boot` being hidden by default on Haiku, where it is the system volume. (Disk, Haiku)
* Improved Snapdragon X1/X2 model name detection on Linux. (#2625, CPU, Linux)
* Fixed the Android build failing with `GL/gl.h` not found, because the NDK ships the EGL headers that turned OpenGL detection on but not the desktop GL headers it includes. (OpenGL, Android)
* Fixed MAC address reporting `02:00:00:00:00:00` on macOS 27. (LocalIP, Apple)
* Fixed assertion failure when percentage exceeds 100. (Percent)
* Fixed a non-existent command being reported as a generic child process error on Windows instead of `command not found`. (Command, Windows)
* Fixed Android display detection on devices running Android 17. (Display, Android)
* Fixed Windows volumes with a per-user quota (such as network shares) reporting a wrong total size and a wrapped-around used size, because the total size was quota-limited while the free size was not. (#2651, Disk, Windows)
* On Windows 10 1809 (build 17763) and later, the whole volume's capacity and free space are now reported by default. Set `disk.useAvailable` to `true` to keep reporting the space that is available to the current user, quota included.
Logos:
* Added filled Artix logo (#2631)
* Renamed PostmarketOS to nura (#2626)
# 2.69.0
Changes:
* ImageMagick 6 is deprecated and will be removed in a future release. It remains available for older Debian and Ubuntu releases; upgrade to ImageMagick 7 when possible.
* The experimental QuickJS format scripting is deprecated, disabled by default, and planned for removal in the next release. Re-enable it with `cmake -DENABLE_QUICKJS=ON`, or migrate scripts to Lua. (General)
* Replaced `--logo-recache` and `logo.recache` with `--logo-cache` and `logo.cache`. Use `true` to reuse or create valid cache entries, `false` to disable caching, or `regen` to force regeneration. (Logo)
* Modules selected with `--structure` now honor their options from the JSON config.
Features:
* Added `logo.position: "auto"` and `--logo-position auto` to place wide logos above module output when the terminal has less than 32 columns available for text. (Logo)
* The position can also be selected in interactive `--gen-config`.
* For now, the default position is `left` for compatibility with previous releases. This may change to `auto` in future releases.
* Improved Bluetooth detection support:
* Added Bluetooth Low Energy detection on Windows and macOS.
* Report device type (LE or classic) and signal quality, if available.
* Added Bluetooth Core 6.0–6.3 version reporting. (BluetoothRadio)
* Improved image log support:
* Image logos on Windows, macOS, and Android now use native image processing libraries instead of ImageMagick.
* For package managers: ImageMagick dependencies can be removed on macOS, Windows and Android as they are no longer used for image logos.
* Windows Terminal supports sixel logos out of the box
* Changes to a source image now correctly invalidate its cache. (Logo)
* Added GIF and APNG support to `--kitty` image protocol. Set `logo.animationFrame` to `0` to play animations in compatible kitty terminals; positive or negative values select a still frame. Android animation requires Android 12 (API 31); terminals without kitty graphics protocol support report an error and fall back to the built-in logo instead. (Logo)
* Added cmake option `-DENABLE_IMAGE_LOGO=<BOOL>` (default `ON`) to disable image logos and reduce binary size. `raw` logos remain available. (Logo)
* Improved Linux support:
* Added RakuOS rum overlay package counting (`{rum}`) and CRUX package detection (`{crux}`). (Packages)
* Added CPU name and frequency detection on SPARC. (CPU)
* Improved COSMIC version detection and added Umbriel version detection. (DE / WM)
* Improved Android support:
* Expanded ROM detection to HarmonyOS, Flyme, OneUI, LineageOS, and many other ROMs. (DE)
* Improved camera detection; Android 7 (API 24) or later is required. (Camera)
* Battery level and charging state are now available to apps; detailed battery information requires root or ADB. (Battery)
* Added display mode, physical size, rotation, and HDR information. App-based detection requires Android 13 (API 33); root or ADB can also detect displays on older versions. (Display)
* Added Wi-Fi interface, connection, standard, and security information. Android 11 (API 30) or later is required. Termux:API is needed for the Wi-Fi permission, and location permission is needed to reveal SSID and BSSID; without location permission the two names appear as `<redacted>`. (Wifi)
* Added Wallpaper detection, which effectively reports `/data/system/users/0/wallpaper`. (Wallpaper)
* Added Media detection, root/ADB only. (Media / Player)
* Improved macOS support:
* Improved process-name detection in Top. (Top)
* Improved wallpaper detection on macOS Sonoma and later. (#2559, Wallpaper)
* Improved Windows support:
* `winget` now counts packages from configured sources, excludes Microsoft Store apps, and caches results. It remains disabled by default. (Packages)
* Player names now match the names shown by Windows (for example, Chrome is reported as Google Chrome). (Player)
* Added battery-level detection for more controllers on Windows and macOS. (Gamepad)
* Improved macOS controller name detection (macOS, Gamepad)
* macOS controller names now match the system; configs that filter by name may need updating.
* Requires macOS 11 or later.
* Improved the built-in HTTP client used by PublicIP and Weather; it now supports custom ports and chunked responses. (PublicIP / Weather)
* Reduced the default `waitTime` for DiskIO, NetIO, and Top from 500 ms to 250 ms. (DiskIO / NetIO / Top)
* Added `general.preload.lua` for loading shared Lua helpers before modules run. It requires a Lua-enabled build and starts the Lua interpreter whenever configured. (General)
* Lua format scripting is now considered stable.
Bugfixes:
* Fixed Snapdragon X2 series model detection on Linux. (#2611, CPU / Linux)
* Fixed image logo caching, padding, and positioning issues, including an iTerm display bug. (Logo)
* Fixed several Windows issues, including Windows Terminal font detection, redirected `--gen-config` output, and gamepad battery reporting for DualShock 4 and Switch controllers. (#2573, TerminalFont; Gamepad; General)
* Fixed formatting and display issues, including ANSI-aware truncation, date/time formatting, and bright key/title colors. (Format / DateTime / Display)
* Fixed `--dynamic-interval` retries and stale results across multiple rounds. (PublicIP / Weather / Display / Monitor / WM / DE / Media / Player / Shell / Terminal)
* Fixed invalid numeric and color options that could cause hangs or excessive output. (Separator / CPUUsage / NetIO / DiskIO / LoadAvg / Colors)
* Fixed JSON output and config validation across several modules, including GPU, Btrfs, Gamepad, Packages, and Custom. (General)
* Fixed GPU memory and device-type reporting, GNOME Classic and Trinity version detection, and default-route family names. (GPU / DE / LocalIP)
* Fixed module output and filtering issues affecting editor failures, sound status, command selection, and ignored keyboard/gamepad devices. (Editor / Sound / Command / Keyboard / Gamepad)
* Fixed package counting with read-only databases and corrected other package detection and JSON output issues. (Packages)
* Fixed Base64 encoding, big-endian handling, and 64-bit value truncation on 32-bit platforms. (General)
Logos:
* Added ALT Atomic
* Removed Zerene
# 2.68.1
Changes:
* The DE / WM / LM modules now reports the full name "Desktop Environment" / "Window Manager" / "Login Manager" instead of the abbreviations.
Features:
* Improved Login Manager (LM) module
* Added support on macOS, Windows and POSIX systems without systemd (by process list enumeration).
* Reports pretty name on Linux.
* Added Top module to print processes with the highest CPU, memory or disk I/O usage. (Top)
* Added module key localization support. (General)
* Added a new option `--key-language <?lang>` (`display.key.language: "<?lang>"` in JSON config). When left empty, it defaults to the system locale.
* See `fastfetch -h key-language` for all supported languages.
* Exposed in custom key format as `{module-name}`.
* Improved Wi-Fi module
* Added Wifi channel width detection, exposed via `{channel-width}` in custom format (reports 0 when not supported).
* Improved Wifi channel frequency accuracy and fortified detection on Windows, macOS.
* Added Wifi detection support on SunOS, Haiku.
* Added Battery detection support on SunOS. (Battery, SunOS)
* Added terminal font size detection support on Termux. (TerminalFont, Android)
* Improved GTK theme/icons/font detection on standalone WMs such as Hyprland, sway, niri and i3. (Theme, Linux)
* Improved fish completion scripts to print enum descriptions. (Completion)
* Enabled Wayland support on Android. (DisplayServer, Android)
* Added DE detection support for ASUS Zenfone. (DE, Android)
* Added new ARM SoCs (CPU, Linux / Android)
Bugfixes:
* Fixed I/O rate calculation precision in DiskIO and NetIO, and prevented division by zero. (DiskIO / NetIO)
* Fixed the fast path of ash version detection. (Shell)
* Fixed memory usage detection support on x86-32 FreeBSD (Memory, FreeBSD)
* Note: Although 32-bit systems are still supported, they are deprecated and barely tested. Users are encouraged to upgrade to 64-bit systems.
* Some internal cleanups and optimizations.
* Attempted to fix potential issues on big-endian systems
* Not tested due to lack of access to big-endian hardware.
Logos:
* Added macOS_old
* Added Omarchy, Omarchy2
# 2.67.1
Bugfixes:
* Fixed a `Symbol not found` error when running on macOS 10.15. (#2499, Codec, macOS)
* Fixed Alacritty font size never being parsed from the TOML config. (#2501, TerminalFont)
* Fixed bright colors incorrectly being active when the terminal uses a light theme. (#2509, Display)
* Fixed Ghostty terminal font detection (TerminalFont)
* Now tries to load the config with the `.ghostty` extension. (#2500)
* Fixed `font-family` fallback order. (#2510)
* Some internal cleanups and optimizations.
Features:
* Added a C23 compiler check so the build process gracefully exits during CMake configuration if the compiler is unsupported. (CMake)
* Added compatibility workarounds for Apple Clang 16 to fix building on macOS 14. (CMake, macOS)
* Reported real Android version codenames (e.g., "Baklava", "Vanilla Ice Cream") instead of "REL". (OS, Android)
* Added Loadavg detection support on Haiku R1B6. (Loadavg, Haiku)
* Enabled image logo support in the Zellij terminal multiplexer. (#2507, Logo)
* Improved Locale detection on Windows (Locale, Windows)
* Now respects `LC_ALL` and `LANG` environment variables if set for better compatibility with MSYS2/cygwin.
* Appends the active system Code Page (e.g., `.UTF-8` or `.Windows-1252`) to the default system locale fallback.
# 2.67.0
Changes:
* The minimum supported compiler version has been raised to GCC 13 (released on 2023-04-26) and Clang 16 (released on 2023-03-17) to accommodate the new C23 syntax used throughout the codebase. (General)
* As a result, building from source in Debian 12 (which only ships GCC 12 by default) is no longer supported. Users must upgrade their compiler or use the prebuilt binaries from the GitHub releases page.
* The `general.preRun` option has been removed due to security concerns. (General)
* Users who relied on this option to run a command before printing output will need to move that logic to an external wrapper.
* The `{status}` placeholder in Battery custom format is now an array type instead of a single comma-separated string. (Battery)
* This is a breaking change for users who print `{status}` in Lua scripts. They can use `table.concat(...)` to join the array into a single string if needed.
* The `--gen-config-*` flags (`--gen-config-full`, `--gen-config-force`, `--gen-config-full-force`) have been removed and their functions have been merged into `--gen-config`. (Global)
* See features below.
Features:
* `--gen-config` now opens an interactive configuration TUI to make generating config files easier.
* It falls back to non-interactive generation when `$NO_COLOR` is set or when stdin/stdout is not a TTY. This behavior can also be used to disable the interactive mode.
* Added an experimental [WebUI](https://fastfetch-cli.github.io/fastfetch-config/) ([separate project](https://github.com/fastfetch-cli/fastfetch-config)) for generating and editing configs.
* Added `-w`/`--watch` as a seconds-based alias for `--dynamic-interval`, defaulting to 1 second when no value is provided. (#2478, Watch)
* Added InitSystem detection on Windows, reporting the first userland process (`smss.exe`). (InitSystem, Windows)
* Added CPU and GPU temperature detection support for Apple M5 series chips. (CPU / GPU, macOS)
* Reported `Basic` as the Windows theme when DWM is disabled. (Theme, Windows)
* Improved Ghostty terminal font detection performance. (#2122, TerminalFont)
* It now parses Ghostty directly instead of running `ghostty +show-config`.
* Added support for a wider range of TOML config syntaxes used by Alacritty. (#2456, TerminalFont)
Bugfixes:
* Fixed a potential fish version detection error. (Shell, Linux)
* Fixed incorrect resolution reporting when a monitor advertises multiple preferred modes. (#2481, Display, Linux)
* Fixed connected monitors being missed when Wayland output events arrive late. (#2451, Display, Linux)
* Fixed VP9 codec detection on macOS. (Codec, macOS)
* Corrected Base64 encoding on big-endian hosts. (#2470)
* Fixed invalid URL parsing in the PublicIP module. (PublicIP)
* Correctly reported virtual GPUs on Windows. (#2461, GPU, Windows)
* Added a size limit for network responses to prevent excessive memory usage and mitigate potential attacks. (PublicIP / Weather)
* Fixed Ubuntu Studio Core detection. (OS, Linux)
* Relaxed the HTTP response check so that both `HTTP/1.0` and `HTTP/1.1` responses are accepted when fetching data over the network. (PublicIP / Weather)
* Various internal cleanups and optimizations:
* Fixed multiple memory leaks (Separator, Camera, Codec, Display).
* Added integer overflow checks to the string buffer implementation.
* Various code cleanups and compiler warning fixes.
Logos:
* Removed Hypros, MagpieOS, Furreto, EmperorOS and Magix
# 2.66.0
Changes:
* CPU package count is no longer reported in the default output.
* Users can still print it in custom formats via `{packages}`
Bugfixes:
* Fixed compatibility with WSL 2.9.3 (#2433, WM, Linux)
* Fixed AMD GPU names not being queried accurately in `driverSpecific` mode (GPU, Linux)
* Fixed GPU core counting for Apple Silicon GPU on Asahi Linux (GPU, Linux)
* Some internal cleanups and optimizations.
Features:
* Added Astra Linux version detection (OS, Linux)
* Improved performance of Windows PowerShell version detection (Shell, Windows)
* Improved performance of Media module on macOS (Media, macOS)
* Added proxmox backup server detection (#2443, OS, Linux)
Logos:
* Added Flatcar, Azure Linux
* Added Chimera_small, Chimera2, Parabola2_small, PostmarketOS2, Qubes_small
* Updated linuxmint_small
* Cleaned up distro names
# 2.65.2
Changes:
* Memory usage calculations now exclude the ZFS ARC cache on Linux, FreeBSD, NetBSD, and SunOS. (#1995 / #2418, Memory)
* This prevents the Memory module from reporting artificially high memory usage on systems with the ZFS kmod enabled.
Bugfixes:
* The GPU module no longer pings sleeping dedicated GPUs on dual-GPU laptops. (#2419, GPU)
* As a result, PCIe link speed detection (introduced in v2.65.0) is now only enabled in `driverSpecific` mode.
* Fixed a crash when detecting hardware codec support with the `amdgpu` driver on Linux. (#2419, Codec, Linux)
Logos:
* Updated CachyOS_small; fixed CachyOS logo colors to match the official logo better
* Added Turkish
# 2.65.1
No changes
# 2.65.0
Changes:
* `display.disableLinewrap` now defaults to `false`.
* This allows long lines to wrap instead of being truncated, preventing confusion for new users.
* Wrapped lines may overlap with the image logo. Users who prefer the old behavior can set `display.disableLinewrap: true` in their config file or use `--disable-linewrap true` on the command line.
* Reorders package manager variables in custom format strings, moving aggregate variables (e.g., `all`, `brew-all`, `flatpak-all`) to the end. (Packages)
* This is a breaking change for users relying on numeric placeholders (e.g., `{1}`). Numeric placeholders are a long-deprecated feature; named placeholders (e.g., `{pacman}`) are always preferred and future-proof.
* Enables `showPeCoreCount` by default to better display hybrid-architecture core counts. (CPU)
* No longer accepts `chafa` options in config files if `chafa` support was disabled at compile time. (Logo)
* This may affect users who generated their config files using `fastfetch --gen-full-config`. To resolve this, simply remove the `chafa` section from the config file.
Features:
* Adds detection for CPU code names (e.g., "Alder Lake", "Zen 4") and manufacturing technologies (e.g., "Intel 7", "TSMC N4") on x86 processors. (#1501, CPU, X86)
* These can be used in custom formats via `{code-name}` and `{technology}`.
* Adds PCIe link speed detection (current and max generation & lanes) for GPUs on Linux and Windows.
* These can be used in custom formats via `{pcie-max-speed}` and `{pcie-curr-speed}`.
* Adds HDR display detection via the `wp-color-management-v1` Wayland protocol. (#2356, Display, Linux)
* Previously, HDR detection was only supported on KDE Plasma.
* Adds the `egl-ext` detection method, which uses `EGL_EXT_device_enumeration` for GPU enumeration. (GPU)
* Adds terminal version and font detection for `kmscon`. (#2393, Terminal / TerminalFont, Linux)
* Adds the currently-in-beta code name "Golden Gate" for macOS 27. (OS, macOS)
* Adds WPA version detection on FreeBSD. (Wifi, FreeBSD)
* Adds package manager support for `porg` (#2405) and `install-release` (#2342). (Packages, Linux)
* Adds Weston version detection. (WM, Linux)
* Improves the core type (P-Core/E-Core) fetching mechanism on Windows by using `EfficiencyClass` instead of legacy frequency inference. (CPU, Windows)
* Improves display detection compatibility with KDE 6.7. (Display, Linux)
* Improves display serial number detection, now preferring alphanumeric serial numbers when available. (Display)
* This can be used in custom formats via `{serial}`.
* Improves the performance of `emerge` package manager detection. (#2406, Packages, Linux)
* Improves error messages for config file parsing errors.
* Improves reliability of the `Codec` module on Linux (Codec, Linux)
* Adds `va-x11` backend for VA-API and VDPAU, which is used if `va-drm` backend fails to initialize.
* Fixes an issue where the Codec module incorrectly reports no results when the `codec.showType` option is set.
Bugfixes:
* Fixes physical core detection on non-x86 architectures and simplifies the frequency detection code. (CPU, Linux)
* Fixes console mode and output code page initialization issues when running `fastfetch` in `Conhost`. (#2383, Windows)
* Fixes public IP detection randomly failing on Linux. (#2401, PublicIP, Linux)
* Fixes several memory leaks.
Logos:
* Adds Zerene OS. (#2404)
# 2.64.2
Bugfixes:
* Fixes image rendering being wiped quickly (#2374)
* Regression from v2.64.0
* Fixes ASCII logo being overwritten in `--dynamic-interval` mode
* Regression from v2.64.0
Logos:
* Updates OpenWrt and adds a small variant (#2376)
* The old one is renamed to `openwrt_old`
# 2.64.1
Features:
* Adds a CMake option `-DPACKAGES_REMOVE_DISABLED` to remove detection code of disabled packages (`-DPACKAGES_DISABLE_<PACKAGE_NAME>`) for slightly smaller binary size (Packages)
Bugfixes:
* Fixes compatibility issues with Lua 5.3
* Avoid possible infinite recursion in `encode_json` when encoding deeply nested tables or circular references
* Fixes compilation issues when building with old macOS SDKs
# 2.64.0
New **optional build** dependencies:
* [`libva`](https://github.com/intel/libva) and [`libvdpau`](https://www.freedesktop.org/wiki/Software/VDPAU) for the new `Codec` module.
* [Lua 5.3 to 5.5](https://www.lua.org/) for Lua scripting support, or [QuickJS](https://github.com/quickjs-ng/quickjs) v0.15.0 or newer for JavaScript scripting support.
Features:
* Adds `Codec` module support for Windows, macOS, Linux, and Android for hardware-accelerated video codec detection (Codec)
* Backends used (results may vary depending on the backend due to driver differences):
* Linux and BSD: VA-API (default) and VDPAU (fallback for NVIDIA). Fastfetch must be built with `libva` and `libvdpau` support to enable these backends.
* Windows: D3D12VA (Windows 11) and D3D11VA+MFT (Windows 10 or older)
* macOS: VideoToolbox
* Android: AMediaCodec
* Common: Vulkan Video (disabled by default; can be enabled with `"useVulkan": true`)
* By default, both encoders and decoders are reported. If no codecs are detected for a given type, `None` is reported. This behavior can be configured using the `"showType": "encoder|decoder"` option.
* Adds experimental Lua script support for custom formats (Global)
* Basic usage (using `Title` as an example): `{ "type": "title", "format": "lua:return string.format('Hello %s@%s', (...).userName, (...).hostName)" }`. The `lua:` prefix indicates a Lua script. A `return` statement is required to pass the final result back to the fastfetch module; otherwise, `nil` is returned implicitly and the entire module output is skipped.
* Parameters are passed via variable arguments `(...)`. Users can assign them to named variables for better readability. For example: `lua:local args = ...; string.format('Hello %s@%s', args.userName, args.hostName)`.
* The Lua interpreter instance is shared across all modules. This allows users to store and manipulate data across modules. For example:
* `{ "type": "shell", "format": "lua:shell = ..." } // Note: no "return" here`
* `{ "type": "terminal", "format": "lua:return shell.prettyName .. ' in ' .. (...).prettyName" } // This will print the detected shell and terminal names`
* A `json_encode(table, is_pretty)` function has been added to the Lua API for easier debugging. For example, `lua:return json_encode(...)` will print all available variables and their values in JSON format.
* Supported Lua versions: Lua 5.3 to 5.5 (Lua 5.1 and LuaJIT are not supported). The Lua version is auto-detected at build time. Once built, users can check the configured Lua version using `fastfetch --list-features`.
* Adds experimental QuickJS script support for custom formats as an alternative to Lua (Global)
* Basic usage: `{ "type": "title", "format": "qjs:`Hello ${this.userName}@${this.hostName}`" }`. The `qjs:` prefix indicates a JavaScript script. No `return` statement is needed; the final result is simply the evaluated value of the script.
* Parameters are passed via the `this` object. Usage is mostly the same as Lua, but using JavaScript syntax.
* Requires [quickjs-ng v0.15.0](https://github.com/quickjs-ng/quickjs/releases/tag/v0.15.0) or newer.
* Adds CMake options `-DMODULE_DISABLE_<MODULE_NAME>=ON` to disable modules at compile time for a smaller binary size
* Use `cmake -L . | grep MODULE_DISABLE_` to list all available options.
* These options rely on LTO for dead code elimination (`-DCMAKE_BUILD_TYPE=Release` should enable LTO by default).
* Adds the ability to remove unneeded ASCII logos without modifying the fastfetch source code, further reducing binary size
* Simply remove the corresponding logo file from the logo directory (`src/logo/ascii/[a-z]/*`) and re-run `cmake`.
* Improves string manipulation specifiers in custom formats
* They are now ANSI escape-aware and work correctly with colored output (e.g., percentages with `num-color`) (#2364). Limitations:
* They are still not wide-character aware and treat CJK and emoji characters as raw bytes.
* Escape sequences in the middle of strings are not supported.
* A new `|` specifier has been added to center strings. For example, `{user-name|20}` will center the username in a 20-character-wide field.
* Adds preliminary `Bootmgr`, `Brightness`, and `WMTheme` detection support for Haiku (#2358, Haiku)
* Adds `Wallpaper` and `WMTheme` detection support for the COSMIC desktop environment (Linux)
* Improves terminal name detection for Nix packages (#2352, Terminal, Linux)
* Adds DDC/CI brightness detection support for FreeBSD (Brightness, FreeBSD)
* DDC/CI communication can be very slow. Users can set the `ddcciSleep: null` option to skip DDC/CI detection.
* Reworks the built-in logo printing logic. ASCII logos and modules are now printed line by line, avoiding issues like #2239
* Note: Image logos are not affected by this change and still print the entire image first before printing any modules.
* Adds a new `--logo-padding-bottom` option to control the padding between the bottom of the logo and the first module when `--logo-position top` is used
* Previously, `--logo-padding-right` was used for both right and bottom padding.
* Adds `Samsung Exynos 2600` to CPU detection (CPU, Android)
* Adds terminal font detection support for the Muxy terminal (TerminalFont, macOS)
* Improves the performance of BusyBox (ash) version detection and always reports `ash` as the pretty name (Shell, Linux)
Bugfixes:
* Fixes SwayFX version detection (WM, Linux)
* Fixes fallback font detection for Ghostty (TerminalFont, macOS)
* Fixes `--stat` output to correctly align with the right border (Global)
* Fixes boot manager on macOS 26 (mBoot) is incorrectly reported as `iBoot` (Bootmgr, macOS)
Logos:
* Adds Quasar (#2338, #2323), Origami, Origami_small (#2321, #2322), BerserkArch (#2324, #2310), and NixOS2 (#2346)
* Minor tweaks and color fixes for the NixOS_small logo (#2357)
* Updates NurOS (#2366)
# 2.63.1
Bugfixes:
* Fixes media length detection for Chrome on Linux (Media, Linux)
* Fixes segmentation fault when specifying unsupported modules on command line
* Disables usage of Netlink for Wi-Fi detection on s390x architectures (Wifi, Linux)
# 2.63.0
Changes:
* Introduces a new optional dependency, `libefl`, for querying the Enlightenment window manager configuration:
* Introduces a new **build-only** dependency, `libefl`, for querying the Enlightenment window manager configuration:
* `libefl-all-dev` on Debian/Ubuntu
* `libefl-devel` on Fedora
* `efl` on Arch Linux
@@ -14,6 +408,7 @@ Features:
* Adds Ubuntu Kylin and Ubuntu Unity flavor detection (OS, Linux)
* Adds NebiDE support (WMTheme, Linux)
* Adds package counting for `cards` on NuTyX (#2287, Packages, Linux)
* Adds `{am-pm}` to custom format for 12-hour time with am/pm (DateTime)
* Adds support for the Enlightenment desktop environment (#2165, WM, Linux)
* Adds support for playback progress detection (Media)
* The module now prints the current playback position and total media duration when supported by the player. If you prefer the previous behavior, you can set `media.percent.type: ["hide-others"]` to hide the new fields.
@@ -563,7 +958,7 @@ Features:
* Added support for interface speed detection on SunOS (LocalIP, SunOS)
* Added detection support for Xlibre (#1888, WM, Linux)
* Improved the accuracy of color detection (Cursor, macOS)
* Improved the proformance of `Nix` package manager detection on macOS by porting optimizations form Linux port (#1893, Packages, macOS)
* Improved the performance of `Nix` package manager detection on macOS by porting optimizations from the Linux port (#1893, Packages, macOS)
Bugfixes:
* Fixed custom object inheriting a key from the previous custom object if the key is blank (#1477)
@@ -1074,7 +1469,7 @@ Features:
* Change package manager name of NetBSD from `pkg` to `pkgsrc` (#1515, Packages, NetBSD)
* Detect SOC name on RISCV (#1519, CPU, Linux)
* Report marketing name of new QS8Es (CPU, Android)
* Acquire acquire more os info from lsb-release if missing from os-release (#1521)
* Acquire more OS info from lsb-release if missing from os-release (#1521)
* CMake: add option `-DCUSTOM_LSB_RELEASE_PATH` to specify the path of `lsb-release` file
* `-DCUSTOM_OS_RELEASE_PATH` has been supported since `v2.11.4`
* Report more SOC names on Android (CPU, Android)
@@ -1542,7 +1937,7 @@ Logos:
Bugfixes:
* Fix bad Intel Arc GPU name detection, which was supposed to be fixed in the last version but the change was reverted accidentally (#1177, GPU, Linux)
* Fix arm32 CPU name detection no longer work. Regression of 2.21.2 (CPU, Linux)
* Fix arm32 CPU name detection no longer working. Regression of 2.21.2 (CPU, Linux)
# 2.21.2
@@ -3037,7 +3432,7 @@ Features:
* Enhance `--percent-type` to allow hiding other texts (#387)
* Add Wifi module support for Linux
* Detect scaled resolutions (Windows, macOS)
* Optimise font module printing (Windows)
* Optimize font module printing (Windows)
* Detect pacman package count inside MSYS2 environment (Windows)
* Add Wifi / Battery module support for Android
* Disk name support for Linux
+684 -200
View File
File diff suppressed because it is too large Load Diff
+792
View File
@@ -0,0 +1,792 @@
# Contributing to fastfetch
<details>
<summary>
Disclaimer
</summary>
This document is generated by AI and reviewed by humans. It is primarily intended for AI-assisted development, while remaining useful to human developers.
</details>
Thank you for your interest in fastfetch. This document covers building, architecture, how to add a module or a logo, code style, commit conventions, and the pull request workflow.
fastfetch is a system information tool written in C23, supporting Linux, macOS, Windows, the BSDs, Solaris, Haiku and Android. The project places strong emphasis on **startup time** and on keeping **dependencies optional**; many design decisions only make sense under that constraint, and this document returns to it repeatedly.
---
## Table of contents
- [Contributor quick reference](#contributor-quick-reference)
- [Getting started](#getting-started)
- [Code map](#code-map)
- [Core architecture: modules vs. detection](#core-architecture-modules-vs-detection)
- [Module registration](#module-registration)
- [Walkthrough: adding a module](#walkthrough-adding-a-module)
- [Walkthrough: adding a logo](#walkthrough-adding-a-logo)
- [Platform conventions](#platform-conventions)
- [Code style](#code-style)
- [Commit messages](#commit-messages)
- [Changelog](#changelog)
- [Tests](#tests)
- [Pull requests](#pull-requests)
- [Pitfalls](#pitfalls)
---
## Contributor quick reference
| Task | Start here | Verify with |
|---|---|---|
| Build and run fastfetch | `run.sh`, `CMakeLists.txt` | `./run.sh` |
| Add a module | `src/modules/<name>/`, `src/detection/<name>/`, `src/modules/modules.c`, `CMakeLists.txt` | `cmake -B build && cmake --build build -j` |
| Add a platform implementation | `src/detection/<name>/<name>_<platform>.c`, the matching platform block in `CMakeLists.txt` | Build on the target platform or CI |
| Add an ASCII logo | `src/logo/ascii/<letter>/<name>.txt`, matching `<letter>.inc` | `./build/fastfetch --logo <name>` |
| Change formatting or JSON output | `src/modules/<name>/<name>.c` | `./build/fastfetch -s <name> --format json` |
| Change shared formatting or containers | `src/common/format.h`, `src/common/color.h`, `src/common/FFstrbuf.h` | Build and run the matching test |
| Run the test suite | `tests/`, `build/` | `cd build && ctest --output-on-failure` |
For a typical code change, the shortest useful iteration is: configure, build the `fastfetch` target, run the affected module, then run the tests. If you add a directory or a generated input, re-run `cmake -B build` so that CMake refreshes its file globs.
---
## Getting started
### Building
The quickest way is `run.sh` in the repository root: it creates `build/`, configures, compiles and runs the binary.
```sh
./run.sh # build and run
./run.sh --format json # arguments are forwarded to fastfetch
```
Manual build:
```sh
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build --target fastfetch -j$(nproc)
./build/fastfetch
```
The default build type is `RelWithDebInfo`. LTO is enabled whenever `ENABLE_LTO=ON` **and** `CMAKE_BUILD_TYPE != Debug`, so the default configuration enables it and only `Debug` builds omit it. This is significant because LTO here is not merely an optimization: it is what removes the code of disabled modules. See [Pitfalls](#pitfalls).
### Common build options
| Option | Default | Notes |
|---|---|---|
| `CMAKE_BUILD_TYPE` | `RelWithDebInfo` | LTO is on for anything but `Debug` |
| `BUILD_TESTS` | `OFF` | Builds the unit tests in `tests/` |
| `BUILD_FLASHFETCH` | `ON` | Also builds the stripped-down `flashfetch` |
| `BINARY_LINK_TYPE` | `dlopen` | `dlopen` / `dynamic` / `static` |
| `ENABLE_ASAN` | `OFF` | Address Sanitizer |
| `ENABLE_LTO` | `ON` | Link-time optimization |
| `MODULE_DISABLE_<NAME>` | `OFF` | Disable a module, e.g. `MODULE_DISABLE_GPU=ON` |
| `SET_TWEAK` | `ON` | Appends a tweak to the dev version; turned off for releases |
`BINARY_LINK_TYPE=dlopen` (the default) is a deliberate design choice: optional dependencies (Vulkan, Wayland, DBus, ImageMagick, chafa, …) are loaded at runtime, so a missing library never prevents startup. When adding a third-party dependency, use the dlopen helpers in `common/library.h` — do not link it directly.
For a minimal-dependency build, see `.github/workflows/build-no-features-test.yml`:
```sh
cmake -DBUILD_TESTS=On -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_X11=OFF \
-DENABLE_DBUS=OFF -DENABLE_ZLIB=OFF ... .
```
### Dependencies
Required: CMake ≥ 3.21 and a C23 compiler (GCC, Clang or MSVC). Everything else is optional.
Optional dependencies are auto-detected: libpci, libdrm, vulkan, wayland, xcb, xrandr, dbus, sqlite3, rpm, imagemagick{6,7}, chafa, zlib, egl, glx, opencl, freetype, elf, libzfs, and more.
---
## Code map
```
src/
├── fastfetch.c entry point: CLI parsing, module dispatch, main loop (36 KB)
├── flashfetch.c entry point for the stripped-down build
├── options/ global (non-module) config: general / display / logo
├── modules/ module layer — module formatting and output
├── detection/ detection layer — platform-specific data retrieval
├── common/ infrastructure: FFstrbuf, FFlist, formatting, printing, networking
├── logo/ 530 ASCII logos plus the image logo backends
└── 3rdparty/ yyjson, widecharwidth, display-library
```
Flow of control:
```
fastfetch.c → options/ (global configuration)
→ modules/ (76 modules, formatting and output)
→ detection/ (one platform implementation each, raw data)
→ common/ (infrastructure)
```
The number of module directories does not match the number of detection directories, which is expected. The following relationships are structural rather than a fixed inventory:
- **13 modules have no detection directory** — they are either pure layout (`break`, `separator`, `colors`, `title`, `logo`) or reuse another module's detection result (`display`, `monitor`, `kernel`, `shell`, `terminal`, `player`, `custom`, `datetime`).
- **4 detection directories serve modules with different names** — `displayserver` (→ `display`, `monitor`), `gtk_qt` (→ `theme`, `icons`, `font`, `cursor`), `terminalshell` (→ `terminal`, `shell`) and `libc`.
Therefore, do not assume that `modules/<x>/` always has a matching `detection/<x>/`.
### Layer boundaries
| Layer | Owns | Must not |
|---|---|---|
| `options/` | **Global** config (colors, logo, threading, timeouts) | hold per-module options |
| `modules/` | formatting, printing, JSON serialization | read `/proc`, call Win32 APIs, parse sysfs |
| `detection/` | cross-platform data retrieval, clean result structs | print anything, read display config |
| `common/` | general-purpose utilities, no business logic | depend on a specific module |
A simple check: **no file under `detection/` should contain `printf` or read `instance.config`.** Symmetrically, no file under `modules/` should contain `#ifdef __linux__`.
---
## Core architecture: modules vs. detection
This is the most important convention in the codebase. Every feature consists of a fixed set of files; using CPU as the example:
```
modules/cpu/option.h module option struct
modules/cpu/cpu.c formatting and output
detection/cpu/cpu.h platform-independent interface
detection/cpu/cpu_linux.c ┐
detection/cpu/cpu_apple.c │
detection/cpu/cpu_windows.c ├─ platform implementations, one linked per build
detection/cpu/cpu_bsd.c │
detection/cpu/cpu_nosupport.c ┘
```
The interface is deliberately minimal, typically consisting of only two declarations:
```c
typedef struct FFCPUResult { ... } FFCPUResult; // result struct
const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu);
```
The `const char*` return value is an **error string**; `nullptr` means success. This pattern is used throughout `detection/` — please keep it consistent.
Helper functions are only exposed when they are genuinely shared between platform implementations (as in `cpu.h`: `ffCPUAppleCodeToName`, `ffCPUDetectByCpuid`).
**The benefit of this separation:** adding a platform never touches `modules/`; fixing output formatting never touches `detection/`.
---
## Module registration
### The descriptor
Every module exports one `FFModuleBaseInfo` (defined in `common/option.h:46`) — essentially a hand-written vtable:
```c
typedef struct FFModuleBaseInfo {
const char* name; // lookup key, e.g. "cpu"
const char* description; // help text
FFModuleDisplayName displayName; // module name in 20 languages
void (*initOptions)(void* options);
void (*destroyOptions)(void* options);
void (*parseJsonObject)(void* options, struct yyjson_val* module);
bool (*printModule)(void* options);
bool (*generateJsonResult)(void* options, yyjson_mut_doc*, yyjson_mut_val*);
void (*generateJsonConfig)(void* options, yyjson_mut_doc*, yyjson_mut_val*);
FFModuleFormatArgList formatArgs; // format placeholder table
const uint8_t defaultOrder; // sort weight
} FFModuleBaseInfo;
```
The source comment acknowledges that this is undefined behavior, since `void*` is not compatible with `FF*Options*`. It is a pragmatic compromise to obtain polymorphism in C; do not attempt to "fix" it.
### The registry: a first-letter hash bucket
`src/modules/modules.c` defines 26 `static FFModuleBaseInfo*` arrays (`A[]` through `Z[]`), each terminated by `nullptr`, collected into `ffModuleInfos[26]`:
```c
FFModuleBaseInfo** modules = ffModuleInfos[toupper(name[0]) - 'A']; // O(1) bucket lookup
for (; *modules; ++modules) { // linear scan in the bucket
if (ffStrEqualsIgnCase(name, (*modules)->name)) { ... }
}
```
Because the registry is small, a single arithmetic bucket lookup followed by a few string comparisons is preferable to a general-purpose hash table. When adding a module, place its descriptor in the bucket matching the first letter of `.name`, and keep the existing `nullptr` terminator at the end.
### The calling convention: zero heap allocation
Every dispatch site (`jsonconfig.c:98`, `commandoption.c:189`) follows the same pattern:
```c
alignas(uint64_t) uint8_t optionBuf[FF_OPTION_MAX_SIZE]; // 256 bytes, on the stack
baseInfo->initOptions(optionBuf);
baseInfo->parseJsonObject(optionBuf, jsonVal); // JSONC path only
baseInfo->printModule(optionBuf); // or generateJsonResult
baseInfo->destroyOptions(optionBuf);
```
`FF_OPTION_MAX_SIZE = 1 << 8` (256 bytes). Every module's `option.h` must end with:
```c
static_assert(sizeof(FFCPUOptions) <= FF_OPTION_MAX_SIZE, "FFCPUOptions size exceeds maximum allowed size");
```
**In other words, no module option struct may exceed 256 bytes.** This is a hard constraint, enforced at compile time.
The three dispatch entry points:
| Entry point | Location | Used for |
|---|---|---|
| `parseModuleJsonObject` | `common/impl/jsonconfig.c:90` | the `modules[]` array in a JSONC config |
| `parseStructureCommand` | `common/impl/commandoption.c:181` | the colon-separated structure string |
### Build-time module discovery
`CMakeLists.txt:134` globs `src/modules/*/*.c`, keeps only the entries whose file name matches their directory name, and generates a `MODULE_DISABLE_<UPPER>` option for each:
```cmake
file(GLOB FF_MODULE_SRCS CONFIGURE_DEPENDS RELATIVE "..." ".../src/modules/*/*.c")
set(FF_MODULE_DIRS "")
foreach(FF_MODULE_SRC ${FF_MODULE_SRCS})
get_filename_component(FF_MODULE_DIR "${FF_MODULE_SRC}" DIRECTORY)
get_filename_component(FF_MODULE_NAME "${FF_MODULE_SRC}" NAME_WE)
if("${FF_MODULE_DIR}" STREQUAL "${FF_MODULE_NAME}")
list(APPEND FF_MODULE_DIRS "${FF_MODULE_DIR}")
endif()
endforeach()
foreach(FF_MODULE_DIR ${FF_MODULE_DIRS})
string(TOUPPER "${FF_MODULE_DIR}" FF_MODULE_UPPER)
option(MODULE_DISABLE_${FF_MODULE_UPPER} "Disable module ${FF_MODULE_DIR}" OFF)
endforeach()
```
Because the glob matches sources rather than directories, a directory counts as a module only when `src/modules/<name>/<name>.c` exists. Empty directories — which git does not track, so they are easy to leave behind — and stray files are ignored instead of breaking the configure step with `Cannot find source file`.
### Module sources are discovered automatically
`FF_MODULE_DIRS` also drives the source list (`CMakeLists.txt:516`):
```cmake
foreach(FF_MODULE_DIR ${FF_MODULE_DIRS})
list(APPEND LIBFASTFETCH_SRC
src/modules/${FF_MODULE_DIR}/${FF_MODULE_DIR}.c
)
endforeach()
```
Consequences:
- `src/modules/<name>/<name>.c` is compiled as soon as the file exists — **there is no source list to edit for the module layer**.
- The file name must match the directory name. A directory whose `.c` file is named differently, or has none at all, is silently not a module: a typo therefore shows up as a module missing from `fastfetch --list-modules`, not as a build error.
- The glob uses `CONFIGURE_DEPENDS`, so with the Makefile and Ninja generators the build re-evaluates it and re-runs CMake when a module source is added or removed. With other generators, or to be safe, re-run `cmake -B build` explicitly.
Only the module layer is automated. Sources under `src/detection/` and `src/common/impl/` are **not** globbed and must still be listed by hand — see [step 5](#5-add-the-platform-sources-to-cmakeliststxt).
---
## Walkthrough: adding a module
Adding a `Foo` module, step by step.
### 1. Define the option struct
`src/modules/foo/option.h`:
```c
#pragma once
#include "common/option.h"
typedef struct FFFooOptions {
FFModuleArgs moduleArgs; // must be the first field
bool showBar;
} FFFooOptions;
static_assert(sizeof(FFFooOptions) <= FF_OPTION_MAX_SIZE, "FFFooOptions size exceeds maximum allowed size");
```
`FFModuleArgs` must come first. It provides `key`, `format`, `outputColor`, `keyColor`, `keyIcon` and `keyWidth`; because it is the first field, `ffJsonConfigParseModuleArgs()` handles these generically, **so no parsing code is required**.
### 2. Implement detection
`src/detection/foo/foo.h`:
```c
#pragma once
#include "fastfetch.h"
typedef struct FFFooResult {
FFstrbuf name;
uint32_t count;
} FFFooResult;
const char* ffDetectFoo(const FFFooOptions* options, FFFooResult* result);
```
`src/detection/foo/foo_linux.c`:
```c
#include "foo.h"
const char* ffDetectFoo(const FFFooOptions* options, FFFooResult* result) {
// read /sys, /proc, sysfs, dbus, ...
return nullptr; // success; return an error string on failure
}
```
**Write one file per target platform, plus a `foo_nosupport.c` fallback for the remaining platforms.** The repository currently contains 45 `*_nosupport.c` files serving this purpose.
### 3. Implement the module
`src/modules/foo/foo.c` — implement the six functions, then define the descriptor:
```c
FFModuleBaseInfo ffFooModuleInfo = {
.name = "Foo",
.description = "Print foo information",
.displayName = {
.en = "Foo", .ar = "Foo", .cs = "Foo", .de = "Foo", .es = "Foo",
.fr = "Foo", .gl = "Foo", .he = "Foo", .id = "Foo", .it = "Foo",
.ja = "Foo", .ko = "Foo", .pl = "Foo", .pt = "Foo", .ru = "Foo",
.tr = "Foo", .uk = "Foo", .vi = "Foo", .zh_CN = "Foo", .zh_TW = "Foo",
},
.initOptions = (void*) ffInitFooOptions,
.destroyOptions = (void*) ffDestroyFooOptions,
.parseJsonObject = (void*) ffParseFooJsonObject,
.printModule = (void*) ffPrintFoo,
.generateJsonResult = (void*) ffGenerateFooJsonResult,
.generateJsonConfig = (void*) ffGenerateFooJsonConfig,
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
{ "Name", "name" },
{ "Count", "count" },
})),
.defaultOrder = 73,
};
```
Points to note:
- **`displayName`** is a literal block of all 20 language fields; there is no shortcut macro, so copy the layout from an existing module: **`en`, `ar`, `cs`, `de`, `es`, `fr`, `gl`, `he`, `id`, `it`, `ja`, `ko`, `pl`, `pt`, `ru`, `tr`, `uk`, `vi`, `zh_CN`, `zh_TW`**.
**Fill in all 20.** The struct is read by byte offset (see [Pitfalls](#6-localization-uses-byte-offsets-not-enums)) and there is **no fallback** — a missing field means the key prints empty in that language.
- **`formatArgs`** must be exhaustive. It drives the placeholder list printed by `fastfetch -h foo-format`; **any placeholder omitted here is neither listed nor usable by the user.**
- The `moduleFormat` section in `doc/json_schema.json` is generated by `fastfetch -h format-json`. Its metadata comes from `FFModuleBaseInfo::formatArgs`. To keep the schema and module descriptors consistent, do not edit the `moduleFormat` section in `doc/json_schema.json` by hand; update the module metadata and regenerate it instead.
- **`defaultOrder`**: use the current maximum plus 1. Search the existing descriptors for `.defaultOrder =` before choosing a value; do not copy a hard-coded value from this document. Leaving it out, or setting it to `0`, excludes the module from the interactive `--gen-config` picker. Only `logo`, `command` and `custom` rely on this behavior, because they require user arguments or are invoked directly by the display layer.
### 4. Register it
- Add `#include "modules/foo/foo.h"` to `src/modules/modules.h`
- Insert into the `F[]` array in `src/modules/modules.c`:
```c
#if !FF_MODULE_DISABLE_FOO
&ffFooModuleInfo,
#endif
```
`FF_MODULE_DISABLE_FOO` is generated by CMake — you do not define it yourself.
### 5. Add the platform sources to `CMakeLists.txt`
The module layer is discovered by glob (see [Build-time module discovery](#module-sources-are-discovered-automatically)), **but `src/detection/**` and `src/common/impl/**` are not**. `CMakeLists.txt` lists them explicitly, inside one mutually exclusive chain of platform blocks:
| Block | Line | Covers |
|---|---|---|
| `if(LINUX)` | `CMakeLists.txt:522` | Linux |
| `elseif(ANDROID)` | `CMakeLists.txt:608` | Android (Termux) |
| `elseif(FreeBSD)` | `CMakeLists.txt:691` | FreeBSD, MidnightBSD, DragonFly |
| `elseif(NetBSD)` | `CMakeLists.txt:788` | NetBSD |
| `elseif(OpenBSD)` | `CMakeLists.txt:872` | OpenBSD |
| `elseif(APPLE)` | `CMakeLists.txt:959` | macOS / iOS |
| `elseif(WIN32)` | `CMakeLists.txt:1046` | Windows |
| `elseif(SunOS)` | `CMakeLists.txt:1121` | Solaris / illumos |
| `elseif(Haiku)` | `CMakeLists.txt:1204` | Haiku |
| `elseif(GNU)` | `CMakeLists.txt:1282` | GNU/Hurd |
Add the platform implementation to every block whose platform it supports, and `foo_nosupport.c` to every remaining block, so that all ten platforms still link:
```cmake
elseif(FreeBSD)
list(APPEND LIBFASTFETCH_SRC
...
src/detection/foo/foo_bsd.c
)
```
Points to note:
- Exactly one block is compiled per build, so a file omitted from a block does not exist for that platform, and the link fails with an undefined reference to `ffDetectFoo()` — **on that platform only**. A missing entry therefore builds fine locally and fails in CI; this is why every block must be covered.
- A platform may reuse another platform's implementation instead of a stub. `src/common/impl/networking_linux.c`, for example, is listed in nine of the ten blocks (all but `WIN32`). Check where the closest sibling module points before adding a new file.
- `DragonFly` is handled by the inner `if(DragonFly)` sub-block inside the FreeBSD block (`CMakeLists.txt:773`); add the variant there, as `processes`, `top` and `wifi` do.
- New helpers under `src/common/impl/` follow the same rule: they are not globbed, and each block that needs one must list it.
- A few files are appended outside the platform chain because they depend on an option or on a specific feature — for example the proprietary GPU backends (`CMakeLists.txt:1379`) and `src/common/impl/wcwidth.c` (`CMakeLists.txt:1408`). Those are written by hand as well.
### 6. Modules that need warm-up
If your module needs a sampling interval (CPU usage) or a network round-trip (public IP, weather), also implement `ffPrepareFoo()` and register it in the switch inside `ffPrepareCommandOption()` in `common/impl/commandoption.c`, under the matching first-letter `case`. Six modules currently do this: CPUUsage, DiskIO, NetIO, PublicIP, Top and Weather.
### 7. Verify
```sh
cmake -B build && cmake --build build -j
./build/fastfetch -s foo --format json # JSON output
./build/fastfetch -h foo-format # list formatArgs placeholders
./build/fastfetch --gen-config # confirm it appears in the picker
```
Note the `-format` suffix on the help flag: `fastfetch -h foo` is not supported; only `fastfetch -h foo-format` works.
If you added detection sources, re-check [step 5](#5-add-the-platform-sources-to-cmakeliststxt) before pushing: a platform block you missed compiles fine locally and fails only when that platform is built.
---
## Walkthrough: adding a logo
A new logo **must** have a corresponding "Logo Request" issue, linked from the PR with `Closes #1234`. Logo PRs without a linked issue are not accepted.
### 1. Add the ASCII file
```
src/logo/ascii/<first-letter>/<distro>.txt
```
For example `src/logo/ascii/d/distro.txt`. Directories are already split by first letter (`a/` … `z/`, plus `_/`).
The file is plain ASCII art with `$1` … `$9` as color placeholders:
```
$3 ,-^-___
$3 /\\\///
$2refined.$1 /\\\\//
```
- `$1` … `$9` map to palette slots 1–9; at most 9 are supported (`FASTFETCH_LOGO_MAX_COLORS = 9`)
- `$$` is a literal `$`
- Characters without a placeholder inherit the current color. Of the 530 existing logos, 239 use no placeholders at all (monochrome) and 291 do; **new logos should use placeholders**, as monochrome is a legacy style
- Tabs are expanded to 4 spaces
- Colors can be overridden with `--logo-color-1` … `--logo-color-9`
### 2. Register it in the `.inc`
CMake turns each `.txt` file into a `FASTFETCH_DATATEXT_LOGO_<UPPERCASE>` macro (`CMakeLists.txt:418`), but **the registry itself is maintained by hand**. Edit `src/logo/ascii/<first-letter>.inc`:
```c
// src/logo/ascii/d.inc
#ifdef FASTFETCH_DATATEXT_LOGO_DISTRO
// Distro
{
.names = { "Distro" }, // ID (preferred) or NAME from /etc/os-release, do NOT add both
.lines = FASTFETCH_DATATEXT_LOGO_DISTRO,
.colors = {
FF_COLOR_FG_PRIMARY, // recommended for using as WHITE replacement, light-theme terminal friendly
FF_COLOR_FG_BLUE, // preferred
FF_COLOR_FG_256 "34",
FF_COLOR_FG_RGB "0;255;0", // not recommended because of bad compatibility with raw TTY
},
},
#endif
```
- `names` is matched case-insensitively. Do not add names that differ only by case, because they can never be distinguished. Every name is also shown by `--list-logos`, so use user-friendly spelling such as an initial capital where appropriate.
- For a new logo, use exactly one name unless there is a specific compatibility reason to add more. That name should first be the `ID` from `/etc/os-release`. If the ID cannot distinguish this logo from another logo for the same OS, use the `NAME` value instead. `logoGetBuiltinDetected` in `src/logo/logo.c` documents the detection order: `ID`, then `NAME`, then tokens from `ID_LIKE`, then the platform name fallback. Manual `logo-source` selection uses the name directly.
- `colors` is positional — entry 0 is `$1`, entry 1 is `$2`, and so on
- `colors[0]` also becomes the title color and `colors[1]` the key color, unless the user overrides them
If the same OS has multiple logo variants, mark the variant explicitly with `.type`:
```c
.type = FF_LOGO_LINE_TYPE_SMALL_BIT,
```
Use `FF_LOGO_LINE_TYPE_ALTER_BIT` for an alternate logo, `FF_LOGO_LINE_TYPE_SMALL_BIT` for a small logo, or combine the flags when both apply. This is also a lookup optimization: a logo marked `FF_LOGO_LINE_TYPE_SMALL_BIT` is considered only for `type = small`, while a logo marked `FF_LOGO_LINE_TYPE_ALTER_BIT` is never selected by automatic detection. Alternate logos are available only when explicitly requested through `-l <source>`.
### 3. Verify
```sh
./build/fastfetch -l distro
./build/fastfetch --list-logos | grep -i distro
```
---
## Platform conventions
The `detection/` layer picks its implementation by **filename suffix**; the choice is made at build time from `CMAKE_SYSTEM_NAME`:
| Suffix | Platform |
|---|---|
| `_linux.c` | Linux |
| `_apple.c` / `_apple.m` | macOS / iOS (`.m` for Objective-C) |
| `_windows.c` / `_windows.cpp` | Windows (`.cpp` for WinRT / WMI) |
| `_bsd.c` | FreeBSD |
| `_nbsd.c` | NetBSD |
| `_obsd.c` | OpenBSD |
| `_sunos.c` | Solaris / illumos |
| `_haiku.c` / `.cpp` | Haiku |
| `_android.c` | Android (Termux) |
| `_gnu.c` | GNU/Hurd |
| `_nosupport.c` | Empty fallback |
Current distribution of platform files in `detection/`:
| Suffix | Files | Suffix | Files |
|---|---|---|---|
| `_linux` | 58 | `_obsd` | 16 |
| `_windows` | 47 | `_haiku` | 13 |
| `_apple` | 46 | `_android` | 12 |
| `_nosupport` | 45 | `_gnu` | 3 |
| `_bsd` | 29 | | |
| `_sunos` | 19 | | |
| `_nbsd` | 17 | | |
(These are repository inventory figures, counting `.c`, `.m`, `.cpp`, and `.h`; they may change as platforms and modules are added.)
**Do not accumulate `#ifdef __linux__` blocks in a single file.** When adding platform support, copy the closest existing implementation and change the suffix.
`common/` follows the same convention: `common/impl/` contains `io_unix.c` / `io_windows.c`, `netif_linux.c` / `netif_apple.c` / `netif_bsd.c` and similar files, with `common/apple/`, `common/windows/` and `common/haiku/` holding platform-specific helpers.
When several platform suffixes could apply, use the most specific implementation supported by the build system (for example, `_nbsd.c` instead of the generic `_bsd.c` on NetBSD). Keep the generic file as the fallback for platforms that share its conventions.
---
## Code style
### Formatting
The project uses clang-format with `BasedOnStyle: LLVM` plus these key overrides:
```yaml
IndentWidth: 4
UseTab: Never
ColumnLimit: 0 # never wrap
InsertBraces: true # braces even on single-statement ifs
PointerAlignment: Left # char* p, not char *p
SortIncludes: Never # include order is managed by hand
AlignAfterOpenBracket: DontAlign
BinPackParameters: false # all params on one line, or one per line
```
Before committing:
```sh
clang-format -i src/modules/foo/*.c src/modules/foo/*.h
```
`src/3rdparty/**`, `build/**` and `src/logo/builtin.c` are listed in `.clang-format-ignore` — **do not reformat them.**
`.editorconfig` specifies LF line endings, a 4-space indent, a final newline, and trailing whitespace trimmed (except in Markdown).
### Naming
| Kind | Convention | Example |
|---|---|---|
| Functions | `ff` + PascalCase | `ffDetectCPU`, `ffPrintCPU` |
| Types | `FF` + PascalCase | `FFCPUResult`, `FFModuleBaseInfo` |
| Variables / fields | camelCase | `coresPhysical`, `keyWidth` |
| Macros | SCREAMING_SNAKE_CASE | `FF_OPTION_MAX_SIZE` |
| Module options | `FF<Name>Options` | `FFCPUOptions` |
| Detection results | `FF<Name>Result` | `FFCPUResult` |
### Compiler warnings
The build enables `-Wall -Wextra -Wconversion` plus several `-Werror`s:
```
-Werror=uninitialized -Werror=return-type -Werror=vla
-Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion
```
**`-Wconversion` is strict**: every implicit narrowing conversion needs an explicit cast.
---
## Commit messages
Format:
```
<Scope>[ (Platform)]: <third-person singular verb> <object>
```
Scope is the module or subsystem name; Platform is optional. Use the third-person singular present tense, capitalize the first letter, no trailing period.
Real examples from recent history:
```
Processes (Haiku): honors `options->countKprocs`
WM (macOS): improves reliability of WM plugin detection
Memory (Windows): prefers `NQSI`
Top (Linux): improves performance of `stat` parsing
Logo (Builtin): adds omarchy
Global: introduces global macro `FF_PATH_PKG_BASE` to replace `_PATH_LOCALBASE`
LM (OpenBSD): adds support
CI: disables fail on alert
Doc: updates README
Presets: moves `top` to the bottom of running modules [ci skip]
```
Common verbs: `adds`, `removes`, `fixes`, `improves`, `updates`, `corrects`, `prefers`, `honors`, `disables`, `enables`, `introduces`, `detects`, `reports`, `skips`, `uses`.
Scopes in use: `Top`, `Processes`, `Memory`, `Logo (Builtin)`, `CI`, `Doc`, `Presets`, `Global`, plus individual module names.
Documentation-only changes use a `[ci skip]` suffix.
---
## Changelog
User-visible changes go into `CHANGELOG.md`, under the topmost version heading:
```markdown
# Unreleased
Changes:
* The DE / WM / LM modules now reports the full name ...
Features:
* Added Top module to print processes with the highest CPU, memory or disk I/O usage. (Top)
* Improved Wi-Fi module
* Added Wifi channel width detection, exposed via `{channel-width}` in custom format.
* Improved Wifi channel frequency accuracy on Windows, macOS.
* Added Battery detection support on SunOS. (Battery, SunOS)
Bugfixes:
* Fixed I/O rate calculation precision in DiskIO and NetIO. (DiskIO / NetIO)
```
Rules:
- Three sections: `Changes:` (behavior changes), `Features:`, `Bugfixes:`
- Past tense: `Added` / `Fixed` / `Improved`
- End each entry with its scope: `(Module, Platform)` or `(ModuleA / ModuleB)`
- Sub-bullets are indented 4 spaces
---
## Tests
Tests are standalone executables in `tests/` using a `VERIFY` macro that exits non-zero on failure:
```c
#define VERIFY(expression) \
if (!(expression)) testFailed(&strbuf, #expression, __LINE__)
```
Current tests: `strbuf.c`, `list.c`, `format.c`, `color.c`, `duration.c`, `strutil.c`.
```sh
cmake -B build -DBUILD_TESTS=On
cmake --build build
cd build && ctest --output-on-failure
```
Coverage focuses on the core data structures and the formatting engine in `common/`. The `detection/` layer has no automated tests, because it depends on the state of a running system; it is instead covered by the CI matrix — 20 workflows under `.github/workflows/` spanning Linux (including musl, loong64, armv7l, i686), Android, macOS, Windows, FreeBSD, NetBSD, OpenBSD, DragonFly, Solaris, OmniOS and Haiku, plus a benchmark job. The Android job is the one that does not run what it builds: it cross-compiles for arm64-v8a, armeabi-v7a and x86_64 with the NDK at API 24 and inspects the result instead, because CI has no device or emulator. Its dynamic-symbol checks are what keep the weak references the platform branch depends on from turning into load failures on older devices.
**If you modify `common/FFstrbuf.h`, `common/format.h` or `common/color.h`, extend the corresponding test.**
---
## Pull requests
1. **Open an issue first** (feature request / bug report / logo request) to confirm that the change is wanted before investing effort. Templates are in `.github/ISSUE_TEMPLATE/`.
2. Branch off `dev` — **`dev` is the main development branch**, not `master`.
3. Follow the [commit message convention](#commit-messages).
4. Update `CHANGELOG.md` for user-visible changes.
5. Open the PR against `dev` and fill in `.github/pull_request_template.md`:
- Summary
- Related issue (**required for new logos**; otherwise the PR is not accepted)
- Changes
- Screenshots (required for visual changes)
- Checklist: confirm you tested locally
### Pre-submit checklist
```sh
clang-format -i <changed files> # format
cmake -B build -DBUILD_TESTS=On && cmake --build build -j
cd build && ctest --output-on-failure # tests
./build/fastfetch --format json # verify JSON output is well-formed
./build/fastfetch -c presets/all.jsonc --stat false # smoke-test every module
```
---
## Pitfalls
The following points are easy to misinterpret when reading this codebase. Most of them follow from the startup-time objective described above.
### 1. Option structs must not exceed 256 bytes
`FF_OPTION_MAX_SIZE = 1 << 8`. Exceeding it is caught at compile time by `static_assert`. Do not attempt to increase the value: it determines the stack cost of every module invocation.
### 2. `FF_MODULE_DISABLE_*` controls registration, not compilation
```c
// verbatim from the top of modules/modules.c:
// FF_MODULE_DISABLE_<module> only controls if the module is registered,
// the module code itself is still compiled.
// We rely `LTO` to remove the unused code (only enabled in Release mode)
```
**Disabling modules in a Debug build does not shrink the binary.** LTO is enabled whenever `CMAKE_BUILD_TYPE != Debug`, and the default `RelWithDebInfo` already satisfies that — so measure size with `RelWithDebInfo` or `Release`, never with `Debug`. (The "Release mode" wording in the comment above is imprecise.)
### 3. Only two things are discovered by glob
The module sources (`CMakeLists.txt:134`) and the logo `.txt` files (`CMakeLists.txt:429`). Both use `CONFIGURE_DEPENDS`, so with the Makefile and Ninja generators the build re-checks the glob and re-runs CMake when the result changes; other generators (Visual Studio and Xcode in particular) do not track it as reliably. Re-run `cmake -B build` after adding a module source or a logo file rather than relying on that behavior.
Everything else — `src/detection/**` and `src/common/impl/**`, and any source outside the platform chain — must be listed in `CMakeLists.txt` by hand; see [step 5](#5-add-the-platform-sources-to-cmakeliststxt).
### 4. CLI module options are removed
Per-module command-line flags such as `--cpu-temp` are **no longer supported**. The only job of `ffParseModuleOptions` now is to translate the flag into a JSON key, then `exit(477)` with a pointer to the config file:
```
Error: Unsupported module option: --cpu-temp
Support of module options has been removed. Please add the flag to the JSON config instead.
Example (demonstration only): `{ "modules": [ { "type": "cpu", "temp": true } ] }`
```
**JSONC is the first-class configuration interface; the command line is not.** When adding module options, implement `parseJsonObject` only — do not add a CLI branch.
### 5. `defaultOrder = 0` hides a module from `--gen-config`
`collectModuleInfos` (`genconfig.c:186`) skips any module whose `defaultOrder` is `0`. C zero-initializes the field, so **omitting it is the same as setting it to 0**. Only `logo`, `command` and `custom` rely on this intentionally.
`defaultOrder` affects only the ordering in the interactive `--gen-config` picker; it has no effect on the runtime output order.
### 6. Localization uses byte offsets, not enums
`instance.config.display.keyLanguage` does not hold a language enum — it holds a **byte offset** such as `offsetof(FFModuleDisplayName, zh_CN)`. The macro `FF_MODULE_GET_DISPLAY_NAME` (`common/option.h:123`) does plain pointer arithmetic with it:
```c
#define FF_MODULE_GET_DISPLAY_NAME(moduleName) \
(*(const char**) ((uint8_t*) &ff ## moduleName ## ModuleInfo.displayName + instance.config.display.keyLanguage))
```
Consequence: **the field order of `FFModuleDisplayName` must never change** — reordering the fields silently corrupts the output for every language.
### 7. The `multithreading` option has limited effect
The global `multithreading` option currently takes effect in exactly one place: `common/impl/networking_linux.c:339`. Modules are still printed sequentially. Modules that need concurrency go through the `ffPrepare*` warm-up hooks instead, which start sampling or fire off requests before the print loop begins.
This may change in the future. The main blocking issue is that there are dependencies between different modules.
### 8. Do not print or read configuration inside `detection/`
The `detection/` layer must stay pure: read system state, fill a struct, return an error string. Any `printf` or any read of `instance.config` there is a design error.
Use `FF_DEBUG` (`src/common/debug.h`) for logging.
### 9. `src/logo/builtin.c` and `3rdparty/` are formatting-exempt
The former is a large generated and hand-maintained data table; the latter is upstream code. Both are excluded via `.clang-format-ignore`; do not reformat either.
---
## Reference
- Configuration guide: <https://github.com/fastfetch-cli/fastfetch/wiki/Configuration>
- JSON schema: `doc/json_schema.json`
- Example presets: `presets/` (`all.jsonc`, `neofetch.jsonc`, `ci.jsonc`, …)
- Man page source: `doc/fastfetch.1.in`
- Code generation scripts: `scripts/` (`gen-pciids.py`, `gen-amdgpuids.py`, `gen-man.py`)
+23 -39
View File
@@ -1,5 +1,6 @@
# Fastfetch
[![Benchmark](https://img.shields.io/badge/GitHub%20Pages-live-blue?logo=github)](https://fastfetch-cli.github.io/fastfetch/dev/bench)
[![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)
@@ -99,7 +100,7 @@ See the Wiki: https://github.com/fastfetch-cli/fastfetch/wiki/Building
* View all data that fastfetch detects: `fastfetch -s <module1>[:<module2>][:<module3>] --format json`
* Display help messages: `fastfetch --help`
* Generate a minimal config file: `fastfetch [-s <module1>[:<module2>]] --gen-config [</path/to/config.jsonc>]`
* Use: `--gen-config-full` to generate a full config file with all optional options
* Use [The online configuration generator](https://fastfetch-cli.github.io/fastfetch-config/) to generate a full config file with all optional options
## Customization
@@ -199,7 +200,8 @@ See [#1096](https://github.com/fastfetch-cli/fastfetch/issues/1096).
### Q: Fastfetch shows fewer dpkg packages than neofetch. Is it a bug?
Neofetch incorrectly counts `rc` packages (packages that have been removed but still have configuration files remaining). See bug: https://github.com/dylanaraps/neofetch/issues/2278
1. Neofetch incorrectly counts `rc` packages for apt (packages that have been removed but still have configuration files remaining). See bug: https://github.com/dylanaraps/neofetch/issues/2278
2. Neofetch incorrectly counts `gpg-pubkey` as packages for rpm. You may check the results of `dnf list --installed | wc -l` and `rpm -qa | wc -l` to see the difference.
### Q: I use Debian / Ubuntu / Debian-derived distro. My GPU is detected as `XXXX Device XXXX (VGA compatible)`. Is this a bug?
@@ -246,7 +248,20 @@ Set the key to a white space.
### Q: How can I display images on Windows?
As of April 2025:
#### Windows Terminal
Windows Terminal supports the sixel image protocol only.
```jsonc
{
"logo": {
"type": "sixel", // DO NOT USE "auto"
"source": "C:/path/to/image.png", // ~ can be used to refer to the Windows user home directory
"width": <image-width-in-chars>, // Optional
"height": <image-height-in-chars> // Optional
}
}
```
#### mintty and Wezterm
@@ -258,38 +273,7 @@ In `config.jsonc`:
"logo": {
"type": "iterm",
"source": "C:/path/to/image.png",
"width": <num-in-chars>
}
}
```
#### Windows Terminal
Windows Terminal supports the sixel image protocol only.
* If you installed fastfetch through MSYS2:
1. Install imagemagick: `pacman -S mingw-w64-<subsystem>-x86_64-imagemagick`
2. In `config.jsonc`:
```jsonc
{
"logo": {
"type": "sixel", // DO NOT USE "auto"
"source": "C:/path/to/image.png", // Do NOT use `~` as fastfetch is a native Windows program and doesn't apply cygwin path conversion
"width": <image-width-in-chars>, // Optional
"height": <image-height-in-chars> // Optional
}
}
```
* If you installed fastfetch via scoop or downloaded the binary directly from the GitHub Releases page:
1. Convert your image manually to sixel format using [any online image conversion service](https://www.google.com/search?q=convert+image+to+sixel)
2. In `config.jsonc`:
```jsonc
{
"logo": {
"type": "raw", // DO NOT USE "auto"
"source": "C:/path/to/image.sixel",
"width": <image-width-in-chars>, // Required
"height": <image-height-in-chars> // Required
"width": <image-width-in-chars>
}
}
```
@@ -334,10 +318,10 @@ If you find Fastfetch useful, please consider donating.
Give us a star to show your support!
<a href="https://star-history.com/#fastfetch-cli/fastfetch&Date">
<a href="https://star-history.dera.page/#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" />
<source media="(prefers-color-scheme: dark)" srcset="https://star-history.dera.page/svg?repos=fastfetch-cli/fastfetch&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://star-history.dera.page/svg?repos=fastfetch-cli/fastfetch&type=Date" />
<img alt="Star History Chart" src="https://star-history.dera.page/svg?repos=fastfetch-cli/fastfetch&type=Date" />
</picture>
</a>
+3 -1
View File
@@ -33,7 +33,9 @@ _fastfetch() {
if type _filedir &>/dev/null; then
_filedir
elif type compgen &>/dev/null; then
COMPREPLY+=($(compgen -f -- "$cur"))
local -a files
readarray -t files < <(compgen -f -- "$cur")
COMPREPLY+=("${files[@]}")
fi
return
;;
+56 -24
View File
@@ -63,46 +63,78 @@ echo '
import json, subprocess, sys
def escape_fish_dq(s: str) -> str:
"""Escape special characters for Fish double quotes to prevent unexpected expansions. One slash in output needs four slashes in script"""
return str(s).replace("\\\\", "\\\\\\\\").replace("\\"", "\\\\\\"").replace("$", "\\\\$")
def main():
data: dict[str, list[dict]] = json.loads(subprocess.check_output(["fastfetch", "--help-raw"]))
enum_functions = []
complete_commands = []
for key in data:
for flag in data[key]:
if flag["long"] == "logo-color-[1-9]":
long_name = flag.get("long", "")
# Handle pseudo flag logo-color-[1-9]
if long_name == "logo-color-[1-9]":
safe_desc_global = escape_fish_dq(flag.get("desc", ""))
for i in range(1, 10):
print(f"""complete -c fastfetch -d "{flag["desc"]}" -l "logo-color-{i}" -x -a "(__fastfetch_complete_color)" """)
complete_commands.append(f"complete -c fastfetch -d \"{safe_desc_global}\" -l \"logo-color-{i}\" -x -a \"(__fastfetch_complete_color)\"")
continue
if flag.get("pseudo", False):
continue
command_prefix = f"""complete -c fastfetch -d "{flag["desc"]}" -l "{flag["long"]}\""""
safe_desc_global = escape_fish_dq(flag.get("desc", ""))
command_prefix = f"complete -c fastfetch -d \"{safe_desc_global}\" -l \"{long_name}\""
if "short" in flag:
command_prefix += f""" -o {flag["short"]}"""
short_name = flag["short"]
command_prefix += f" -o {short_name}"
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(flag["arg"]["enum"])
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")
arg_type: str = flag["arg"]["type"]
if arg_type == "bool":
complete_commands.append(f"{command_prefix} -x -a \"(__fastfetch_complete_bool)\"")
elif arg_type == "color":
complete_commands.append(f"{command_prefix} -x -a \"(__fastfetch_complete_color)\"")
elif arg_type == "command":
complete_commands.append(f"{command_prefix} -x -a \"(__fastfetch_complete_command)\"")
elif arg_type == "config":
complete_commands.append(f"{command_prefix} -x -a \"(__fastfetch_complete_config)\"")
elif arg_type == "enum":
# Sanitize flag name to create a valid Fish function name
func_name = long_name.replace("-", "_").replace("[", "_").replace("]", "_")
func_name = f"__fastfetch_complete_enum_{func_name}"
# Generate the enum function
func_lines = [f"function {func_name}"]
for enum_val, enum_desc in flag["arg"]["enum"].items():
safe_val = escape_fish_dq(enum_val)
safe_desc = escape_fish_dq(enum_desc)
func_lines.append(f" echo -e \"{safe_val}\\t{safe_desc}\"")
func_lines.append("end\n")
enum_functions.append("\n".join(func_lines))
# Append complete command pointing to the new function
complete_commands.append(f"{command_prefix} -x -a \"({func_name})\"")
elif arg_type == "logo":
complete_commands.append(f"{command_prefix} -x -a \"(__fastfetch_complete_logo)\"")
elif arg_type == "structure":
complete_commands.append(f"{command_prefix} -x -a \"(__fish_complete_list : __fastfetch_complete_structure)\"")
elif arg_type == "path":
complete_commands.append(f"{command_prefix} -r -F")
else:
print(f"{command_prefix} -x")
complete_commands.append(f"{command_prefix} -x")
else:
print(f"{command_prefix} -f")
complete_commands.append(f"{command_prefix} -f")
# Print generated enum functions first, then complete rules
print("\n".join(enum_functions))
print("\n".join(complete_commands))
if __name__ == "__main__":
+60
View File
@@ -1,3 +1,63 @@
fastfetch (2.68.1~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.68.1
-- Carter Li <zhangsongcui@live.cn> Wed, 02 Sep 2026 10:47:51 +0800
fastfetch (2.68.0~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.68.0
-- Carter Li <zhangsongcui@live.cn> Tue, 01 Sep 2026 16:34:36 +0800
fastfetch (2.67.0~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.67.0
-- Carter Li <zhangsongcui@live.cn> Thu, 06 Aug 2026 16:22:22 +0800
fastfetch (2.66.0~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.66.0
-- Carter Li <zhangsongcui@live.cn> Fri, 10 Jul 2026 15:13:37 +0800
fastfetch (2.65.2~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.65.2
-- Carter Li <zhangsongcui@live.cn> Mon, 29 Jun 2026 10:05:47 +0800
fastfetch (2.65.1~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.65.1
-- Carter Li <zhangsongcui@live.cn> Wed, 24 Jun 2026 14:21:06 +0800
fastfetch (2.64.2~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.64.2
-- Carter Li <zhangsongcui@live.cn> Mon, 08 Jun 2026 15:45:11 +0800
fastfetch (2.63.1~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.63.1
-- Carter Li <zhangsongcui@live.cn> Fri, 15 May 2026 09:31:54 +0800
fastfetch (2.63.0~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.63.0
-- Carter Li <zhangsongcui@live.cn> Wed, 13 May 2026 16:02:28 +0800
fastfetch (2.62.1~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.62.1
-- Carter Li <zhangsongcui@live.cn> Fri, 24 Apr 2026 15:45:15 +0800
fastfetch (2.62.0~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium
* Update to 2.62.0
+1 -1
View File
@@ -2,7 +2,7 @@ Source: fastfetch
Section: universe/utils
Priority: optional
Maintainer: Carter Li <zhangsongcui@live.cn>
Build-Depends: libelf-dev, libvulkan-dev, libwayland-dev, libxrandr-dev, libxcb-randr0-dev, libdconf-dev, libdbus-1-dev, libmagickcore-dev, libsqlite3-dev, librpm-dev, libegl-dev, libglx-dev, ocl-icd-opencl-dev, libpulse-dev, libdrm-dev, libddcutil-dev, libchafa-dev, pkgconf, cmake (>= 3.12), debhelper (>= 11.2), dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, dh-sequence-ctest, ninja-build, python3-setuptools
Build-Depends: libelf-dev, libvulkan-dev, libwayland-dev, libxrandr-dev, libxcb-randr0-dev, libdconf-dev, libdbus-1-dev, libmagickcore-dev, libsqlite3-dev, librpm-dev, libegl-dev, libglx-dev, ocl-icd-opencl-dev, libdrm-dev, libchafa-dev, libefl-all-dev, pkgconf, cmake (>= 3.12), debhelper (>= 11.2), dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, dh-sequence-ctest, ninja-build, python3-setuptools
Standards-Version: 4.0.0
Homepage: https://github.com/fastfetch-cli/fastfetch
+1 -1
View File
@@ -10,7 +10,7 @@ SCRIPT_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
ROOT_DIR="$(cd -- "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
OUT_DIR="$(dirname "$ROOT_DIR")"
PPA="ppa:zhangsongcui3371/fastfetch"
CODENAMES=( jammy noble plucky questing resolute )
CODENAMES=( jammy noble plucky questing resolute stonking )
DRY_RUN=0
if [[ -d "$OUT_DIR/build" ]]; then
+80 -24
View File
@@ -83,6 +83,16 @@
"type": "num",
"default": 0
}
},
{
"long": "watch",
"short": "w",
"desc": "Alias of dynamic-interval, but the value is in seconds instead of milliseconds. If no value is provided, it defaults to 1 second",
"arg": {
"type": "num",
"optional": true,
"default": 1
}
}
],
"Config": [
@@ -97,26 +107,8 @@
},
{
"long": "gen-config",
"desc": "Generate a minimal config file at the specified path",
"remark": "Defaults to \"~/.config/fastfetch/config.jsonc\". Prints the generated config if <path> is \"-\"",
"arg": {
"type": "path",
"optional": true
}
},
{
"long": "gen-config-full",
"desc": "Generate a full config file with all optional settings at the specified path",
"remark": "Defaults to \"~/.config/fastfetch/config.jsonc\". Prints the generated config if <path> is \"-\"",
"arg": {
"type": "path",
"optional": true
}
},
{
"long": "gen-config-force",
"desc": "Generate a config file at the specified path, overwriting any existing file",
"remark": "Defaults to \"~/.config/fastfetch/config.jsonc\"",
"desc": "Interactively generate a config file at the specified path",
"remark": "Opens an interactive configuration UI when run in a terminal. Falls back to non-interactive generation when env-var `$NO_COLOR` is set or stdin/stdout is not a TTY. Defaults to \"~/.config/fastfetch/config.jsonc\". Prints the generated config if <path> is \"-\"",
"arg": {
"type": "path",
"optional": true
@@ -203,6 +195,7 @@
"file-raw": "Text file, printed as is",
"data": "Text data, printed with color code replacement",
"data-raw": "Text data, printed as is",
"command-raw": "Command to run, whose output is printed as is",
"sixel": "Image file, rendered as sixel",
"kitty": "Image file, rendered using the Kitty graphics protocol",
"kitty-direct": "Image file, tells the terminal emulator to read image data from the specified file",
@@ -277,6 +270,14 @@
"type": "num"
}
},
{
"long": "logo-padding-bottom",
"desc": "Set the padding at the bottom of the logo",
"remark": "Only used with \"--logo-position top\"",
"arg": {
"type": "num"
}
},
{
"long": "logo-print-remaining",
"desc": "Specify whether to print remaining logo lines when the logo is taller than the module list",
@@ -292,6 +293,7 @@
"arg": {
"type": "enum",
"enum": {
"auto": "Automatically choose left or top based on terminal width",
"left": "Left",
"top": "Top",
"right": "Right"
@@ -299,12 +301,33 @@
}
},
{
"long": "logo-recache",
"desc": "If true, regenerate the image logo cache",
"long": "logo-cache",
"desc": "Specify how the image logo cache is used",
"remark": "See \"--help logo-animation-frame\" for the one case where a cached rendering can outlive the image type that produced it",
"arg": {
"type": "bool",
"type": "enum",
"optional": true,
"default": false
"default": "true",
"enum": {
"true": "Reuse a cached rendering when it is valid, and write it back on a cache miss",
"false": "Ignore the image logo cache completely: neither read nor write it",
"regen": "Ignore any existing cached rendering and regenerate it"
}
}
},
{
"long": "logo-animation-frame",
"desc": "Select which frame of an animated image logo to render",
"remark": [
"Animated kitty graphics only, and only if the image source is animated; 1 or higher renders that frame as a still image, 0 plays the animation",
"A selected frame is cached exactly like the first frame is, sharing its entries; the frame number is recorded next to them, so changing this option re-renders",
"That record is per cache directory, not per image type: switching --logo-type between two types that both have a cached rendering here, and asking for a different frame, can pair one type's rendering with the other's frame number",
"Run \"--logo-cache regen\" after such a switch"
],
"arg": {
"type": "num",
"optional": true,
"default": 1
}
},
{
@@ -593,6 +616,39 @@
"default": "string"
}
},
{
"long": "key-language",
"desc": "Specify the language used for module keys",
"remark": "Leave empty for auto-detection based on the system locale. Unsupported locales fall back to English",
"arg": {
"type": "enum",
"default": "en",
"optional": true,
"enum": {
"en": "English",
"ar": "Arabic",
"cs": "Czech",
"de": "German",
"es": "Spanish",
"fi": "Finnish",
"fr": "French",
"gl": "Galician",
"he": "Hebrew",
"id": "Indonesian",
"it": "Italian",
"ja": "Japanese",
"ko": "Korean",
"pl": "Polish",
"pt": "Portuguese",
"ru": "Russian",
"tr": "Turkish",
"uk": "Ukrainian",
"vi": "Vietnamese",
"zh_CN": "Simplified Chinese",
"zh_TW": "Traditional Chinese"
}
}
},
{
"long": "bright-color",
"desc": "Specify whether keys, title, and ASCII logo should be printed in bright color",
+444 -78
View File
@@ -19,15 +19,14 @@
},
"key": {
"description": "Module key\nUse a single space (` `) to hide the key",
"type": "string",
"minLength": 1
"type": "string"
},
"keyColor": {
"description": "Color of the module key. Overrides `display.color.key`",
"description": "Color of the module key. Overrides `display.color.keys`",
"$ref": "#/$defs/colors"
},
"keyWidth": {
"description": "Width of the module key. Overrides `display.keyWidth`",
"description": "Width of the module key. Overrides `display.key.width`",
"type": "integer",
"minimum": 1
},
@@ -131,7 +130,9 @@
"SunOS",
"OpenBSD",
"NetBSD",
"Haiku"
"Haiku",
"GNU",
"Unknown"
]
},
"architectures": {
@@ -150,7 +151,9 @@
"sparc",
"alpha",
"hppa",
"m68k"
"sh",
"m68k",
"Unknown"
]
},
"conditions": {
@@ -243,7 +246,7 @@
"oneOf": [
{
"type": "boolean",
"description": "True to show the module only if it succeeded; false to show it only if it failed"
"description": "True to show the module only if the last run succeeded; false to show it only if the last run failed"
},
{
"type": "null",
@@ -274,19 +277,19 @@
"batteryFormat": {
"description": "Output format for the `Battery` module. See Wiki for formatting syntax\n 1. {manufacturer}: Battery manufacturer\n 2. {model-name}: Battery model name\n 3. {technology}: Battery technology\n 4. {capacity}: Battery capacity (percentage num)\n 5. {status}: Battery status\n 6. {temperature}: Battery temperature (formatted)\n 7. {cycle-count}: Battery cycle count\n 8. {serial}: Battery serial number\n 9. {manufacture-date}: Battery manufacture date\n 10. {capacity-bar}: Battery capacity (percentage bar)\n 11. {time-days}: Battery time remaining days\n 12. {time-hours}: Battery time remaining hours\n 13. {time-minutes}: Battery time remaining minutes\n 14. {time-seconds}: Battery time remaining seconds\n 15. {time-formatted}: Battery time remaining (formatted)",
"description": "Output format for the `Battery` module. See Wiki for formatting syntax\n 1. {manufacturer}: Battery manufacturer\n 2. {model-name}: Battery model name *\n 3. {technology}: Battery technology\n 4. {capacity}: Battery capacity (percentage num)\n 5. {status}: Battery status\n 6. {temperature}: Battery temperature (formatted)\n 7. {cycle-count}: Battery cycle count\n 8. {serial}: Battery serial number\n 9. {manufacture-date}: Battery manufacture date\n 10. {capacity-bar}: Battery capacity (percentage bar)\n 11. {time-days}: Battery time remaining days\n 12. {time-hours}: Battery time remaining hours\n 13. {time-minutes}: Battery time remaining minutes\n 14. {time-seconds}: Battery time remaining seconds\n 15. {time-formatted}: Battery time remaining (formatted)",
"type": "string"
},
"biosFormat": {
"description": "Output format for the `BIOS` module. See Wiki for formatting syntax\n 1. {date}: BIOS date\n 2. {release}: BIOS release\n 3. {vendor}: BIOS vendor\n 4. {version}: BIOS version\n 5. {type}: Firmware type",
"description": "Output format for the `BIOS` module. See Wiki for formatting syntax\n 1. {date}: BIOS date\n 2. {release}: BIOS release\n 3. {vendor}: BIOS vendor\n 4. {version}: BIOS version\n 5. {type}: Firmware type *",
"type": "string"
},
"bluetoothFormat": {
"description": "Output format for the `Bluetooth` module. See Wiki for formatting syntax\n 1. {name}: Name\n 2. {address}: Address\n 3. {type}: Type\n 4. {battery-percentage}: Battery percentage number\n 5. {connected}: Is connected\n 6. {battery-percentage-bar}: Battery percentage bar",
"description": "Output format for the `Bluetooth` module. See Wiki for formatting syntax\n 1. {name}: Name\n 2. {address}: Address\n 3. {type}: Type\n 4. {device-type}: Bluetooth stacks the device answers on\n 5. {battery-percentage}: Battery percentage number\n 6. {battery-percentage-bar}: Battery percentage bar\n 7. {signal-quality}: Signal quality number\n 8. {signal-quality-bar}: Signal quality bar\n 9. {connected}: Is connected",
"type": "string"
},
"bluetoothradioFormat": {
"description": "Output format for the `BluetoothRadio` module. See Wiki for formatting syntax\n 1. {name}: Radio name for discovering\n 2. {address}: Address\n 3. {lmp-version}: LMP version\n 4. {lmp-subversion}: LMP subversion\n 5. {version}: Bluetooth version\n 6. {vendor}: Vendor\n 7. {discoverable}: Discoverable\n 8. {connectable}: Connectable / Pairable",
"description": "Output format for the `BluetoothRadio` module. See Wiki for formatting syntax\n 1. {name}: Radio name for discovering *\n 2. {address}: Address\n 3. {lmp-version}: LMP version\n 4. {lmp-subversion}: LMP subversion\n 5. {version}: Bluetooth version\n 6. {vendor}: Vendor\n 7. {discoverable}: Discoverable\n 8. {connectable}: Connectable / Pairable",
"type": "string"
},
"boardFormat": {
@@ -298,11 +301,11 @@
"type": "string"
},
"brightnessFormat": {
"description": "Output format for the `Brightness` module. See Wiki for formatting syntax\n 1. {percentage}: Screen brightness (percentage num)\n 2. {name}: Screen name\n 3. {max}: Maximum brightness value\n 4. {min}: Minimum brightness value\n 5. {current}: Current brightness value\n 6. {percentage-bar}: Screen brightness (percentage bar)\n 7. {is-builtin}: Is built-in screen",
"description": "Output format for the `Brightness` module. See Wiki for formatting syntax\n 1. {percentage}: Screen brightness (percentage num)\n 2. {name}: Screen name *\n 3. {max}: Maximum brightness value\n 4. {min}: Minimum brightness value\n 5. {current}: Current brightness value\n 6. {percentage-bar}: Screen brightness (percentage bar)\n 7. {is-builtin}: Is built-in screen",
"type": "string"
},
"btrfsFormat": {
"description": "Output format for the `Btrfs` module. See Wiki for formatting syntax\n 1. {name}: Name / Label\n 2. {uuid}: UUID\n 3. {devices}: Associated devices\n 4. {features}: Enabled features\n 5. {used}: Size used\n 6. {allocated}: Size allocated\n 7. {total}: Size total\n 8. {used-percentage}: Used percentage num\n 9. {allocated-percentage}: Allocated percentage num\n 10. {used-percentage-bar}: Used percentage bar\n 11. {allocated-percentage-bar}: Allocated percentage bar\n 12. {node-size}: Node size\n 13. {sector-size}: Sector size",
"description": "Output format for the `Btrfs` module. See Wiki for formatting syntax\n 1. {name}: Name / Label *\n 2. {uuid}: UUID\n 3. {devices}: Associated devices\n 4. {features}: Enabled features\n 5. {used}: Size used\n 6. {allocated}: Size allocated\n 7. {total}: Size total\n 8. {used-percentage}: Used percentage num\n 9. {allocated-percentage}: Allocated percentage num\n 10. {used-percentage-bar}: Used percentage bar\n 11. {allocated-percentage-bar}: Allocated percentage bar\n 12. {node-size}: Node size\n 13. {sector-size}: Sector size",
"type": "string"
},
"cameraFormat": {
@@ -313,6 +316,10 @@
"description": "Output format for the `Chassis` module. See Wiki for formatting syntax\n 1. {type}: Chassis type\n 2. {vendor}: Chassis vendor\n 3. {version}: Chassis version\n 4. {serial}: Chassis serial number",
"type": "string"
},
"codecFormat": {
"description": "Output format for the `Codec` module. See Wiki for formatting syntax\n 1. {gpu}: GPU name *\n 2. {direction}: Decoder / Encoder *\n 3. {types}: Compatibility alias of codec types\n 4. {platform-api}: Platform API used for detection",
"type": "string"
},
"commandFormat": {
"description": "Output format for the `Command` module. See Wiki for formatting syntax\n 1. {result}: Command result",
"type": "string"
@@ -322,7 +329,7 @@
"type": "string"
},
"cpucacheFormat": {
"description": "Output format for the `CPUCache` module. See Wiki for formatting syntax\n 1. {result}: Separate result\n 2. {sum}: Sum result",
"description": "Output format for the `CPUCache` module. See Wiki for formatting syntax\n 1. {result}: Separate result\n 2. {sum}: Sum result\n 3. {level}: Cache level *",
"type": "string"
},
"cpuusageFormat": {
@@ -342,15 +349,15 @@
"type": "string"
},
"displayFormat": {
"description": "Output format for the `Display` module. See Wiki for formatting syntax\n 1. {width}: Screen configured width (in pixels)\n 2. {height}: Screen configured height (in pixels)\n 3. {refresh-rate}: Screen configured refresh rate (in Hz)\n 4. {scaled-width}: Screen scaled width (in pixels)\n 5. {scaled-height}: Screen scaled height (in pixels)\n 6. {name}: Screen name\n 7. {type}: Screen type (Built-in or External)\n 8. {rotation}: Screen rotation (in degrees)\n 9. {is-primary}: True if being the primary screen\n 10. {physical-width}: Screen physical width (in millimeters)\n 11. {physical-height}: Screen physical height (in millimeters)\n 12. {inch}: Physical diagonal length in inches\n 13. {ppi}: Pixels per inch (PPI)\n 14. {bit-depth}: Bits per color channel\n 15. {hdr-enabled}: True if high dynamic range (HDR) mode is enabled\n 16. {manufacture-year}: Year of manufacturing\n 17. {manufacture-week}: Nth week of manufacturing in the year\n 18. {serial}: Serial number\n 19. {platform-api}: The platform API used when detecting the display\n 20. {hdr-compatible}: True if the display is HDR compatible\n 21. {scale-factor}: HiDPI scale factor\n 22. {preferred-width}: Screen preferred width (in pixels)\n 23. {preferred-height}: Screen preferred height (in pixels)\n 24. {preferred-refresh-rate}: Screen preferred refresh rate (in Hz)\n 25. {dpi}: DPI",
"description": "Output format for the `Display` module. See Wiki for formatting syntax\n 1. {width}: Screen configured width (in pixels)\n 2. {height}: Screen configured height (in pixels)\n 3. {refresh-rate}: Screen configured refresh rate (in Hz)\n 4. {scaled-width}: Screen scaled width (in pixels)\n 5. {scaled-height}: Screen scaled height (in pixels)\n 6. {name}: Screen name *\n 7. {type}: Screen type (Built-in or External) *\n 8. {rotation}: Screen rotation (in degrees)\n 9. {is-primary}: True if being the primary screen\n 10. {physical-width}: Screen physical width (in millimeters)\n 11. {physical-height}: Screen physical height (in millimeters)\n 12. {inch}: Physical diagonal length in inches\n 13. {ppi}: Pixels per inch (PPI)\n 14. {bit-depth}: Bits per color channel\n 15. {hdr-enabled}: True if high dynamic range (HDR) mode is enabled\n 16. {manufacture-year}: Year of manufacturing\n 17. {manufacture-week}: Nth week of manufacturing in the year\n 18. {serial}: Serial number\n 19. {platform-api}: The platform API used when detecting the display\n 20. {hdr-compatible}: True if the display is HDR compatible\n 21. {scale-factor}: HiDPI scale factor\n 22. {preferred-width}: Screen preferred width (in pixels)\n 23. {preferred-height}: Screen preferred height (in pixels)\n 24. {preferred-refresh-rate}: Screen preferred refresh rate (in Hz)\n 25. {dpi}: DPI",
"type": "string"
},
"diskFormat": {
"description": "Output format for the `Disk` module. See Wiki for formatting syntax\n 1. {size-used}: Size used\n 2. {size-total}: Size total\n 3. {size-percentage}: Size percentage num\n 4. {files-used}: Files used\n 5. {files-total}: Files total\n 6. {files-percentage}: Files percentage num\n 7. {is-external}: True if external volume\n 8. {is-hidden}: True if hidden volume\n 9. {filesystem}: Filesystem\n 10. {name}: Label / name\n 11. {is-readonly}: True if read-only\n 12. {create-time}: Create time in local timezone\n 13. {size-percentage-bar}: Size percentage bar\n 14. {files-percentage-bar}: Files percentage bar\n 15. {days}: Days after creation\n 16. {hours}: Hours after creation\n 17. {minutes}: Minutes after creation\n 18. {seconds}: Seconds after creation\n 19. {milliseconds}: Milliseconds after creation\n 20. {mountpoint}: Mount point / drive letter\n 21. {mount-from}: Mount from (device path)\n 22. {years}: Years integer after creation\n 23. {days-of-year}: Days of year after creation\n 24. {years-fraction}: Years fraction after creation\n 25. {size-free}: Size free\n 26. {size-available}: Size available",
"description": "Output format for the `Disk` module. See Wiki for formatting syntax\n 1. {size-used}: Size used (formatted)\n 2. {size-total}: Size total (formatted)\n 3. {size-percentage}: Size percentage num\n 4. {files-used}: Files used\n 5. {files-total}: Files total\n 6. {files-percentage}: Files percentage num\n 7. {is-external}: True if external volume\n 8. {is-hidden}: True if hidden volume\n 9. {filesystem}: Filesystem *\n 10. {name}: Label / name *\n 11. {is-readonly}: True if read-only\n 12. {create-time}: Create time in local timezone\n 13. {size-percentage-bar}: Size percentage bar\n 14. {files-percentage-bar}: Files percentage bar\n 15. {days}: Days after creation\n 16. {hours}: Hours after creation\n 17. {minutes}: Minutes after creation\n 18. {seconds}: Seconds after creation\n 19. {milliseconds}: Milliseconds after creation\n 20. {mountpoint}: Mount point / drive letter *\n 21. {mount-from}: Mount from (device path) *\n 22. {years}: Years integer after creation\n 23. {days-of-year}: Days of year after creation\n 24. {years-fraction}: Years fraction after creation\n 25. {size-free}: Size free (formatted)\n 26. {bytes-used}: Size used (in bytes)\n 27. {bytes-total}: Size total (in bytes)",
"type": "string"
},
"diskioFormat": {
"description": "Output format for the `DiskIO` module. See Wiki for formatting syntax\n 1. {size-read}: Size of data read [per second] (formatted)\n 2. {size-written}: Size of data written [per second] (formatted)\n 3. {name}: Device name\n 4. {dev-path}: Device raw file path\n 5. {bytes-read}: Size of data read [per second] (in bytes)\n 6. {bytes-written}: Size of data written [per second] (in bytes)\n 7. {read-count}: Number of reads\n 8. {write-count}: Number of writes",
"description": "Output format for the `DiskIO` module. See Wiki for formatting syntax\n 1. {size-read}: Size of data read [per second] (formatted)\n 2. {size-written}: Size of data written [per second] (formatted)\n 3. {name}: Device name *\n 4. {dev-path}: Device raw file path *\n 5. {bytes-read}: Size of data read [per second] (in bytes)\n 6. {bytes-written}: Size of data written [per second] (in bytes)\n 7. {read-count}: Number of reads\n 8. {write-count}: Number of writes",
"type": "string"
},
"dnsFormat": {
@@ -370,7 +377,7 @@
"type": "string"
},
"gpuFormat": {
"description": "Output format for the `GPU` module. See Wiki for formatting syntax\n 1. {vendor}: GPU vendor\n 2. {name}: GPU name\n 3. {driver}: GPU driver\n 4. {temperature}: GPU temperature\n 5. {core-count}: GPU core count\n 6. {type}: GPU type\n 7. {dedicated-total}: GPU total dedicated memory\n 8. {dedicated-used}: GPU used dedicated memory\n 9. {shared-total}: GPU total shared memory\n 10. {shared-used}: GPU used shared memory\n 11. {platform-api}: The platform API used when detecting the GPU\n 12. {frequency}: Current frequency in GHz\n 13. {index}: GPU vendor specific index\n 14. {dedicated-percentage-num}: Dedicated memory usage percentage num\n 15. {dedicated-percentage-bar}: Dedicated memory usage percentage bar\n 16. {shared-percentage-num}: Shared memory usage percentage num\n 17. {shared-percentage-bar}: Shared memory usage percentage bar\n 18. {core-usage-num}: Core usage percentage num\n 19. {core-usage-bar}: Core usage percentage bar\n 20. {memory-type}: Memory type (Windows only)",
"description": "Output format for the `GPU` module. See Wiki for formatting syntax\n 1. {vendor}: GPU vendor\n 2. {name}: GPU name\n 3. {driver}: GPU driver\n 4. {temperature}: GPU temperature\n 5. {core-count}: GPU core count\n 6. {type}: GPU type\n 7. {dedicated-total}: GPU total dedicated memory\n 8. {dedicated-used}: GPU used dedicated memory\n 9. {shared-total}: GPU total shared memory\n 10. {shared-used}: GPU used shared memory\n 11. {platform-api}: The platform API used when detecting the GPU\n 12. {frequency}: Current frequency in GHz\n 13. {index}: GPU vendor specific index\n 14. {dedicated-percentage-num}: Dedicated memory usage percentage num\n 15. {dedicated-percentage-bar}: Dedicated memory usage percentage bar\n 16. {shared-percentage-num}: Shared memory usage percentage num\n 17. {shared-percentage-bar}: Shared memory usage percentage bar\n 18. {core-usage-num}: Core usage percentage num\n 19. {core-usage-bar}: Core usage percentage bar\n 20. {memory-type}: Memory type (Windows only)\n 21. {pcie-max-speed}: PCIe maximum speed in gen and lanes\n 22. {pcie-curr-speed}: PCIe current speed in gen and lanes",
"type": "string"
},
"hostFormat": {
@@ -386,7 +393,7 @@
"type": "string"
},
"kernelFormat": {
"description": "Output format for the `Kernel` module. See Wiki for formatting syntax\n 1. {sysname}: Sysname\n 2. {release}: Release\n 3. {version}: Version\n 4. {arch}: Architecture\n 5. {display-version}: Display version\n 6. {page-size}: Page size",
"description": "Output format for the `Kernel` module. See Wiki for formatting syntax\n 1. {sysname}: Sysname\n 2. {release}: Release\n 3. {version}: Version\n 4. {arch}: Architecture\n 5. {page-size}: Page size",
"type": "string"
},
"keyboardFormat": {
@@ -394,7 +401,7 @@
"type": "string"
},
"lmFormat": {
"description": "Output format for the `LM` module. See Wiki for formatting syntax\n 1. {service}: LM service\n 2. {type}: LM type\n 3. {version}: LM version",
"description": "Output format for the `LM` module. See Wiki for formatting syntax\n 1. {service}: LM service / process name\n 2. {pretty-name}: LM pretty name\n 3. {version}: LM version",
"type": "string"
},
"loadavgFormat": {
@@ -406,7 +413,7 @@
"type": "string"
},
"localipFormat": {
"description": "Output format for the `LocalIp` module. See Wiki for formatting syntax\n 1. {ipv4}: IPv4 address\n 2. {ipv6}: IPv6 address\n 3. {mac}: MAC address\n 4. {ifname}: Interface name\n 5. {is-default-route}: Is default route\n 6. {mtu}: MTU size in bytes\n 7. {speed}: Link speed (formatted)\n 8. {flags}: Interface flags",
"description": "Output format for the `LocalIp` module. See Wiki for formatting syntax\n 1. {ipv4}: IPv4 address\n 2. {ipv6}: IPv6 address\n 3. {mac}: MAC address *\n 4. {ifname}: Interface name *\n 5. {is-default-route}: Is default route\n 6. {mtu}: MTU size in bytes\n 7. {speed}: Link speed (formatted)\n 8. {flags}: Interface flags",
"type": "string"
},
"mediaFormat": {
@@ -418,7 +425,7 @@
"type": "string"
},
"monitorFormat": {
"description": "Output format for the `Monitor` module. See Wiki for formatting syntax\n 1. {name}: Display name\n 2. {width}: Native resolution width in pixels\n 3. {height}: Native resolution height in pixels\n 4. {physical-width}: Physical width in millimeters\n 5. {physical-height}: Physical height in millimeters\n 6. {inch}: Physical diagonal length in inches\n 7. {ppi}: Pixels per inch (PPI)\n 8. {manufacture-year}: Year of manufacturing\n 9. {manufacture-week}: Nth week of manufacturing in the year\n 10. {serial}: Serial number\n 11. {refresh-rate}: Maximum refresh rate in Hz\n 12. {hdr-compatible}: True if the display is HDR compatible",
"description": "Output format for the `Monitor` module. See Wiki for formatting syntax\n 1. {name}: Display name *\n 2. {width}: Native resolution width in pixels\n 3. {height}: Native resolution height in pixels\n 4. {physical-width}: Physical width in millimeters\n 5. {physical-height}: Physical height in millimeters\n 6. {inch}: Physical diagonal length in inches\n 7. {ppi}: Pixels per inch (PPI)\n 8. {manufacture-year}: Year of manufacturing\n 9. {manufacture-week}: Nth week of manufacturing in the year\n 10. {serial}: Serial number\n 11. {refresh-rate}: Maximum refresh rate in Hz\n 12. {hdr-compatible}: True if the display is HDR compatible",
"type": "string"
},
"mouseFormat": {
@@ -426,7 +433,7 @@
"type": "string"
},
"netioFormat": {
"description": "Output format for the `NetIO` module. See Wiki for formatting syntax\n 1. {rx-size}: Size of data received [per second] (formatted)\n 2. {tx-size}: Size of data sent [per second] (formatted)\n 3. {ifname}: Interface name\n 4. {is-default-route}: Is default route\n 5. {rx-bytes}: Size of data received [per second] (in bytes)\n 6. {tx-bytes}: Size of data sent [per second] (in bytes)\n 7. {rx-packets}: Number of packets received [per second]\n 8. {tx-packets}: Number of packets sent [per second]\n 9. {rx-errors}: Number of errors received [per second]\n 10. {tx-errors}: Number of errors sent [per second]\n 11. {rx-drops}: Number of packets dropped when receiving [per second]\n 12. {tx-drops}: Number of packets dropped when sending [per second]",
"description": "Output format for the `NetIO` module. See Wiki for formatting syntax\n 1. {rx-size}: Size of data received [per second] (formatted)\n 2. {tx-size}: Size of data sent [per second] (formatted)\n 3. {ifname}: Interface name *\n 4. {is-default-route}: Is default route\n 5. {rx-bytes}: Size of data received [per second] (in bytes)\n 6. {tx-bytes}: Size of data sent [per second] (in bytes)\n 7. {rx-packets}: Number of packets received [per second]\n 8. {tx-packets}: Number of packets sent [per second]\n 9. {rx-errors}: Number of errors received [per second]\n 10. {tx-errors}: Number of errors sent [per second]\n 11. {rx-drops}: Number of packets dropped when receiving [per second]\n 12. {tx-drops}: Number of packets dropped when sending [per second]",
"type": "string"
},
"openclFormat": {
@@ -438,15 +445,15 @@
"type": "string"
},
"osFormat": {
"description": "Output format for the `OS` module. See Wiki for formatting syntax\n 1. {sysname}: Name of the kernel\n 2. {name}: Name of the OS\n 3. {pretty-name}: Pretty name of the OS, if available\n 4. {id}: ID of the OS\n 5. {id-like}: ID like of the OS\n 6. {variant}: Variant of the OS\n 7. {variant-id}: Variant ID of the OS\n 8. {version}: Version of the OS\n 9. {version-id}: Version ID of the OS\n 10. {codename}: Version codename of the OS\n 11. {build-id}: Build ID of the OS\n 12. {arch}: Architecture of the OS",
"description": "Output format for the `OS` module. See Wiki for formatting syntax\n 1. {sysname}: Name of the kernel *\n 2. {name}: Name of the OS *\n 3. {pretty-name}: Pretty name of the OS, if available\n 4. {id}: ID of the OS\n 5. {id-like}: ID like of the OS\n 6. {variant}: Variant of the OS\n 7. {variant-id}: Variant ID of the OS\n 8. {version}: Version of the OS\n 9. {version-id}: Version ID of the OS\n 10. {codename}: Version codename of the OS\n 11. {build-id}: Build ID of the OS\n 12. {arch}: Architecture of the OS\n 13. {kernel-release}: Release of the kernel",
"type": "string"
},
"packagesFormat": {
"description": "Output format for the `Packages` module. See Wiki for formatting syntax\n 1. {all}: Number of all packages\n 2. {am-system}: Number of am-system packages\n 3. {am-user}: Number of am-user (aka appman) packages\n 4. {appimage}: Number of appimage packages\n 5. {apk}: Number of apk packages\n 6. {brew}: Number of brew packages\n 7. {brew-all}: Total number of all brew packages\n 8. {brew-cask}: Number of brew-cask packages\n 9. {cards}: Number of cards packages\n 10. {choco}: Number of choco packages\n 11. {dpkg}: Number of dpkg packages\n 12. {emerge}: Number of emerge packages\n 13. {eopkg}: Number of eopkg packages\n 14. {flatpak-all}: Total number of all flatpak app packages\n 15. {flatpak-system}: Number of flatpak-system app packages\n 16. {flatpak-user}: Number of flatpak-user app packages\n 17. {guix-all}: Total number of all guix packages\n 18. {guix-home}: Number of guix-home packages\n 19. {guix-system}: Number of guix-system packages\n 20. {guix-user}: Number of guix-user packages\n 21. {hpkg-all}: Total number of all hpkg packages\n 22. {hpkg-system}: Number of hpkg-system packages\n 23. {hpkg-user}: Number of hpkg-user packages\n 24. {kiss}: Number of kiss packages\n 25. {linglong}: Number of linglong packages\n 26. {lpkg}: Number of lpkg packages\n 27. {lpkgbuild}: Number of lpkgbuild packages\n 28. {macports}: Number of macports packages\n 29. {mport}: Number of mport packages\n 30. {moss}: Number of moss packages\n 31. {nix-all}: Total number of all nix packages\n 32. {nix-default}: Number of nix-default packages\n 33. {nix-system}: Number of nix-system packages\n 34. {nix-user}: Number of nix-user packages\n 35. {opkg}: Number of opkg packages\n 36. {pacman}: Number of pacman packages\n 37. {pacman-branch}: Pacman branch on manjaro\n 38. {pacstall}: Number of pacstall packages\n 39. {paludis}: Number of paludis packages\n 40. {pisi}: Number of pisi packages\n 41. {pkg}: Number of pkg packages\n 42. {pkgsrc}: Number of pkgsrc packages\n 43. {pkgtool}: Number of pkgtool packages\n 44. {rpm}: Number of rpm packages\n 45. {scoop-global}: Number of scoop-global packages\n 46. {scoop-user}: Number of scoop-user packages\n 47. {snap}: Number of snap packages\n 48. {soar}: Number of soar packages\n 49. {sorcery}: Number of sorcery packages\n 50. {winget}: Number of winget packages\n 51. {xbps}: Number of xbps packages",
"description": "Output format for the `Packages` module. See Wiki for formatting syntax\n 1. {am-system}: Number of am-system packages\n 2. {am-user}: Number of am-user (aka appman) packages\n 3. {appimage}: Number of appimage packages\n 4. {apk}: Number of apk packages\n 5. {brew}: Number of brew packages\n 6. {brew-cask}: Number of brew-cask packages\n 7. {cards}: Number of cards packages\n 8. {choco}: Number of choco packages\n 9. {crux}: Number of crux packages\n 10. {dpkg}: Number of dpkg packages\n 11. {emerge}: Number of emerge packages\n 12. {eopkg}: Number of eopkg packages\n 13. {flatpak-system}: Number of flatpak-system app packages\n 14. {flatpak-user}: Number of flatpak-user app packages\n 15. {guix-home}: Number of guix-home packages\n 16. {guix-system}: Number of guix-system packages\n 17. {guix-user}: Number of guix-user packages\n 18. {hpkg-system}: Number of hpkg-system packages\n 19. {hpkg-user}: Number of hpkg-user packages\n 20. {install-release}: Number of install-release packages\n 21. {kiss}: Number of kiss packages\n 22. {linglong}: Number of linglong packages\n 23. {lpkg}: Number of lpkg packages\n 24. {lpkgbuild}: Number of lpkgbuild packages\n 25. {macports}: Number of macports packages\n 26. {mport}: Number of mport packages\n 27. {moss}: Number of moss packages\n 28. {nix-default}: Number of nix-default packages\n 29. {nix-system}: Number of nix-system packages\n 30. {nix-user}: Number of nix-user packages\n 31. {opkg}: Number of opkg packages\n 32. {pacman}: Number of pacman packages\n 33. {pacman-branch}: Pacman branch on manjaro\n 34. {pacstall}: Number of pacstall packages\n 35. {paludis}: Number of paludis packages\n 36. {pisi}: Number of pisi packages\n 37. {pkg}: Number of pkg packages\n 38. {pkgsrc}: Number of pkgsrc packages\n 39. {pkgtool}: Number of pkgtool packages\n 40. {porg}: Number of porg packages\n 41. {rpm}: Number of rpm packages\n 42. {rum}: Number of rum overlay packages\n 43. {scoop-global}: Number of scoop-global packages\n 44. {scoop-user}: Number of scoop-user packages\n 45. {snap}: Number of snap packages\n 46. {soar}: Number of soar packages\n 47. {sorcery}: Number of sorcery packages\n 48. {winget}: Number of winget packages\n 49. {xbps}: Number of xbps packages\n 50. {brew-all}: Total number of all brew packages\n 51. {flatpak-all}: Total number of all flatpak app packages\n 52. {guix-all}: Total number of all guix packages\n 53. {hpkg-all}: Total number of all hpkg packages\n 54. {nix-all}: Total number of all nix packages\n 55. {all}: Number of all packages",
"type": "string"
},
"physicaldiskFormat": {
"description": "Output format for the `PhysicalDisk` module. See Wiki for formatting syntax\n 1. {size}: Device size (formatted)\n 2. {name}: Device name\n 3. {interconnect}: Device interconnect type\n 4. {dev-path}: Device raw file path\n 5. {serial}: Serial number\n 6. {physical-type}: Device kind (SSD or HDD)\n 7. {removable-type}: Device kind (Removable or Fixed)\n 8. {readonly-type}: Device kind (Read-only or Read-write)\n 9. {revision}: Product revision\n 10. {temperature}: Device temperature (formatted)",
"description": "Output format for the `PhysicalDisk` module. See Wiki for formatting syntax\n 1. {size}: Device size (formatted)\n 2. {name}: Device name *\n 3. {interconnect}: Device interconnect type\n 4. {dev-path}: Device raw file path *\n 5. {serial}: Serial number\n 6. {physical-type}: Device kind (SSD or HDD)\n 7. {removable-type}: Device kind (Removable or Fixed)\n 8. {readonly-type}: Device kind (Read-only or Read-write)\n 9. {revision}: Product revision\n 10. {temperature}: Device temperature (formatted)",
"type": "string"
},
"physicalmemoryFormat": {
@@ -458,11 +465,11 @@
"type": "string"
},
"poweradapterFormat": {
"description": "Output format for the `PowerAdapter` module. See Wiki for formatting syntax\n 1. {watts}: Power adapter watts\n 2. {name}: Power adapter name\n 3. {manufacturer}: Power adapter manufacturer\n 4. {model}: Power adapter model\n 5. {description}: Power adapter description\n 6. {serial}: Power adapter serial number",
"description": "Output format for the `PowerAdapter` module. See Wiki for formatting syntax\n 1. {watts}: Power adapter watts\n 2. {name}: Power adapter name\n 3. {manufacturer}: Power adapter manufacturer\n 4. {model-name}: Power adapter model name\n 5. {description}: Power adapter description\n 6. {serial}: Power adapter serial number",
"type": "string"
},
"processesFormat": {
"description": "Output format for the `Processes` module. See Wiki for formatting syntax\n 1. {result}: Process count",
"description": "Output format for the `Processes` module. See Wiki for formatting syntax\n 1. {result}: Process count\n 2. {threads}: Thread count",
"type": "string"
},
"publicipFormat": {
@@ -478,7 +485,7 @@
"type": "string"
},
"swapFormat": {
"description": "Output format for the `Swap` module. See Wiki for formatting syntax\n 1. {used}: Used size\n 2. {total}: Total size\n 3. {percentage}: Percentage used (num)\n 4. {percentage-bar}: Percentage used (bar)\n 5. {name}: Name",
"description": "Output format for the `Swap` module. See Wiki for formatting syntax\n 1. {used}: Used size\n 2. {total}: Total size\n 3. {percentage}: Percentage used (num)\n 4. {percentage-bar}: Percentage used (bar)\n 5. {name}: Name *",
"type": "string"
},
"terminalFormat": {
@@ -501,6 +508,10 @@
"description": "Output format for the `Title` module. See Wiki for formatting syntax\n 1. {user-name}: User name\n 2. {host-name}: Host name\n 3. {home-dir}: Home directory\n 4. {exe-path}: Executable path of current process\n 5. {user-shell}: User's default shell\n 6. {user-name-colored}: User name (colored)\n 7. {at-symbol-colored}: @ symbol (colored)\n 8. {host-name-colored}: Host name (colored)\n 9. {full-user-name}: Full user name\n 10. {user-id}: UID (*nix) / SID (Windows)\n 11. {pid}: PID of current process\n 12. {cwd}: CWD with home dir replaced by `~`",
"type": "string"
},
"topFormat": {
"description": "Output format for the `Top` module. See Wiki for formatting syntax\n 1. {name}: Process name\n 2. {pid}: Process ID\n 3. {cpu}: CPU usage\n 4. {mem}: Memory usage (RSS) in bytes\n 5. {disk-read}: Disk read bytes per second (0 if unsupported)\n 6. {disk-write}: Disk write bytes per second (0 if unsupported)\n 7. {threads}: Number of threads\n 8. {cpu-percentage}: CPU usage percentage\n 9. {mem-formatted}: Memory usage (RSS) formatted\n 10. {disk-read-formatted}: Disk read formatted\n 11. {disk-write-formatted}: Disk write formatted",
"type": "string"
},
"themeFormat": {
"description": "Output format for the `Theme` module. See Wiki for formatting syntax\n 1. {theme1}: Theme part 1\n 2. {theme2}: Theme part 2",
"type": "string"
@@ -538,7 +549,7 @@
"type": "string"
},
"wifiFormat": {
"description": "Output format for the `Wifi` module. See Wiki for formatting syntax\n 1. {inf-desc}: Interface description\n 2. {inf-status}: Interface status\n 3. {status}: Connection status\n 4. {ssid}: Connection SSID\n 5. {bssid}: Connection BSSID\n 6. {protocol}: Connection protocol\n 7. {signal-quality}: Connection signal quality (percentage num)\n 8. {rx-rate}: Connection RX rate\n 9. {tx-rate}: Connection TX rate\n 10. {security}: Connection Security algorithm\n 11. {signal-quality-bar}: Connection signal quality (percentage bar)\n 12. {channel}: Connection channel number\n 13. {band}: Connection channel band in GHz",
"description": "Output format for the `Wifi` module. See Wiki for formatting syntax\n 1. {inf-desc}: Interface description\n 2. {inf-status}: Interface status\n 3. {status}: Connection status\n 4. {ssid}: Connection SSID\n 5. {bssid}: Connection BSSID\n 6. {protocol}: Connection protocol\n 7. {signal-quality}: Connection signal quality (percentage num)\n 8. {rx-rate}: Connection RX rate\n 9. {tx-rate}: Connection TX rate\n 10. {security}: Connection Security algorithm\n 11. {signal-quality-bar}: Connection signal quality (percentage bar)\n 12. {channel}: Connection channel number\n 13. {channel-width}: Connection channel width in MHz\n 14. {band}: Connection channel band in GHz",
"type": "string"
},
"wmthemeFormat": {
@@ -546,7 +557,7 @@
"type": "string"
},
"zpoolFormat": {
"description": "Output format for the `Zpool` module. See Wiki for formatting syntax\n 1. {name}: Zpool name\n 2. {guid}: Zpool guid\n 3. {state}: Zpool state\n 4. {size-used}: Size used\n 5. {size-allocated}: Size allocated\n 6. {size-total}: Size total\n 7. {used-percentage}: Size used percentage num\n 8. {allocated-percentage}: Size allocated percentage num\n 9. {frag-percentage}: Fragmentation percentage num\n 10. {used-percentage-bar}: Size used percentage bar\n 11. {allocated-percentage-bar}: Size allocated percentage bar\n 12. {frag-percentage-bar}: Fragmentation percentage bar\n 13. {is-readonly}: Is read-only",
"description": "Output format for the `Zpool` module. See Wiki for formatting syntax\n 1. {name}: Zpool name *\n 2. {guid}: Zpool guid *\n 3. {state}: Zpool state\n 4. {size-used}: Size used\n 5. {size-allocated}: Size allocated\n 6. {size-total}: Size total\n 7. {used-percentage}: Size used percentage num\n 8. {allocated-percentage}: Size allocated percentage num\n 9. {frag-percentage}: Fragmentation percentage num\n 10. {used-percentage-bar}: Size used percentage bar\n 11. {allocated-percentage-bar}: Size allocated percentage bar\n 12. {frag-percentage-bar}: Fragmentation percentage bar\n 13. {is-readonly}: Is read-only",
"type": "string"
}
},
@@ -731,6 +742,11 @@
"description": "Top padding of the logo",
"minimum": 0
},
"bottom": {
"type": "integer",
"description": "Bottom padding of the logo; only supported when position is `top`",
"minimum": 0
},
"left": {
"type": "integer",
"description": "Left padding of the logo",
@@ -753,21 +769,36 @@
"description": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol only",
"default": false
},
"recache": {
"type": "boolean",
"description": "If true, regenerate image logo cache",
"default": false
"cache": {
"description": "How the image logo cache is used. true reuses a cached rendering when it is valid and writes it back on a cache miss; false ignores the cache completely, neither reading nor writing it; \"regen\" ignores any existing cached rendering and regenerates it",
"oneOf": [
{
"type": "boolean",
"description": "Whether to use the image logo cache"
},
{
"const": "regen",
"description": "Regenerate the image logo cache, ignoring any existing cached rendering"
}
],
"default": true
},
"position": {
"type": "string",
"description": "Position of the logo",
"description": "Position of the logo. Auto places a left-side logo above the output when the terminal is too narrow to reserve 32 columns for module output.",
"enum": [
"auto",
"left",
"top",
"right"
],
"default": "left"
},
"animationFrame": {
"type": "integer",
"description": "Frame of an animated image to render:\n0 plays the animation (kitty image protocol only), a positive value is the 1-based frame number, and a negative value counts back from the end, so -1 is the last frame.\nOnly the JSON config can express a negative value, as the command line parser reads a leading `-` as another option",
"default": 1
},
"chafa": {
"type": "object",
"additionalProperties": false,
@@ -903,15 +934,21 @@
"description": "Set the timeout (ms) when waiting for child processes, `-1` for no timeout",
"default": 5000
},
"preRun": {
"type": "string",
"description": "Command to run before printing logos",
"default": ""
},
"detectVersion": {
"type": "boolean",
"description": "Whether to detect and display component versions. Mainly for benchmarking",
"default": true
},
"preload": {
"description": "Scripts to run while the config is read, before any module runs",
"type": "object",
"additionalProperties": false,
"properties": {
"lua": {
"type": "string",
"description": "Lua script to run once, as soon as the config is read, for example `dofile('/path/to/helpers.lua')`"
}
}
}
}
},
@@ -1053,6 +1090,121 @@
"description": "Left padding for keys",
"minimum": 0,
"default": 0
},
"language": {
"description": "Language used for module keys. `null` for auto detection based on system locale",
"oneOf": [
{
"type": "null",
"description": "Auto detection based on system locale"
},
{
"type": "string",
"const": "en",
"description": "English"
},
{
"type": "string",
"const": "ar",
"description": "Arabic"
},
{
"type": "string",
"const": "cs",
"description": "Czech"
},
{
"type": "string",
"const": "de",
"description": "German"
},
{
"type": "string",
"const": "es",
"description": "Spanish"
},
{
"type": "string",
"const": "fi",
"description": "Finnish"
},
{
"type": "string",
"const": "fr",
"description": "French"
},
{
"type": "string",
"const": "gl",
"description": "Galician"
},
{
"type": "string",
"const": "he",
"description": "Hebrew"
},
{
"type": "string",
"const": "id",
"description": "Indonesian"
},
{
"type": "string",
"const": "it",
"description": "Italian"
},
{
"type": "string",
"const": "ja",
"description": "Japanese"
},
{
"type": "string",
"const": "ko",
"description": "Korean"
},
{
"type": "string",
"const": "pl",
"description": "Polish"
},
{
"type": "string",
"const": "pt",
"description": "Portuguese"
},
{
"type": "string",
"const": "ru",
"description": "Russian"
},
{
"type": "string",
"const": "tr",
"description": "Turkish"
},
{
"type": "string",
"const": "uk",
"description": "Ukrainian"
},
{
"type": "string",
"const": "vi",
"description": "Vietnamese"
},
{
"type": "string",
"const": "zh_CN",
"description": "Simplified Chinese"
},
{
"type": "string",
"const": "zh_TW",
"description": "Traditional Chinese"
}
],
"default": "en"
}
}
},
@@ -1440,9 +1592,11 @@
"cpu",
"cpucache",
"cpuusage",
"codec",
"command",
"colors",
"cursor",
"custom",
"datetime",
"display",
"disk",
@@ -1462,6 +1616,7 @@
"loadavg",
"locale",
"localip",
"logo",
"media",
"memory",
"monitor",
@@ -1477,6 +1632,7 @@
"poweradapter",
"processes",
"publicip",
"top",
"separator",
"shell",
"sound",
@@ -1610,6 +1766,24 @@
"type": "boolean",
"default": false
},
"showType": {
"description": "Which Bluetooth stacks to look for",
"oneOf": [
{
"const": "classic",
"description": "Look for BR/EDR devices only"
},
{
"const": "le",
"description": "Look for Bluetooth Low Energy devices only"
},
{
"const": "both",
"description": "Look for devices on either stack"
}
],
"default": "both"
},
"percent": {
"$ref": "#/$defs/percent"
},
@@ -1745,10 +1919,18 @@
"$ref": "#/$defs/percent"
},
"ddcciSleep": {
"type": "integer",
"description": "Sleep time in milliseconds between DDC/CI requests\nSee <https://www.ddcutil.com/performance_options/#option-sleep-multiplier> for details",
"minimum": 0,
"maximum": 400,
"description": "Sleep time in milliseconds between DDC/CI requests\nSet to null to skip DDC/CI detection",
"oneOf": [
{
"type": "null",
"description": "Skip DDC/CI detection"
},
{
"type": "integer",
"minimum": 0,
"maximum": 400
}
],
"default": 10
},
"compact": {
@@ -1878,6 +2060,67 @@
}
}
},
{
"title": "Codec",
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"const": "codec",
"description": "Print hardware video acceleration codec types (decode / encode)"
},
"splitGPU": {
"description": "Whether to print each GPU separately. If false, merge codecs from all GPUs",
"type": "boolean",
"default": false
},
"useVulkan": {
"description": "Whether to use Vulkan for codec detection instead of other platform-specific APIs",
"type": "boolean",
"default": false
},
"showType": {
"description": "Which types of codecs to detect and show",
"type": "string",
"oneOf": [
{
"const": "both",
"description": "Show both decoders and encoders"
},
{
"const": "decoder",
"description": "Show only decoders"
},
{
"const": "encoder",
"description": "Show only encoders"
}
],
"default": "both"
},
"key": {
"$ref": "#/$defs/key"
},
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"keyIcon": {
"$ref": "#/$defs/keyIcon"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"format": {
"$ref": "#/$defs/codecFormat"
},
"condition": {
"$ref": "#/$defs/conditions"
}
}
},
{
"title": "CPU",
"type": "object",
@@ -1897,7 +2140,7 @@
"showPeCoreCount": {
"description": "Whether to detect and display CPU frequencies for different core types (for example, P-cores and E-cores), if supported",
"type": "boolean",
"default": false
"default": true
},
"key": {
"$ref": "#/$defs/key"
@@ -1931,8 +2174,10 @@
"const": "cpucache",
"description": "Print CPU cache sizes"
},
"percent": {
"$ref": "#/$defs/percent"
"compact": {
"type": "boolean",
"description": "Print one line with a total per cache level instead of one line per level",
"default": false
},
"key": {
"$ref": "#/$defs/key"
@@ -2051,6 +2296,7 @@
"description": "Set the number of white spaces to print before the symbol",
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"block": {
@@ -2062,6 +2308,7 @@
"description": "Set the block width in spaces",
"type": "integer",
"minimum": 1,
"maximum": 9,
"default": 3
},
"range": {
@@ -2119,7 +2366,7 @@
"additionalProperties": false,
"properties": {
"type": {
"description": "Run a custom shell command",
"description": "Run custom shell scripts",
"const": "command"
},
"shell": {
@@ -2134,10 +2381,24 @@
"description": "Command text to execute",
"type": "string"
},
"useStdErr": {
"description": "Whether to use stderr instead of stdout for command output",
"type": "boolean",
"default": false
"useOutput": {
"description": "Which of the command's output streams to capture\nThe stream that is not captured is discarded",
"type": "string",
"oneOf": [
{
"const": "stdout",
"description": "Capture stdout only and discard stderr"
},
{
"const": "stderr",
"description": "Capture stderr only and discard stdout"
},
{
"const": "both",
"description": "Capture both stdout and stderr"
}
],
"default": "both"
},
"parallel": {
"description": "Whether to execute the command in parallel with other commands\nThis can improve performance when using multiple commands, but may cause issues with some commands",
@@ -2181,9 +2442,6 @@
"const": "cursor",
"description": "Print cursor style name"
},
"percent": {
"$ref": "#/$defs/percent"
},
"key": {
"$ref": "#/$defs/key"
},
@@ -2217,8 +2475,7 @@
"const": "custom"
},
"key": {
"description": "Leave empty to hide the key",
"type": "string"
"$ref": "#/$defs/key"
},
"keyColor": {
"$ref": "#/$defs/keyColor"
@@ -2250,9 +2507,6 @@
"const": "datetime",
"description": "Print the current date and time"
},
"percent": {
"$ref": "#/$defs/percent"
},
"key": {
"$ref": "#/$defs/key"
},
@@ -2462,7 +2716,7 @@
},
"useAvailable": {
"type": "boolean",
"description": "Use f_bavail (lpFreeBytesAvailableToCaller for Windows) instead of f_bfree to calculate used bytes\nMay be required for macOS to display correct results",
"description": "Use f_bavail instead of f_bfree to calculate used bytes\nMay be required for macOS to display correct results\nOn Windows, set to true to make fastfetch honors the quota settings",
"default": false
},
"percent": {
@@ -2511,8 +2765,8 @@
},
"waitTime": {
"type": "integer",
"description": "Wait time (in ms). Disk I/O = (totalBytesEnd - totalBytesStart) / waitTime",
"default": 200,
"description": "Wait time (in ms) used to measure the I/O rate (calculated in bytes/sec).\nAvoid setting this too low, as the kernel requires time to accurately update counters.\nIgnored if 'detectTotal' is true.",
"default": 250,
"minimum": 1
},
"key": {
@@ -2629,9 +2883,6 @@
"const": "editor",
"description": "Print information about the default editor (`$VISUAL` or `$EDITOR`)"
},
"percent": {
"$ref": "#/$defs/percent"
},
"key": {
"$ref": "#/$defs/key"
},
@@ -2664,9 +2915,6 @@
"const": "font",
"description": "Print system font names"
},
"percent": {
"$ref": "#/$defs/percent"
},
"key": {
"$ref": "#/$defs/key"
},
@@ -2771,6 +3019,10 @@
"const": "opencl",
"description": "Use OpenCL API.\nSlow and requires proper OpenCL drivers to be installed"
},
{
"const": "egl-ext",
"description": "Use EGL_EXT_device_enumeration and EGL_EXT_device_query APIs.\nSlow and only detects GPUs that support these extensions"
},
{
"const": "opengl",
"description": "Use OpenGL API.\nSlow and only detects one GPU.\nUsed for OpenBSD"
@@ -3408,8 +3660,8 @@
},
"waitTime": {
"type": "integer",
"description": "Wait time (in ms). Net I/O = (totalBytesEnd - totalBytesStart) / waitTime",
"default": 200,
"description": "Wait time (in ms) used to measure the I/O rate (calculated in bytes/sec).\nAvoid setting this too low, as the kernel requires time to accurately update counters.\nIgnored if 'detectTotal' is true.",
"default": 250,
"minimum": 1
},
"key": {
@@ -3568,18 +3820,24 @@
"enum": [
"am",
"apk",
"appimage",
"brew",
"cards",
"choco",
"crux",
"dpkg",
"emerge",
"eopkg",
"flatpak",
"guix",
"hpkg",
"installrelease",
"kiss",
"linglong",
"lpkg",
"lpkgbuild",
"macports",
"moss",
"mport",
"nix",
"opkg",
@@ -3588,10 +3846,14 @@
"paludis",
"pisi",
"pkg",
"pkgsrc",
"pkgtool",
"porg",
"rpm",
"rum",
"scoop",
"snap",
"soar",
"sorcery",
"winget",
"xbps"
@@ -3603,8 +3865,7 @@
"description": "Enable all package managers",
"type": "null"
}
],
"default": ["winget"]
]
},
"combined": {
"description": "Whether to combine related package managers into single counts (e.g., nix-system + nix-user = nix)",
@@ -3791,7 +4052,12 @@
"properties": {
"type": {
"const": "processes",
"description": "Print the number of running processes"
"description": "Print the number of running processes and threads"
},
"countKprocs": {
"description": "Whether to take kernel processes and threads into account",
"type": "boolean",
"default": false
},
"key": {
"$ref": "#/$defs/key"
@@ -3826,10 +4092,9 @@
"const": "publicip"
},
"url": {
"description": "URL of the public IP detection server to use. Only HTTP is supported",
"description": "URL of the public IP detection server to use. Only HTTP is supported\nIf empty, `http://ipinfo.io/json` is requested (`http://v6.ipinfo.io/json` when `ipv6` is set), with TCP Fast Open enabled. A non-empty URL disables both and makes `ipv6` have no effect",
"type": "string",
"format": "url",
"default": "http://ipinfo.io/ip"
"format": "url"
},
"timeout": {
"description": "Time in milliseconds to wait for the public IP server to respond\nSet to 0 to disable the timeout",
@@ -3887,6 +4152,7 @@
"description": "Number of times to repeat the separator string, or 0 to auto-detect",
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"condition": {
@@ -4236,6 +4502,103 @@
}
}
},
{
"title": "Top",
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"const": "top",
"description": "Print processes with the highest CPU, memory, disk I/O usage, latest start time or thread count"
},
"sort": {
"type": "string",
"description": "Sort processes by CPU, memory, disk IO usage, start time or thread count",
"enum": [
"cpu",
"memory",
"disk-read",
"disk-write",
"start-time",
"threads"
],
"default": "cpu"
},
"showTypes": {
"description": "Specify which resource usages are detected and displayed.\nIf memory or threads is enabled is enabled alone, only a single process snapshot is taken and `waitTime` sampling wait is skipped",
"default": [
"cpu",
"memory",
"disk"
],
"oneOf": [
{
"type": "string",
"enum": [
"cpu",
"memory",
"disk",
"threads"
]
},
{
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"enum": [
"cpu",
"memory",
"disk",
"threads"
]
}
}
]
},
"processes": {
"type": "integer",
"description": "Number of top processes to print",
"minimum": 1,
"default": 5
},
"waitTime": {
"type": "integer",
"description": "Wait time between process samples, in milliseconds. Ignored when showTypes contains \"memory\" only",
"minimum": 1,
"default": 250
},
"compact": {
"type": "boolean",
"description": "Print all process on a single line",
"default": false
},
"percent": {
"$ref": "#/$defs/percent"
},
"key": {
"$ref": "#/$defs/key"
},
"keyColor": {
"$ref": "#/$defs/keyColor"
},
"keyIcon": {
"$ref": "#/$defs/keyIcon"
},
"keyWidth": {
"$ref": "#/$defs/keyWidth"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
},
"format": {
"$ref": "#/$defs/topFormat"
},
"condition": {
"$ref": "#/$defs/conditions"
}
}
},
{
"title": "TPM",
"type": "object",
@@ -4494,6 +4857,9 @@
"const": "wifi",
"description": "Print connected Wi-Fi info (SSID, connection and security protocol)"
},
"percent": {
"$ref": "#/$defs/percent"
},
"key": {
"$ref": "#/$defs/key"
},
+10 -5
View File
@@ -50,6 +50,10 @@
"driverSpecific": true,
"temp": true
},
{
"type": "codec",
"splitGPU": true
},
"memory",
"physicalmemory",
{
@@ -95,17 +99,18 @@
"gamepad",
"mouse",
"keyboard",
{
"type": "weather",
"timeout": 1000
},
"tpm",
"netio",
"diskio",
{
"type": "physicaldisk",
"temp": true
},
"tpm",
{
"type": "weather",
"timeout": 1000
},
"top",
"version",
"break",
"colors"
+12 -7
View File
@@ -52,6 +52,10 @@
"driverSpecific": true,
"temp": true
},
{
"type": "codec",
"splitGPU": true
},
"memory",
"physicalmemory",
{
@@ -90,24 +94,25 @@
"opengl",
"opencl",
"users",
// "bluetooth", // doesn't work on macOS because it requires bluetooth permissions
// "bluetoothradio",
"bluetooth",
"bluetoothradio",
"sound",
"camera",
"gamepad",
"mouse",
"keyboard",
{
"type": "weather",
"timeout": 1000
},
"tpm",
"netio",
"diskio",
{
"type": "physicaldisk",
"temp": true
},
"tpm",
{
"type": "weather",
"timeout": 1000
},
"top",
"version",
"logo",
"break",
+13 -16
View File
@@ -1,6 +1,3 @@
// Load with --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": {
@@ -45,12 +42,12 @@
},
{
"type": "kernel",
"key": "│ ├",
"key": "│ ├{icon}",
"keyColor": "yellow"
},
{
"type": "packages",
"key": "│ ├󰏖",
"key": "│ ├{icon}",
"keyColor": "yellow"
},
{
@@ -65,22 +62,22 @@
},
{
"type": "lm",
"key": "│ ├󰧨",
"key": "│ ├{icon}",
"keyColor": "blue"
},
{
"type": "wmtheme",
"key": "│ ├󰉼",
"key": "│ ├{icon}",
"keyColor": "blue"
},
{
"type": "icons",
"key": "│ ├󰀻",
"key": "│ ├{icon}",
"keyColor": "blue"
},
{
"type": "terminal",
"key": "│ ├",
"key": "│ ├{icon}",
"keyColor": "blue"
},
{
@@ -95,32 +92,32 @@
},
{
"type": "cpu",
"key": "│ ├󰻠",
"key": "│ ├{icon}",
"keyColor": "green"
},
{
"type": "gpu",
"key": "│ ├󰍛",
"key": "│ ├{icon}",
"keyColor": "green"
},
{
"type": "disk",
"key": "│ ├",
"key": "│ ├{icon}",
"keyColor": "green"
},
{
"type": "memory",
"key": "│ ├󰑭",
"key": "│ ├{icon}",
"keyColor": "green"
},
{
"type": "swap",
"key": "│ ├󰓡",
"key": "│ ├{icon}",
"keyColor": "green"
},
{
"type": "uptime",
"key": "│ ├󰅐",
"key": "│ ├{icon}",
"keyColor": "green"
},
{
@@ -135,7 +132,7 @@
},
{
"type": "player",
"key": "│ ├󰥠",
"key": "│ ├{icon}",
"keyColor": "cyan"
},
{
+1 -1
View File
@@ -1,4 +1,4 @@
// Inspired by Catnap
// Inspired by Catnap (https://github.com/iinsertNameHere/catnap)
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
+2 -2
View File
@@ -1,4 +1,4 @@
// Inspired by Catnap
// Inspired by Catnap (https://github.com/iinsertNameHere/catnap)
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
@@ -12,7 +12,7 @@
},
"modules": [
{
// draw borders first to make colors of left and right border consistant
// draw borders first to make colors of left and right border consistent
"key": " user",
"type": "title",
"format": "{user-name}",
+1 -1
View File
@@ -1,4 +1,4 @@
// Inspired by Catnap
// Inspired by Catnap (https://github.com/iinsertNameHere/catnap)
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
+1 -1
View File
@@ -1,4 +1,4 @@
// Inspired by Catnap
// Inspired by Catnap (https://github.com/iinsertNameHere/catnap)
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
+9 -2
View File
@@ -90,7 +90,7 @@
{
"type": "disk",
"key": "║{#cyan}│ {icon} Disk │{$4}│{#keys}║{$2}",
"format": "{size-used} \/ {size-total} ({size-percentage}) - {filesystem}",
"format": "{mountpoint} {size-used} \/ {size-total} ({size-percentage}) - {filesystem}",
},
{
"type": "battery",
@@ -195,7 +195,7 @@
"keyIcon": "",
"key": "║{#red}│ {icon} Clang │{$4}│{#keys}║{$2}",
"text": "clang --version | findstr version", // Finds the line with "version"
"format": "clang {~-6}" // Prints the last 6 characters (version number)
"format": "clang {~14,20}" // Prints 14~20 characters (version number)
},
{
"type": "command",
@@ -204,6 +204,13 @@
"text": "node --version",
"format": "node {~1}" // {~1} removes first character (v)
},
{
"type": "command",
"keyIcon": "",
"key": "║{#red}│ {icon} Python │{$4}│{#keys}║{$2}",
"text": "python --version",
"format": "python {~7}" // {~7} removes first 7 characters ("Python" with extra space)
},
{
"type": "command",
"keyIcon": "",
-3
View File
@@ -1,6 +1,3 @@
// Load with --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",
"display": {
-3
View File
@@ -1,6 +1,3 @@
// Load with --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": {
+19 -3
View File
@@ -16,6 +16,13 @@
"separator",
"os",
"host",
{
"type": "board",
"key": "Host",
"condition": {
"succeeded": false
}
},
{
"type": "kernel",
"format": "{release}"
@@ -31,8 +38,14 @@
"compactType": "original",
"key": "Resolution"
},
"de",
"wm",
{
"type": "de",
"key": "DE"
},
{
"type": "wm",
"key": "WM"
},
"wmtheme",
"theme",
"icons",
@@ -41,7 +54,10 @@
"type": "terminalfont",
"format": "{/name}{-}{/}{name}{?size} {size}{?}"
},
"cpu",
{
"type": "cpu",
"showPeCoreCount": false
},
{
"type": "gpu",
"key": "GPU",
+1 -1
View File
@@ -33,7 +33,7 @@ endBold = r"\fR" # end bold text tag
# path to the current directory
pathToCurrentDir = path.dirname(__file__)
# path to the JSON option file
pathToHelpFile = path.join(pathToCurrentDir, "../src/data/help.json")
pathToHelpFile = path.join(pathToCurrentDir, "../doc/help.json")
# man page section
manSection = 1
# title (center header)
+18
View File
@@ -0,0 +1,18 @@
Copyright (c) 2014-2016 Hayaki Saito
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+13
View File
@@ -0,0 +1,13 @@
src/quant.c is derived from ppmquant, originally by Jef Poskanzer.
Copyright (C) 1989, 1991 by Jef Poskanzer.
Copyright (C) 2001 by Bryan Henderson.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation. This software is provided "as is" without express or
implied warranty.
+49
View File
@@ -0,0 +1,49 @@
"sixel" license (original license)
==================================
src/tosixel.c and src/fromsixel.c are derived from "sixel" original version (2014-3-2)
Package: http://nanno.dip.jp/softlib/man/rlogin/sixel.tar.gz
Unofficial repo: https://github.com/saitoha/sixel
This work is written by kmiya@ culti. He distributes it under very permissive license.
The original license text(in Japanese) is:
```
このプログラム及びソースコードの使用について個人・商用を問わず
ご自由に使用していただいで結構です。
また、配布・転載・紹介もご連絡の必要もありません。
ソースの改変による配布も自由ですが、どのバージョンの改変かを
明記されることを希望します。
バージョン情報が無い場合は、配布物の年月日を明記されることを
希望します。
2014/10/05 kmiya
```
The unofficial translation:
```
Anyone is free to use this program for any purpose,
commercial or non-commercial, without any restriction.
Anyone is free to distribute, copy, publish, or
advertise this software, without any contact.
Anyone is free to distribute with modification of the
source code, but I "hope" that its based version or
date will be written clearly.
2014/10/05 kmiya
```
kmiya also said this is compatible with MIT/BSD/GPL.
+218
View File
@@ -0,0 +1,218 @@
# libsixel (encoder subset, vendored)
Encoder-only subset of [libsixel](https://github.com/saitoha/libsixel) `1.8.7-r2`,
used by `src/logo/image/` to render the `sixel` logo type **on Windows and macOS**.
## Why this is vendored
Neither MSYS2 nor vcpkg packages libsixel, so on Windows there is nothing to
`dlopen()` or to link against. The encoder is small and has no external
dependencies, so the necessary files are embedded instead. The intent is to upstream
a libsixel package to MSYS2 later and switch to it; until then this directory is the
source of truth.
macOS *does* have a package — Homebrew's `libsixel` is this very version, `1.8.7-r2`
(`brew info libsixel`) — but it is deliberately not used. It drags in `jpeg-turbo` /
`libpng` for the decoder side we never call, and linking it would mean a different
encoder on each platform. Since Windows needs an embedded copy regardless, one shared
copy is simpler than two.
## Why only Windows and macOS
Windows loses ImageMagick entirely — its image backend moves to WIC, which decodes
and scales but cannot *encode* sixel — so it needs an encoder of its own.
macOS does not get ImageMagick either: `ENABLE_IMAGEMAGICK6` / `ENABLE_IMAGEMAGICK7`
are gated on `LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR Haiku OR
GNU`, with no `APPLE`, and its image backend is ImageIO. So it shares the same
requirement.
On every other platform ImageMagick stays, and it already produces sixel through
its own SIXEL coder. Adding libsixel there would mean a second encoder for a
capability that already works: one more dependency for zero gain. So `ENABLE_SIXEL`
is gated on `WIN32 OR APPLE`, and these sources are **not compiled at all** on
Linux / the BSDs.
Consequence: sixel bytes differ between Windows / macOS (libsixel) and the rest
(ImageMagick). That is deliberate and accepted — see
`doc/windows-image-backend.md` decision 9.
## Transparency
The subset is used for its keycolor support. `sixel_dither_set_transparent()` marks a
palette index as the transparent one; `output_rgb_palette_definition()` then leaves that
entry out of the palette definition, and `sixel_encode_body()` never puts a keycolor
pixel into the node map, so nothing is drawn there and the terminal background shows
through. `src/logo/image/sixel.c` drives this for sources that contain fully transparent
pixels — it maps those pixels onto a dedicated index one past the quantized palette,
because keying a *content* colour would also drop every opaque pixel that shares it.
Two things have to line up for the background to actually be transparent: the caller has to
mark a keycolor, so the keyed pixels are never painted (above), **and** the encoder has to ask
for a transparent background, so the terminal leaves those unpainted pixels alone instead of
filling them. The second half is the DCS `P2` parameter — see
[Local modifications](#local-modifications) item 3.
Note what this is and is not: it is a **palette-index** keycolor, not alpha support. A
partially transparent pixel has to be drawn in its unblended colour, since a sixel has
no way to blend with whatever the terminal has behind it.
⚠️ Do not vendor a *newer* libsixel in the belief that this version cannot do
transparency. It can, and it was measured: the official `1.8.7-r2` omits the keycolor
entry and leaves the keyed pixels unpainted, with the remaining pixels correctly placed.
When a transparent background is not showing up, check the caller first — historically
the caller simply never called `sixel_dither_set_transparent()`, and an image logo only
renders correctly once it does. If the caller *is* setting a keycolor and the background is
still solid, check `P2` instead: the keyed pixels are being left unpainted correctly, but the
terminal is filling them.
## What was kept
Starting from `sixel_dither_new` / `sixel_dither_initialize` / `sixel_output_new` /
`sixel_encode` and following the dependency closure, only these files are reachable:
| File | Provides |
|---|---|
| `tosixel.c` | `sixel_encode`, `sixel_putc`, `sixel_node_*`, DCS envelope handling |
| `dither.c` / `dither.h` | `sixel_dither_new`, `sixel_dither_initialize`, `sixel_dither_unref` |
| `output.c` / `output.h` | `sixel_output_new`, `sixel_output_unref` |
| `quant.c` / `quant.h` | Median-cut palette construction |
| `pixelformat.c` | `sixel_helper_compute_depth`, `sixel_helper_normalize_pixelformat` |
| `allocator.c` / `allocator.h` | `sixel_allocator_*` |
| `status.c` / `status.h` | `sixel_helper_set_additional_message` |
| `malloc_stub.h` | Included by `allocator.c`; compiles to nothing when `HAVE_MALLOC` |
| `sixel.h` | Public API (upstream `include/sixel.h`) |
## What was removed
Everything else in the upstream tree, in particular:
- **Decoding**: `decoder.c`, `fromsixel.c`, `frompnm.c`, `fromgif.c`, `frame.c`,
`loader.c`, `stb_image.h`, `stb_image_write.*`. Image decoding is done by the
platform backend (WIC on Windows, ImageIO on macOS, ImageMagick elsewhere), so
libsixel only ever sees an RGBA8 buffer here.
- **The `sixel_encoder_*` / `sixel_decoder_*` high-level API**: `encoder.c`,
`writer.c`, `tty.c`, `scale.c`. These pull in file I/O, terminal probing and the
loader registry. We call the dither/output/encode trio directly.
- **`rgblookup.h` / `rgblookup.gperf`**: a gperf-generated color-name table used
only by `encoder.c` for `--builtin-palette` parsing.
- **`converters/`** (`img2sixel`, `sixel2png`), **`python/`**, **`tools/`**,
**`tests/`**, **`images/`** (216 test images), and the packaging templates
(`package.json.in.in`, `libsixel.pc.in`).
- **The autotools machinery**: `configure`, `Makefile.in`, `aclocal.m4`, `m4/`,
`ltmain.sh`, `config.h.in`, … See item 2 under
[Local modifications](#local-modifications).
- **Six of the nine `LICENSE.*` files**: `LICENSE.images` / `.mesa` / `.pngsuite` /
`.sdump` / `.stb` cover only material that was dropped (test images, the OpenGL
example, the `sdump` tool, stb). The three that remain are the complete set
required by the files above — verified against each file's own header, see
[License](#license).
Result: **20 files / 256 KB**, down from 319 files / 11.3 MB. Note that 8.0 MB of
that 11.3 MB was `images/` fixtures, so the meaningful comparison is code:
`src/` + `include/` went from 50 files / 1.17 MB to 20 files / 256 KB.
## Local modifications
Four deliberate divergences from upstream. Re-apply all four when re-syncing.
1. **`sixel.h` — `SIXELAPI` is empty.** Upstream defines it as
`__declspec(dllexport)` on Windows. This subset is compiled into `libfastfetch`
statically rather than into a standalone DLL, so the attribute would (a) add
every libsixel symbol to fastfetch's export table and (b) make `sixel.h`'s
declarations disagree with the ones in `dither.h` / `output.h` / `quant.h` /
`allocator.h`, which do not carry it (clang warns:
`-Wdll-attribute-on-redeclaration`).
2. **`config.h` is hand-written.** Upstream generates it with `configure`. Only
these vendored files read it, and they reference a small fixed set of macros,
so the values are hard-coded. Two things to watch:
- `HAVE_TESTS` must stay **undefined**, not `0`: `sixel.h` gates its test-only
declarations with `#ifdef HAVE_TESTS`, so `#define HAVE_TESTS 0` would still
pull in declarations for functions we do not compile.
- `HAVE_MEMORY_H` / `HAVE_STRING_H` must be `1`. fastfetch builds with
`-Werror=implicit-function-declaration`, so a missing `<memory.h>` /
`<string.h>` include in `pixelformat.c` / `status.c` is a hard error.
3. **`tosixel.c` — the DCS `P2` parameter is initialised to 1.** `sixel_encode_header()`
declares `int p[3] = {0, 0, 0}`, and the trailing-zero trimming right below it then drops
all three, so the envelope is a bare `ESC P q`. That means `P2 = 0`, which tells the
terminal to fill every unset pixel with **colour-table entry 0** — and that entry is
defined by the image's own palette, so a keycolor image comes out with a solid rectangle
behind it rather than transparency. Setting `p[1] = 1` leaves unset pixels untouched.
The trimming still drops the trailing aspect-ratio parameter, so the envelope is
`ESC P 0;1 q`. `P3` defaults to 0 and the two spellings are equivalent — verified by
decoding both with libsixel's own decoder and with ImageMagick's. ImageMagick's SIXEL
coder and chafa both write `0;1;0` explicitly.
This only shows up on a terminal that implements the VT340 background rule. Windows
Terminal does (`_backgroundFillRequired = (_conformanceLevel == 1 || !transparent)` in
`src/terminal/adapter/SixelParser.cpp`), which is where it was reproduced; WezTerm does
not fill, so the identical bytes look correct there. It is also why Linux never showed
the problem: that path goes through ImageMagick, which already sends `P2 = 1`.
4. **`output.c` — release the allocator reference if output allocation fails.**
`sixel_output_new()` creates an allocator or takes an additional reference before
allocating the output context. If that allocation fails, the reference is not owned by
an output object and must be released before returning `SIXEL_BAD_ALLOCATION`.
Fastfetch passes a null allocator, so without this cleanup the newly created allocator
becomes unreachable on this error path. The successful path and returned error code are
unchanged.
The vendored sources are also exempted from `-Wconversion` in `CMakeLists.txt`:
upstream has ~160 implicit int→`unsigned char` narrowing warnings. Everything else
(`-Wall -Wextra` and fastfetch's `-Werror=` set) applies unchanged, and the subset
compiles clean.
## Re-syncing with upstream
```sh
VER=1.8.7-r2
git clone --depth 1 --branch "$VER" https://github.com/saitoha/libsixel /tmp/libsixel
# 1. copy the closure (paths change from src/foo.c to foo.c, include/sixel.h to sixel.h)
for f in tosixel.c dither.c dither.h output.c output.h quant.c quant.h \
pixelformat.c allocator.c allocator.h status.c status.h malloc_stub.h; do
cp "/tmp/libsixel/src/$f" .
done
cp /tmp/libsixel/include/sixel.h .
cp /tmp/libsixel/LICENSE /tmp/libsixel/LICENSE.sixel /tmp/libsixel/LICENSE.pnmcolormap .
# 2. re-apply the four local modifications listed above
# 3. verify
```
Verification (must be 0 diagnostics, and the encoder must emit a DCS-wrapped stream).
Both platforms compile this subset, so run it on both:
```sh
# Windows: CC=/c/msys64/clang64/bin/cc.exe
# macOS: CC=cc (verified with Apple clang 21: 0 diagnostics)
CC=cc
FLAGS="-I. -Wall -Wextra -Wconversion -Wno-conversion -Werror=uninitialized \
-Werror=return-type -Werror=vla -Werror=incompatible-pointer-types \
-Werror=implicit-function-declaration -Werror=int-conversion -std=gnu23"
for f in tosixel dither output quant allocator pixelformat status; do
$CC $FLAGS -c $f.c -o /dev/null || echo "FAILED: $f"
done
```
If upstream adds a call from the closure to a new file, the build fails at link
time with an undefined `sixel_*` symbol — add that file and repeat.
## License
MIT-compatible, but three separate notices apply and all three files must be kept.
Mapping verified against each source file's own copyright header:
| File | Applies to |
|---|---|
| `LICENSE` | MIT, Copyright (c) 2014-2016 Hayaki Saito — `dither.c`, `output.c`, `pixelformat.c`, `allocator.c`, `status.c` (their headers say 2014-2018/2019; same MIT terms) |
| `LICENSE.sixel` | `tosixel.c` — derived from kmiya's original `sixel` (2014-3-2), permissive, re-licensed MIT by Hayaki Saito |
| `LICENSE.pnmcolormap` | `quant.c` — derived from `ppmquant` by Jef Poskanzer / Bryan Henderson |
Upstream also ships `LICENSE.images`, `.mesa`, `.pngsuite`, `.sdump` and `.stb`;
none of them cover a file in this subset, so they were not carried over. If a
re-sync ever pulls in a file from the decoder side (`fromgif.c` → `.stb`,
`fromsixel.c` → `.sixel`), re-check this table.
+379
View File
@@ -0,0 +1,379 @@
/*
* Copyright (c) 2014-2018 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
/* STDC_HEADERS */
#include <stdlib.h>
#if HAVE_ASSERT_H
# include <assert.h>
#endif /* HAVE_ASSERT_H */
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#if HAVE_ERRNO_H
# include <errno.h>
#endif /* HAVE_ERRNO_H */
#if HAVE_MEMORY_H
# include <memory.h>
#endif /* HAVE_MEMORY_H */
#include "allocator.h"
#include "malloc_stub.h"
/* create allocator object */
SIXELSTATUS
sixel_allocator_new(
sixel_allocator_t /* out */ **ppallocator, /* allocator object to be created */
sixel_malloc_t /* in */ fn_malloc, /* custom malloc() function */
sixel_calloc_t /* in */ fn_calloc, /* custom calloc() function */
sixel_realloc_t /* in */ fn_realloc, /* custom realloc() function */
sixel_free_t /* in */ fn_free) /* custom free() function */
{
SIXELSTATUS status = SIXEL_FALSE;
if (ppallocator == NULL) {
sixel_helper_set_additional_message(
"sixel_allocator_new: given argument ppallocator is null.");
status = SIXEL_BAD_ARGUMENT;
goto end;
}
if (fn_malloc == NULL) {
fn_malloc = malloc;
}
if (fn_calloc == NULL) {
fn_calloc = calloc;
}
if (fn_realloc == NULL) {
fn_realloc = realloc;
}
if (fn_free == NULL) {
fn_free = free;
}
*ppallocator = fn_malloc(sizeof(sixel_allocator_t));
if (*ppallocator == NULL) {
sixel_helper_set_additional_message(
"sixel_allocator_new: fn_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
(*ppallocator)->ref = 1;
(*ppallocator)->fn_malloc = fn_malloc;
(*ppallocator)->fn_calloc = fn_calloc;
(*ppallocator)->fn_realloc = fn_realloc;
(*ppallocator)->fn_free = fn_free;
status = SIXEL_OK;
end:
return status;
}
/* destruct allocator object */
static void
sixel_allocator_destroy(
sixel_allocator_t /* in */ *allocator) /* allocator object to
be destroyed */
{
/* precondition */
assert(allocator);
assert(allocator->fn_free);
allocator->fn_free(allocator);
}
/* increase reference count of allocatort object (thread-unsafe) */
SIXELAPI void
sixel_allocator_ref(
sixel_allocator_t /* in */ *allocator) /* allocator object to be
increment reference counter */
{
/* precondition */
assert(allocator);
/* TODO: be thread safe */
++allocator->ref;
}
/* decrease reference count of output context object (thread-unsafe) */
SIXELAPI void
sixel_allocator_unref(
sixel_allocator_t /* in */ *allocator) /* allocator object to be unreference */
{
/* TODO: be thread safe */
if (allocator) {
assert(allocator->ref > 0);
--allocator->ref;
if (allocator->ref == 0) {
sixel_allocator_destroy(allocator);
}
}
}
/* call custom malloc() */
SIXELAPI void *
sixel_allocator_malloc(
sixel_allocator_t /* in */ *allocator, /* allocator object */
size_t /* in */ n) /* allocation size */
{
/* precondition */
assert(allocator);
assert(allocator->fn_malloc);
if (n == 0) {
sixel_helper_set_additional_message(
"sixel_allocator_malloc: called with n == 0");
return NULL;
}
if (n > SIXEL_ALLOCATE_BYTES_MAX) {
return NULL;
}
return allocator->fn_malloc(n);
}
/* call custom calloc() */
SIXELAPI void *
sixel_allocator_calloc(
sixel_allocator_t /* in */ *allocator, /* allocator object */
size_t /* in */ nelm, /* number of elements */
size_t /* in */ elsize) /* size of element */
{
size_t n;
/* precondition */
assert(allocator);
assert(allocator->fn_calloc);
n = nelm * elsize;
if (n == 0) {
sixel_helper_set_additional_message(
"sixel_allocator_malloc: called with n == 0");
return NULL;
}
if (n > SIXEL_ALLOCATE_BYTES_MAX) {
return NULL;
}
return allocator->fn_calloc(nelm, elsize);
}
/* call custom realloc() */
SIXELAPI void *
sixel_allocator_realloc(
sixel_allocator_t /* in */ *allocator, /* allocator object */
void /* in */ *p, /* existing buffer to be re-allocated */
size_t /* in */ n) /* re-allocation size */
{
/* precondition */
assert(allocator);
assert(allocator->fn_realloc);
if (n == 0) {
sixel_helper_set_additional_message(
"sixel_allocator_malloc: called with n == 0");
return NULL;
}
if (n > SIXEL_ALLOCATE_BYTES_MAX) {
return NULL;
}
return allocator->fn_realloc(p, n);
}
/* call custom free() */
SIXELAPI void
sixel_allocator_free(
sixel_allocator_t /* in */ *allocator, /* allocator object */
void /* in */ *p) /* existing buffer to be freed */
{
/* precondition */
assert(allocator);
assert(allocator->fn_free);
allocator->fn_free(p);
}
#if HAVE_TESTS
volatile int sixel_debug_malloc_counter;
void *
sixel_bad_malloc(size_t size)
{
return sixel_debug_malloc_counter-- == 0 ? NULL: malloc(size);
}
void *
sixel_bad_calloc(size_t count, size_t size)
{
(void) count;
(void) size;
return NULL;
}
void *
sixel_bad_realloc(void *ptr, size_t size)
{
(void) ptr;
(void) size;
return NULL;
}
#endif /* HAVE_TESTS */
#if 0
int
rpl_posix_memalign(void **memptr, size_t alignment, size_t size)
{
#if HAVE_POSIX_MEMALIGN
return posix_memalign(memptr, alignment, size);
#elif HAVE_ALIGNED_ALLOC
*memptr = aligned_alloc(alignment, size);
return *memptr ? 0: ENOMEM;
#elif HAVE_MEMALIGN
*memptr = memalign(alignment, size);
return *memptr ? 0: ENOMEM;
#elif HAVE__ALIGNED_MALLOC
return _aligned_malloc(size, alignment);
#else
# error
#endif /* _MSC_VER */
}
#endif
#if HAVE_TESTS
static int
test1(void)
{
int nret = EXIT_FAILURE;
SIXELSTATUS status;
sixel_allocator_t *allocator = NULL;
status = sixel_allocator_new(NULL, malloc, calloc, realloc, free);
if (status != SIXEL_BAD_ARGUMENT) {
goto error;
}
status = sixel_allocator_new(&allocator, NULL, calloc, realloc, free);
if (SIXEL_FAILED(status)) {
goto error;
}
status = sixel_allocator_new(&allocator, malloc, NULL, realloc, free);
if (SIXEL_FAILED(status)) {
goto error;
}
status = sixel_allocator_new(&allocator, malloc, calloc, NULL, free);
if (SIXEL_FAILED(status)) {
goto error;
}
status = sixel_allocator_new(&allocator, malloc, calloc, realloc, NULL);
if (SIXEL_FAILED(status)) {
goto error;
}
nret = EXIT_SUCCESS;
error:
return nret;
}
static int
test2(void)
{
int nret = EXIT_FAILURE;
SIXELSTATUS status;
sixel_allocator_t *allocator = NULL;
sixel_debug_malloc_counter = 1;
status = sixel_allocator_new(&allocator, sixel_bad_malloc, calloc, realloc, free);
if (status == SIXEL_BAD_ALLOCATION) {
goto error;
}
nret = EXIT_SUCCESS;
error:
return nret;
}
SIXELAPI int
sixel_allocator_tests_main(void)
{
int nret = EXIT_FAILURE;
size_t i;
typedef int (* testcase)(void);
static testcase const testcases[] = {
test1,
test2
};
for (i = 0; i < sizeof(testcases) / sizeof(testcase); ++i) {
nret = testcases[i]();
if (nret != EXIT_SUCCESS) {
goto error;
}
}
nret = EXIT_SUCCESS;
error:
return nret;
}
#endif /* HAVE_TESTS */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2014-2016 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBSIXEL_ALLOCATOR_H
#define LIBSIXEL_ALLOCATOR_H
#include <sixel.h>
struct sixel_allocator {
unsigned int ref; /* reference counter */
sixel_malloc_t fn_malloc;
sixel_calloc_t fn_calloc;
sixel_realloc_t fn_realloc;
sixel_free_t fn_free;
};
#if HAVE_TESTS
int
sixel_allocator_tests_main(void);
#endif
#endif /* LIBSIXEL_ALLOCATOR_H */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+58
View File
@@ -0,0 +1,58 @@
/*
* Minimal hand-written replacement for the autoconf-generated config.h.
*
* Upstream libsixel ships config.h.in and lets `configure` produce config.h.
* We only vendor the encoder-side subset (see README.md), and those files
* reference a small, fixed set of macros, so the values are hard-coded here
* instead of carrying the autotools machinery.
*
* The values below hold for every platform fastfetch targets:
* Windows/MinGW-w64, Linux/glibc, Linux/musl, macOS and the BSDs.
* Re-check this file whenever the vendored subset is re-synced with upstream.
*/
#ifndef LIBSIXEL_CONFIG_H
#define LIBSIXEL_CONFIG_H
/* Standard headers (upstream: AC_CHECK_HEADERS) */
#define HAVE_ASSERT_H 1
#define HAVE_ERRNO_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MATH_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_TYPES_H 1
/* libc functions (upstream: AC_CHECK_FUNCS) */
#define HAVE_LDIV 1
#define HAVE_MALLOC 1
#define HAVE_REALLOC 1
/* Byte order of the 32bpp pixel readers in pixelformat.c; 0 = little endian */
#define SWAP_BYTES 0
/*
* Guards the diagnostic pragma push/pop in dither.c. Not needed, and the
* pragma spelling is not portable across the compilers we support.
*/
#define HAVE_DIAGNOSTIC_DEPRECATED_DECLARATIONS 0
/* Verbose quantizer tracing to stderr */
#define HAVE_DEBUG 0
/*
* HAVE_TESTS must stay *undefined* rather than 0: sixel.h gates its test-only
* declarations with `#ifdef HAVE_TESTS`, so defining it to 0 would still pull
* in declarations for functions we do not compile.
*/
#undef HAVE_TESTS
/* Optional image loaders and features; not vendored */
#undef HAVE_GD
#undef HAVE_GDK_PIXBUF2
#undef HAVE_JPEG
#undef HAVE_LIBCURL
#undef HAVE_LIBPNG
#endif /* LIBSIXEL_CONFIG_H */
+918
View File
@@ -0,0 +1,918 @@
/*
* Copyright (c) 2014-2018 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#if HAVE_MATH_H
# include <math.h>
#endif /* HAVE_MATH_H */
#if HAVE_STRING_H
# include <string.h>
#endif /* HAVE_STRING_H */
#if HAVE_LIMITS_H
# include <limits.h>
#endif /* HAVE_LIMITS_H */
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#include "dither.h"
#include "quant.h"
#include <sixel.h>
static const unsigned char pal_mono_dark[] = {
0x00, 0x00, 0x00, 0xff, 0xff, 0xff
};
static const unsigned char pal_mono_light[] = {
0xff, 0xff, 0xff, 0x00, 0x00, 0x00
};
static const unsigned char pal_gray_1bit[] = {
0x00, 0x00, 0x00, 0xff, 0xff, 0xff
};
static const unsigned char pal_gray_2bit[] = {
0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff
};
static const unsigned char pal_gray_4bit[] = {
0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x33, 0x33, 0x33,
0x44, 0x44, 0x44, 0x55, 0x55, 0x55, 0x66, 0x66, 0x66, 0x77, 0x77, 0x77,
0x88, 0x88, 0x88, 0x99, 0x99, 0x99, 0xaa, 0xaa, 0xaa, 0xbb, 0xbb, 0xbb,
0xcc, 0xcc, 0xcc, 0xdd, 0xdd, 0xdd, 0xee, 0xee, 0xee, 0xff, 0xff, 0xff
};
static const unsigned char pal_gray_8bit[] = {
0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03,
0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0b, 0x0b, 0x0b,
0x0c, 0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0f, 0x0f, 0x0f,
0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13,
0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17,
0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x1a, 0x1a, 0x1a, 0x1b, 0x1b, 0x1b,
0x1c, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f,
0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23,
0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27,
0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b,
0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f,
0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x33, 0x33, 0x33,
0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 0x37, 0x37,
0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x3a, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b,
0x3c, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3e, 0x3f, 0x3f, 0x3f,
0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43,
0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47,
0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x4a, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b,
0x4c, 0x4c, 0x4c, 0x4d, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4f, 0x4f, 0x4f,
0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53,
0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57,
0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b,
0x5c, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5e, 0x5f, 0x5f, 0x5f,
0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63,
0x64, 0x64, 0x64, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67,
0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, 0x6b, 0x6b,
0x6c, 0x6c, 0x6c, 0x6d, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f, 0x6f, 0x6f,
0x70, 0x70, 0x70, 0x71, 0x71, 0x71, 0x72, 0x72, 0x72, 0x73, 0x73, 0x73,
0x74, 0x74, 0x74, 0x75, 0x75, 0x75, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77,
0x78, 0x78, 0x78, 0x79, 0x79, 0x79, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7b,
0x7c, 0x7c, 0x7c, 0x7d, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f, 0x7f,
0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83,
0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x86, 0x86, 0x86, 0x87, 0x87, 0x87,
0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0x8a, 0x8b, 0x8b, 0x8b,
0x8c, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f,
0x90, 0x90, 0x90, 0x91, 0x91, 0x91, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93,
0x94, 0x94, 0x94, 0x95, 0x95, 0x95, 0x96, 0x96, 0x96, 0x97, 0x97, 0x97,
0x98, 0x98, 0x98, 0x99, 0x99, 0x99, 0x9a, 0x9a, 0x9a, 0x9b, 0x9b, 0x9b,
0x9c, 0x9c, 0x9c, 0x9d, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e, 0x9f, 0x9f, 0x9f,
0xa0, 0xa0, 0xa0, 0xa1, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3,
0xa4, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa6, 0xa6, 0xa7, 0xa7, 0xa7,
0xa8, 0xa8, 0xa8, 0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa, 0xab, 0xab, 0xab,
0xac, 0xac, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xae, 0xaf, 0xaf, 0xaf,
0xb0, 0xb0, 0xb0, 0xb1, 0xb1, 0xb1, 0xb2, 0xb2, 0xb2, 0xb3, 0xb3, 0xb3,
0xb4, 0xb4, 0xb4, 0xb5, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7,
0xb8, 0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xbb, 0xbb, 0xbb,
0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0xbf, 0xbf,
0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc1, 0xc2, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3,
0xc4, 0xc4, 0xc4, 0xc5, 0xc5, 0xc5, 0xc6, 0xc6, 0xc6, 0xc7, 0xc7, 0xc7,
0xc8, 0xc8, 0xc8, 0xc9, 0xc9, 0xc9, 0xca, 0xca, 0xca, 0xcb, 0xcb, 0xcb,
0xcc, 0xcc, 0xcc, 0xcd, 0xcd, 0xcd, 0xce, 0xce, 0xce, 0xcf, 0xcf, 0xcf,
0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3,
0xd4, 0xd4, 0xd4, 0xd5, 0xd5, 0xd5, 0xd6, 0xd6, 0xd6, 0xd7, 0xd7, 0xd7,
0xd8, 0xd8, 0xd8, 0xd9, 0xd9, 0xd9, 0xda, 0xda, 0xda, 0xdb, 0xdb, 0xdb,
0xdc, 0xdc, 0xdc, 0xdd, 0xdd, 0xdd, 0xde, 0xde, 0xde, 0xdf, 0xdf, 0xdf,
0xe0, 0xe0, 0xe0, 0xe1, 0xe1, 0xe1, 0xe2, 0xe2, 0xe2, 0xe3, 0xe3, 0xe3,
0xe4, 0xe4, 0xe4, 0xe5, 0xe5, 0xe5, 0xe6, 0xe6, 0xe6, 0xe7, 0xe7, 0xe7,
0xe8, 0xe8, 0xe8, 0xe9, 0xe9, 0xe9, 0xea, 0xea, 0xea, 0xeb, 0xeb, 0xeb,
0xec, 0xec, 0xec, 0xed, 0xed, 0xed, 0xee, 0xee, 0xee, 0xef, 0xef, 0xef,
0xf0, 0xf0, 0xf0, 0xf1, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3,
0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf7, 0xf7, 0xf7,
0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb, 0xfb,
0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff
};
static const unsigned char pal_xterm256[] = {
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x80, 0x00,
0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0xc0, 0xc0, 0xc0,
0x80, 0x80, 0x80, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00,
0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x87, 0x00, 0x00, 0xaf,
0x00, 0x00, 0xd7, 0x00, 0x00, 0xff, 0x00, 0x5f, 0x00, 0x00, 0x5f, 0x5f,
0x00, 0x5f, 0x87, 0x00, 0x5f, 0xaf, 0x00, 0x5f, 0xd7, 0x00, 0x5f, 0xff,
0x00, 0x87, 0x00, 0x00, 0x87, 0x5f, 0x00, 0x87, 0x87, 0x00, 0x87, 0xaf,
0x00, 0x87, 0xd7, 0x00, 0x87, 0xff, 0x00, 0xaf, 0x00, 0x00, 0xaf, 0x5f,
0x00, 0xaf, 0x87, 0x00, 0xaf, 0xaf, 0x00, 0xaf, 0xd7, 0x00, 0xaf, 0xff,
0x00, 0xd7, 0x00, 0x00, 0xd7, 0x5f, 0x00, 0xd7, 0x87, 0x00, 0xd7, 0xaf,
0x00, 0xd7, 0xd7, 0x00, 0xd7, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x5f,
0x00, 0xff, 0x87, 0x00, 0xff, 0xaf, 0x00, 0xff, 0xd7, 0x00, 0xff, 0xff,
0x5f, 0x00, 0x00, 0x5f, 0x00, 0x5f, 0x5f, 0x00, 0x87, 0x5f, 0x00, 0xaf,
0x5f, 0x00, 0xd7, 0x5f, 0x00, 0xff, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x5f,
0x5f, 0x5f, 0x87, 0x5f, 0x5f, 0xaf, 0x5f, 0x5f, 0xd7, 0x5f, 0x5f, 0xff,
0x5f, 0x87, 0x00, 0x5f, 0x87, 0x5f, 0x5f, 0x87, 0x87, 0x5f, 0x87, 0xaf,
0x5f, 0x87, 0xd7, 0x5f, 0x87, 0xff, 0x5f, 0xaf, 0x00, 0x5f, 0xaf, 0x5f,
0x5f, 0xaf, 0x87, 0x5f, 0xaf, 0xaf, 0x5f, 0xaf, 0xd7, 0x5f, 0xaf, 0xff,
0x5f, 0xd7, 0x00, 0x5f, 0xd7, 0x5f, 0x5f, 0xd7, 0x87, 0x5f, 0xd7, 0xaf,
0x5f, 0xd7, 0xd7, 0x5f, 0xd7, 0xff, 0x5f, 0xff, 0x00, 0x5f, 0xff, 0x5f,
0x5f, 0xff, 0x87, 0x5f, 0xff, 0xaf, 0x5f, 0xff, 0xd7, 0x5f, 0xff, 0xff,
0x87, 0x00, 0x00, 0x87, 0x00, 0x5f, 0x87, 0x00, 0x87, 0x87, 0x00, 0xaf,
0x87, 0x00, 0xd7, 0x87, 0x00, 0xff, 0x87, 0x5f, 0x00, 0x87, 0x5f, 0x5f,
0x87, 0x5f, 0x87, 0x87, 0x5f, 0xaf, 0x87, 0x5f, 0xd7, 0x87, 0x5f, 0xff,
0x87, 0x87, 0x00, 0x87, 0x87, 0x5f, 0x87, 0x87, 0x87, 0x87, 0x87, 0xaf,
0x87, 0x87, 0xd7, 0x87, 0x87, 0xff, 0x87, 0xaf, 0x00, 0x87, 0xaf, 0x5f,
0x87, 0xaf, 0x87, 0x87, 0xaf, 0xaf, 0x87, 0xaf, 0xd7, 0x87, 0xaf, 0xff,
0x87, 0xd7, 0x00, 0x87, 0xd7, 0x5f, 0x87, 0xd7, 0x87, 0x87, 0xd7, 0xaf,
0x87, 0xd7, 0xd7, 0x87, 0xd7, 0xff, 0x87, 0xff, 0x00, 0x87, 0xff, 0x5f,
0x87, 0xff, 0x87, 0x87, 0xff, 0xaf, 0x87, 0xff, 0xd7, 0x87, 0xff, 0xff,
0xaf, 0x00, 0x00, 0xaf, 0x00, 0x5f, 0xaf, 0x00, 0x87, 0xaf, 0x00, 0xaf,
0xaf, 0x00, 0xd7, 0xaf, 0x00, 0xff, 0xaf, 0x5f, 0x00, 0xaf, 0x5f, 0x5f,
0xaf, 0x5f, 0x87, 0xaf, 0x5f, 0xaf, 0xaf, 0x5f, 0xd7, 0xaf, 0x5f, 0xff,
0xaf, 0x87, 0x00, 0xaf, 0x87, 0x5f, 0xaf, 0x87, 0x87, 0xaf, 0x87, 0xaf,
0xaf, 0x87, 0xd7, 0xaf, 0x87, 0xff, 0xaf, 0xaf, 0x00, 0xaf, 0xaf, 0x5f,
0xaf, 0xaf, 0x87, 0xaf, 0xaf, 0xaf, 0xaf, 0xaf, 0xd7, 0xaf, 0xaf, 0xff,
0xaf, 0xd7, 0x00, 0xaf, 0xd7, 0x5f, 0xaf, 0xd7, 0x87, 0xaf, 0xd7, 0xaf,
0xaf, 0xd7, 0xd7, 0xaf, 0xd7, 0xff, 0xaf, 0xff, 0x00, 0xaf, 0xff, 0x5f,
0xaf, 0xff, 0x87, 0xaf, 0xff, 0xaf, 0xaf, 0xff, 0xd7, 0xaf, 0xff, 0xff,
0xd7, 0x00, 0x00, 0xd7, 0x00, 0x5f, 0xd7, 0x00, 0x87, 0xd7, 0x00, 0xaf,
0xd7, 0x00, 0xd7, 0xd7, 0x00, 0xff, 0xd7, 0x5f, 0x00, 0xd7, 0x5f, 0x5f,
0xd7, 0x5f, 0x87, 0xd7, 0x5f, 0xaf, 0xd7, 0x5f, 0xd7, 0xd7, 0x5f, 0xff,
0xd7, 0x87, 0x00, 0xd7, 0x87, 0x5f, 0xd7, 0x87, 0x87, 0xd7, 0x87, 0xaf,
0xd7, 0x87, 0xd7, 0xd7, 0x87, 0xff, 0xd7, 0xaf, 0x00, 0xd7, 0xaf, 0x5f,
0xd7, 0xaf, 0x87, 0xd7, 0xaf, 0xaf, 0xd7, 0xaf, 0xd7, 0xd7, 0xaf, 0xff,
0xd7, 0xd7, 0x00, 0xd7, 0xd7, 0x5f, 0xd7, 0xd7, 0x87, 0xd7, 0xd7, 0xaf,
0xd7, 0xd7, 0xd7, 0xd7, 0xd7, 0xff, 0xd7, 0xff, 0x00, 0xd7, 0xff, 0x5f,
0xd7, 0xff, 0x87, 0xd7, 0xff, 0xaf, 0xd7, 0xff, 0xd7, 0xd7, 0xff, 0xff,
0xff, 0x00, 0x00, 0xff, 0x00, 0x5f, 0xff, 0x00, 0x87, 0xff, 0x00, 0xaf,
0xff, 0x00, 0xd7, 0xff, 0x00, 0xff, 0xff, 0x5f, 0x00, 0xff, 0x5f, 0x5f,
0xff, 0x5f, 0x87, 0xff, 0x5f, 0xaf, 0xff, 0x5f, 0xd7, 0xff, 0x5f, 0xff,
0xff, 0x87, 0x00, 0xff, 0x87, 0x5f, 0xff, 0x87, 0x87, 0xff, 0x87, 0xaf,
0xff, 0x87, 0xd7, 0xff, 0x87, 0xff, 0xff, 0xaf, 0x00, 0xff, 0xaf, 0x5f,
0xff, 0xaf, 0x87, 0xff, 0xaf, 0xaf, 0xff, 0xaf, 0xd7, 0xff, 0xaf, 0xff,
0xff, 0xd7, 0x00, 0xff, 0xd7, 0x5f, 0xff, 0xd7, 0x87, 0xff, 0xd7, 0xaf,
0xff, 0xd7, 0xd7, 0xff, 0xd7, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0x5f,
0xff, 0xff, 0x87, 0xff, 0xff, 0xaf, 0xff, 0xff, 0xd7, 0xff, 0xff, 0xff,
0x08, 0x08, 0x08, 0x12, 0x12, 0x12, 0x1c, 0x1c, 0x1c, 0x26, 0x26, 0x26,
0x30, 0x30, 0x30, 0x3a, 0x3a, 0x3a, 0x44, 0x44, 0x44, 0x4e, 0x4e, 0x4e,
0x58, 0x58, 0x58, 0x62, 0x62, 0x62, 0x6c, 0x6c, 0x6c, 0x76, 0x76, 0x76,
0x80, 0x80, 0x80, 0x8a, 0x8a, 0x8a, 0x94, 0x94, 0x94, 0x9e, 0x9e, 0x9e,
0xa8, 0xa8, 0xa8, 0xb2, 0xb2, 0xb2, 0xbc, 0xbc, 0xbc, 0xc6, 0xc6, 0xc6,
0xd0, 0xd0, 0xd0, 0xda, 0xda, 0xda, 0xe4, 0xe4, 0xe4, 0xee, 0xee, 0xee,
};
/*
* VT340 undocumented behavior regarding the color palette reported
* by Vertis Sidus(@vrtsds):
* it loads the first fifteen colors as 1 through 15, and loads the
* sixteenth color as 0.
*/
static const unsigned char pal_vt340_mono[] = {
/* 1 Gray-2 */ 13 * 255 / 100, 13 * 255 / 100, 13 * 255 / 100,
/* 2 Gray-4 */ 26 * 255 / 100, 26 * 255 / 100, 26 * 255 / 100,
/* 3 Gray-6 */ 40 * 255 / 100, 40 * 255 / 100, 40 * 255 / 100,
/* 4 Gray-1 */ 6 * 255 / 100, 6 * 255 / 100, 6 * 255 / 100,
/* 5 Gray-3 */ 20 * 255 / 100, 20 * 255 / 100, 20 * 255 / 100,
/* 6 Gray-5 */ 33 * 255 / 100, 33 * 255 / 100, 33 * 255 / 100,
/* 7 White 7 */ 46 * 255 / 100, 46 * 255 / 100, 46 * 255 / 100,
/* 8 Black 0 */ 0 * 255 / 100, 0 * 255 / 100, 0 * 255 / 100,
/* 9 Gray-2 */ 13 * 255 / 100, 13 * 255 / 100, 13 * 255 / 100,
/* 10 Gray-4 */ 26 * 255 / 100, 26 * 255 / 100, 26 * 255 / 100,
/* 11 Gray-6 */ 40 * 255 / 100, 40 * 255 / 100, 40 * 255 / 100,
/* 12 Gray-1 */ 6 * 255 / 100, 6 * 255 / 100, 6 * 255 / 100,
/* 13 Gray-3 */ 20 * 255 / 100, 20 * 255 / 100, 20 * 255 / 100,
/* 14 Gray-5 */ 33 * 255 / 100, 33 * 255 / 100, 33 * 255 / 100,
/* 15 White 7 */ 46 * 255 / 100, 46 * 255 / 100, 46 * 255 / 100,
/* 0 Black */ 0 * 255 / 100, 0 * 255 / 100, 0 * 255 / 100,
};
static const unsigned char pal_vt340_color[] = {
/* 1 Blue */ 20 * 255 / 100, 20 * 255 / 100, 80 * 255 / 100,
/* 2 Red */ 80 * 255 / 100, 13 * 255 / 100, 13 * 255 / 100,
/* 3 Green */ 20 * 255 / 100, 80 * 255 / 100, 20 * 255 / 100,
/* 4 Magenta */ 80 * 255 / 100, 20 * 255 / 100, 80 * 255 / 100,
/* 5 Cyan */ 20 * 255 / 100, 80 * 255 / 100, 80 * 255 / 100,
/* 6 Yellow */ 80 * 255 / 100, 80 * 255 / 100, 20 * 255 / 100,
/* 7 Gray 50% */ 53 * 255 / 100, 53 * 255 / 100, 53 * 255 / 100,
/* 8 Gray 25% */ 26 * 255 / 100, 26 * 255 / 100, 26 * 255 / 100,
/* 9 Blue* */ 33 * 255 / 100, 33 * 255 / 100, 60 * 255 / 100,
/* 10 Red* */ 60 * 255 / 100, 26 * 255 / 100, 26 * 255 / 100,
/* 11 Green* */ 33 * 255 / 100, 60 * 255 / 100, 33 * 255 / 100,
/* 12 Magenta* */ 60 * 255 / 100, 33 * 255 / 100, 60 * 255 / 100,
/* 13 Cyan* */ 33 * 255 / 100, 60 * 255 / 100, 60 * 255 / 100,
/* 14 Yellow* */ 60 * 255 / 100, 60 * 255 / 100, 33 * 255 / 100,
/* 15 Gray 75% */ 80 * 255 / 100, 80 * 255 / 100, 80 * 255 / 100,
/* 0 Black */ 0 * 255 / 100, 0 * 255 / 100, 0 * 255 / 100,
};
/* create dither context object */
SIXELAPI SIXELSTATUS
sixel_dither_new(
sixel_dither_t /* out */ **ppdither, /* dither object to be created */
int /* in */ ncolors, /* required colors */
sixel_allocator_t /* in */ *allocator) /* allocator, null if you use
default allocator */
{
SIXELSTATUS status = SIXEL_FALSE;
size_t headsize;
size_t datasize;
size_t wholesize;
int quality_mode;
/* ensure given pointer is not null */
if (ppdither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: ppdither is null.");
status = SIXEL_BAD_ARGUMENT;
goto end;
}
if (allocator == NULL) {
status = sixel_allocator_new(&allocator, NULL, NULL, NULL, NULL);
if (SIXEL_FAILED(status)) {
*ppdither = NULL;
goto end;
}
} else {
sixel_allocator_ref(allocator);
}
if (ncolors < 0) {
ncolors = SIXEL_PALETTE_MAX;
quality_mode = SIXEL_QUALITY_HIGHCOLOR;
} else {
if (ncolors > SIXEL_PALETTE_MAX) {
status = SIXEL_BAD_INPUT;
goto end;
} else if (ncolors < 1) {
status = SIXEL_BAD_INPUT;
sixel_helper_set_additional_message(
"sixel_dither_new: palette colors must be more than 0");
goto end;
}
quality_mode = SIXEL_QUALITY_LOW;
}
headsize = sizeof(sixel_dither_t);
datasize = (size_t)(ncolors * 3);
wholesize = headsize + datasize;
*ppdither = (sixel_dither_t *)sixel_allocator_malloc(allocator, wholesize);
if (*ppdither == NULL) {
sixel_allocator_unref(allocator);
sixel_helper_set_additional_message(
"sixel_dither_new: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
(*ppdither)->ref = 1;
(*ppdither)->palette = (unsigned char*)(*ppdither + 1);
(*ppdither)->cachetable = NULL;
(*ppdither)->reqcolors = ncolors;
(*ppdither)->ncolors = ncolors;
(*ppdither)->origcolors = (-1);
(*ppdither)->keycolor = (-1);
(*ppdither)->optimized = 0;
(*ppdither)->optimize_palette = 0;
(*ppdither)->complexion = 1;
(*ppdither)->bodyonly = 0;
(*ppdither)->method_for_largest = SIXEL_LARGE_NORM;
(*ppdither)->method_for_rep = SIXEL_REP_CENTER_BOX;
(*ppdither)->method_for_diffuse = SIXEL_DIFFUSE_FS;
(*ppdither)->quality_mode = quality_mode;
(*ppdither)->pixelformat = SIXEL_PIXELFORMAT_RGB888;
(*ppdither)->allocator = allocator;
status = SIXEL_OK;
end:
return status;
}
/* create dither context object (deprecated) */
SIXELAPI sixel_dither_t *
sixel_dither_create(
int /* in */ ncolors)
{
SIXELSTATUS status = SIXEL_FALSE;
sixel_dither_t *dither = NULL;
status = sixel_dither_new(&dither, ncolors, NULL);
if (SIXEL_FAILED(status)) {
goto end;
}
end:
return dither;
}
SIXELAPI void
sixel_dither_destroy(
sixel_dither_t /* in */ *dither)
{
sixel_allocator_t *allocator;
if (dither) {
allocator = dither->allocator;
sixel_allocator_free(allocator, dither->cachetable);
dither->cachetable = NULL;
sixel_allocator_free(allocator, dither);
sixel_allocator_unref(allocator);
}
}
SIXELAPI void
sixel_dither_ref(
sixel_dither_t /* in */ *dither)
{
/* TODO: be thread safe */
++dither->ref;
}
SIXELAPI void
sixel_dither_unref(
sixel_dither_t /* in */ *dither)
{
/* TODO: be thread safe */
if (dither != NULL && --dither->ref == 0) {
sixel_dither_destroy(dither);
}
}
SIXELAPI sixel_dither_t *
sixel_dither_get(
int /* in */ builtin_dither)
{
SIXELSTATUS status = SIXEL_FALSE;
unsigned char *palette;
int ncolors;
int keycolor;
sixel_dither_t *dither = NULL;
switch (builtin_dither) {
case SIXEL_BUILTIN_MONO_DARK:
ncolors = 2;
palette = (unsigned char *)pal_mono_dark;
keycolor = 0;
break;
case SIXEL_BUILTIN_MONO_LIGHT:
ncolors = 2;
palette = (unsigned char *)pal_mono_light;
keycolor = 0;
break;
case SIXEL_BUILTIN_XTERM16:
ncolors = 16;
palette = (unsigned char *)pal_xterm256;
keycolor = (-1);
break;
case SIXEL_BUILTIN_XTERM256:
ncolors = 256;
palette = (unsigned char *)pal_xterm256;
keycolor = (-1);
break;
case SIXEL_BUILTIN_VT340_MONO:
ncolors = 16;
palette = (unsigned char *)pal_vt340_mono;
keycolor = (-1);
break;
case SIXEL_BUILTIN_VT340_COLOR:
ncolors = 16;
palette = (unsigned char *)pal_vt340_color;
keycolor = (-1);
break;
case SIXEL_BUILTIN_G1:
ncolors = 2;
palette = (unsigned char *)pal_gray_1bit;
keycolor = (-1);
break;
case SIXEL_BUILTIN_G2:
ncolors = 4;
palette = (unsigned char *)pal_gray_2bit;
keycolor = (-1);
break;
case SIXEL_BUILTIN_G4:
ncolors = 16;
palette = (unsigned char *)pal_gray_4bit;
keycolor = (-1);
break;
case SIXEL_BUILTIN_G8:
ncolors = 256;
palette = (unsigned char *)pal_gray_8bit;
keycolor = (-1);
break;
default:
goto end;
}
status = sixel_dither_new(&dither, ncolors, NULL);
if (SIXEL_FAILED(status)) {
dither = NULL;
goto end;
}
dither->palette = palette;
dither->keycolor = keycolor;
dither->optimized = 1;
dither->optimize_palette = 0;
end:
return dither;
}
static void
sixel_dither_set_method_for_largest(
sixel_dither_t /* in */ *dither,
int /* in */ method_for_largest)
{
if (method_for_largest == SIXEL_LARGE_AUTO) {
method_for_largest = SIXEL_LARGE_NORM;
}
dither->method_for_largest = method_for_largest;
}
static void
sixel_dither_set_method_for_rep(
sixel_dither_t /* in */ *dither,
int /* in */ method_for_rep)
{
if (method_for_rep == SIXEL_REP_AUTO) {
method_for_rep = SIXEL_REP_CENTER_BOX;
}
dither->method_for_rep = method_for_rep;
}
static void
sixel_dither_set_quality_mode(
sixel_dither_t /* in */ *dither,
int /* in */ quality_mode)
{
if (quality_mode == SIXEL_QUALITY_AUTO) {
if (dither->ncolors <= 8) {
quality_mode = SIXEL_QUALITY_HIGH;
} else {
quality_mode = SIXEL_QUALITY_LOW;
}
}
dither->quality_mode = quality_mode;
}
SIXELAPI SIXELSTATUS
sixel_dither_initialize(
sixel_dither_t /* in */ *dither,
unsigned char /* in */ *data,
int /* in */ width,
int /* in */ height,
int /* in */ pixelformat,
int /* in */ method_for_largest,
int /* in */ method_for_rep,
int /* in */ quality_mode)
{
unsigned char *buf = NULL;
unsigned char *normalized_pixels = NULL;
unsigned char *input_pixels;
SIXELSTATUS status = SIXEL_FALSE;
/* ensure dither object is not null */
if (dither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: dither is null.");
status = SIXEL_BAD_ARGUMENT;
goto end;
}
/* increment ref count */
sixel_dither_ref(dither);
sixel_dither_set_pixelformat(dither, pixelformat);
switch (pixelformat) {
case SIXEL_PIXELFORMAT_RGB888:
input_pixels = data;
break;
default:
/* normalize pixelformat */
normalized_pixels
= (unsigned char *)sixel_allocator_malloc(dither->allocator, (size_t)(width * height * 3));
if (normalized_pixels == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_initialize: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
status = sixel_helper_normalize_pixelformat(
normalized_pixels,
&pixelformat,
data,
pixelformat,
width,
height);
if (SIXEL_FAILED(status)) {
goto end;
}
input_pixels = normalized_pixels;
break;
}
sixel_dither_set_method_for_largest(dither, method_for_largest);
sixel_dither_set_method_for_rep(dither, method_for_rep);
sixel_dither_set_quality_mode(dither, quality_mode);
status = sixel_quant_make_palette(&buf,
input_pixels,
(unsigned int)(width * height * 3),
SIXEL_PIXELFORMAT_RGB888,
(unsigned int)dither->reqcolors,
(unsigned int *)&dither->ncolors,
(unsigned int *)&dither->origcolors,
dither->method_for_largest,
dither->method_for_rep,
dither->quality_mode,
dither->allocator);
if (SIXEL_FAILED(status)) {
goto end;
}
memcpy(dither->palette, buf, (size_t)(dither->ncolors * 3));
dither->optimized = 1;
if (dither->origcolors <= dither->ncolors) {
dither->method_for_diffuse = SIXEL_DIFFUSE_NONE;
}
sixel_quant_free_palette(buf, dither->allocator);
status = SIXEL_OK;
end:
free(normalized_pixels);
/* decrement ref count */
sixel_dither_unref(dither);
return status;
}
/* set diffusion type, choose from enum methodForDiffuse */
SIXELAPI void
sixel_dither_set_diffusion_type(
sixel_dither_t /* in */ *dither,
int /* in */ method_for_diffuse)
{
if (method_for_diffuse == SIXEL_DIFFUSE_AUTO) {
if (dither->ncolors > 16) {
method_for_diffuse = SIXEL_DIFFUSE_FS;
} else {
method_for_diffuse = SIXEL_DIFFUSE_ATKINSON;
}
}
dither->method_for_diffuse = method_for_diffuse;
}
/* get number of palette colors */
SIXELAPI int
sixel_dither_get_num_of_palette_colors(
sixel_dither_t /* in */ *dither)
{
return dither->ncolors;
}
/* get number of histogram colors */
SIXELAPI int
sixel_dither_get_num_of_histogram_colors(
sixel_dither_t /* in */ *dither) /* dither context object */
{
return dither->origcolors;
}
/* typoed: remained for keeping compatibility */
SIXELAPI int
sixel_dither_get_num_of_histgram_colors(
sixel_dither_t /* in */ *dither) /* dither context object */
{
return sixel_dither_get_num_of_histogram_colors(dither);
}
/* get palette */
SIXELAPI unsigned char *
sixel_dither_get_palette(
sixel_dither_t /* in */ *dither) /* dither context object */
{
return dither->palette;
}
/* set palette */
SIXELAPI void
sixel_dither_set_palette(
sixel_dither_t /* in */ *dither, /* dither context object */
unsigned char /* in */ *palette)
{
memcpy(dither->palette, palette, (size_t)(dither->ncolors * 3));
}
/* set the factor of complexion color correcting */
SIXELAPI void
sixel_dither_set_complexion_score(
sixel_dither_t /* in */ *dither, /* dither context object */
int /* in */ score) /* complexion score (>= 1) */
{
dither->complexion = score;
}
/* set whether omitting palette difinition */
SIXELAPI void
sixel_dither_set_body_only(
sixel_dither_t /* in */ *dither, /* dither context object */
int /* in */ bodyonly) /* 0: output palette section
1: do not output palette section */
{
dither->bodyonly = bodyonly;
}
/* set whether optimize palette size */
SIXELAPI void
sixel_dither_set_optimize_palette(
sixel_dither_t /* in */ *dither, /* dither context object */
int /* in */ do_opt) /* 0: optimize palette size
1: don't optimize palette size */
{
dither->optimize_palette = do_opt;
}
/* set pixelformat */
SIXELAPI void
sixel_dither_set_pixelformat(
sixel_dither_t /* in */ *dither, /* dither context object */
int /* in */ pixelformat) /* one of enum pixelFormat */
{
dither->pixelformat = pixelformat;
}
/* set transparent */
SIXELAPI void
sixel_dither_set_transparent(
sixel_dither_t /* in */ *dither, /* dither context object */
int /* in */ transparent) /* transparent color index */
{
dither->keycolor = transparent;
}
/* set transparent */
SIXELAPI sixel_index_t *
sixel_dither_apply_palette(
sixel_dither_t /* in */ *dither,
unsigned char /* in */ *pixels,
int /* in */ width,
int /* in */ height)
{
SIXELSTATUS status = SIXEL_FALSE;
size_t bufsize;
sixel_index_t *dest = NULL;
int ncolors;
unsigned char *normalized_pixels = NULL;
unsigned char *input_pixels;
/* ensure dither object is not null */
if (dither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_apply_palette: dither is null.");
status = SIXEL_BAD_ARGUMENT;
goto end;
}
sixel_dither_ref(dither);
bufsize = (size_t)(width * height) * sizeof(sixel_index_t);
dest = (sixel_index_t *)sixel_allocator_malloc(dither->allocator, bufsize);
if (dest == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
/* if quality_mode is full, do not use palette caching */
if (dither->quality_mode == SIXEL_QUALITY_FULL) {
dither->optimized = 0;
}
if (dither->cachetable == NULL && dither->optimized) {
if (dither->palette != pal_mono_dark && dither->palette != pal_mono_light) {
dither->cachetable = (unsigned short *)sixel_allocator_calloc(dither->allocator,
(size_t)(1 << 3 * 5),
sizeof(unsigned short));
if (dither->cachetable == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: sixel_allocator_calloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
}
}
if (dither->pixelformat != SIXEL_PIXELFORMAT_RGB888) {
/* normalize pixelformat */
normalized_pixels
= (unsigned char *)sixel_allocator_malloc(dither->allocator, (size_t)(width * height * 3));
if (normalized_pixels == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
status = sixel_helper_normalize_pixelformat(normalized_pixels,
&dither->pixelformat,
pixels, dither->pixelformat,
width, height);
if (SIXEL_FAILED(status)) {
goto end;
}
input_pixels = normalized_pixels;
} else {
input_pixels = pixels;
}
status = sixel_quant_apply_palette(dest,
input_pixels,
width, height, 3,
dither->palette,
dither->ncolors,
dither->method_for_diffuse,
dither->optimized,
dither->optimize_palette,
dither->complexion,
dither->cachetable,
&ncolors,
dither->allocator);
if (SIXEL_FAILED(status)) {
free(dest);
dest = NULL;
goto end;
}
dither->ncolors = ncolors;
end:
free(normalized_pixels);
sixel_dither_unref(dither);
return dest;
}
#if HAVE_TESTS
static int
test1(void)
{
sixel_dither_t *dither = NULL;
int nret = EXIT_FAILURE;
#if HAVE_DIAGNOSTIC_DEPRECATED_DECLARATIONS
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
dither = sixel_dither_create(2);
#if HAVE_DIAGNOSTIC_DEPRECATED_DECLARATIONS
# pragma GCC diagnostic pop
#endif
if (dither == NULL) {
goto error;
}
sixel_dither_ref(dither);
sixel_dither_unref(dither);
nret = EXIT_SUCCESS;
error:
sixel_dither_unref(dither);
return nret;
}
static int
test2(void)
{
sixel_dither_t *dither = NULL;
int colors;
int nret = EXIT_FAILURE;
#if HAVE_DIAGNOSTIC_DEPRECATED_DECLARATIONS
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
dither = sixel_dither_create(INT_MAX);
#if HAVE_DIAGNOSTIC_DEPRECATED_DECLARATIONS
# pragma GCC diagnostic pop
#endif
if (dither == NULL) {
goto error;
}
sixel_dither_set_body_only(dither, 1);
colors = sixel_dither_get_num_of_histogram_colors(dither);
if (colors != -1) {
goto error;
}
nret = EXIT_SUCCESS;
error:
sixel_dither_unref(dither);
return nret;
}
SIXELAPI int
sixel_dither_tests_main(void)
{
int nret = EXIT_FAILURE;
size_t i;
typedef int (* testcase)(void);
static testcase const testcases[] = {
test1,
test2,
};
for (i = 0; i < sizeof(testcases) / sizeof(testcase); ++i) {
nret = testcases[i]();
if (nret != EXIT_SUCCESS) {
goto error;
}
}
nret = EXIT_SUCCESS;
error:
return nret;
}
#endif /* HAVE_TESTS */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+78
View File
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2014-2016 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBSIXEL_DITHER_H
#define LIBSIXEL_DITHER_H
#include <sixel.h>
/* dither context object */
struct sixel_dither {
unsigned int ref; /* reference counter */
unsigned char *palette; /* palette definition */
unsigned short *cachetable; /* cache table */
int reqcolors; /* requested colors */
int ncolors; /* active colors */
int origcolors; /* original colors */
int optimized; /* pixel is 15bpp compressable */
int optimize_palette; /* minimize palette size */
int complexion; /* for complexion correction */
int bodyonly; /* do not output palette section if true */
int method_for_largest; /* method for finding the largest dimention
for splitting */
int method_for_rep; /* method for choosing a color from the box */
int method_for_diffuse; /* method for diffusing */
int quality_mode; /* quality of histogram */
int keycolor; /* background color */
int pixelformat; /* pixelformat for internal processing */
sixel_allocator_t *allocator; /* allocator */
};
#ifdef __cplusplus
extern "C" {
#endif
/* apply palette */
sixel_index_t *
sixel_dither_apply_palette(struct sixel_dither /* in */ *dither,
unsigned char /* in */ *pixels,
int /* in */ width,
int /* in */ height);
#if HAVE_TESTS
int
sixel_frame_tests_main(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* LIBSIXEL_DITHER_H */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+50
View File
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2014-2016 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef MALLOC_STUB_H
#define MALLOC_STUB_H
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */
#if !HAVE_MALLOC
void * rpl_malloc(size_t n);
#endif /* !HAVE_MALLOC */
#if !HAVE_REALLOC
void * rpl_realloc(void *p, size_t n);
#endif /* !HAVE_REALLOC */
#if 0
int rpl_posix_memalign(void **memptr, size_t alignment, size_t size);
#endif
#endif /* MALLOC_STUB_H */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+211
View File
@@ -0,0 +1,211 @@
/*
* Copyright (c) 2014-2019 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
/* STDC_HEADERS */
# include <stdio.h>
# include <stdlib.h>
#if HAVE_ASSERT_H
# include <assert.h>
#endif /* HAVE_ASSERT_H */
#include <sixel.h>
#include "output.h"
/* create new output context object */
SIXELAPI SIXELSTATUS
sixel_output_new(
sixel_output_t /* out */ **output,
sixel_write_function /* in */ fn_write,
void /* in */ *priv,
sixel_allocator_t /* in */ *allocator)
{
SIXELSTATUS status = SIXEL_FALSE;
size_t size;
if (allocator == NULL) {
status = sixel_allocator_new(&allocator, NULL, NULL, NULL, NULL);
if (SIXEL_FAILED(status)) {
goto end;
}
} else {
sixel_allocator_ref(allocator);
}
size = sizeof(sixel_output_t) + SIXEL_OUTPUT_PACKET_SIZE * 2;
*output = (sixel_output_t *)sixel_allocator_malloc(allocator, size);
if (*output == NULL) {
sixel_helper_set_additional_message(
"sixel_output_new: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
sixel_allocator_unref(allocator);
goto end;
}
(*output)->ref = 1;
(*output)->has_8bit_control = 0;
(*output)->has_sdm_glitch = 0;
(*output)->has_gri_arg_limit = 1;
(*output)->skip_dcs_envelope = 0;
(*output)->palette_type = SIXEL_PALETTETYPE_AUTO;
(*output)->fn_write = fn_write;
(*output)->save_pixel = 0;
(*output)->save_count = 0;
(*output)->active_palette = (-1);
(*output)->node_top = NULL;
(*output)->node_free = NULL;
(*output)->priv = priv;
(*output)->pos = 0;
(*output)->penetrate_multiplexer = 0;
(*output)->encode_policy = SIXEL_ENCODEPOLICY_AUTO;
(*output)->allocator = allocator;
status = SIXEL_OK;
end:
return status;
}
/* deprecated: create an output object */
SIXELAPI sixel_output_t *
sixel_output_create(sixel_write_function fn_write, void *priv)
{
SIXELSTATUS status = SIXEL_FALSE;
sixel_output_t *output = NULL;
status = sixel_output_new(&output, fn_write, priv, NULL);
if (SIXEL_FAILED(status)) {
goto end;
}
end:
return output;
}
/* destroy output context object */
SIXELAPI void
sixel_output_destroy(sixel_output_t *output)
{
sixel_allocator_t *allocator;
if (output) {
allocator = output->allocator;
sixel_allocator_free(allocator, output);
sixel_allocator_unref(allocator);
}
}
/* increase reference count of output context object (thread-unsafe) */
SIXELAPI void
sixel_output_ref(sixel_output_t *output)
{
/* TODO: be thread-safe */
++output->ref;
}
/* decrease reference count of output context object (thread-unsafe) */
SIXELAPI void
sixel_output_unref(sixel_output_t *output)
{
/* TODO: be thread-safe */
if (output) {
assert(output->ref > 0);
output->ref--;
if (output->ref == 0) {
sixel_output_destroy(output);
}
}
}
/* get 8bit output mode which indicates whether it uses C1 control characters */
SIXELAPI int
sixel_output_get_8bit_availability(sixel_output_t *output)
{
return output->has_8bit_control;
}
/* set 8bit output mode state */
SIXELAPI void
sixel_output_set_8bit_availability(sixel_output_t *output, int availability)
{
output->has_8bit_control = availability;
}
/* set whether limit arguments of DECGRI('!') to 255 */
SIXELAPI void
sixel_output_set_gri_arg_limit(
sixel_output_t /* in */ *output, /* output context */
int /* in */ value) /* 0: don't limit arguments of DECGRI
1: limit arguments of DECGRI to 255 */
{
output->has_gri_arg_limit = value;
}
/* set GNU Screen penetration feature enable or disable */
SIXELAPI void
sixel_output_set_penetrate_multiplexer(sixel_output_t *output, int penetrate)
{
output->penetrate_multiplexer = penetrate;
}
/* set whether we skip DCS envelope */
SIXELAPI void
sixel_output_set_skip_dcs_envelope(sixel_output_t *output, int skip)
{
output->skip_dcs_envelope = skip;
}
/* set palette type: RGB or HLS */
SIXELAPI void
sixel_output_set_palette_type(sixel_output_t *output, int palettetype)
{
output->palette_type = palettetype;
}
/* set encodeing policy: auto, fast or size */
SIXELAPI void
sixel_output_set_encode_policy(sixel_output_t *output, int encode_policy)
{
output->encode_policy = encode_policy;
}
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+91
View File
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2014-2016 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBSIXEL_OUTPUT_H
#define LIBSIXEL_OUTPUT_H
typedef struct sixel_node {
struct sixel_node *next;
int pal;
int sx;
int mx;
char *map;
} sixel_node_t;
struct sixel_output {
int ref;
sixel_allocator_t *allocator;
/* compatiblity flags */
/* 0: 7bit terminal,
* 1: 8bit terminal */
unsigned char has_8bit_control;
/* 0: the terminal has sixel scrolling
* 1: the terminal does not have sixel scrolling */
unsigned char has_sixel_scrolling;
/* 1: the argument of repeat introducer(DECGRI) is not limitted
0: the argument of repeat introducer(DECGRI) is limitted 255 */
unsigned char has_gri_arg_limit;
/* 0: DECSDM set (CSI ? 80 h) enables sixel scrolling
1: DECSDM set (CSI ? 80 h) disables sixel scrolling */
unsigned char has_sdm_glitch;
/* 0: do not skip DCS envelope
* 1: skip DCS envelope */
unsigned char skip_dcs_envelope;
/* PALETTETYPE_AUTO: select palette type automatically
* PALETTETYPE_HLS : HLS color space
* PALETTETYPE_RGB : RGB color space */
unsigned char palette_type;
sixel_write_function fn_write;
int save_pixel;
int save_count;
int active_palette;
sixel_node_t *node_top;
sixel_node_t *node_free;
int penetrate_multiplexer;
int encode_policy;
void *priv;
int pos;
unsigned char buffer[1];
};
#endif /* LIBSIXEL_OUTPUT_H */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+725
View File
@@ -0,0 +1,725 @@
/*
* Copyright (c) 2014-2019 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
/* STDC_HEADERS */
#include <stdio.h>
#include <stdlib.h>
#if HAVE_MEMORY_H
# include <memory.h>
#endif /* HAVE_MEMORY_H */
#include <sixel.h>
static void
get_rgb(unsigned char const *data,
int const pixelformat,
int depth,
unsigned char *r,
unsigned char *g,
unsigned char *b)
{
unsigned int pixels = 0;
#if SWAP_BYTES
unsigned int low;
unsigned int high;
#endif
int count = 0;
while (count < depth) {
pixels = *(data + count) | (pixels << 8);
count++;
}
/* TODO: we should swap bytes (only necessary on LSByte first hardware?) */
#if SWAP_BYTES
if (depth == 2) {
low = pixels & 0xff;
high = (pixels >> 8) & 0xff;
pixels = (low << 8) | high;
}
#endif
switch (pixelformat) {
case SIXEL_PIXELFORMAT_RGB555:
*r = ((pixels >> 10) & 0x1f) << 3;
*g = ((pixels >> 5) & 0x1f) << 3;
*b = ((pixels >> 0) & 0x1f) << 3;
break;
case SIXEL_PIXELFORMAT_RGB565:
*r = ((pixels >> 11) & 0x1f) << 3;
*g = ((pixels >> 5) & 0x3f) << 2;
*b = ((pixels >> 0) & 0x1f) << 3;
break;
case SIXEL_PIXELFORMAT_RGB888:
*r = (pixels >> 16) & 0xff;
*g = (pixels >> 8) & 0xff;
*b = (pixels >> 0) & 0xff;
break;
case SIXEL_PIXELFORMAT_BGR555:
*r = ((pixels >> 0) & 0x1f) << 3;
*g = ((pixels >> 5) & 0x1f) << 3;
*b = ((pixels >> 10) & 0x1f) << 3;
break;
case SIXEL_PIXELFORMAT_BGR565:
*r = ((pixels >> 0) & 0x1f) << 3;
*g = ((pixels >> 5) & 0x3f) << 2;
*b = ((pixels >> 11) & 0x1f) << 3;
break;
case SIXEL_PIXELFORMAT_BGR888:
*r = (pixels >> 0) & 0xff;
*g = (pixels >> 8) & 0xff;
*b = (pixels >> 16) & 0xff;
break;
case SIXEL_PIXELFORMAT_RGBA8888:
*r = (pixels >> 24) & 0xff;
*g = (pixels >> 16) & 0xff;
*b = (pixels >> 8) & 0xff;
break;
case SIXEL_PIXELFORMAT_ARGB8888:
*r = (pixels >> 16) & 0xff;
*g = (pixels >> 8) & 0xff;
*b = (pixels >> 0) & 0xff;
break;
case SIXEL_PIXELFORMAT_BGRA8888:
*r = (pixels >> 8) & 0xff;
*g = (pixels >> 16) & 0xff;
*b = (pixels >> 24) & 0xff;
break;
case SIXEL_PIXELFORMAT_ABGR8888:
*r = (pixels >> 0) & 0xff;
*g = (pixels >> 8) & 0xff;
*b = (pixels >> 16) & 0xff;
break;
case SIXEL_PIXELFORMAT_GA88:
*r = *g = *b = (pixels >> 8) & 0xff;
break;
case SIXEL_PIXELFORMAT_G8:
case SIXEL_PIXELFORMAT_AG88:
*r = *g = *b = pixels & 0xff;
break;
default:
*r = *g = *b = 0;
break;
}
}
SIXELAPI int
sixel_helper_compute_depth(int pixelformat)
{
int depth = (-1); /* unknown */
switch (pixelformat) {
case SIXEL_PIXELFORMAT_ARGB8888:
case SIXEL_PIXELFORMAT_RGBA8888:
case SIXEL_PIXELFORMAT_ABGR8888:
case SIXEL_PIXELFORMAT_BGRA8888:
depth = 4;
break;
case SIXEL_PIXELFORMAT_RGB888:
case SIXEL_PIXELFORMAT_BGR888:
depth = 3;
break;
case SIXEL_PIXELFORMAT_RGB555:
case SIXEL_PIXELFORMAT_RGB565:
case SIXEL_PIXELFORMAT_BGR555:
case SIXEL_PIXELFORMAT_BGR565:
case SIXEL_PIXELFORMAT_AG88:
case SIXEL_PIXELFORMAT_GA88:
depth = 2;
break;
case SIXEL_PIXELFORMAT_G1:
case SIXEL_PIXELFORMAT_G2:
case SIXEL_PIXELFORMAT_G4:
case SIXEL_PIXELFORMAT_G8:
case SIXEL_PIXELFORMAT_PAL1:
case SIXEL_PIXELFORMAT_PAL2:
case SIXEL_PIXELFORMAT_PAL4:
case SIXEL_PIXELFORMAT_PAL8:
depth = 1;
break;
default:
break;
}
return depth;
}
static void
expand_rgb(unsigned char *dst,
unsigned char const *src,
int width, int height,
int pixelformat, int depth)
{
int x;
int y;
int dst_offset;
int src_offset;
unsigned char r, g, b;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
src_offset = depth * (y * width + x);
dst_offset = 3 * (y * width + x);
get_rgb(src + src_offset, pixelformat, depth, &r, &g, &b);
*(dst + dst_offset + 0) = r;
*(dst + dst_offset + 1) = g;
*(dst + dst_offset + 2) = b;
}
}
}
static SIXELSTATUS
expand_palette(unsigned char *dst, unsigned char const *src,
int width, int height, int const pixelformat)
{
SIXELSTATUS status = SIXEL_FALSE;
int x;
int y;
int i;
int bpp; /* bit per plane */
switch (pixelformat) {
case SIXEL_PIXELFORMAT_PAL1:
case SIXEL_PIXELFORMAT_G1:
bpp = 1;
break;
case SIXEL_PIXELFORMAT_PAL2:
case SIXEL_PIXELFORMAT_G2:
bpp = 2;
break;
case SIXEL_PIXELFORMAT_PAL4:
case SIXEL_PIXELFORMAT_G4:
bpp = 4;
break;
case SIXEL_PIXELFORMAT_PAL8:
case SIXEL_PIXELFORMAT_G8:
for (i = 0; i < width * height; ++i, ++src) {
*dst++ = *src;
}
status = SIXEL_OK;
goto end;
default:
status = SIXEL_BAD_ARGUMENT;
sixel_helper_set_additional_message(
"expand_palette: invalid pixelformat.");
goto end;
}
#if HAVE_DEBUG
fprintf(stderr, "expanding PAL%d to PAL8...\n", bpp);
#endif
for (y = 0; y < height; ++y) {
for (x = 0; x < width * bpp / 8; ++x) {
for (i = 0; i < 8 / bpp; ++i) {
*dst++ = *src >> (8 / bpp - 1 - i) * bpp & ((1 << bpp) - 1);
}
src++;
}
x = width - x * 8 / bpp;
if (x > 0) {
for (i = 0; i < x; ++i) {
*dst++ = *src >> (8 - (i + 1) * bpp) & ((1 << bpp) - 1);
}
src++;
}
}
status = SIXEL_OK;
end:
return status;
}
SIXELAPI SIXELSTATUS
sixel_helper_normalize_pixelformat(
unsigned char /* out */ *dst, /* destination buffer */
int /* out */ *dst_pixelformat, /* converted pixelformat */
unsigned char const /* in */ *src, /* source pixels */
int /* in */ src_pixelformat, /* format of source image */
int /* in */ width, /* width of source image */
int /* in */ height) /* height of source image */
{
SIXELSTATUS status = SIXEL_FALSE;
switch (src_pixelformat) {
case SIXEL_PIXELFORMAT_G8:
expand_rgb(dst, src, width, height, src_pixelformat, 1);
*dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
break;
case SIXEL_PIXELFORMAT_RGB565:
case SIXEL_PIXELFORMAT_RGB555:
case SIXEL_PIXELFORMAT_BGR565:
case SIXEL_PIXELFORMAT_BGR555:
case SIXEL_PIXELFORMAT_GA88:
case SIXEL_PIXELFORMAT_AG88:
expand_rgb(dst, src, width, height, src_pixelformat, 2);
*dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
break;
case SIXEL_PIXELFORMAT_RGB888:
case SIXEL_PIXELFORMAT_BGR888:
expand_rgb(dst, src, width, height, src_pixelformat, 3);
*dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
break;
case SIXEL_PIXELFORMAT_RGBA8888:
case SIXEL_PIXELFORMAT_ARGB8888:
case SIXEL_PIXELFORMAT_BGRA8888:
case SIXEL_PIXELFORMAT_ABGR8888:
expand_rgb(dst, src, width, height, src_pixelformat, 4);
*dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
break;
case SIXEL_PIXELFORMAT_PAL1:
case SIXEL_PIXELFORMAT_PAL2:
case SIXEL_PIXELFORMAT_PAL4:
*dst_pixelformat = SIXEL_PIXELFORMAT_PAL8;
status = expand_palette(dst, src, width, height, src_pixelformat);
if (SIXEL_FAILED(status)) {
goto end;
}
break;
case SIXEL_PIXELFORMAT_G1:
case SIXEL_PIXELFORMAT_G2:
case SIXEL_PIXELFORMAT_G4:
*dst_pixelformat = SIXEL_PIXELFORMAT_G8;
status = expand_palette(dst, src, width, height, src_pixelformat);
if (SIXEL_FAILED(status)) {
goto end;
}
break;
case SIXEL_PIXELFORMAT_PAL8:
memcpy(dst, src, (size_t)(width * height));
*dst_pixelformat = src_pixelformat;
break;
default:
status = SIXEL_BAD_ARGUMENT;
goto end;
}
status = SIXEL_OK;
end:
return status;
}
#if HAVE_TESTS
static int
test1(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_RGB888;
unsigned char src[] = { 0x46, 0xf3, 0xe5 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if ((dst[0] << 16 | dst[1] << 8 | dst[2]) != (src[0] << 16 | src[1] << 8 | src[2])) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test1");
return nret;
}
static int
test2(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_RGB555;
unsigned char src[] = { 0x47, 0x9c };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if ((dst[0] >> 3 << 10 | dst[1] >> 3 << 5 | dst[2] >> 3) != (src[0] << 8 | src[1])) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test2");
return nret;
}
static int
test3(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_RGB565;
unsigned char src[] = { 0x47, 0x9c };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if ((dst[0] >> 3 << 11 | dst[1] >> 2 << 5 | dst[2] >> 3) != (src[0] << 8 | src[1])) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test3");
return nret;
}
static int
test4(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_BGR888;
unsigned char src[] = { 0x46, 0xf3, 0xe5 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if ((dst[2] << 16 | dst[1] << 8 | dst[0]) != (src[0] << 16 | src[1] << 8 | src[2])) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test4");
return nret;
}
static int
test5(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_BGR555;
unsigned char src[] = { 0x23, 0xc8 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if ((dst[2] >> 3 << 10 | dst[1] >> 3 << 5 | dst[0] >> 3) != (src[0] << 8 | src[1])) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test5");
return nret;
}
static int
test6(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_BGR565;
unsigned char src[] = { 0x47, 0x88 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if ((dst[2] >> 3 << 11 | dst[1] >> 2 << 5 | dst[0] >> 3) != (src[0] << 8 | src[1])) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test6");
return nret;
}
static int
test7(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_AG88;
unsigned char src[] = { 0x47, 0x88 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if (dst[0] != src[1]) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test7");
return nret;
}
static int
test8(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_GA88;
unsigned char src[] = { 0x47, 0x88 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if (dst[0] != src[0]) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test8");
return nret;
}
static int
test9(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_RGBA8888;
unsigned char src[] = { 0x46, 0xf3, 0xe5, 0xf0 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if (dst[0] != src[0]) {
goto error;
}
if (dst[1] != src[1]) {
goto error;
}
if (dst[2] != src[2]) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test8");
return nret;
}
static int
test10(void)
{
unsigned char dst[3];
int dst_pixelformat = SIXEL_PIXELFORMAT_RGB888;
int src_pixelformat = SIXEL_PIXELFORMAT_ARGB8888;
unsigned char src[] = { 0x46, 0xf3, 0xe5, 0xf0 };
int ret = 0;
int nret = EXIT_FAILURE;
ret = sixel_helper_normalize_pixelformat(dst,
&dst_pixelformat,
src,
src_pixelformat,
1,
1);
if (ret != 0) {
goto error;
}
if (dst_pixelformat != SIXEL_PIXELFORMAT_RGB888) {
goto error;
}
if (dst[0] != src[1]) {
goto error;
}
if (dst[1] != src[2]) {
goto error;
}
if (dst[2] != src[3]) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test8");
return nret;
}
SIXELAPI int
sixel_pixelformat_tests_main(void)
{
int nret = EXIT_FAILURE;
size_t i;
typedef int (* testcase)(void);
static testcase const testcases[] = {
test1,
test2,
test3,
test4,
test5,
test6,
test7,
test8,
test9,
test10,
};
for (i = 0; i < sizeof(testcases) / sizeof(testcase); ++i) {
nret = testcases[i]();
if (nret != EXIT_SUCCESS) {
goto error;
}
}
nret = EXIT_SUCCESS;
error:
return nret;
}
#endif /* HAVE_TESTS */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+1549
View File
File diff suppressed because it is too large Load Diff
+90
View File
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2014-2016 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBSIXEL_QUANT_H
#define LIBSIXEL_QUANT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sixel.h>
/* choose colors using median-cut method */
SIXELSTATUS
sixel_quant_make_palette(
unsigned char /* out */ **result,
unsigned const char /* in */ *data, /* data for sampling */
unsigned int /* in */ length, /* data size */
int /* in */ pixelformat,
unsigned int /* in */ reqcolors,
unsigned int /* in */ *ncolors,
unsigned int /* in */ *origcolors,
int /* in */ methodForLargest,
int /* in */ methodForRep,
int /* in */ qualityMode,
sixel_allocator_t /* in */ *allocator);
/* apply color palette into specified pixel buffers */
SIXELSTATUS
sixel_quant_apply_palette(
sixel_index_t /* out */ *result,
unsigned char /* in */ *data,
int /* in */ width,
int /* in */ height,
int /* in */ pixelformat,
unsigned char /* in */ *palette,
int /* in */ reqcolor,
int const /* in */ methodForDiffuse,
int /* in */ foptimize,
int /* in */ foptimize_palette,
int /* in */ complexion,
unsigned short /* in */ *cachetable,
int /* in */ *ncolor,
sixel_allocator_t /* in */ *allocator);
/* deallocate specified palette */
void
sixel_quant_free_palette(
unsigned char /* in */ *data,
sixel_allocator_t /* in */ *allocator);
#if HAVE_TESTS
int
sixel_quant_tests_main(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* LIBSIXEL_QUANT_H */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+12
View File
@@ -0,0 +1,12 @@
{
"home": "https://github.com/saitoha/libsixel",
"license": "MIT ( embed in source )",
"version": "1.8.7-r2",
"author": "Hayaki Saito",
"modifications": [
"sixel.h: SIXELAPI is empty, so the statically linked subset exports nothing",
"config.h: hand-written, because only the vendored files read it",
"tosixel.c: DCS P2 initialised to 1, so unset pixels are not filled with colour-table entry 0",
"output.c: release the allocator reference if output-context allocation fails"
]
}
+1173
View File
File diff suppressed because it is too large Load Diff
+355
View File
@@ -0,0 +1,355 @@
/*
* Copyright (c) 2014-2018 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "config.h"
/* STDC_HEADERS */
#include <stdio.h>
#include <stdlib.h>
#if HAVE_MEMORY_H
# include <memory.h>
#endif /* HAVE_MEMORY_H */
#ifdef HAVE_STRING_H
# include <string.h>
#endif /* HAVE_STRING_H */
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif /* HAVE_ERRNO_H */
#ifdef HAVE_LIBCURL
# include <curl/curl.h>
#endif /* HAVE_LIBCURL */
#include <sixel.h>
#include "status.h"
#define SIXEL_MESSAGE_OK ("succeeded")
#define SIXEL_MESSAGE_FALSE ("unexpected error (SIXEL_FALSE)");
#define SIXEL_MESSAGE_UNEXPECTED ("unexpected error")
#define SIXEL_MESSAGE_INTERRUPTED ("interrupted by a signal")
#define SIXEL_MESSAGE_BAD_ALLOCATION ("runtime error: bad allocation error")
#define SIXEL_MESSAGE_BAD_ARGUMENT ("runtime error: bad argument detected")
#define SIXEL_MESSAGE_BAD_INPUT ("runtime error: bad input detected")
#define SIXEL_MESSAGE_BAD_INTEGER_OVERFLOW ("runtime error: integer overflow")
#define SIXEL_MESSAGE_RUNTIME_ERROR ("runtime error")
#define SIXEL_MESSAGE_LOGIC_ERROR ("logic error")
#define SIXEL_MESSAGE_NOT_IMPLEMENTED ("feature error: not implemented")
#define SIXEL_MESSAGE_FEATURE_ERROR ("feature error")
#define SIXEL_MESSAGE_STBI_ERROR ("stb_image error")
#define SIXEL_MESSAGE_STBIW_ERROR ("stb_image_write error")
#define SIXEL_MESSAGE_JPEG_ERROR ("libjpeg error")
#define SIXEL_MESSAGE_PNG_ERROR ("libpng error")
#define SIXEL_MESSAGE_GDK_ERROR ("GDK error")
#define SIXEL_MESSAGE_GD_ERROR ("GD error")
static char g_buffer[1024] = { 0x0 };
/* set detailed error message (thread-unsafe) */
SIXELAPI void
sixel_helper_set_additional_message(
const char /* in */ *message /* error message */
)
{
size_t len;
if (message == 0)
return;
len = strlen(message);
memcpy(g_buffer, message, len < sizeof(g_buffer) ? len: sizeof(g_buffer) - 1);
g_buffer[sizeof(g_buffer) - 1] = 0;
}
/* get detailed error message (thread-unsafe) */
SIXELAPI char const *
sixel_helper_get_additional_message(void)
{
return g_buffer;
}
/* convert error status code int formatted string */
SIXELAPI char const *
sixel_helper_format_error(
SIXELSTATUS /* in */ status /* status code */
)
{
static char buffer[1024];
char const *error_string;
char *p;
size_t len;
switch (status & 0x1000) {
case SIXEL_OK:
switch (status) {
case SIXEL_INTERRUPTED:
error_string = SIXEL_MESSAGE_INTERRUPTED;
break;
case SIXEL_OK:
default:
error_string = SIXEL_MESSAGE_OK;
break;
}
break;
case SIXEL_FALSE:
switch (status & 0x1f00) {
case SIXEL_RUNTIME_ERROR:
switch (status) {
case SIXEL_BAD_ALLOCATION:
error_string = SIXEL_MESSAGE_BAD_ALLOCATION;
break;
case SIXEL_BAD_ARGUMENT:
error_string = SIXEL_MESSAGE_BAD_ARGUMENT;
break;
case SIXEL_BAD_INPUT:
error_string = SIXEL_MESSAGE_BAD_INPUT;
break;
case SIXEL_BAD_INTEGER_OVERFLOW:
error_string = SIXEL_MESSAGE_BAD_INTEGER_OVERFLOW;
break;
default:
error_string = SIXEL_MESSAGE_RUNTIME_ERROR;
break;
}
break;
case SIXEL_LOGIC_ERROR:
error_string = SIXEL_MESSAGE_LOGIC_ERROR;
break;
case SIXEL_FEATURE_ERROR:
switch (status) {
case SIXEL_NOT_IMPLEMENTED:
error_string = SIXEL_MESSAGE_NOT_IMPLEMENTED;
break;
default:
error_string = SIXEL_MESSAGE_FEATURE_ERROR;
break;
}
break;
case SIXEL_LIBC_ERROR:
p = strerror(errno);
len = strlen(p) + 1;
memcpy(buffer, p, len < sizeof(buffer) ? len: sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = 0;
error_string = buffer;
break;
#ifdef HAVE_LIBCURL
case SIXEL_CURL_ERROR:
error_string = curl_easy_strerror(status & 0xff);
break;
#endif
#ifdef HAVE_JPEG
case SIXEL_JPEG_ERROR:
error_string = SIXEL_MESSAGE_JPEG_ERROR;
break;
#endif
#ifdef HAVE_LIBPNG
case SIXEL_PNG_ERROR:
error_string = SIXEL_MESSAGE_PNG_ERROR;
break;
#endif
#ifdef HAVE_GDK_PIXBUF2
case SIXEL_GDK_ERROR:
error_string = SIXEL_MESSAGE_GDK_ERROR;
break;
#endif
#ifdef HAVE_GD
case SIXEL_GD_ERROR:
error_string = SIXEL_MESSAGE_GD_ERROR;
break;
#endif
case SIXEL_STBI_ERROR:
error_string = SIXEL_MESSAGE_STBI_ERROR;
break;
case SIXEL_STBIW_ERROR:
error_string = SIXEL_MESSAGE_STBIW_ERROR;
break;
case SIXEL_FALSE:
error_string = SIXEL_MESSAGE_FALSE;
break;
default:
error_string = SIXEL_MESSAGE_UNEXPECTED;
break;
}
break;
default:
error_string = SIXEL_MESSAGE_UNEXPECTED;
break;
}
return error_string;
}
#if HAVE_TESTS
static int
test1(void)
{
int nret = EXIT_FAILURE;
char const *message;
message = sixel_helper_format_error(SIXEL_OK);
if (strcmp(message, SIXEL_MESSAGE_OK) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_INTERRUPTED);
if (strcmp(message, SIXEL_MESSAGE_INTERRUPTED) != 0) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test1");
return nret;
}
static int
test2(void)
{
int nret = EXIT_FAILURE;
char const *message;
message = sixel_helper_format_error(SIXEL_BAD_ALLOCATION);
if (strcmp(message, SIXEL_MESSAGE_BAD_ALLOCATION) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_BAD_ARGUMENT);
if (strcmp(message, SIXEL_MESSAGE_BAD_ARGUMENT) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_BAD_INPUT);
if (strcmp(message, SIXEL_MESSAGE_BAD_INPUT) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_RUNTIME_ERROR);
if (strcmp(message, SIXEL_MESSAGE_RUNTIME_ERROR) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_LOGIC_ERROR);
if (strcmp(message, SIXEL_MESSAGE_LOGIC_ERROR) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_NOT_IMPLEMENTED);
if (strcmp(message, SIXEL_MESSAGE_NOT_IMPLEMENTED) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_FEATURE_ERROR);
if (strcmp(message, SIXEL_MESSAGE_FEATURE_ERROR) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_LIBC_ERROR);
if (strcmp(message, SIXEL_MESSAGE_UNEXPECTED) == 0) {
goto error;
}
#ifdef HAVE_LIBCURL
message = sixel_helper_format_error(SIXEL_CURL_ERROR);
if (strcmp(message, SIXEL_MESSAGE_UNEXPECTED) == 0) {
goto error;
}
#endif
#if HAVE_JPEG
message = sixel_helper_format_error(SIXEL_JPEG_ERROR);
if (strcmp(message, SIXEL_MESSAGE_JPEG_ERROR) != 0) {
goto error;
}
#endif
#if HAVE_LIBPNG
message = sixel_helper_format_error(SIXEL_PNG_ERROR);
if (strcmp(message, SIXEL_MESSAGE_PNG_ERROR) != 0) {
goto error;
}
#endif
#if HAVE_GD
message = sixel_helper_format_error(SIXEL_GD_ERROR);
if (strcmp(message, SIXEL_MESSAGE_GD_ERROR) != 0) {
goto error;
}
#endif
#if HAVE_GDK_PIXBUF2
message = sixel_helper_format_error(SIXEL_GDK_ERROR);
if (strcmp(message, SIXEL_MESSAGE_GDK_ERROR) != 0) {
goto error;
}
#endif
message = sixel_helper_format_error(SIXEL_STBI_ERROR);
if (strcmp(message, SIXEL_MESSAGE_STBI_ERROR) != 0) {
goto error;
}
message = sixel_helper_format_error(SIXEL_STBIW_ERROR);
if (strcmp(message, SIXEL_MESSAGE_STBIW_ERROR) != 0) {
goto error;
}
return EXIT_SUCCESS;
error:
perror("test2");
return nret;
}
SIXELAPI int
sixel_status_tests_main(void)
{
int nret = EXIT_FAILURE;
size_t i;
typedef int (* testcase)(void);
static testcase const testcases[] = {
test1,
test2,
};
for (i = 0; i < sizeof(testcases) / sizeof(testcase); ++i) {
nret = testcases[i]();
if (nret != EXIT_SUCCESS) {
goto error;
}
}
nret = EXIT_SUCCESS;
error:
return nret;
}
#endif /* HAVE_TESTS */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2014-2016 Hayaki Saito
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBSIXEL_STATUS_H
#define LIBSIXEL_STATUS_H
#ifdef __cplusplus
extern "C" {
#endif
#if HAVE_TESTS
int
sixel_status_tests_main(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* LIBSIXEL_STATUS_H */
/* emacs Local Variables: */
/* emacs mode: c */
/* emacs tab-width: 4 */
/* emacs indent-tabs-mode: nil */
/* emacs c-basic-offset: 4 */
/* emacs End: */
/* vim: set expandtab ts=4 sts=4 sw=4 : */
/* EOF */
+1635
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
{
"home": "https://github.com/ibireme/yyjson",
"license": "MIT ( embed in source )",
"version": "0.12.0",
"version": "0.13.0",
"author": "ibireme"
}
+700 -285
View File
File diff suppressed because it is too large Load Diff
+911 -674
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -8,7 +8,10 @@ typedef struct FFPlatformSysinfo {
FFstrbuf release;
FFstrbuf version;
FFstrbuf architecture;
uint32_t pageSize;
// The base-2 logarithm of the memory page size, i.e. a page is `1 << pageSizeShift` bytes.
// Page sizes are powers of two on every supported platform. Storing the exponent instead of
// the byte count keeps page count arithmetic in 64 bits and makes the invariant explicit.
uint32_t pageSizeShift;
} FFPlatformSysinfo;
typedef struct FFPlatform {
@@ -31,6 +34,10 @@ typedef struct FFPlatform {
FFstrbuf userShell;
FFPlatformSysinfo sysinfo;
#if _WIN32
uint32_t initCP; // The code page used by the console when the program started
#endif
} FFPlatform;
void ffPlatformInit(FFPlatform* platform);
+48
View File
@@ -0,0 +1,48 @@
#pragma once
#include "fastfetch.h"
// A cache for a value that is built at most once per generation.
//
// The value itself is owned by the entry owner (usually a file scope `static`); the entry only
// remembers whether that value is still valid and knows how to drop it. `--dynamic-interval`
// starts a new generation for every round, dropping all the values that have been built so far,
// so the modules re-detect them instead of replaying the first round's snapshot.
//
// An entry registers itself the first time it is used. There is therefore no central list to keep
// in sync, and a cache cannot be forgotten in it. Do not use this type for state that is carried
// across calls to derive a rate (cpuusage, diskio, netio, top): that is a baseline rather than a
// snapshot, and dropping it makes the first sample of a round read as zero.
//
// The storage pointed to by `storage` must stay valid for the whole run; only the value behind it
// is dropped by an invalidation.
//
// Not thread safe: entries are only touched from a single thread, on a frame boundary, while the
// modules are not running.
typedef struct FFcacheEntry {
const char* name; // For diagnostics.
void* storage; // Owned by the entry owner. May be nullptr.
void (*init)(void* storage); // Optional. Runs whenever the entry is stale.
void (*destroy)(void* storage); // Optional. Must be idempotent, and tolerate a partially initialized storage.
bool initialized;
bool registered;
struct FFcacheEntry* next; // Internal: registry link.
} FFcacheEntry;
// Returns `entry->storage`, running `init` on it first when the entry is stale. The entry is marked
// initialized before `init` runs, so a call made from within `init` returns the partially built
// value instead of recursing.
[[gnu::nonnull(1)]] void* ffCacheGet(FFcacheEntry* entry);
// Staleness test for entries whose initialization needs arguments that are not part of the cache
// identity (such as the cover file request of `ffDetectMedia`) and therefore cannot live behind
// `init(void*)`. Returns true exactly once per generation: the caller must then build the value
// itself.
[[gnu::nonnull(1), nodiscard]] bool ffCacheBeginInit(FFcacheEntry* entry);
// Drops the cached value of one entry, so that the next request builds it again. Idempotent, and
// safe on an entry that has never been used.
[[gnu::nonnull(1)]] void ffCacheInvalidate(FFcacheEntry* entry);
// Drops every value that has been built so far. Called once per `--dynamic-interval` round.
void ffCacheInvalidateAll(void);
+52 -24
View File
@@ -1,11 +1,10 @@
#pragma once
#include "common/attributes.h"
#include <stdbool.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#define FF_LIST_DEFAULT_ALLOC 16
@@ -15,43 +14,43 @@ typedef struct FFlist {
uint32_t capacity;
} FFlist;
void* ffListAdd(FFlist* list, uint32_t elementSize);
// Removes the first element, and copy its value to `*result`
bool ffListShift(FFlist* list, uint32_t elementSize, void* __restrict result);
// `result` is only written when the list is not empty, so it may be null for an empty list
[[gnu::nonnull(1), nodiscard]] bool ffListShift(FFlist* list, uint32_t elementSize, void* __restrict result);
// Removes the last element, and copy its value to `*result`
bool ffListPop(FFlist* list, uint32_t elementSize, void* __restrict result);
[[gnu::nonnull(1), nodiscard]] bool ffListPop(FFlist* list, uint32_t elementSize, void* __restrict result);
static inline void ffListInit(FFlist* list) {
[[gnu::nonnull(1)]] static inline void ffListInit(FFlist* list) {
list->capacity = 0;
list->length = 0;
list->data = NULL;
list->data = nullptr;
}
static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) {
[[gnu::nonnull(1)]] static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) {
ffListInit(list);
list->capacity = capacity;
list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t) capacity * elementSize);
list->data = __builtin_expect(capacity == 0, 0) ? nullptr : (uint8_t*) malloc((size_t) capacity * elementSize);
}
FF_A_NODISCARD static inline FFlist ffListCreate() {
[[nodiscard]] static inline FFlist ffListCreate() {
FFlist result;
ffListInit(&result);
return result;
}
FF_A_NODISCARD static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) {
[[nodiscard]] static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) {
FFlist result;
ffListInitA(&result, elementSize, capacity);
return result;
}
FF_A_NODISCARD static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) {
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) {
assert(list->capacity > index);
return list->data + (index * elementSize);
}
FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
// Not `pure`: `compFunc` is caller-supplied and may have side effects
[[gnu::nonnull(1, 3, 4), nodiscard]] static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
for (uint32_t i = 0; i < list->length; i++) {
if (compFunc(ffListGet(list, elementSize, i), compElement)) {
return i;
@@ -61,16 +60,17 @@ FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, u
return list->length;
}
FF_A_NODISCARD static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
// Not `pure`, same reason as ffListFirstIndexComp
[[gnu::nonnull(1, 3, 4), nodiscard]] static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
return ffListFirstIndexComp(list, elementSize, compElement, compFunc) != list->length;
}
static inline void ffListSort(FFlist* list, uint32_t elementSize, int (*compar)(const void*, const void*)) {
[[gnu::nonnull(1, 3)]] static inline void ffListSort(FFlist* list, uint32_t elementSize, int (*compar)(const void*, const void*)) {
qsort(list->data, list->length, elementSize, compar);
}
// Move the contents of `src` into `list`, and left `src` empty
static inline void ffListInitMove(FFlist* list, FFlist* src) {
[[gnu::nonnull(1)]] static inline void ffListInitMove(FFlist* list, FFlist* src) {
if (src) {
list->capacity = src->capacity;
list->length = src->length;
@@ -81,7 +81,7 @@ static inline void ffListInitMove(FFlist* list, FFlist* src) {
}
}
static inline void ffListDestroy(FFlist* list) {
[[gnu::nonnull(1)]] static inline void ffListDestroy(FFlist* list) {
if (!list->data) {
return;
}
@@ -89,14 +89,14 @@ static inline void ffListDestroy(FFlist* list) {
// Avoid free-after-use. These 3 assignments are cheap so don't remove them
list->capacity = list->length = 0;
free(list->data);
list->data = NULL;
list->data = nullptr;
}
static inline void ffListClear(FFlist* list) {
[[gnu::nonnull(1)]] static inline void ffListClear(FFlist* list) {
list->length = 0;
}
static inline void ffListReserve(FFlist* list, uint32_t elementSize, uint32_t newCapacity) {
[[gnu::nonnull(1)]] static inline void ffListReserve(FFlist* list, uint32_t elementSize, uint32_t newCapacity) {
if (__builtin_expect(newCapacity <= list->capacity, false)) {
return;
}
@@ -105,12 +105,34 @@ static inline void ffListReserve(FFlist* list, uint32_t elementSize, uint32_t ne
list->capacity = newCapacity;
}
[[gnu::nonnull(1)]] static inline void* ffListAdd(FFlist* list, uint32_t elementSize) {
if (__builtin_expect(list->length == list->capacity, false)) {
ffListReserve(list, elementSize, list->capacity == 0 ? FF_LIST_DEFAULT_ALLOC : list->capacity * 2);
}
++list->length;
return ffListGet(list, elementSize, list->length - 1);
}
[[gnu::nonnull(1)]] static inline void ffListRemoveAt(FFlist* list, uint32_t elementSize, uint32_t index) {
assert(list->length > index);
memmove(list->data + (index * elementSize), list->data + ((index + 1) * elementSize), (size_t) (list->length - index - 1) * elementSize);
--list->length;
}
[[gnu::nonnull(1, 4)]] static inline void ffListInsertAt(FFlist* list, uint32_t elementSize, uint32_t index, const void* element) {
assert(list->length >= index);
ffListAdd(list, elementSize);
memmove(list->data + ((index + 1) * elementSize), list->data + (index * elementSize), (size_t) (list->length - index - 1) * elementSize);
memcpy(list->data + (index * elementSize), element, elementSize);
}
#define FF_LIST_FOR_EACH(itemType, itemVarName, listVar) \
for (itemType* itemVarName = (itemType*) (listVar).data; \
itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \
++itemVarName)
#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy)
#define FF_LIST_AUTO_DESTROY [[gnu::cleanup(ffListDestroy)]] FFlist
#define FF_LIST_GET(itemType, listVar, index) \
({ \
@@ -120,6 +142,12 @@ static inline void ffListReserve(FFlist* list, uint32_t elementSize, uint32_t ne
#define FF_LIST_ADD(itemType, listVar) (itemType*) ffListAdd(&(listVar), (uint32_t) sizeof(itemType))
#define FF_LIST_REMOVE_AT(itemType, listVar, index) \
ffListRemoveAt(&(listVar), (uint32_t) sizeof(itemType), (index))
#define FF_LIST_INSERT_AT(itemType, listVar, index, pElement) \
ffListInsertAt(&(listVar), (uint32_t) sizeof(itemType), (index), (pElement))
#define FF_LIST_FIRST(itemType, listVar) FF_LIST_GET(itemType, listVar, 0)
#define FF_LIST_LAST(itemType, listVar) \
({ \
@@ -129,9 +157,9 @@ static inline void ffListReserve(FFlist* list, uint32_t elementSize, uint32_t ne
#define FF_LIST_CONTAINS(listVar, pCompElement, compFunc) \
({ \
typedef __typeof__(*(pCompElement)) compElementType; \
typedef typeof(*(pCompElement)) compElementType; \
typedef bool compFuncType(const compElementType*, const compElementType*); \
static_assert(__builtin_types_compatible_p(__typeof__(compFunc), compFuncType), "Incompatible callback function"); \
static_assert(__builtin_types_compatible_p(typeof(compFunc), compFuncType), "Incompatible callback function"); \
ffListContains(&(listVar), (uint32_t) sizeof(*(pCompElement)), (pCompElement), (bool (*)(const void*, const void*)) compFunc); \
})
+286 -185
View File
@@ -1,7 +1,5 @@
#pragma once
#include "common/attributes.h"
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -9,6 +7,8 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "common/memrchr.h"
#include "common/arrutil.h"
#ifdef FF_USE_SYSTEM_YYJSON
#include <yyjson.h>
@@ -24,6 +24,29 @@ __stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch);
#define FASTFETCH_STRBUF_DEFAULT_ALLOC 32
// ---------------------------------------------------------------------------------------------
// Contract attributes used throughout this header:
//
// `gnu::pure` marks a function that reads memory (through its arguments and through globals) but
// writes nothing observable, so the compiler may cache and reorder calls to it. It is applied to
// the comparison / search accessors, and deliberately NOT to:
// * the `To*` converters -- `strtod` / `strtoull` / `strtoll` write `errno`;
// * `ffStrbufEndsWithFn` -- the caller-supplied `fn` may have side effects;
// * `ffStrbufWriteTo` / `ffStrbufPutTo` -- they write to a `FILE*`.
//
// `gnu::nonnull(N)` is added wherever the function dereferences argument N unconditionally. The
// two cannot be combined with a null check: clang reports `-Wtautological-pointer-compare` /
// `-Wpointer-bool-conversion` (both in `-Wall`) when a `nonnull` parameter is compared against
// null, so a redundant `assert(p != nullptr)` is dropped in favour of the attribute. Asserts that
// state something `nonnull` cannot express -- pointer aliasing (`value != strbuf`), index ranges
// (`start <= strbuf->length`), or a non-pointer invariant -- are kept.
//
// `nodiscard` is NOT applied to the "was the buffer modified" boolean returns
// (`ffStrbufSubstr*`, `ffStrbufRemoveSubstr`, `ffStrbufEnsureEndsWithC`, ...). Ignoring that
// result is a normal, intended use of those functions -- `ffStrbufSubstrBefore` alone has 153 call
// sites and ~147 of them discard the result -- so `nodiscard` would only produce noise.
// ---------------------------------------------------------------------------------------------
// static string (allocated == 0), chars points to a string literal
// dynamic string (allocated > 0), chars points to a heap allocated buffer
typedef struct FFstrbuf {
@@ -32,82 +55,70 @@ typedef struct FFstrbuf {
char* chars;
} FFstrbuf;
static inline void ffStrbufInit(FFstrbuf* strbuf);
void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate);
void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments);
void ffStrbufInitMoveNS(FFstrbuf* strbuf, uint32_t length, char* heapStr);
[[gnu::nonnull(1)]] static inline void ffStrbufInit(FFstrbuf* strbuf);
[[gnu::nonnull(1)]] void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate);
[[gnu::nonnull(1, 2), gnu::format(printf, 2, 0)]] void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments);
[[gnu::nonnull(1, 3)]] void ffStrbufInitMoveNS(FFstrbuf* strbuf, uint32_t length, char* heapStr);
[[gnu::format(printf, 2, 3), gnu::nonnull(1, 2)]] void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...);
[[gnu::format(printf, 1, 2), gnu::nonnull(1), nodiscard]] FFstrbuf ffStrbufCreateF(const char* format, ...);
void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free);
void ffStrbufEnsureFixedLengthFree(FFstrbuf* strbuf, uint32_t free);
[[gnu::nonnull(1)]] void ffStrbufEnsureFixedLengthFree(FFstrbuf* strbuf, uint32_t free);
[[gnu::nonnull(1)]] void ffStrbufEnsureFreeNoCheck(FFstrbuf* strbuf, uint32_t free);
void ffStrbufClear(FFstrbuf* strbuf);
[[gnu::nonnull(1)]] static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value);
[[gnu::nonnull(1, 3)]] void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int));
[[gnu::format(printf, 2, 3), gnu::nonnull(1, 2)]] void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...);
[[gnu::nonnull(1, 2), gnu::format(printf, 2, 0)]] void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments);
// Returns the pointer to the terminator, or nullptr if `value` was nullptr; callers are free to
// ignore it, so not `nodiscard`.
[[gnu::nonnull(1)]] const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char until);
static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value);
void ffStrbufAppendC(FFstrbuf* strbuf, char c);
void ffStrbufAppendNC(FFstrbuf* strbuf, uint32_t num, char c);
void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value);
void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int));
FF_A_PRINTF(2, 3) void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...);
void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments);
const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char until);
[[gnu::nonnull(1)]] void ffStrbufPrependNS(FFstrbuf* strbuf, uint32_t length, const char* value);
[[gnu::nonnull(1)]] void ffStrbufPrependC(FFstrbuf* strbuf, char c);
void ffStrbufPrependNS(FFstrbuf* strbuf, uint32_t length, const char* value);
void ffStrbufPrependC(FFstrbuf* strbuf, char c);
void ffStrbufInsertNC(FFstrbuf* strbuf, uint32_t index, uint32_t num, char c);
[[gnu::nonnull(1)]] void ffStrbufInsertNC(FFstrbuf* strbuf, uint32_t index, uint32_t num, char c);
// Clear the content of strbuf and set new value
// NOTE: Unlike ffStrbufAppend*, ffStrbufSet* functions may NOT reserve extra space
void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value);
void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value);
FF_A_PRINTF(2, 3) void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...);
[[gnu::nonnull(1, 2)]] void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value);
[[gnu::nonnull(1, 3)]] void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value);
[[gnu::format(printf, 2, 3), gnu::nonnull(1, 2)]] void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...);
void ffStrbufTrimLeft(FFstrbuf* strbuf, char c);
void ffStrbufTrimRight(FFstrbuf* strbuf, char c);
void ffStrbufTrimLeftSpace(FFstrbuf* strbuf);
void ffStrbufTrimRightSpace(FFstrbuf* strbuf);
[[gnu::nonnull(1)]] void ffStrbufTrimLeft(FFstrbuf* strbuf, char c);
[[gnu::nonnull(1)]] void ffStrbufTrimRight(FFstrbuf* strbuf, char c);
[[gnu::nonnull(1)]] void ffStrbufTrimLeftSpace(FFstrbuf* strbuf);
[[gnu::nonnull(1)]] void ffStrbufTrimRightSpace(FFstrbuf* strbuf);
bool ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endIndex);
void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str);
void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]);
[[gnu::nonnull(1)]] bool ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endIndex);
[[gnu::nonnull(1, 2)]] void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str);
// `strings` is only dereferenced when `numStrings > 0`, so it is intentionally not `nonnull(3)`
[[gnu::nonnull(1)]] void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]);
FF_A_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
FF_A_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str);
FF_A_NODISCARD uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c);
void ffStrbufReplaceAllC(FFstrbuf* strbuf, char find, char replace);
[[gnu::nonnull(1)]] void ffStrbufReplaceAllC(FFstrbuf* strbuf, char find, char replace);
// Returns true if the strbuf is modified
bool ffStrbufSubstrBefore(FFstrbuf* strbuf, uint32_t index);
bool ffStrbufSubstrAfter(FFstrbuf* strbuf, uint32_t index); // Not including the index
bool ffStrbufSubstrAfterFirstC(FFstrbuf* strbuf, char c);
bool ffStrbufSubstrAfterFirstS(FFstrbuf* strbuf, const char* str);
bool ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, char c);
bool ffStrbufSubstr(FFstrbuf* strbuf, uint32_t start, uint32_t end);
[[gnu::nonnull(1)]] bool ffStrbufSubstrBefore(FFstrbuf* strbuf, uint32_t index);
[[gnu::nonnull(1)]] bool ffStrbufSubstrAfter(FFstrbuf* strbuf, uint32_t index); // Not including the index
[[gnu::nonnull(1)]] bool ffStrbufSubstrAfterFirstC(FFstrbuf* strbuf, char c);
[[gnu::nonnull(1, 2)]] bool ffStrbufSubstrAfterFirstS(FFstrbuf* strbuf, const char* str);
[[gnu::nonnull(1)]] bool ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, char c);
[[gnu::nonnull(1)]] bool ffStrbufSubstr(FFstrbuf* strbuf, uint32_t start, uint32_t end);
FF_A_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
[[gnu::nonnull(1), gnu::pure, nodiscard]] uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end);
[[gnu::nonnull(1, 2)]] bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end);
bool ffStrbufEnsureEndsWithC(FFstrbuf* strbuf, char c);
[[gnu::nonnull(1)]] bool ffStrbufEnsureEndsWithC(FFstrbuf* strbuf, char c);
void ffStrbufWriteTo(const FFstrbuf* strbuf, FILE* file);
void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file);
FF_A_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue);
FF_A_NODISCARD int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue);
FF_A_NODISCARD uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue);
void ffStrbufUpperCase(FFstrbuf* strbuf);
void ffStrbufLowerCase(FFstrbuf* strbuf);
[[gnu::nonnull(1)]] void ffStrbufUpperCase(FFstrbuf* strbuf);
[[gnu::nonnull(1)]] void ffStrbufLowerCase(FFstrbuf* strbuf);
// Function alters the buffer to extract lines or delimited segments (replaces the delimiter with '\0')
// so that buffer MUST be heap allocated (NOT a static string)
// `lineptr` must be `NULL` and `n` MUST be `0` for the first call
// `lineptr` must be `nullptr` and `n` MUST be `0` for the first call
// Caller MUST NOT free `*lineptr`
bool ffStrbufGetdelim(char** lineptr, size_t* n, char delimiter, FFstrbuf* buffer);
void ffStrbufGetdelimRestore(char** lineptr, size_t* n, char delimiter, FFstrbuf* buffer);
[[gnu::nonnull(1, 2, 4)]] bool ffStrbufGetdelim(char** lineptr, size_t* n, char delimiter, FFstrbuf* buffer);
[[gnu::nonnull(1, 2, 4)]] void ffStrbufGetdelimRestore(char** lineptr, size_t* n, char delimiter, FFstrbuf* buffer);
/**
* @brief Read a line from a FFstrbuf.
@@ -117,7 +128,7 @@ void ffStrbufGetdelimRestore(char** lineptr, size_t* n, char delimiter, FFstrbuf
* @param[in,out] lineptr The pointer to a pointer that will be set to the start of the line
(points to buffer's internal memory address to avoid memory allocation and copy).
MUST NOT be freed by the caller, unlike `getline(3)`.
* MUST be NULL for the first call.
* MUST be nullptr for the first call.
* @param[in,out] n The pointer to the size of the buffer of lineptr.
MUST be 0 for the first call.
* @param[in] buffer The buffer to read from.
@@ -125,37 +136,39 @@ void ffStrbufGetdelimRestore(char** lineptr, size_t* n, char delimiter, FFstrbuf
*
* @return true if a line has been read, false if the end of the buffer has been reached.
*/
static inline bool ffStrbufGetline(char** lineptr, size_t* n, FFstrbuf* buffer) {
[[gnu::nonnull(1, 2, 3), nodiscard]] static inline bool ffStrbufGetline(char** lineptr, size_t* n, FFstrbuf* buffer) {
return ffStrbufGetdelim(lineptr, n, '\n', buffer);
}
/**
* @brief Restore the end of a line that was modified by ffStrbufGetline.
* @warning This function should be called before breaking an ffStrbufGetline loop if `buffer` will be used later.
*/
static inline void ffStrbufGetlineRestore(char** lineptr, size_t* n, FFstrbuf* buffer) {
[[gnu::nonnull(1, 2, 3)]] static inline void ffStrbufGetlineRestore(char** lineptr, size_t* n, FFstrbuf* buffer) {
ffStrbufGetdelimRestore(lineptr, n, '\n', buffer);
}
bool ffStrbufRemoveDupWhitespaces(FFstrbuf* strbuf);
bool ffStrbufMatchSeparatedNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
bool ffStrbufMatchSeparatedIgnCaseNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
bool ffStrbufSeparatedContainNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
bool ffStrbufSeparatedContainIgnCaseNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
[[gnu::nonnull(1)]] bool ffStrbufRemoveDupWhitespaces(FFstrbuf* strbuf);
// `comp` is only dereferenced when `compLength > 0` in the first pair, and is never dereferenced
// when `strbuf` is empty in the second pair, so neither takes `nonnull(3)`
[[gnu::nonnull(1), gnu::pure, nodiscard]] bool ffStrbufMatchSeparatedNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
[[gnu::nonnull(1), gnu::pure, nodiscard]] bool ffStrbufMatchSeparatedIgnCaseNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
[[gnu::nonnull(1), gnu::pure, nodiscard]] bool ffStrbufSeparatedContainNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
[[gnu::nonnull(1), gnu::pure, nodiscard]] bool ffStrbufSeparatedContainIgnCaseNS(const FFstrbuf* strbuf, uint32_t compLength, const char* comp, char separator);
int ffStrbufAppendUtf32CodePoint(FFstrbuf* strbuf, uint32_t codepoint);
[[gnu::nonnull(1)]] int ffStrbufAppendUtf32CodePoint(FFstrbuf* strbuf, uint32_t codepoint);
void ffStrbufAppendSInt(FFstrbuf* strbuf, int64_t value);
void ffStrbufAppendUInt(FFstrbuf* strbuf, uint64_t value);
[[gnu::nonnull(1)]] void ffStrbufAppendSInt(FFstrbuf* strbuf, int64_t value);
[[gnu::nonnull(1)]] void ffStrbufAppendUInt(FFstrbuf* strbuf, uint64_t value);
// Appends a double value to the string buffer with the specified precision (0~15).
// if `precision < 0`, let yyjson decide the precision
void ffStrbufAppendDouble(FFstrbuf* strbuf, double value, int8_t precision, bool trailingZeros);
[[gnu::nonnull(1)]] void ffStrbufAppendDouble(FFstrbuf* strbuf, double value, int8_t precision, bool trailingZeros);
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) {
FFstrbuf strbuf;
ffStrbufInitA(&strbuf, allocate);
return strbuf;
}
static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict src) {
[[gnu::nonnull(1, 2)]] static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict src) {
if (src->allocated == 0) { // static string
*strbuf = *src;
} else {
@@ -164,14 +177,14 @@ static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf*
}
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) {
[[gnu::nonnull(1), nodiscard]] static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) {
FFstrbuf strbuf;
ffStrbufInitCopy(&strbuf, src);
return strbuf;
}
// Move the content of `src` into `strbuf`, and left `src` empty
static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) {
[[gnu::nonnull(1)]] static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) {
if (src) {
*strbuf = *src;
ffStrbufInit(src);
@@ -180,43 +193,18 @@ static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) {
}
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) {
FFstrbuf strbuf;
ffStrbufInitMove(&strbuf, src);
return strbuf;
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateVF(const char* format, va_list arguments) {
FFstrbuf strbuf;
ffStrbufInitVF(&strbuf, format, arguments);
return strbuf;
}
FF_A_PRINTF(2, 3) static inline void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) {
va_list arguments;
va_start(arguments, format);
ffStrbufInitVF(strbuf, format, arguments);
va_end(arguments);
}
FF_A_PRINTF(1, 2) FF_A_NODISCARD static inline FFstrbuf
ffStrbufCreateF(const char* format, ...) {
FFstrbuf strbuf;
va_list arguments;
va_start(arguments, format);
ffStrbufInitVF(&strbuf, format, arguments);
va_end(arguments);
return strbuf;
}
static inline void ffStrbufInitMoveS(FFstrbuf* strbuf, char* heapStr) {
[[gnu::nonnull(1, 2)]] static inline void ffStrbufInitMoveS(FFstrbuf* strbuf, char* heapStr) {
ffStrbufInitMoveNS(strbuf, (uint32_t) strlen(heapStr), heapStr);
}
// Despite the name, this function resets strbuf to the initial/unallocated state
static inline void ffStrbufDestroy(FFstrbuf* strbuf) {
[[gnu::nonnull(1)]] static inline void ffStrbufDestroy(FFstrbuf* strbuf) {
if (strbuf->allocated > 0) {
free(strbuf->chars);
}
@@ -224,8 +212,7 @@ static inline void ffStrbufDestroy(FFstrbuf* strbuf) {
ffStrbufInit(strbuf);
}
FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
assert(strbuf != NULL);
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
if (strbuf->allocated == 0) {
return 0;
}
@@ -233,23 +220,83 @@ FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
return strbuf->allocated - strbuf->length - 1; // - 1 for the null byte
}
static inline void ffStrbufRecalculateLength(FFstrbuf* strbuf) {
[[gnu::nonnull(1)]] static inline void ffStrbufEnsureFree(FFstrbuf* strbuf, uint32_t free) {
if (__builtin_expect(free == 0, false)) {
if (__builtin_expect(!(strbuf->allocated == 0 && strbuf->length > 0), true)) {
return;
}
} else {
if (__builtin_expect(ffStrbufGetFree(strbuf) >= free, true)) {
return;
}
}
ffStrbufEnsureFreeNoCheck(strbuf, free);
}
[[gnu::nonnull(1)]] static inline void ffStrbufClear(FFstrbuf* strbuf) {
extern char* CHAR_NULL_PTR;
if (strbuf->allocated == 0) {
strbuf->chars = CHAR_NULL_PTR;
} else {
strbuf->chars[0] = '\0';
}
strbuf->length = 0;
}
[[gnu::nonnull(1)]] static inline void ffStrbufAppendC(FFstrbuf* strbuf, char c) {
ffStrbufEnsureFree(strbuf, 1);
strbuf->chars[strbuf->length++] = c;
strbuf->chars[strbuf->length] = '\0';
}
[[gnu::nonnull(1)]] static inline void ffStrbufAppendNC(FFstrbuf* strbuf, uint32_t num, char c) {
if (__builtin_expect(num == 0, false)) {
return;
}
ffStrbufEnsureFree(strbuf, num);
memset(&strbuf->chars[strbuf->length], c, num);
strbuf->length += num;
strbuf->chars[strbuf->length] = '\0';
}
[[gnu::nonnull(1)]] static inline void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value) {
if (__builtin_expect(value == nullptr || length == 0, false)) {
return;
}
ffStrbufEnsureFree(strbuf, length);
memcpy(&strbuf->chars[strbuf->length], value, length);
strbuf->length += length;
strbuf->chars[strbuf->length] = '\0';
}
[[gnu::nonnull(1)]] static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value) {
assert(value != strbuf);
if (value == nullptr) {
return;
}
ffStrbufAppendNS(strbuf, value->length, value->chars);
}
[[gnu::nonnull(1)]] static inline void ffStrbufRecalculateLength(FFstrbuf* strbuf) {
strbuf->length = (uint32_t) strlen(strbuf->chars);
}
static inline void ffStrbufSetS(FFstrbuf* strbuf, const char* value) {
assert(strbuf != NULL);
if (value == NULL) {
// `value` may be null (clears the buffer); `strbuf` may not
[[gnu::nonnull(1)]] static inline void ffStrbufSetS(FFstrbuf* strbuf, const char* value) {
if (value == nullptr) {
ffStrbufClear(strbuf);
} else {
ffStrbufSetNS(strbuf, (uint32_t) strlen(value), value);
}
}
static inline bool ffStrbufSetJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) {
assert(strbuf != NULL);
[[gnu::nonnull(1)]] static inline bool ffStrbufSetJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) {
if (yyjson_is_str(jsonVal)) {
ffStrbufSetNS(strbuf, (uint32_t) unsafe_yyjson_get_len(jsonVal), unsafe_yyjson_get_str(jsonVal));
return true;
@@ -259,13 +306,15 @@ static inline bool ffStrbufSetJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) {
return false;
}
static inline void ffStrbufAppendS(FFstrbuf* strbuf, const char* value) {
if (value == NULL) {
[[gnu::nonnull(1)]] static inline void ffStrbufAppendS(FFstrbuf* strbuf, const char* value) {
if (value == nullptr) {
return;
}
ffStrbufAppendNS(strbuf, (uint32_t) strlen(value), value);
}
// Returns whether `jsonVal` was a string. Callers routinely pre-check with `yyjson_is_str`, so the
// result is not `nodiscard`.
static inline bool ffStrbufAppendJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) {
if (yyjson_is_str(jsonVal)) {
ffStrbufAppendNS(strbuf, (uint32_t) unsafe_yyjson_get_len(jsonVal), unsafe_yyjson_get_str(jsonVal));
@@ -274,13 +323,13 @@ static inline bool ffStrbufAppendJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal)
return false;
}
static inline void ffStrbufInit(FFstrbuf* strbuf) {
[[gnu::nonnull(1)]] static inline void ffStrbufInit(FFstrbuf* strbuf) {
extern char* CHAR_NULL_PTR;
strbuf->allocated = strbuf->length = 0;
strbuf->chars = CHAR_NULL_PTR;
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreate(void) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreate(void) {
FFstrbuf strbuf;
ffStrbufInit(&strbuf);
return strbuf;
@@ -297,139 +346,159 @@ static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) {
strbuf->chars = (char*) str;
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateStatic(const char* str) {
FFstrbuf strbuf;
ffStrbufInitStatic(&strbuf, str);
return strbuf;
}
static inline void ffStrbufSetStatic(FFstrbuf* strbuf, const char* value) {
[[gnu::nonnull(1)]] static inline void ffStrbufSetStatic(FFstrbuf* strbuf, const char* value) {
if (strbuf->allocated > 0) {
free(strbuf->chars);
}
if (value != NULL) {
if (value != nullptr) {
ffStrbufInitStatic(strbuf, value);
} else {
ffStrbufInit(strbuf);
}
}
static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* str) {
[[gnu::nonnull(1)]] static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* str) {
ffStrbufInit(strbuf);
ffStrbufAppendNS(strbuf, length, str);
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) {
FFstrbuf strbuf;
ffStrbufInitNS(&strbuf, length, str);
return strbuf;
}
// Returns whether `jsonVal` was a string; not `nodiscard`, same reason as ffStrbufAppendJsonVal
static inline bool ffStrbufInitJsonVal(FFstrbuf* strbuf, yyjson_val* jsonVal) {
ffStrbufInit(strbuf);
return ffStrbufAppendJsonVal(strbuf, jsonVal);
}
static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) {
[[gnu::nonnull(1)]] static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) {
ffStrbufInit(strbuf);
ffStrbufAppendS(strbuf, str);
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateS(const char* str) {
FFstrbuf strbuf;
ffStrbufInitS(&strbuf, str);
return strbuf;
}
static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value) {
assert(value != strbuf);
if (value == NULL) {
return;
}
ffStrbufAppendNS(strbuf, value->length, value->chars);
}
static inline void ffStrbufPrepend(FFstrbuf* strbuf, FFstrbuf* value) {
if (value == NULL) {
[[gnu::nonnull(1)]] static inline void ffStrbufPrepend(FFstrbuf* strbuf, FFstrbuf* value) {
if (value == nullptr) {
return;
}
ffStrbufPrependNS(strbuf, value->length, value->chars);
}
static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) {
if (value == NULL) {
[[gnu::nonnull(1)]] static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) {
if (value == nullptr) {
return;
}
ffStrbufPrependNS(strbuf, (uint32_t) strlen(value), value);
}
static inline FF_A_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
uint32_t length = strbuf->length > comp->length ? comp->length : strbuf->length;
return memcmp(strbuf->chars, comp->chars, length + 1);
}
static inline FF_A_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
return ffStrbufComp(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) {
return strcmp(strbuf->chars, comp);
}
static inline FF_A_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) {
return ffStrbufCompS(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) {
return strcasecmp(strbuf->chars, comp);
}
static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) {
return ffStrbufIgnCaseCompS(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
return ffStrbufIgnCaseCompS(strbuf, comp->chars);
}
static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
return ffStrbufIgnCaseComp(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) {
return memchr(strbuf->chars, c, strbuf->length) != NULL;
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline bool ffStrbufContainC(const FFstrbuf* strbuf, char c) {
return memchr(strbuf->chars, c, strbuf->length) != nullptr;
}
static inline FF_A_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) {
return strstr(strbuf->chars, str) != NULL;
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) {
return strstr(strbuf->chars, str) != nullptr;
}
static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) {
return ffStrbufContainS(strbuf, str->chars);
}
static inline FF_A_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) {
return strcasestr(strbuf->chars, str) != NULL;
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) {
return strcasestr(strbuf->chars, str) != nullptr;
}
static inline FF_A_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) {
return ffStrbufContainIgnCaseS(strbuf, str->chars);
}
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) {
assert(start <= strbuf->length);
const char* ptr = (const char*) memchr(strbuf->chars + start, c, strbuf->length - start);
return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length;
}
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline bool ffStrbufContainAnyC(const FFstrbuf* strbuf, const char* cs) {
assert(cs != nullptr);
return strpbrk(strbuf->chars, cs) != nullptr;
}
[[gnu::nonnull(1, 3), gnu::pure, nodiscard]] static inline uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str) {
assert(start <= strbuf->length);
const char* ptr = strstr(strbuf->chars + start, str);
return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length;
}
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c) {
assert(start <= strbuf->length);
const char* ptr = (const char*) memrchr(strbuf->chars, c, start + 1);
return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length;
}
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) {
return ffStrbufNextIndexC(strbuf, 0, c);
}
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) {
return ffStrbufNextIndexS(strbuf, 0, searched->chars);
}
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) {
return ffStrbufNextIndexS(strbuf, 0, str);
}
static inline FF_A_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) {
if (strbuf->length == 0) {
return 0;
}
@@ -437,19 +506,19 @@ static inline FF_A_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf,
return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c);
}
static inline bool ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1)]] static inline bool ffStrbufSubstrBeforeFirstC(FFstrbuf* strbuf, char c) {
return ffStrbufSubstrBefore(strbuf, ffStrbufFirstIndexC(strbuf, c));
}
static inline bool ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1)]] static inline bool ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) {
return ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c));
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) {
return strbuf->chars[0] == c;
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) {
if (length > strbuf->length) {
return false;
}
@@ -457,34 +526,34 @@ static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, c
return memcmp(strbuf->chars, start, length) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) {
return ffStrbufStartsWithSN(strbuf, start, (uint32_t) strlen(start));
}
static inline FF_A_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) {
return ffStrbufStartsWithSN(strbuf, start->chars, start->length);
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) {
[[gnu::nonnull(1, 3), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) {
if (length > strbuf->length) {
return false;
}
return strncasecmp(strbuf->chars, start, length) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) {
return ffStrbufStartsWithIgnCaseNS(strbuf, (uint32_t) strlen(start), start);
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) {
return ffStrbufStartsWithIgnCaseNS(strbuf, start->length, start->chars);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) {
return strbuf->length == 0 ? false : strbuf->chars[strbuf->length - 1] == c;
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
[[gnu::nonnull(1, 3), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
if (endLength > strbuf->length) {
return false;
}
@@ -492,76 +561,108 @@ static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uin
return memcmp(strbuf->chars + strbuf->length - endLength, end, endLength) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) {
return ffStrbufEndsWithNS(strbuf, (uint32_t) strlen(end), end);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) {
// Not `pure`: the caller-supplied `fn` may have side effects
[[gnu::nonnull(1, 2), nodiscard]] static inline bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) {
return strbuf->length == 0 ? false : fn(strbuf->chars[strbuf->length - 1]);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) {
return ffStrbufEndsWithNS(strbuf, end->length, end->chars);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
[[gnu::nonnull(1, 3), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
if (endLength > strbuf->length) {
return false;
}
return strcasecmp(strbuf->chars + strbuf->length - endLength, end) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) {
return ffStrbufEndsWithIgnCaseNS(strbuf, (uint32_t) strlen(end), end);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) {
return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars);
}
static inline void ffStrbufTrim(FFstrbuf* strbuf, char c) {
[[gnu::nonnull(1)]] static inline void ffStrbufTrim(FFstrbuf* strbuf, char c) {
ffStrbufTrimRight(strbuf, c);
ffStrbufTrimLeft(strbuf, c);
}
static inline void ffStrbufTrimSpace(FFstrbuf* strbuf) {
[[gnu::nonnull(1)]] static inline void ffStrbufTrimSpace(FFstrbuf* strbuf) {
ffStrbufTrimRightSpace(strbuf);
ffStrbufTrimLeftSpace(strbuf);
}
static inline bool ffStrbufMatchSeparatedS(const FFstrbuf* strbuf, const char* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufMatchSeparatedS(const FFstrbuf* strbuf, const char* comp, char separator) {
return ffStrbufMatchSeparatedNS(strbuf, (uint32_t) strlen(comp), comp, separator);
}
static inline bool ffStrbufMatchSeparated(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufMatchSeparated(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
return ffStrbufMatchSeparatedNS(strbuf, comp->length, comp->chars, separator);
}
static inline bool ffStrbufMatchSeparatedIgnCaseS(const FFstrbuf* strbuf, const char* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufMatchSeparatedIgnCaseS(const FFstrbuf* strbuf, const char* comp, char separator) {
return ffStrbufMatchSeparatedIgnCaseNS(strbuf, (uint32_t) strlen(comp), comp, separator);
}
static inline bool ffStrbufMatchSeparatedIgnCase(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufMatchSeparatedIgnCase(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
return ffStrbufMatchSeparatedIgnCaseNS(strbuf, comp->length, comp->chars, separator);
}
static inline bool ffStrbufSeparatedContainS(const FFstrbuf* strbuf, const char* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufSeparatedContainS(const FFstrbuf* strbuf, const char* comp, char separator) {
return ffStrbufSeparatedContainNS(strbuf, (uint32_t) strlen(comp), comp, separator);
}
static inline bool ffStrbufSeparatedContain(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufSeparatedContain(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
return ffStrbufSeparatedContainNS(strbuf, comp->length, comp->chars, separator);
}
static inline bool ffStrbufSeparatedContainIgnCaseS(const FFstrbuf* strbuf, const char* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufSeparatedContainIgnCaseS(const FFstrbuf* strbuf, const char* comp, char separator) {
return ffStrbufSeparatedContainIgnCaseNS(strbuf, (uint32_t) strlen(comp), comp, separator);
}
static inline bool ffStrbufSeparatedContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
[[gnu::nonnull(1, 2), gnu::pure, nodiscard]] static inline bool ffStrbufSeparatedContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* comp, char separator) {
return ffStrbufSeparatedContainIgnCaseNS(strbuf, comp->length, comp->chars, separator);
}
// Returns true if the strbuf is modified
bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf);
[[gnu::nonnull(1, 2)]] static inline void ffStrbufWriteTo(const FFstrbuf* strbuf, FILE* file) {
fwrite(strbuf->chars, sizeof(*strbuf->chars), strbuf->length, file);
}
#define FF_STRBUF_AUTO_DESTROY FFstrbuf FF_A_CLEANUP(ffStrbufDestroy)
[[gnu::nonnull(1, 2)]] static inline void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file) {
ffStrbufWriteTo(strbuf, file);
fputc('\n', file);
}
// Not `pure`: `strtod` reads the LC_NUMERIC locale and writes errno
[[gnu::nonnull(1), nodiscard]] static inline double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue) {
char* str_end;
double result = strtod(strbuf->chars, &str_end);
return str_end == strbuf->chars ? defaultValue : result;
}
// Not `pure`: `strtoull` reads the LC_NUMERIC locale and writes errno
[[gnu::nonnull(1), nodiscard]] static inline uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue) {
char* str_end;
unsigned long long result = strtoull(strbuf->chars, &str_end, 10);
return str_end == strbuf->chars ? defaultValue : (uint64_t) result;
}
// Not `pure`: `strtoll` reads the LC_NUMERIC locale and writes errno
[[gnu::nonnull(1), nodiscard]] static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue) {
char* str_end;
long long result = strtoll(strbuf->chars, &str_end, 10);
return str_end == strbuf->chars ? defaultValue : (int64_t) result;
}
// Returns true if the strbuf is modified
[[gnu::nonnull(1)]] [[gnu::nonnull(1)]] bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf);
#define FF_STRBUF_AUTO_DESTROY [[gnu::cleanup(ffStrbufDestroy)]] FFstrbuf
#define FF_STRBUF_STATIC(str) { .allocated = 0, .length = (uint32_t) sizeof(str) - 1, .chars = str }
+45
View File
@@ -0,0 +1,45 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
// The NDK marks an API unavailable whenever it is newer than the API level the build targets, and
// fastfetch keeps running on devices below the levels it uses: AImageDecoder is 30, decoding past
// the first frame is 31, and AMediaCodec_getName is 28. CMake compiles the files that reach for
// them with -D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__ -Werror=unguarded-availability, which turns
// those entry points into weak references and makes every unguarded use an error. Two things follow:
//
// * A weak reference resolves to null on an older device, so every use needs a run-time check --
// that is FF_ANDROID_API_AT_LEAST. Unguarded, the call would jump to a null pointer.
// * Annotating a helper with FF_ANDROID_REQUIRES_API keeps the check in one place: the compiler rejects
// any call of that helper which is not itself inside a guard.
//
// https://developer.android.com/ndk/guides/using-newer-apis
#define FF_ANDROID_REQUIRES_API(x) [[clang::availability(android, introduced = x)]]
#define FF_ANDROID_API_AT_LEAST(x) __builtin_available(android x, *)
// The UIDs that hold android.permission.DUMP, which is what `dumpsys` checks before it prints
// anything: every other UID is refused on stdout and the command still exits 0, which a caller cannot
// tell apart from a command that printed nothing useful. Forking a `dumpsys` from anywhere else is
// therefore pure waste, and for some fields `dumpsys` is the only route there is.
//
// The refusal is not always the permission, and the text differs per service and per release. On
// an Android 16 device an app UID gets `Permission Denial: can't dump DisplayManagerService ... due to
// missing android.permission.DUMP permission` for `display`, but `Can't find service: battery` for
// `battery` -- that service is not in the list `dumpsys -l` shows an app at all, while `display` is.
// The UID is what decides, so one check covers both.
//
// android.os.Process.ROOT_UID and SHELL_UID. The shell UID has a second use: it owns exactly one
// package name, which the system services accept, so a process that cannot derive its own package
// can answer with that one instead.
typedef enum FFAndroidPrivilegedUid : uint32_t {
FF_ANDROID_PRIVILEGED_UID_ROOT = 0,
FF_ANDROID_PRIVILEGED_UID_SHELL = 2000,
} FFAndroidPrivilegedUid;
// Whether the given UID is allowed to run `dumpsys`. The UID is passed in rather than read here, so
// that the caller can take it from `instance.state.platform.uid` -- which is what makes the
// privileged path reachable from a test that does not run as root or as the shell.
static inline bool ffAndroidIsRootOrShell(uint32_t uid) {
return uid == FF_ANDROID_PRIVILEGED_UID_ROOT || uid == FF_ANDROID_PRIVILEGED_UID_SHELL;
}
+560
View File
@@ -0,0 +1,560 @@
#include "common/android/applabel.h"
#include "common/android/binder.h"
#include "common/android/dex.h"
#include "common/android/zip.h"
#include "common/debug.h"
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
// The package manager, and the one method that describes an app to a caller that is not the shell.
// IPackageManager has always been part of framework.jar -- it is not one of the frameworks that
// moved into an APEX -- so there is one path and no fallback.
#define FF_ANDROID_LABEL_SERVICE "package"
#define FF_ANDROID_LABEL_DESCRIPTOR "android.content.pm.IPackageManager"
#define FF_ANDROID_LABEL_JAR "/system/framework/framework.jar"
#define FF_ANDROID_LABEL_STUB "Landroid/content/pm/IPackageManager$Stub;"
#define FF_ANDROID_LABEL_TRANSACTION "TRANSACTION_getApplicationInfo"
#define FF_ANDROID_LABEL_TABLE "resources.arsc"
// The longest package name AIDL accepts is 255 characters, and the request is one string16 of it, the
// interface token, a 64-bit flags argument and a 32-bit user id.
// clang-format off
#define FF_ANDROID_LABEL_REQUEST_SIZE \
(12 + ((4 + 2 * (sizeof(FF_ANDROID_LABEL_DESCRIPTOR) - 1) + 3) & ~3u) \
+ ((4 + 2 * 255 + 3) & ~3u) + 8u + 4u)
// clang-format on
// An ApplicationInfo parcel runs 2.0 to 3.2 KB on the test device, and the surplus is what a reply
// with more split names and directories than any of those would spend.
#define FF_ANDROID_LABEL_REPLY_SIZE (16 * 1024)
// Long enough for the `/data/app/~~<22 base64 chars>==/<package>-<22 chars>==/base.apk` the platform
// installs to, with room to spare.
#define FF_ANDROID_LABEL_PATH_SIZE 512
// ---------------------------------------------------------------------------------------------
// The resource table
// ---------------------------------------------------------------------------------------------
//
// `resources.arsc` is a ResTable: a header, a global string pool, and then one ResTable_package per
// package it defines, each carrying its own pools for type names and entry keys followed by the
// types themselves. Resolving `labelRes` is two indices deep -- the package's number names the
// package and the type, the low half names the entry -- and every step below reads the file rather
// than a table of what the file is expected to hold, because the layout is the platform's and the
// numbers are per APK.
// ResChunk_header: type(2) headerSize(2) size(4). Every chunk in the file starts with one.
#define FF_ARSC_TABLE_TYPE 0x0002
#define FF_ARSC_STRING_POOL_TYPE 0x0001
#define FF_ARSC_TABLE_PACKAGE_TYPE 0x0200
#define FF_ARSC_TABLE_TYPE_TYPE 0x0201
// ResStringPool: header(8) stringCount(4) styleCount(4) flags(4) stringsStart(4) stylesStart(4)
#define FF_ARSC_POOL_HEADER_SIZE 28
#define FF_ARSC_OFF_POOL_CHUNK_SIZE 4
#define FF_ARSC_OFF_POOL_COUNT 8
#define FF_ARSC_OFF_POOL_FLAGS 16
#define FF_ARSC_OFF_POOL_STRINGS_START 20
// A UTF-8 pool says so with this bit, and then holds the strings as UTF-8 rather than as UTF-16.
#define FF_ARSC_POOL_FLAG_UTF8 0x0100
// ResTable_package: header(8) id(4) name(256, a UTF-16 array) typeStrings(4) lastPublicType(4) ...
#define FF_ARSC_OFF_PACKAGE_ID 8
#define FF_ARSC_OFF_PACKAGE_TYPE_STRINGS (8 + 4 + 256)
// ResTable_type: header(8) id(1) flags(1) reserved(2) entryCount(4) entriesStart(4) config(...)
#define FF_ARSC_OFF_TYPE_ID 8
#define FF_ARSC_OFF_TYPE_FLAGS 9
#define FF_ARSC_OFF_TYPE_ENTRY_COUNT 12
#define FF_ARSC_OFF_TYPE_ENTRIES_START 16
#define FF_ARSC_OFF_TYPE_CONFIG 20
// The two shapes a type can take that this does not read: a sparse type stores its offsets as
// index-offset pairs rather than as a flat table, and a 16-bit one stores them at half width. Neither
// is in the APKs measured, and both would resolve an entry to the wrong offset rather than to none,
// so they are refused rather than read as if they were the plain shape.
#define FF_ARSC_TYPE_FLAG_SPARSE 0x01
#define FF_ARSC_TYPE_FLAG_OFFSET16 0x02
// ResTable_entry: size(2) flags(2), where size is the header's own length and the value follows it.
#define FF_ARSC_ENTRY_FLAG_COMPLEX 0x0001
// Res_value: size(2) res0(1) dataType(1) data(4). TYPE_STRING makes data an index into the global
// string pool; every other type is either a number or a reference to another resource.
#define FF_ARSC_OFF_VALUE_DATA_TYPE 3
#define FF_ARSC_OFF_VALUE_DATA 4
#define FF_ARSC_TYPE_STRING 0x03
// A type chunk's offset table has one word per entry, and this is what an entry with no value in that
// configuration looks like. It is not zero: offset zero is a real entry, at the start of the block.
#define FF_ARSC_NO_ENTRY 0xffffffffu
// The type a label resolves to. `string` is what `@string/...` compiles to, and it is what tells a
// label from the icons and banners that sit beside it in the same reply -- those point at `mipmap`
// or `drawable` entries whose value is a path inside the APK, so resolving them would hand back
// `res/9w.png` instead of a name.
#define FF_ANDROID_LABEL_STRING_TYPE "string"
static uint16_t readU16(const uint8_t* p) {
return (uint16_t) ((uint16_t) p[0] | (uint16_t) ((uint16_t) p[1] << 8));
}
static uint32_t readU32(const uint8_t* p) {
return (uint32_t) p[0] | ((uint32_t) p[1] << 8) | ((uint32_t) p[2] << 16) | ((uint32_t) p[3] << 24);
}
// One ResStringPool, of which a table has three.
typedef struct FFAndroidLabelPool {
const uint8_t* table;
size_t tableSize;
size_t offset;
uint32_t chunkSize;
uint32_t count;
uint32_t headerSize;
uint32_t stringsStart;
bool utf8;
} FFAndroidLabelPool;
[[gnu::nonnull(2), nodiscard]] static bool poolInit(FFAndroidLabelPool* pool, const uint8_t* table, size_t tableSize, size_t offset) {
if (offset > tableSize || tableSize - offset < FF_ARSC_POOL_HEADER_SIZE) {
return false;
}
if (readU16(table + offset) != FF_ARSC_STRING_POOL_TYPE) {
return false;
}
pool->table = table;
pool->tableSize = tableSize;
pool->offset = offset;
pool->chunkSize = readU32(table + offset + FF_ARSC_OFF_POOL_CHUNK_SIZE);
pool->count = readU32(table + offset + FF_ARSC_OFF_POOL_COUNT);
pool->headerSize = readU16(table + offset + 2);
pool->stringsStart = readU32(table + offset + FF_ARSC_OFF_POOL_STRINGS_START);
pool->utf8 = (readU32(table + offset + FF_ARSC_OFF_POOL_FLAGS) & FF_ARSC_POOL_FLAG_UTF8) != 0;
return pool->headerSize >= FF_ARSC_POOL_HEADER_SIZE && pool->chunkSize > pool->headerSize;
}
// The length in front of a string. A UTF-8 pool writes one or two bytes, a UTF-16 pool one or two
// 16-bit words, and the top bit of the first says which of the two it is.
[[gnu::nonnull(1, 3), nodiscard]] static bool readLength8(const FFAndroidLabelPool* pool, size_t* position, uint32_t* length) {
if (*position >= pool->tableSize) {
return false;
}
uint32_t value = pool->table[(*position)++];
if (value & 0x80) {
if (*position >= pool->tableSize) {
return false;
}
value = ((value & 0x7F) << 8) | pool->table[(*position)++];
}
*length = value;
return true;
}
[[gnu::nonnull(1, 3), nodiscard]] static bool readLength16(const FFAndroidLabelPool* pool, size_t* position, uint32_t* length) {
if (*position + 2 > pool->tableSize) {
return false;
}
uint32_t value = readU16(pool->table + *position);
*position += 2;
if (value & 0x8000) {
if (*position + 2 > pool->tableSize) {
return false;
}
value = ((value & 0x7FFF) << 16) | readU16(pool->table + *position);
*position += 2;
}
*length = value;
return true;
}
[[gnu::nonnull(1)]] static void appendCodePoint(FFstrbuf* result, uint32_t code) {
char encoded[4] = {};
uint32_t length = 0;
if (code < 0x80) {
encoded[length++] = (char) code;
} else if (code < 0x800) {
encoded[length++] = (char) (0xC0 | (code >> 6));
encoded[length++] = (char) (0x80 | (code & 0x3F));
} else if (code < 0x10000) {
encoded[length++] = (char) (0xE0 | (code >> 12));
encoded[length++] = (char) (0x80 | ((code >> 6) & 0x3F));
encoded[length++] = (char) (0x80 | (code & 0x3F));
} else {
encoded[length++] = (char) (0xF0 | (code >> 18));
encoded[length++] = (char) (0x80 | ((code >> 12) & 0x3F));
encoded[length++] = (char) (0x80 | ((code >> 6) & 0x3F));
encoded[length++] = (char) (0x80 | (code & 0x3F));
}
ffStrbufAppendNS(result, length, encoded);
}
// One string out of a pool.
//
// The two lengths in front of a UTF-8 string are a *character* count and a *byte* count, and they
// differ for everything outside ASCII. Decoding `characters` bytes is the trap: a label of a few
// multi-byte characters comes back as its first character followed by replacement bytes. Measured on
// the test device, where every resource table read is a UTF-8 pool, this was the difference between
// the right label and mojibake.
[[gnu::nonnull(1, 3), nodiscard]] static bool poolGet(const FFAndroidLabelPool* pool, uint32_t index, FFstrbuf* result) {
if (index >= pool->count) {
return false;
}
const size_t offsets = pool->offset + pool->headerSize;
if (offsets + ((size_t) index + 1) * 4 > pool->tableSize) {
return false;
}
size_t position = pool->offset + pool->stringsStart + readU32(pool->table + offsets + (size_t) index * 4);
if (position >= pool->tableSize) {
return false;
}
if (pool->utf8) {
uint32_t characters = 0;
uint32_t bytes = 0;
if (!readLength8(pool, &position, &characters) || !readLength8(pool, &position, &bytes)) {
return false;
}
// An empty string is reported as a miss rather than written: the caller sets its fallback
// before asking, and ffStrbufSetNS() with a length of zero *clears* the buffer, which would
// throw that fallback away instead of leaving it alone.
if (bytes == 0 || bytes > pool->tableSize - position) {
return false;
}
ffStrbufSetNS(result, bytes, (const char*) (pool->table + position));
return true;
}
uint32_t units = 0;
if (!readLength16(pool, &position, &units)) {
return false;
}
if (units == 0 || (size_t) units * 2 > pool->tableSize - position) {
return false;
}
for (uint32_t i = 0; i < units; i++) {
uint32_t code = readU16(pool->table + position + (size_t) i * 2);
// A code point outside the basic plane arrives as a surrogate pair, and the two halves are
// not characters of their own: half of a pair encoded on its own is not valid UTF-8.
if (code >= 0xD800 && code <= 0xDBFF && i + 1 < units) {
const uint32_t low = readU16(pool->table + position + ((size_t) i + 1) * 2);
if (low >= 0xDC00 && low <= 0xDFFF) {
code = 0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00);
i++;
}
}
appendCodePoint(result, code);
}
return true;
}
// The one ResTable_package this table defines, with the two pools a lookup starts from.
typedef struct FFAndroidLabelTable {
const uint8_t* data;
size_t size;
FFAndroidLabelPool values;
FFAndroidLabelPool types;
size_t packageOffset;
size_t packageHeaderSize;
size_t packageSize;
uint32_t packageId;
} FFAndroidLabelTable;
[[gnu::nonnull(1), nodiscard]] static bool tableInit(FFAndroidLabelTable* table, const uint8_t* data, size_t size) {
// ResTable_header: header(8) packageCount(4). The header's own size is where the global pool
// starts, which is 12 in every table measured -- but it is the field rather than the number.
if (size < 12 || readU16(data) != FF_ARSC_TABLE_TYPE) {
return false;
}
table->data = data;
table->size = size;
const uint32_t headerSize = readU16(data + 2);
if (!poolInit(&table->values, data, size, headerSize)) {
return false;
}
size_t position = (size_t) headerSize + table->values.chunkSize;
while (position + 8 <= size) {
const uint16_t type = readU16(data + position);
const uint16_t chunkHeader = readU16(data + position + 2);
const uint32_t chunkSize = readU32(data + position + 4);
if (chunkSize < 8 || chunkSize > size - position) {
break;
}
// A table can define several packages -- an app that links a shared library's resources has
// more than one -- and the id in the resource reference is what picks the one to read.
if (type == FF_ARSC_TABLE_PACKAGE_TYPE && chunkSize >= chunkHeader && chunkHeader >= FF_ARSC_OFF_PACKAGE_TYPE_STRINGS + 4) {
table->packageOffset = position;
table->packageHeaderSize = chunkHeader;
table->packageSize = chunkSize;
table->packageId = readU32(data + position + FF_ARSC_OFF_PACKAGE_ID);
if (!poolInit(&table->types, data, size, position + readU32(data + position + FF_ARSC_OFF_PACKAGE_TYPE_STRINGS))) {
return false;
}
return true;
}
position += chunkSize;
}
return false;
}
// A type chunk whose ResTable_config is all zeroes is the one that applies when nothing about the
// device or the locale matches a more specific chunk. An app with a translation has several chunks
// for one type, and picking the first one that happens along would answer with whatever language it
// was written in.
[[gnu::nonnull(1), nodiscard]] static bool isDefaultConfig(const uint8_t* config, size_t length) {
if (length == 0) {
return false;
}
for (size_t i = 0; i < length; i++) {
if (config[i] != 0) {
return false;
}
}
return true;
}
[[gnu::nonnull(1, 5), nodiscard]] static bool resolveIn(const FFAndroidLabelTable* table, uint32_t typeId, uint32_t entryId, bool defaultOnly, FFstrbuf* result) {
const size_t end = table->packageOffset + table->packageSize;
for (size_t position = table->packageOffset + table->packageHeaderSize; position + 8 <= end;) {
const uint16_t type = readU16(table->data + position);
const uint16_t header = readU16(table->data + position + 2);
const uint32_t size = readU32(table->data + position + 4);
if (size < 8 || size > end - position) {
return false;
}
if (type == FF_ARSC_TABLE_TYPE_TYPE && header >= FF_ARSC_OFF_TYPE_CONFIG) {
const uint8_t id = table->data[position + FF_ARSC_OFF_TYPE_ID];
const uint8_t flags = table->data[position + FF_ARSC_OFF_TYPE_FLAGS];
if (id == typeId && (flags & (FF_ARSC_TYPE_FLAG_SPARSE | FF_ARSC_TYPE_FLAG_OFFSET16)) == 0 && size >= header) {
const uint32_t entryCount = readU32(table->data + position + FF_ARSC_OFF_TYPE_ENTRY_COUNT);
const uint32_t entriesStart = readU32(table->data + position + FF_ARSC_OFF_TYPE_ENTRIES_START);
const size_t offsets = position + header;
if (entryId < entryCount && offsets + ((size_t) entryId + 1) * 4 <= end) {
if (defaultOnly && !isDefaultConfig(table->data + position + FF_ARSC_OFF_TYPE_CONFIG, (size_t) header - FF_ARSC_OFF_TYPE_CONFIG)) {
position += size;
continue;
}
const uint32_t offset = readU32(table->data + offsets + (size_t) entryId * 4);
// `entriesStart` is relative to the chunk, not to the package, and both it and
// the entry's own offset come out of the file.
if (offset != FF_ARSC_NO_ENTRY && entriesStart <= size && offset <= size - entriesStart) {
const size_t entry = position + entriesStart + offset;
const size_t value = entry + readU16(table->data + entry);
if (value >= entry && value + 8 <= end && (readU16(table->data + entry + 2) & FF_ARSC_ENTRY_FLAG_COMPLEX) == 0
&& table->data[value + FF_ARSC_OFF_VALUE_DATA_TYPE] == FF_ARSC_TYPE_STRING) {
return poolGet(&table->values, readU32(table->data + value + FF_ARSC_OFF_VALUE_DATA), result);
}
}
}
}
}
position += size;
}
return false;
}
// Resolves one resource id to its string, and only when the type it names is a `string`.
//
// The type name is the whole reason this reads the package's type pool rather than trusting the id:
// `labelRes` and the icon, logo and banner ids that sit beside it in the same reply are all resource
// ids of the same package, and the difference between them is the type they point at. A `mipmap` id
// resolves perfectly well -- to `res/9w.png`.
[[gnu::nonnull(1, 3), nodiscard]] static bool tableResolve(const FFAndroidLabelTable* table, uint32_t resourceId, FFstrbuf* result) {
const uint32_t typeId = (resourceId >> 16) & 0xFF;
if (((resourceId >> 24) & 0xFF) != table->packageId || typeId == 0) {
return false;
}
FFstrbuf typeName;
ffStrbufInit(&typeName);
const bool isString = poolGet(&table->types, typeId - 1, &typeName) && ffStrbufEqualS(&typeName, FF_ANDROID_LABEL_STRING_TYPE);
ffStrbufDestroy(&typeName);
if (!isString) {
return false;
}
// The configuration that applies is the unqualified one; a chunk that only applies to a locale
// or a density is the fallback rather than the answer, which is what the second pass is for.
return resolveIn(table, typeId, resourceId & 0xFFFF, true, result)
|| resolveIn(table, typeId, resourceId & 0xFFFF, false, result);
}
// ---------------------------------------------------------------------------------------------
// The reply
// ---------------------------------------------------------------------------------------------
// The reply's own copy of the APK path. `sourceDir` is a string in the ApplicationInfo parcel and it
// ends in `.apk`; nothing else in the reply does, which is what makes it findable without walking
// the parcel's field order -- that would mean recovering `ApplicationInfo.writeToParcel` out of the
// device's dex and then framing sixty fields of unknown width, to reach one string that is already
// recognizable.
[[gnu::nonnull(1, 3), nodiscard]] static bool findApkPath(const uint8_t* data, size_t size, char* result, size_t capacity) {
for (size_t i = 8; i < size; i++) {
if (data[i] != '/') {
continue;
}
size_t end = i;
while (end < size && data[end] >= 0x20 && data[end] < 0x7F) {
end++;
}
const size_t length = end - i;
if (length >= 5 && length < capacity && memcmp(data + end - 4, ".apk", 4) == 0) {
memcpy(result, data + i, length);
result[length] = '\0';
return true;
}
i = end;
}
return false;
}
// ---------------------------------------------------------------------------------------------
typedef struct FFAndroidLabelMapping {
const uint8_t* data;
size_t size;
} FFAndroidLabelMapping;
[[gnu::nonnull(1)]] static void labelUnmap(FFAndroidLabelMapping* mapping) {
if (mapping->data != nullptr) {
munmap((void*) mapping->data, mapping->size);
}
}
[[gnu::nonnull(2), nodiscard]] static const char* labelMap(const char* path, FFAndroidLabelMapping* mapping) {
const int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
FF_DEBUG("open(%s) failed: %s", path, strerror(errno));
return "open(apk) failed";
}
struct stat status = {};
const bool failed = fstat(fd, &status) != 0;
if (failed || status.st_size <= 0) {
FF_DEBUG("fstat(%s) reported %s", path, failed ? strerror(errno) : "an empty file");
close(fd);
return "fstat(apk) failed";
}
void* mapped = mmap(nullptr, (size_t) status.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
if (mapped == MAP_FAILED) {
FF_DEBUG("mmap(%s, %lld bytes) failed: %s", path, (long long) status.st_size, strerror(errno));
return "mmap(apk) failed";
}
mapping->data = mapped;
mapping->size = (size_t) status.st_size;
return nullptr;
}
// One reply buffer for every call this file makes, and it makes one per query.
static uint8_t s_reply[FF_ANDROID_LABEL_REPLY_SIZE];
const char* ffAndroidGetAppLabel(const char* packageName, FFstrbuf* result) {
// The transaction code comes out of the jar rather than from a table here: it is a property of
// the `.aidl` the device's ROM was built from, and a vendor that inserts a method ahead of this
// one shifts every code behind it. See common/android/dex.h.
int32_t transaction = FF_DEX_STATIC_INT_UNRESOLVED;
const FFDexStaticIntRequest lookup = {
.classDescriptor = FF_ANDROID_LABEL_STUB,
.fieldName = FF_ANDROID_LABEL_TRANSACTION,
.result = &transaction,
};
const char* error = ffDexStaticInts(FF_ANDROID_LABEL_JAR, &lookup, 1);
if (error != nullptr) {
return error;
}
if (transaction == FF_DEX_STATIC_INT_UNRESOLVED) {
return "framework.jar does not declare IPackageManager.getApplicationInfo";
}
[[gnu::cleanup(ffBinderClose)]] FFBinder binder = { .fd = -1 };
error = ffBinderOpen(&binder);
if (error != nullptr) {
return error;
}
[[gnu::cleanup(ffBinderServiceHandleRelease)]] FFBinderServiceHandle service = { .binder = &binder };
error = ffBinderLookupService(&binder, FF_ANDROID_LABEL_SERVICE, FF_BINDER_SM_GET_SERVICE, &service.handle);
if (error != nullptr) {
FF_DEBUG("Looking up \"%s\" failed: %s", FF_ANDROID_LABEL_SERVICE, error);
return error;
}
uint8_t request[FF_ANDROID_LABEL_REQUEST_SIZE];
FFBinderParcel parcel = ffBinderParcelCreate(request, sizeof(request));
ffBinderParcelPutInterfaceToken(&parcel, FF_ANDROID_LABEL_DESCRIPTOR);
ffBinderParcelPutString16(&parcel, packageName);
// `getApplicationInfo(String, long flags, int userId)`. The flags argument is 64-bit from Android
// 13 on and 32-bit before it, and the wider one is what works on both: a release that reads an
// int takes the low word and leaves the zero high word unread, because an AIDL stub stops
// reading once its own arguments are in. The narrow one is not symmetric -- a release that reads
// a long would take half of its own flags argument for the user id.
ffBinderParcelPutU64(&parcel, 0);
ffBinderParcelPutI32(&parcel, 0);
FFBinderReply reply = ffBinderReplyCreate(s_reply, sizeof(s_reply));
error = ffBinderTransact(&binder, service.handle, (uint32_t) transaction, 0, &parcel, &reply);
if (error != nullptr) {
return error;
}
if (ffBinderReplyIsStatus(&reply)) {
return "The package manager rejected the request";
}
// The AIDL status first, then the presence marker of a nullable Parcelable: a package the caller
// is not allowed to see answers an empty ApplicationInfo rather than an error.
if (ffBinderReadI32(reply.data, reply.size, 0) != 0) {
return "The package manager refused to describe the app";
}
if (ffBinderReadI32(reply.data, reply.size, 4) == 0) {
FF_DEBUG("The package manager described \"%s\" as an empty ApplicationInfo", packageName);
return nullptr;
}
char path[FF_ANDROID_LABEL_PATH_SIZE];
if (!findApkPath(reply.data, reply.size, path, sizeof(path))) {
return "The reply carries no APK path";
}
FF_DEBUG("\"%s\" is installed at \"%s\"", packageName, path);
[[gnu::cleanup(labelUnmap)]] FFAndroidLabelMapping mapping = {};
error = labelMap(path, &mapping);
if (error != nullptr) {
return error;
}
FFAndroidZipEntry table = {};
error = ffAndroidZipFindEntry(mapping.data, mapping.size, FF_ANDROID_LABEL_TABLE, &table);
if (error != nullptr) {
return error;
}
if (table.method != FF_ZIP_METHOD_STORED) {
FF_DEBUG("\"%s\" stores resources.arsc with compression method %u", packageName, (unsigned) table.method);
return "The resource table is stored compressed";
}
FFAndroidLabelTable resources = {};
if (!tableInit(&resources, table.payload, table.payloadSize)) {
return "The resource table could not be read";
}
// Every word of the reply shaped like one of this package's resource ids, in the order they
// appear, and the first one that resolves to a `string` is the label. See the header for what
// that rule was audited against and why it beats recovering the parcel's field order.
for (size_t offset = 8; offset + 4 <= reply.size; offset += 4) {
if (tableResolve(&resources, readU32(reply.data + offset), result)) {
FF_DEBUG("\"%s\" shows itself as \"%s\"", packageName, result->chars);
return nullptr;
}
}
FF_DEBUG("No resource id in the reply of \"%s\" resolves to a string", packageName);
return nullptr;
}
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include "fastfetch.h"
// The name an app presents to the user, which is not its package name: an app installed as
// `com.termux` presents itself as `Termux:Launcher` on the launcher, in its notifications and on
// the settings screen.
//
// Every route that answers with an *already resolved* label is closed to an app UID, and each one
// was measured on the test device rather than assumed:
//
// * `dumpsys package` needs android.permission.DUMP.
// * `cmd package dump` is filtered down to 929 bytes for an app UID, against 1.2 MB for the shell.
// * The task descriptions the activity service hands out only ever describe the caller's own task.
// * `getApplicationInfo` answers with `labelRes` -- a resource id -- and leaves `nonLocalizedLabel`
// null, so there is no string in the reply to read.
//
// What is open is the APK itself. `getApplicationInfo` carries its path (`sourceDir`), APKs are
// world readable, and the `resources.arsc` inside one is *stored* rather than deflated -- the
// platform expects to mmap it -- so resolving an id out of it needs no decompressor. That is the
// route this takes: one transaction, one mapping, no fork and no child process.
//
// The label is the resource id in the reply whose type is `string`. That is a rule about the reply
// rather than about the parcel's field order, and it was audited against the manifest's own
// `android:label` over every package installed on the test device: nine in ten have exactly one
// `string` candidate and it is the right one every time, a handful more have two and the first is
// still the right one, and the rest have none because their label is a literal string rather than a
// reference (`android:label="Example"`), so the reply carries no id at all. No package resolved to
// a wrong string; the counts behind that are in doc/app-label.md.
//
// Writes the label into `result` when it can be resolved, and leaves `result` alone otherwise --
// which includes the cases above where there is nothing to resolve. The caller sets its fallback
// first, so that an unresolved label costs nothing but the query.
//
// Returns nullptr on success, a static message when the query itself could not be made. An error is
// not a fallback: it says the label was not looked for, not that the app has none.
[[gnu::nonnull(1, 2), nodiscard]] const char* ffAndroidGetAppLabel(const char* packageName, FFstrbuf* result);
+334
View File
@@ -0,0 +1,334 @@
#include "common/android/binder.h"
#include "common/debug.h"
#include "common/io.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
const char* ffBinderOpen(FFBinder* binder) {
*binder = (FFBinder) { .fd = -1, .shared = nullptr, .sharedSize = 0, .protocolVersion = 0 };
FF_AUTO_CLOSE_FD int fd = open(FF_BINDER_DEVICE, O_RDWR | O_CLOEXEC);
if (fd < 0) {
FF_DEBUG("open(" FF_BINDER_DEVICE ") failed: %s", strerror(errno));
return "Failed to open " FF_BINDER_DEVICE;
}
struct binder_version version = { .protocol_version = 0 };
const int versionIoctl = ioctl(fd, BINDER_VERSION, &version);
if (versionIoctl != 0 || version.protocol_version != BINDER_CURRENT_PROTOCOL_VERSION) {
FF_DEBUG("BINDER_VERSION reported protocol %u, expected %u (%s)",
version.protocol_version, BINDER_CURRENT_PROTOCOL_VERSION,
versionIoctl != 0 ? strerror(errno) : "version mismatch");
return "Unsupported binder protocol version";
}
// The region is read-only: the kernel writes reply payloads into it and hands out their
// addresses in BR_REPLY, so it has to stay mapped for as long as the handle is used.
void* shared = mmap(nullptr, FF_BINDER_SHARED_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, fd, 0);
if (shared == MAP_FAILED) {
FF_DEBUG("mmap(" FF_BINDER_DEVICE ") failed: %s", strerror(errno));
return "Failed to mmap " FF_BINDER_DEVICE;
}
*binder = (FFBinder) {
.fd = fd,
.shared = (uint8_t*) shared,
.sharedSize = FF_BINDER_SHARED_SIZE,
.protocolVersion = version.protocol_version,
};
fd = -1; // ownership moved into *binder, which ffBinderClose() lets go
return nullptr;
}
void ffBinderClose(FFBinder* binder) {
if (binder->shared != nullptr) {
munmap(binder->shared, binder->sharedSize);
}
if (binder->fd >= 0) {
close(binder->fd);
}
binder->fd = -1;
binder->shared = nullptr;
binder->sharedSize = 0;
}
const char* ffBinderTransact(FFBinder* binder, uint32_t handle, uint32_t code, uint32_t flags, const FFBinderParcel* parcel, FFBinderReply* reply) {
reply->size = 0;
reply->code = 0;
reply->flags = 0;
reply->handleCount = 0;
reply->fdCount = 0;
if (parcel->truncated) {
FF_DEBUG("The parcel was truncated at %zu bytes, the caller buffer holds %zu",
parcel->size, parcel->capacity);
return "Binder parcel does not fit the caller buffer";
}
uint8_t writeBuffer[sizeof(uint32_t) + sizeof(struct binder_transaction_data)];
const struct binder_transaction_data transaction = {
.target = { .handle = handle },
.cookie = 0,
.code = code,
.flags = flags,
.sender_pid = 0,
.sender_euid = 0,
.data_size = parcel->size,
.offsets_size = 0,
.data = { .ptr = { .buffer = (binder_uintptr_t) (uintptr_t) parcel->data, .offsets = 0 } },
};
const uint32_t transactionCommand = BC_TRANSACTION;
memcpy(writeBuffer, &transactionCommand, sizeof(uint32_t));
memcpy(writeBuffer + sizeof(uint32_t), &transaction, sizeof(transaction));
// The read buffer only has to hold the command words and the binder_transaction_data that
// follows BR_REPLY; the payload itself lives in the mmap region.
uint8_t readBuffer[FF_BINDER_REPLY_BUFFER_SIZE];
struct binder_write_read exchange = {
.write_size = sizeof(writeBuffer),
.write_consumed = 0,
.write_buffer = (binder_uintptr_t) (uintptr_t) writeBuffer,
.read_size = sizeof(readBuffer),
.read_consumed = 0,
.read_buffer = (binder_uintptr_t) (uintptr_t) readBuffer,
};
if (ioctl(binder->fd, BINDER_WRITE_READ, &exchange) != 0) {
FF_DEBUG("BINDER_WRITE_READ(handle=%u, code=%u) failed: %s", handle, code, strerror(errno));
return "BINDER_WRITE_READ failed";
}
const uint8_t* cursor = readBuffer;
const uint8_t* end = readBuffer + (size_t) exchange.read_consumed;
while ((size_t) (end - cursor) >= sizeof(uint32_t)) {
uint32_t command = 0;
memcpy(&command, cursor, sizeof(uint32_t));
cursor += sizeof(uint32_t);
switch (command) {
case BR_NOOP:
case BR_TRANSACTION_COMPLETE:
case BR_SPAWN_LOOPER:
break;
case BR_FAILED_REPLY:
FF_DEBUG("BR_FAILED_REPLY for handle=%u, code=%u", handle, code);
return "Binder transaction failed";
case BR_DEAD_REPLY:
FF_DEBUG("BR_DEAD_REPLY: handle=%u is dead", handle);
return "Binder service is not running";
case BR_INCREFS:
case BR_ACQUIRE:
case BR_RELEASE:
case BR_DECREFS:
cursor += sizeof(struct binder_ptr_cookie);
break;
case BR_DEAD_BINDER:
case BR_CLEAR_DEATH_NOTIFICATION_DONE:
cursor += sizeof(binder_uintptr_t);
break;
case BR_ERROR:
cursor += sizeof(int32_t);
break;
case BR_REPLY: {
if ((size_t) (end - cursor) < sizeof(struct binder_transaction_data)) {
FF_DEBUG("BR_REPLY is truncated: %zu of %zu bytes left",
(size_t) (end - cursor), sizeof(struct binder_transaction_data));
return "Truncated binder reply";
}
struct binder_transaction_data data;
memcpy(&data, cursor, sizeof(data));
cursor += sizeof(data);
reply->code = data.code;
reply->flags = data.flags;
const uint8_t* payload = (const uint8_t*) (uintptr_t) data.data.ptr.buffer;
const size_t payloadSize = (size_t) data.data_size;
const uint8_t* offsets = (const uint8_t*) (uintptr_t) data.data.ptr.offsets;
const size_t offsetsSize = (size_t) data.offsets_size;
const char* error = nullptr;
if (payloadSize > 0) {
if (payloadSize > reply->capacity) {
FF_DEBUG("The reply carries %zu payload bytes, the caller buffer holds %zu",
payloadSize, reply->capacity);
error = "Binder reply does not fit the caller buffer";
} else {
memcpy(reply->data, payload, payloadSize);
reply->size = payloadSize;
}
}
// Walk the offset table for the flat objects the service sent us. A reply may carry
// both kinds at once and they are not interchangeable: a handle is a reference that
// has to be acquired (see below) to outlive the reply buffer, while a file
// descriptor was installed in our own fd table by the kernel and is simply ours.
for (size_t offset = 0; offset + sizeof(binder_size_t) <= offsetsSize; offset += sizeof(binder_size_t)) {
binder_size_t objectOffset = 0;
memcpy(&objectOffset, offsets + offset, sizeof(objectOffset));
if (objectOffset + sizeof(struct flat_binder_object) > payloadSize) {
continue;
}
struct flat_binder_object object;
memcpy(&object, payload + objectOffset, sizeof(object));
if (object.hdr.type == BINDER_TYPE_HANDLE) {
if (reply->handleCount < FF_BINDER_MAX_HANDLES) {
reply->handles[reply->handleCount++] = object.handle;
}
} else if (object.hdr.type == BINDER_TYPE_FD) {
if (reply->fdCount < FF_BINDER_MAX_FDS) {
reply->fds[reply->fdCount++] = (int32_t) object.handle;
} else {
// Nothing is going to hold this one and nothing is going to close it.
close((int) object.handle);
}
}
}
// The kernel gave us a new reference whose only strong reference belongs to the
// reply buffer, so it has to be acquired before that buffer is freed -- otherwise
// the handle silently degrades to a weak reference and every later transaction on
// it fails with BR_FAILED_REPLY. libbinder does the same in acquire_object().
uint8_t tail[FF_BINDER_MAX_HANDLES * 4 * sizeof(uint32_t) + sizeof(uint32_t) + sizeof(binder_uintptr_t)];
size_t tailSize = 0;
for (uint32_t i = 0; i < reply->handleCount; i++) {
const uint32_t acquire = BC_ACQUIRE;
const uint32_t increfs = BC_INCREFS;
memcpy(tail + tailSize, &acquire, sizeof(uint32_t));
tailSize += sizeof(uint32_t);
memcpy(tail + tailSize, &reply->handles[i], sizeof(uint32_t));
tailSize += sizeof(uint32_t);
memcpy(tail + tailSize, &increfs, sizeof(uint32_t));
tailSize += sizeof(uint32_t);
memcpy(tail + tailSize, &reply->handles[i], sizeof(uint32_t));
tailSize += sizeof(uint32_t);
}
const uint32_t freeCommand = BC_FREE_BUFFER;
const binder_uintptr_t freeBuffer = data.data.ptr.buffer;
memcpy(tail + tailSize, &freeCommand, sizeof(uint32_t));
tailSize += sizeof(uint32_t);
memcpy(tail + tailSize, &freeBuffer, sizeof(freeBuffer));
tailSize += sizeof(freeBuffer);
struct binder_write_read release = {
.write_size = tailSize,
.write_consumed = 0,
.write_buffer = (binder_uintptr_t) (uintptr_t) tail,
.read_size = 0,
.read_consumed = 0,
.read_buffer = 0,
};
// This one ioctl carries the whole tail, so its failure is not cosmetic: without
// BC_ACQUIRE the handles handed to the caller are only weakly referenced and every
// later transaction on them fails with BR_FAILED_REPLY, which says nothing about the
// real cause. Reported, but only when nothing more specific is already at hand.
if (ioctl(binder->fd, BINDER_WRITE_READ, &release) != 0 && error == nullptr) {
FF_DEBUG("BC_ACQUIRE/BC_FREE_BUFFER failed: %s", strerror(errno));
error = "Releasing the binder reply failed";
}
return error;
}
default:
FF_DEBUG("Unexpected binder command 0x%08x for handle=%u, code=%u", command, handle, code);
return "Unexpected binder command";
}
}
FF_DEBUG("The binder reply for handle=%u, code=%u held no BR_REPLY (%zu bytes read)",
handle, code, (size_t) exchange.read_consumed);
return "No reply from binder";
}
const char* ffBinderLookupService(FFBinder* binder, const char* name, uint32_t transactionCode, uint32_t* handle) {
uint8_t parcelBuffer[256];
FFBinderParcel parcel = ffBinderParcelCreate(parcelBuffer, sizeof(parcelBuffer));
ffBinderParcelPutInterfaceToken(&parcel, FF_BINDER_SM_DESCRIPTOR);
ffBinderParcelPutString16(&parcel, name);
uint8_t replyBuffer[256];
FFBinderReply reply = ffBinderReplyCreate(replyBuffer, sizeof(replyBuffer));
const char* error = ffBinderTransact(binder, FF_BINDER_SERVICE_MANAGER_HANDLE, transactionCode, 0, &parcel, &reply);
if (error != nullptr) {
return error;
}
if (ffBinderReplyIsStatus(&reply)) {
FF_DEBUG("The service manager returned a status parcel for %s, code=%u", name, transactionCode);
return "Service manager rejected the request";
}
const int32_t exception = ffBinderReadI32(reply.data, reply.size, 0);
if (exception != 0) {
FF_DEBUG("The service manager raised exception %d for %s", exception, name);
return "Service manager raised an exception";
}
if (reply.handleCount == 0) {
FF_DEBUG("The service manager returned no handle for %s", name);
return "Service is not registered";
}
*handle = reply.handles[0];
return nullptr;
}
void ffBinderServiceHandleRelease(FFBinderServiceHandle* service) {
if (service->binder == nullptr || service->handle == 0) {
return;
}
// The mirror of the acquire at the end of ffBinderTransact(): one strong and one weak reference
// each, dropped in the same order they were taken. The kernel keeps the service node alive until
// the last one goes, so this is what stops a short-lived fastfetch from holding one for the whole
// of its life.
const uint32_t commands[] = { BC_RELEASE, BC_DECREFS };
uint8_t tail[2 * 2 * sizeof(uint32_t)];
size_t tailSize = 0;
for (size_t i = 0; i < 2; i++) {
memcpy(tail + tailSize, &commands[i], sizeof(uint32_t));
tailSize += sizeof(uint32_t);
memcpy(tail + tailSize, &service->handle, sizeof(uint32_t));
tailSize += sizeof(uint32_t);
}
struct binder_write_read release = {
.write_size = tailSize,
.write_consumed = 0,
.write_buffer = (binder_uintptr_t) (uintptr_t) tail,
.read_size = 0,
.read_consumed = 0,
.read_buffer = 0,
};
// Not reported: this runs from a cleanup attribute, where there is no caller left to report to,
// and the only way for it to fail is a binder that is already dead -- which every earlier call on
// the same binder would have said already.
ioctl(service->binder->fd, BINDER_WRITE_READ, &release);
service->handle = 0;
}
void ffBinderAcquiredRelease(FFBinderAcquired* acquired) {
if (acquired->replied == nullptr || *acquired->replied == false) {
return; // nothing was acquired
}
// A descriptor is not a reference: the kernel installed it in our own fd table when it delivered
// the reply, and nobody else holds it, so closing it is the whole of giving it back.
for (uint32_t i = 0; i < acquired->fdCount; i++) {
close(acquired->fds[i]);
}
// The mirror of the acquire the transaction appended to its tail, in the same order it took them.
// No binder to talk through means the handles went with it when it was closed.
if (acquired->binder == nullptr || acquired->binder->fd < 0) {
return;
}
for (uint32_t i = 0; i < acquired->handleCount; i++) {
FFBinderServiceHandle handle = { .binder = acquired->binder, .handle = acquired->handles[i] };
ffBinderServiceHandleRelease(&handle);
}
}
+277
View File
@@ -0,0 +1,277 @@
#pragma once
// Android exposes no public C API for the system services that carry the data fastfetch wants: the
// NDK has no BatteryManager / WifiManager, libbinder_ndk only speaks to AIDL HALs (it refuses to
// prepare a transaction for a binder that has no NDK class), and `/system/bin/service call` costs a
// fork/exec worth 15-20 ms. What is left is /dev/binder itself, which is all that `service` uses
// underneath. This header speaks that protocol directly: open() + mmap() + BINDER_WRITE_READ, no
// extra shared library, no child process, ~0.13 ms per call once a handle is cached.
//
// Three details are easy to get wrong. All three were confirmed against the device's own
// libbinder.so and with a ptrace trace of `service`, and getting any of them wrong makes the
// service answer BAD_TYPE (0x80000001) or BR_FAILED_REPLY (0x7211):
//
// * A request parcel must start with three int32 values -- strict mode policy, work source and
// 'SYST'. Parcel::markForBinder() writes nothing for kernel binder, but the receiving side's
// Parcel::enforceInterface() still compares the third word against its own header.
// * Parcel::writeString16() writes the length, the UTF-16 code units, a UTF-16 NUL terminator and
// then pads to four bytes. Skipping the terminator shifts every following field by four bytes.
// * A handle arriving in a reply is owned by that reply buffer. It has to be acquired
// (BC_ACQUIRE + BC_INCREFS) before BC_FREE_BUFFER; otherwise only a weak reference survives and
// every later transaction on it fails, because the kernel looks up a strong reference.
#include "fastfetch.h" // IWYU pragma: keep
// The structures and command words below are not defined here: bionic generates this header from
// bionic/libc/kernel/uapi/linux/android/binder.h and every NDK ships it, so it is the
// authoritative copy of the binder ABI -- struct binder_write_read, struct binder_transaction_data,
// struct flat_binder_object, BINDER_WRITE_READ / BINDER_VERSION, the BC_* and BR_* command words,
// TF_* and BINDER_TYPE_*. Using it beats transcribing it: a second copy can only be wrong, and if
// the header itself is wrong that is the NDK's problem to fix, not something fastfetch could have
// caught by keeping its own.
#include <linux/android/binder.h>
#include <string.h>
#include <sys/ioctl.h>
#define FF_BINDER_DEVICE "/dev/binder"
// The kernel allocates reply payloads out of the region handed to mmap(); 1 MiB is what libbinder
// asks for. Replies themselves are small -- `listServices` on this device is the largest at a few
// hundred bytes -- but the region also carries the per-process buffer pool.
#define FF_BINDER_SHARED_SIZE (1024 * 1024)
// A command word plus the binder_transaction_data that follows it. The payload never lands here:
// it lives in the mmap region, and BR_REPLY only hands over a pointer to it.
#define FF_BINDER_REPLY_BUFFER_SIZE 1024
// How many handles a reply may transfer to us. Replies that carry more than this still succeed, but
// the surplus handles are left unacquired and will fail on first use.
#define FF_BINDER_MAX_HANDLES 4
// How many file descriptors a reply may hand over. A descriptor is not a handle: the kernel installs
// it in the caller's own fd table as it delivers the reply, so it is owned rather than borrowed and
// the caller closes it. A reply carrying more than this still succeeds, and the surplus is closed
// again by ffBinderTransact() because nothing would be left holding it.
#define FF_BINDER_MAX_FDS 4
// The three int32 values Parcel::writeInterfaceToken() puts in front of the descriptor, and that
// Parcel::enforceInterface() checks the last of. These come from libbinder rather than from the
// kernel, which is why they are spelled out here.
#define FF_BINDER_STRICT_MODE_PENALTY_GATHER 0x80000000u // (1 << 31), Parcel.cpp
#define FF_BINDER_UNSET_WORK_SOURCE 0xffffffffu // IPCThreadState::kUnsetWorkSource
#define FF_BINDER_HEADER 0x53595354u // B_PACK_CHARS('S', 'Y', 'S', 'T')
typedef struct FFBinder {
int fd;
uint8_t* shared;
size_t sharedSize;
int32_t protocolVersion;
} FFBinder;
// Opens /dev/binder, checks the protocol version and maps the shared region. Returns nullptr on
// success, a static message otherwise; the device is left closed on failure.
[[gnu::nonnull(1), nodiscard]] const char* ffBinderOpen(FFBinder* binder);
// Usable as a cleanup attribute. Safe on a zeroed or already closed FFBinder.
[[gnu::nonnull(1)]] void ffBinderClose(FFBinder* binder);
// ---------------------------------------------------------------------------------------------
// Parcel writing. The caller owns the buffer; anything that does not fit is dropped and recorded
// in `truncated`, which ffBinderTransact() then reports as an error.
// ---------------------------------------------------------------------------------------------
typedef struct FFBinderParcel {
uint8_t* data;
size_t capacity;
size_t size;
bool truncated;
} FFBinderParcel;
[[nodiscard]] static inline FFBinderParcel ffBinderParcelCreate(uint8_t* data, size_t capacity) {
return (FFBinderParcel) { .data = data, .capacity = capacity, .size = 0, .truncated = false };
}
[[gnu::nonnull(1), nodiscard]] static inline uint8_t* ffBinderParcelReserve(FFBinderParcel* parcel, size_t bytes) {
if (bytes > parcel->capacity - parcel->size) {
parcel->truncated = true;
return nullptr;
}
uint8_t* result = parcel->data + parcel->size;
parcel->size += bytes;
return result;
}
[[gnu::nonnull(1)]] static inline void ffBinderParcelPutU32(FFBinderParcel* parcel, uint32_t value) {
uint8_t* dst = ffBinderParcelReserve(parcel, sizeof(uint32_t));
if (dst != nullptr) {
memcpy(dst, &value, sizeof(uint32_t));
}
}
[[gnu::nonnull(1)]] static inline void ffBinderParcelPutI32(FFBinderParcel* parcel, int32_t value) {
uint8_t* dst = ffBinderParcelReserve(parcel, sizeof(int32_t));
if (dst != nullptr) {
memcpy(dst, &value, sizeof(int32_t));
}
}
[[gnu::nonnull(1)]] static inline void ffBinderParcelPutU64(FFBinderParcel* parcel, uint64_t value) {
uint8_t* dst = ffBinderParcelReserve(parcel, sizeof(uint64_t));
if (dst != nullptr) {
memcpy(dst, &value, sizeof(uint64_t));
}
}
// AIDL string16. The descriptors and service names fastfetch asks for are ASCII, so one byte is one
// UTF-16 code unit; anything else would have to be encoded properly here.
[[gnu::nonnull(1, 2)]] static inline void ffBinderParcelPutString16(FFBinderParcel* parcel, const char* value) {
const size_t length = strlen(value);
const size_t payload = sizeof(uint32_t) + (length + 1) * 2; // length, code units, NUL terminator
const size_t padded = (payload + 3) & ~(size_t) 3;
uint8_t* dst = ffBinderParcelReserve(parcel, padded);
if (dst == nullptr) {
return;
}
memset(dst, 0, padded);
const uint32_t length32 = (uint32_t) length;
memcpy(dst, &length32, sizeof(uint32_t));
for (size_t i = 0; i < length; i++) {
dst[sizeof(uint32_t) + i * 2] = (uint8_t) value[i];
}
// The two bytes after the last code unit stay zero: that is the UTF-16 NUL terminator, and
// Parcel::readInplace() advances by (length + 1) * sizeof(char16_t) to account for it.
}
[[gnu::nonnull(1, 2)]] static inline void ffBinderParcelPutInterfaceToken(FFBinderParcel* parcel, const char* descriptor) {
ffBinderParcelPutU32(parcel, FF_BINDER_STRICT_MODE_PENALTY_GATHER);
ffBinderParcelPutU32(parcel, FF_BINDER_UNSET_WORK_SOURCE);
ffBinderParcelPutU32(parcel, FF_BINDER_HEADER);
ffBinderParcelPutString16(parcel, descriptor);
}
// ---------------------------------------------------------------------------------------------
// Transactions
// ---------------------------------------------------------------------------------------------
typedef struct FFBinderReply {
uint8_t* data; // caller owned; receives the payload
size_t capacity; // ditto
size_t size; // payload length in bytes
uint32_t code; // transaction code the service echoed back
uint32_t flags; // TF_* of the reply
uint32_t handleCount;
uint32_t handles[FF_BINDER_MAX_HANDLES];
uint32_t fdCount;
int32_t fds[FF_BINDER_MAX_FDS]; // owned by the caller, which closes them
} FFBinderReply;
[[nodiscard]] static inline FFBinderReply ffBinderReplyCreate(uint8_t* data, size_t capacity) {
return (FFBinderReply) { .data = data, .capacity = capacity, .size = 0, .code = 0, .flags = 0, .handleCount = 0, .handles = {}, .fdCount = 0, .fds = {} };
}
// A reply carrying TF_STATUS_CODE is not an AIDL parcel at all: the first four bytes are the raw
// status_t that onTransact() returned (-74 being UNKNOWN_TRANSACTION, i.e. no such method). Check
// this before interpreting anything else.
[[gnu::nonnull(1), nodiscard]] static inline bool ffBinderReplyIsStatus(const FFBinderReply* reply) {
return (reply->flags & TF_STATUS_CODE) != 0;
}
[[gnu::nonnull(1), nodiscard]] static inline uint32_t ffBinderReadU32(const uint8_t* data, size_t size, size_t offset) {
uint32_t value = 0;
if (offset + sizeof(uint32_t) <= size) {
memcpy(&value, data + offset, sizeof(uint32_t));
}
return value;
}
[[gnu::nonnull(1), nodiscard]] static inline int32_t ffBinderReadI32(const uint8_t* data, size_t size, size_t offset) {
int32_t value = 0;
if (offset + sizeof(int32_t) <= size) {
memcpy(&value, data + offset, sizeof(int32_t));
}
return value;
}
[[gnu::nonnull(1), nodiscard]] static inline uint64_t ffBinderReadU64(const uint8_t* data, size_t size, size_t offset) {
uint64_t value = 0;
if (offset + sizeof(uint64_t) <= size) {
memcpy(&value, data + offset, sizeof(uint64_t));
}
return value;
}
// Synchronous transaction. Returns nullptr on success, a static message otherwise.
//
// `flags` carries the TF_* values for the request, and one of them is not cosmetic: a reply that
// carries a file descriptor is only delivered at all when the request asked with TF_ACCEPT_FDS. A
// request that did not gets BR_FAILED_REPLY instead, which reads like a service that is not running
// rather than like a missing flag. TF_ONE_WAY is the other one the kernel acts on, and it is what
// makes a call fire-and-forget -- there is then no reply to fill `reply` from.
//
// Handles the reply carries are acquired and added to `reply->handles` before the reply buffer is
// freed; descriptors are added to `reply->fds`, which the caller owns and closes.
//
// `handle` 0 is the service manager; every other handle comes from ffBinderLookupService(). A
// service that never replies blocks this call forever -- none of the services fastfetch reads does,
// but there is no timeout here to fall back on.
[[gnu::nonnull(1, 5, 6), nodiscard]] const char* ffBinderTransact(FFBinder* binder, uint32_t handle, uint32_t code, uint32_t flags, const FFBinderParcel* parcel, FFBinderReply* reply);
// ---------------------------------------------------------------------------------------------
// Service manager
// ---------------------------------------------------------------------------------------------
#define FF_BINDER_SERVICE_MANAGER_HANDLE 0u
#define FF_BINDER_SM_DESCRIPTOR "android.os.IServiceManager"
// Entry points of android.os.IServiceManager, as this device answers them. The numbers do not match
// the AOSP sources: checkService is 4 here, not 3. FF_BINDER_SM_GET_SERVICE returns a nullable
// IBinder and is the simplest reply to parse; FF_BINDER_SM_CHECK_SERVICE is what `service` itself
// calls and answers with a parcelable instead.
#define FF_BINDER_SM_GET_SERVICE 1u
#define FF_BINDER_SM_GET_SERVICE2 2u
#define FF_BINDER_SM_CHECK_SERVICE 4u
#define FF_BINDER_SM_LIST_SERVICES 6u
// Resolves a service name to a handle through the service manager. Returns nullptr on success.
[[gnu::nonnull(1, 2, 4), nodiscard]] const char* ffBinderLookupService(FFBinder* binder, const char* name, uint32_t transactionCode, uint32_t* handle);
// A handle resolved through the service manager, held together with the binder it came from so that a
// single cleanup attribute can give it back on every path out of the function that took it. Zeroed --
// or left at handle 0 by a lookup that has not run or did not succeed -- it is a no-op, which is what
// makes it safe to declare above the lookup itself.
typedef struct FFBinderServiceHandle {
FFBinder* binder;
uint32_t handle;
} FFBinderServiceHandle;
// Returns the strong and weak references ffBinderLookupService() acquired on the handle. Usable as a
// cleanup attribute; safe on a zeroed or already released FFBinderServiceHandle.
[[gnu::nonnull(1)]] void ffBinderServiceHandleRelease(FFBinderServiceHandle* service);
// ---------------------------------------------------------------------------------------------
// Handles a transaction acquired
// ---------------------------------------------------------------------------------------------
// Whatever ffBinderTransact() collected for the caller, released together on the way out of a
// function -- the handles it acquired, plus the descriptors it delivered, which are owned rather
// than borrowed and would otherwise stay open for the life of the process.
//
// Unlike FFBinderServiceHandle this cannot be declared before the transaction runs, because which
// handles came back is only known afterwards. `replied` is therefore a separate flag the caller
// raises once ffBinderTransact() has returned: it acquires the handles even when it goes on to fail
// (a reply that did not fit the caller buffer still had its BC_ACQUIRE tail sent), so releasing
// without it would drop a reference that was never taken.
typedef struct FFBinderAcquired {
FFBinder* binder;
const uint32_t* handles;
uint32_t handleCount;
const int32_t* fds;
uint32_t fdCount;
const bool* replied;
} FFBinderAcquired;
// Usable as a cleanup attribute; safe on a zeroed FFBinderAcquired, and on one whose transaction did
// not reply.
[[gnu::nonnull(1)]] void ffBinderAcquiredRelease(FFBinderAcquired* acquired);
File diff suppressed because it is too large Load Diff
+167
View File
@@ -0,0 +1,167 @@
#pragma once
// AIDL gives every method of an interface a transaction code at build time:
//
// static final int TRANSACTION_<method> = IBinder.FIRST_CALL_TRANSACTION + <declaration index>;
//
// so the number is a property of the `.aidl` of the release that built the device's jar, not of any
// public header. Counting the methods in an AOSP checkout only describes that checkout, and it goes
// wrong the moment a release or a vendor fork inserts a method ahead of the one being looked for:
// `IWifiManager.getConnectionInfo` is 29 on Android 11 and 41 on Android 16. There is no negotiation
// and no discovery -- a wrong code reaches a different method, or none.
//
// Being a compile-time constant, the value lands in the `static_values` array of the `X$Stub` class
// in the jar's dex, paired position by position with that class's static field list. Reading the two
// together gives the mapping of the build that is actually on the device, on any release, with
// nothing to keep in sync.
//
// `libdexfile.so` cannot do this for us. It is dlopen-able from an app UID through the ART apex, but
// it is not in the NDK and its only C ABI -- the `ADexFile_*` family -- covers methods, not fields;
// the field and class-data APIs are C++ with no ABI guarantee.
//
// `ffReadFileBuffer` would work but pulls the whole jar through the heap for one integer. The jar is
// mapped instead, and only the pages actually read are faulted in.
#include "fastfetch.h"
// What a request is written when the jar does not answer it, on every path out of ffDexStaticInts --
// a jar that cannot be opened and a field the class does not declare both leave it behind, so a
// caller reads a result rather than what its own stack happened to hold there. No transaction code
// is negative: AIDL numbers them from `IBinder.FIRST_CALL_TRANSACTION`, which is 1.
//
// This is what keeps the reader a lookup and nothing more. Whether a code is one the caller cannot do
// without or one it only uses when the build declares it, whether what came back is enough to carry
// on, and whether the module reports a value or an error are the caller's decisions, made by reading
// the results. The reader finds numbers and says which ones it could not.
#define FF_DEX_STATIC_INT_UNRESOLVED (-1)
// One `<classDescriptor>.<fieldName>` lookup, and where its value is written. `classDescriptor` is
// the dex type descriptor, e.g. "Landroid/net/wifi/IWifiManager$Stub;".
typedef struct FFDexStaticIntRequest {
const char* classDescriptor;
const char* fieldName;
int32_t* result;
} FFDexStaticIntRequest;
// Resolves the int value of every request out of the dex entries of `jarPath`, walking `classes.dex`,
// `classes2.dex`, ... in order until one of them defines the class.
//
// Asking for several fields at once is not a convenience. A lookup is dominated by the type table,
// which lists every type the dex references -- 8428 descriptors in `framework.jar`'s `classes.dex`,
// each one read from a different part of a 51 MB mapping -- and a single pass answers every request
// whose class is named in it. Measured over three devices' own `framework.jar`, four fields of two
// classes cost one pass rather than four.
//
// Every request is written a code or FF_DEX_STATIC_INT_UNRESOLVED. A request is never allowed to
// take the others down with it: the classes a caller asks for are looked for independently, and one
// the jar does not declare leaves its own result at the sentinel while the rest are answered.
//
// Not finding a code is not a failure. A jar that is readable answers the call, whether it declares
// every field asked for, some of them, or none -- the results say which, and what that means for the
// module is the caller's to decide. The return value is therefore reserved for the one thing the
// caller cannot read out of the results: the jar itself, which is reported when it cannot be opened
// or does not hold a dex that can be read. nullptr means the lookup ran.
[[gnu::nonnull(1, 2), nodiscard]] const char* ffDexStaticInts(const char* jarPath, const FFDexStaticIntRequest* requests, uint32_t count);
// ---------------------------------------------------------------------------------------------
// Reading a Parcelable's wire layout
// ---------------------------------------------------------------------------------------------
//
// A Parcelable's `writeToParcel` puts its fields on the wire in the order the method reads them, and
// that order is the only thing that says where each one is. It is not in the class's declaration: a
// dex stores a class's instance fields sorted by field index, which is sorted by *name*, so the
// declaration order a reader would want is not recorded anywhere but the method body.
//
// Recovering it therefore means walking the bytecode. The compiler emits
//
// iget v0, p0, LDisplayInfo;->logicalWidth:I
// invoke-virtual {p1, v0}, Landroid/os/Parcel;->writeInt(I)V
//
// once per field, in write order, so the `iget` opcodes in a linear pass over the instruction grid
// are the sequence. Two things have to be got right for that pass to stay on the grid, and both are
// easy to get wrong in a way that still produces a plausible-looking list:
//
// * Instructions are 1, 2, 3, 4 or 5 code units wide, and the width is a property of the opcode.
// The table below is ART's `Instruction::SizeInCodeUnits`.
// * The payload pseudo-instructions a `switch` or a `fill-array-data` leaves in the stream have a
// low byte of zero and a high byte of 1, 2 or 3. They are not instructions, they sit behind every
// reachable instruction, and stepping into one desynchronises the grid -- so the walk stops at the
// first of them rather than trying to step over it.
//
// An array field is read twice: once for its `length`, which is the count that goes on the wire, and
// again inside the loop that writes the elements. A class cannot declare two instance fields under
// one name, so a repeat is always that reload, and the first occurrence is where the field is
// written. The reader de-duplicates by name for that reason.
//
// What is *not* recovered is how each field is framed -- `writeString` against `writeString8`,
// `writeParcelable` against `writeTypedObject`. That is a property of the method the field is handed
// to, not of the field, and two `String` fields of the same class can differ: `DisplayInfo.name` goes
// through `writeString8` while `DeviceProductInfo.mName` goes through `writeString`. Telling them
// apart would mean resolving every invoke target, so the type descriptor is reported instead and the
// caller frames the fields its descriptor settles -- an `I`, a `J`, an `[F` -- and names the few it
// does not. Measured over three releases' own `framework.jar`, that is four names per class.
//
// The point of asking the device rather than carrying a table is that the field set moves: `DisplayInfo`
// has 34 instance fields on Android 11, 42 on 13 and 59 on 16, and the fields that arrived in between
// (`displayGroupId`, `renderFrameRate`, `appsSupportedModes`, `committedState`, ...) are exactly the
// ones a parser written against one release reads out of the middle of another. Reading the sequence
// from the build that is running makes every one of them optional by construction.
// A field name and a type descriptor are ASCII and short -- the longest name in `DisplayInfo` is 28
// bytes and the longest descriptor `Landroid/hardware/display/DeviceProductInfo$ManufactureDate;` is
// 60. A longer one is a class this reader was not written for, and is reported as unresolved rather
// than truncated: half a name would silently match nothing, which is indistinguishable from the field
// not being there.
#define FF_DEX_PARCEL_FIELD_NAME_MAX 40
#define FF_DEX_PARCEL_FIELD_TYPE_MAX 72
// One field of the write sequence. `type` is the dex type descriptor, e.g. "I", "[F",
// "Ljava/lang/String;" or "Landroid/view/DisplayAddress;".
typedef struct FFDexParcelField {
char name[FF_DEX_PARCEL_FIELD_NAME_MAX];
char type[FF_DEX_PARCEL_FIELD_TYPE_MAX];
} FFDexParcelField;
// One class, and the two things that can be asked about it: the write sequence of one of its methods,
// and which instance fields it declares. Either half may be left out, and both are answered out of
// the same `class_data_item` -- which is why they are one request rather than two calls.
//
// Asking for them together is not a convenience. Both halves are read from a walk that is dominated
// by the type table -- 8428 descriptors in `framework.jar`'s `classes.dex`, each read from a
// different part of a 51 MB mapping -- and the fields a class declares are listed in the very
// `class_data_item` the sequence is read out of. A second call would map the jar again, open every
// entry again and make that pass again to reach a list the first call already had in hand. Measured
// on a Redmi 9A, that second call was 7.0 ms of a 23.5 ms lookup.
typedef struct FFDexParcelRequest {
const char* classDescriptor;
// The write sequence. Left out by a request that only wants the instance fields, in which case
// `fields`, `capacity` and `count` are not read.
const char* methodName;
FFDexParcelField* fields;
uint32_t capacity;
uint32_t* count; // how many fields the sequence holds, or 0 when the jar cannot answer
// The instance fields. This is the question a Parcelable whose layout is not field-driven needs.
// `DisplayCutout` is one: its `writeCutoutToParcel` reads everything through `-$$Nest$` accessors
// the compiler synthesised, so there is no `iget` to walk and no class name on the wire either.
// What does say how long its body is, is which fields the class carries -- Android 11 declares
// three, Android 13 adds `mCutoutPathParserInfo` and Android 16 adds `mSideOverrides`, and each
// one adds a known run of writes behind the three both have. A declaration is a field set rather
// than an order, which is exactly what this answers.
const char* const* instanceFieldNames;
bool* instanceFieldResults;
uint32_t instanceFieldCount;
} FFDexParcelRequest;
// Resolves every request out of the dex entries of `jarPath`, walking `classes.dex`, `classes2.dex`,
// ... in order until one of them defines the class -- the same walk, and the same one pass over the
// type table, that ffDexStaticInts makes.
//
// Every request is written its answers before anything can fail: a count of 0 for the sequence, and
// `false` for every instance field. A class the jar does not declare, a method it does not declare,
// and a sequence longer than the caller's `capacity` all leave the count at 0, and none of them holds
// back the others: they are independent questions about the same pass. A count of 0 is not a failure
// but an answer -- this build does not write that class, so a caller reading it has nothing to walk.
// The return value is reserved for the jar itself, as in ffDexStaticInts.
[[gnu::nonnull(1, 2), nodiscard]] const char* ffDexParcelFields(const char* jarPath, const FFDexParcelRequest* requests, uint32_t count);
+65
View File
@@ -0,0 +1,65 @@
#include "common/android/package.h"
#include "common/android/api.h"
#include "common/debug.h"
#include "common/strutil.h"
#include <string.h>
#include <unistd.h>
// There is no way for a process to ask for its own package name: it is not in /proc/self/status, and
// an app cannot list /data/data. The executable path carries it instead -- an app's binaries live
// under /data/data/<package>/ or /data/user/<user>/<package>/, and /proc/self/exe resolves there.
// Under Termux that is /data/data/com.termux/files/usr/bin/<binary>, whose third component is the
// package.
//
// The memory cgroup carries the same information (4:memory:/apps/com.termux on the device this was
// verified on), but the unified hierarchy spells it out as /apps/uid_10478/pid_26943 with no name
// left in it, so the executable is the portable half of the two.
bool ffAndroidGetOwnPackage(char* buffer, size_t capacity) {
char path[4096];
const ssize_t length = readlink("/proc/self/exe", path, sizeof(path) - 1);
if (length <= 0) {
FF_DEBUG("Cannot read /proc/self/exe, so the calling package cannot be derived");
return false;
}
path[length] = '\0';
const char* rest = nullptr;
const char* const dataPrefix = "/data/data/";
const char* const userPrefix = "/data/user/";
if (ffStrStartsWith(path, dataPrefix)) {
rest = path + strlen(dataPrefix);
} else if (ffStrStartsWith(path, userPrefix)) {
// /data/user/<user>/<package>/... -- the user number has to be stepped over before the
// package name starts, and only strchr() answers where that is.
rest = strchr(path + strlen(userPrefix), '/');
if (rest != nullptr) {
rest += 1;
}
}
if (rest == nullptr) {
const uint32_t uid = instance.state.platform.uid;
FF_DEBUG("The executable is not in an app data directory (\"%s\"), uid %u", path, uid);
if (uid != FF_ANDROID_PRIVILEGED_UID_SHELL) {
return false;
}
static const char shellPackage[] = FF_ANDROID_SHELL_PACKAGE;
if (sizeof(shellPackage) > capacity) {
return false;
}
memcpy(buffer, shellPackage, sizeof(shellPackage));
FF_DEBUG("The calling package is \"%s\" (the shell owns it)", buffer);
return true;
}
const char* end = strchr(rest, '/');
const size_t nameLength = end != nullptr ? (size_t) (end - rest) : strlen(rest);
if (nameLength == 0 || nameLength >= capacity) {
return false;
}
memcpy(buffer, rest, nameLength);
buffer[nameLength] = '\0';
FF_DEBUG("The calling package is \"%s\"", buffer);
return true;
}
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include "fastfetch.h"
// The one package name the shell UID owns. android.os.Process.SHELL_UID is a single app UID that
// owns exactly one package, so a process that cannot derive a package of its own -- a static build
// pushed to /data/local/tmp is the case that showed up -- can answer with this name and have the
// system services accept it. See FF_ANDROID_PRIVILEGED_UID_SHELL in common/android/api.h.
#define FF_ANDROID_SHELL_PACKAGE "com.android.shell"
// Some of the system services take the caller's package name as an argument and check it against the
// calling UID rather than against the name being real: a name nobody owns, and a real name belonging
// to another app, are refused exactly like a null one. So it has to be the caller's own name.
//
// Whether the name is checked at all depends on the service and the release -- `getConnectionInfo`
// answered "Package com.termux does not belong to <shell uid>" on one Android 16 device while the
// same name was accepted on an Android 11 one, and `getWallpaper` refuses a null, empty or foreign
// name on that Android 16 device -- so passing the real one is what works everywhere.
//
// Writes the name into `buffer`, terminator included, and returns whether one was found. `capacity`
// is the caller's, because the parcel the name ends up in is sized from it.
[[gnu::nonnull(1), nodiscard]] bool ffAndroidGetOwnPackage(char* buffer, size_t capacity);
+100
View File
@@ -0,0 +1,100 @@
#include "common/android/zip.h"
#include "common/debug.h"
#include <string.h>
static uint16_t zipU16(const uint8_t* p) {
return (uint16_t) ((uint16_t) p[0] | (uint16_t) ((uint16_t) p[1] << 8));
}
static uint32_t zipU32(const uint8_t* p) {
return (uint32_t) p[0] | ((uint32_t) p[1] << 8) | ((uint32_t) p[2] << 16) | ((uint32_t) p[3] << 24);
}
const char* ffAndroidZipFindEntry(const uint8_t* archive, size_t archiveSize, const char* entry, FFAndroidZipEntry* result) {
const size_t entryLength = strlen(entry);
if (archiveSize < FF_ZIP_EOCD_SIZE) {
return "The archive is too small to be a zip";
}
// The record is the last thing in the file, so it is searched for backwards -- over at most the
// 64 KiB a trailing comment can take, not over the whole archive.
const size_t newest = archiveSize - FF_ZIP_EOCD_SIZE;
const size_t oldest = archiveSize > FF_ZIP_EOCD_MAX_COMMENT + FF_ZIP_EOCD_SIZE
? archiveSize - FF_ZIP_EOCD_MAX_COMMENT - FF_ZIP_EOCD_SIZE
: 0;
size_t eocd = SIZE_MAX;
for (size_t i = newest;; --i) {
if (memcmp(archive + i, FF_ZIP_EOCD_MAGIC, sizeof(FF_ZIP_EOCD_MAGIC) - 1) == 0) {
eocd = i;
break;
}
if (i == oldest) {
// The walk stops here rather than at zero: a `size_t` countdown that has to reach zero
// before it stops would wrap and read the whole file backwards, which is the very scan
// this is here to avoid.
break;
}
}
if (eocd == SIZE_MAX) {
FF_DEBUG("No end-of-central-directory record in the last %zu bytes of a %zu byte archive",
newest - oldest + FF_ZIP_EOCD_SIZE, archiveSize);
return "The archive has no zip directory";
}
const uint32_t directorySize = zipU32(archive + eocd + FF_ZIP_OFF_EOCD_DIRECTORY_SIZE);
const uint32_t directoryOffset = zipU32(archive + eocd + FF_ZIP_OFF_EOCD_DIRECTORY);
if (directoryOffset > archiveSize || directorySize > archiveSize - directoryOffset) {
return "The zip directory is out of range";
}
// The directory is walked to its end rather than for the entry count the record carries: that
// count is a 16-bit field which a 65535-entry archive pins at 0xFFFF and moves into a zip64
// record, while the two bounds above describe the directory itself on every archive this small.
const size_t directoryEnd = (size_t) directoryOffset + directorySize;
for (size_t offset = directoryOffset; offset + FF_ZIP_CENTRAL_SIZE <= directoryEnd;) {
if (memcmp(archive + offset, FF_ZIP_CENTRAL_MAGIC, sizeof(FF_ZIP_CENTRAL_MAGIC) - 1) != 0) {
return "A zip directory entry is malformed";
}
const uint16_t nameLength = zipU16(archive + offset + FF_ZIP_OFF_CENTRAL_NAME_LENGTH);
const uint16_t extraLength = zipU16(archive + offset + FF_ZIP_OFF_CENTRAL_EXTRA_LENGTH);
const uint16_t commentLength = zipU16(archive + offset + FF_ZIP_OFF_CENTRAL_COMMENT_LENGTH);
const size_t entrySize = FF_ZIP_CENTRAL_SIZE + (size_t) nameLength + (size_t) extraLength + (size_t) commentLength;
if (entrySize > directoryEnd - offset) {
FF_DEBUG("A zip entry claims %zu bytes but only %zu remain in the directory",
entrySize, (size_t) (directoryEnd - offset));
return "A zip directory entry runs past the directory";
}
if (nameLength == entryLength && memcmp(archive + offset + FF_ZIP_CENTRAL_SIZE, entry, entryLength) == 0) {
const uint32_t compressedSize = zipU32(archive + offset + FF_ZIP_OFF_CENTRAL_COMPRESSED_SIZE);
const uint32_t uncompressedSize = zipU32(archive + offset + FF_ZIP_OFF_CENTRAL_UNCOMPRESSED_SIZE);
const uint32_t localOffset = zipU32(archive + offset + FF_ZIP_OFF_CENTRAL_LOCAL_OFFSET);
if (compressedSize == FF_ZIP_ZIP64_SENTINEL || uncompressedSize == FF_ZIP_ZIP64_SENTINEL || localOffset == FF_ZIP_ZIP64_SENTINEL) {
FF_DEBUG("The zip entry \"%s\" is zip64: compressed=%u, uncompressed=%u, localOffset=%u",
entry, compressedSize, uncompressedSize, localOffset);
return "The zip entry is stored as zip64, which is not supported";
}
if (localOffset > archiveSize || FF_ZIP_LOCAL_HEADER_SIZE > archiveSize - localOffset) {
return "A zip local header is out of range";
}
const uint16_t localNameLength = zipU16(archive + localOffset + FF_ZIP_OFF_NAME_LENGTH);
const uint16_t localExtraLength = zipU16(archive + localOffset + FF_ZIP_OFF_EXTRA_LENGTH);
const size_t headerSize = FF_ZIP_LOCAL_HEADER_SIZE + (size_t) localNameLength + (size_t) localExtraLength;
if (headerSize > archiveSize - localOffset || compressedSize > archiveSize - localOffset - headerSize) {
return "The zip entry bounds are out of range";
}
result->method = zipU16(archive + offset + FF_ZIP_OFF_CENTRAL_METHOD);
result->uncompressedSize = uncompressedSize;
result->payload = archive + localOffset + headerSize;
result->payloadSize = compressedSize;
return nullptr;
}
offset += entrySize;
}
FF_DEBUG("No entry in the %zu byte archive is named \"%s\"", archiveSize, entry);
return "The archive has no entry with that name";
}
+66
View File
@@ -0,0 +1,66 @@
#pragma once
#include "fastfetch.h"
// Locating an entry inside a zip, which is what both the jar reader and the app label reader need:
// one looks for `classesN.dex`, the other for the resource table of an APK.
//
// The entry is found through the central directory rather than by scanning for its local header,
// and that is not a micro-optimisation. A local header is preceded by everything that came before
// it, so scanning costs a pass over all of it, once per lookup: `framework.jar` is 52 MB and its
// `classes2.dex` starts 9.6 MB in. Measured on the test device, where the sound module resolves
// seven codes, looking the entries up by scanning was the difference between 30 ms and 2 seconds.
//
// The sizes and the compression method are read from the directory rather than from the entry's own
// local header, which is the more reliable of the two: a local header is allowed to leave its sizes
// at zero and put them in a data descriptor behind the payload, and an archive writer is free to
// choose that. Only the local header's two length fields are used, because they are what says where
// the payload begins -- the local extra field does not have to match the central one.
// The zip local file header, from APPNOTE.TXT 4.3.7.
#define FF_ZIP_LOCAL_HEADER_SIZE 30
#define FF_ZIP_OFF_NAME_LENGTH 26
#define FF_ZIP_OFF_EXTRA_LENGTH 28
// The central directory.
#define FF_ZIP_CENTRAL_MAGIC "PK\x01\x02"
#define FF_ZIP_CENTRAL_SIZE 46
#define FF_ZIP_OFF_CENTRAL_METHOD 10
#define FF_ZIP_OFF_CENTRAL_COMPRESSED_SIZE 20
#define FF_ZIP_OFF_CENTRAL_UNCOMPRESSED_SIZE 24
#define FF_ZIP_OFF_CENTRAL_NAME_LENGTH 28
#define FF_ZIP_OFF_CENTRAL_EXTRA_LENGTH 30
#define FF_ZIP_OFF_CENTRAL_COMMENT_LENGTH 32
#define FF_ZIP_OFF_CENTRAL_LOCAL_OFFSET 42
// The end of central directory record, which points at the directory. It is the last thing in the
// file, behind a comment of at most 64 KiB, so it is searched for backwards over that much.
#define FF_ZIP_EOCD_MAGIC "PK\x05\x06"
#define FF_ZIP_EOCD_SIZE 22
#define FF_ZIP_EOCD_MAX_COMMENT 0xffffu
#define FF_ZIP_OFF_EOCD_DIRECTORY_SIZE 12
#define FF_ZIP_OFF_EOCD_DIRECTORY 16
// A size or offset of 0xFFFFFFFF means the real one is in a zip64 extra field. AOSP's framework jars
// and the APKs measured so far are orders of magnitude below that, and carrying the extra field
// reader for them is not worth it.
#define FF_ZIP_ZIP64_SENTINEL 0xffffffffu
#define FF_ZIP_METHOD_STORED 0
#define FF_ZIP_METHOD_DEFLATED 8
// One entry, as the archive describes it. `payload` points into the mapping the caller passed in and
// is not a copy: for a STORED entry it is the file's own bytes, and for a DEFLATED one it is the raw
// deflate stream, which the caller inflates with `uncompressedSize` as the bound.
typedef struct FFAndroidZipEntry {
const uint8_t* payload;
size_t payloadSize;
uint32_t uncompressedSize;
uint16_t method;
} FFAndroidZipEntry;
// Resolves `entry` through the archive's central directory, writing where its payload is into
// `result`. Returns nullptr on success, a static message otherwise -- an archive that is not a zip,
// a directory that is out of range, an entry that is not there and an entry stored as zip64 are all
// reported rather than answered with a pointer into nothing.
[[gnu::nonnull(1, 3, 4), nodiscard]] const char* ffAndroidZipFindEntry(const uint8_t* archive, size_t archiveSize, const char* entry, FFAndroidZipEntry* result);
+1 -1
View File
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>fastfetch</string>
<string>@BUNDLE_ID@</string>
<key>CFBundleName</key>
<string>@PROJECT_NAME@</string>
<key>CFBundleShortVersionString</key>
+57 -25
View File
@@ -1,36 +1,47 @@
#include "cf_helpers.h"
#include "common/debug.h"
const char* ffCfNumGetInt64(CFTypeRef cf, int64_t* result) {
if (CFGetTypeID(cf) == CFNumberGetTypeID()) {
if (!CFNumberGetValue((CFNumberRef) cf, kCFNumberSInt64Type, result)) {
FF_DEBUG("CFNumberGetValue(kCFNumberSInt64Type) failed, the number is of type 0x%08lx",
(unsigned long) CFNumberGetType((CFNumberRef) cf));
return "Number type is not SInt64";
}
return NULL;
return nullptr;
} else if (CFGetTypeID(cf) == CFDataGetTypeID()) {
if (CFDataGetLength((CFDataRef) cf) != sizeof(int64_t)) {
FF_DEBUG("CFData holds %ld bytes, int64_t needs %zu",
(long) CFDataGetLength((CFDataRef) cf), sizeof(int64_t));
return "Data length is not sizeof(int64_t)";
}
CFDataGetBytes((CFDataRef) cf, CFRangeMake(0, sizeof(int64_t)), (uint8_t*) result);
return NULL;
return nullptr;
}
FF_DEBUG("Expected a CFNumber or CFData, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is neither 'CFNumber' nor 'CFData'";
}
const char* ffCfNumGetInt(CFTypeRef cf, int32_t* result) {
if (CFGetTypeID(cf) == CFNumberGetTypeID()) {
if (!CFNumberGetValue((CFNumberRef) cf, kCFNumberSInt32Type, result)) {
FF_DEBUG("CFNumberGetValue(kCFNumberSInt32Type) failed, the number is of type 0x%08lx",
(unsigned long) CFNumberGetType((CFNumberRef) cf));
return "Number type is not SInt32";
}
return NULL;
return nullptr;
} else if (CFGetTypeID(cf) == CFDataGetTypeID()) {
if (CFDataGetLength((CFDataRef) cf) != sizeof(*result)) {
FF_DEBUG("CFData holds %ld bytes, int32_t needs %zu",
(long) CFDataGetLength((CFDataRef) cf), sizeof(*result));
return "Data length is not sizeof(int32_t)";
}
CFDataGetBytes((CFDataRef) cf, CFRangeMake(0, sizeof(*result)), (uint8_t*) result);
return NULL;
return nullptr;
}
FF_DEBUG("Expected a CFNumber or CFData, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is neither 'CFNumber' nor 'CFData'";
}
@@ -38,29 +49,33 @@ const char* ffCfNumGetDouble(CFTypeRef cf, double* result) {
if (CFGetTypeID(cf) == CFNumberGetTypeID()) {
if (!CFNumberGetValue((CFNumberRef) cf, kCFNumberDoubleType, result) &&
!CFNumberGetValue((CFNumberRef) cf, kCFNumberFloatType, result)) {
FF_DEBUG("CFNumber is of type 0x%08lx, neither Double nor Float",
(unsigned long) CFNumberGetType((CFNumberRef) cf));
return "Number type is not Double or Float";
}
return NULL;
return nullptr;
}
FF_DEBUG("Expected a CFNumber, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is neither 'CFNumber'";
}
const char* ffCfDateGetEpoch(CFTypeRef cf, uint64_t* result) {
if (CFGetTypeID(cf) != CFDateGetTypeID()) {
FF_DEBUG("Expected a CFDate, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is not 'CFDate'";
}
CFAbsoluteTime absTime = CFDateGetAbsoluteTime((CFDateRef) cf);
// Convert from seconds to milliseconds and add the difference between 1970 and 2001 in milliseconds
*result = (uint64_t) ((absTime + 978307200 /*kCFAbsoluteTimeIntervalSince1970*/) * 1000);
return NULL;
return nullptr;
}
const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) {
ffStrbufClear(result);
if (!cf) {
return NULL;
return nullptr;
}
if (CFGetTypeID(cf) == CFStringGetTypeID()) {
@@ -72,10 +87,11 @@ const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) {
} else {
uint32_t length = (uint32_t) CFStringGetLength(cfStr);
if (length == 0) {
return NULL;
return nullptr;
}
ffStrbufEnsureFixedLengthFree(result, (uint32_t) CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8));
if (!CFStringGetCString(cfStr, result->chars, result->allocated, kCFStringEncodingUTF8)) {
FF_DEBUG("CFStringGetCString() failed for a %u character string", (unsigned) length);
return "CFStringGetCString() failed";
}
// CFStringGetCString ensures the buffer is NUL terminated
@@ -86,45 +102,48 @@ const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result) {
CFDataRef cfData = (CFDataRef) cf;
uint32_t length = (uint32_t) CFDataGetLength(cfData);
if (length == 0) {
return NULL;
return nullptr;
}
ffStrbufEnsureFixedLengthFree(result, length + 1);
CFDataGetBytes(cfData, CFRangeMake(0, length), (uint8_t*) result->chars);
result->length = (uint32_t) strnlen(result->chars, length);
result->chars[result->length] = '\0';
} else {
FF_DEBUG("Expected a CFString or CFData, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is neither 'CFString' nor 'CFData'";
}
return NULL;
return nullptr;
}
const char* ffCfDataGetDataAsString(CFTypeRef cf, FFstrbuf* result) {
ffStrbufClear(result);
if (!cf) {
return NULL;
return nullptr;
}
if (CFGetTypeID(cf) == CFDataGetTypeID()) {
CFDataRef cfData = (CFDataRef) cf;
uint32_t length = (uint32_t) CFDataGetLength(cfData);
if (length == 0) {
return NULL;
return nullptr;
}
ffStrbufEnsureFixedLengthFree(result, length + 1);
CFDataGetBytes(cfData, CFRangeMake(0, length), (uint8_t*) result->chars);
result->length = length;
result->chars[result->length] = '\0';
} else {
FF_DEBUG("Expected a CFData, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is not 'CFData'";
}
return NULL;
return nullptr;
}
const char* ffCfDictGetString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* result) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
@@ -133,7 +152,8 @@ const char* ffCfDictGetString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* r
const char* ffCfDictGetDataAsString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* result) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
@@ -142,21 +162,24 @@ const char* ffCfDictGetDataAsString(CFDictionaryRef dict, CFStringRef key, FFstr
const char* ffCfDictGetBool(CFDictionaryRef dict, CFStringRef key, bool* result) {
CFBooleanRef cf = (CFBooleanRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
if (CFGetTypeID(cf) != CFBooleanGetTypeID()) {
FF_DEBUG("Expected a CFBoolean, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is not 'CFBoolean'";
}
*result = CFBooleanGetValue(cf);
return NULL;
return nullptr;
}
const char* ffCfDictGetInt(CFDictionaryRef dict, CFStringRef key, int* result) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
@@ -165,7 +188,8 @@ const char* ffCfDictGetInt(CFDictionaryRef dict, CFStringRef key, int* result) {
const char* ffCfDictGetInt64(CFDictionaryRef dict, CFStringRef key, int64_t* result) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
@@ -174,7 +198,8 @@ const char* ffCfDictGetInt64(CFDictionaryRef dict, CFStringRef key, int64_t* res
const char* ffCfDictGetDouble(CFDictionaryRef dict, CFStringRef key, double* result) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
@@ -183,17 +208,21 @@ const char* ffCfDictGetDouble(CFDictionaryRef dict, CFStringRef key, double* res
const char* ffCfDictGetData(CFDictionaryRef dict, CFStringRef key, uint32_t offset, uint32_t size, uint8_t* result, uint32_t* length) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
if (CFGetTypeID(cf) != CFDataGetTypeID()) {
FF_DEBUG("Expected a CFData, got TypeID 0x%08lx", (unsigned long) CFGetTypeID(cf));
return "TypeID is not 'CFData'";
}
CFIndex trueLength = CFDataGetLength((CFDataRef) cf);
if (trueLength < offset + size) {
FF_DEBUG("The CFData holds %ld bytes, the caller asked for [%u, %u)",
(long) trueLength, offset, offset + size);
return "Data length is less than offset + size";
}
@@ -202,22 +231,25 @@ const char* ffCfDictGetData(CFDictionaryRef dict, CFStringRef key, uint32_t offs
}
CFDataGetBytes((CFDataRef) cf, CFRangeMake(offset, size), result);
return NULL;
return nullptr;
}
const char* ffCfDictGetDict(CFDictionaryRef dict, CFStringRef key, CFDictionaryRef* result) {
CFDictionaryRef cf = (CFDictionaryRef) CFDictionaryGetValue(dict, key);
if (cf == NULL || CFGetTypeID(cf) != CFDictionaryGetTypeID()) {
if (cf == nullptr || CFGetTypeID(cf) != CFDictionaryGetTypeID()) {
FF_DEBUG("Expected a CFDictionary, got %s",
cf == nullptr ? "no value at all" : "a value of another type");
return "TypeID is not 'CFDictionary'";
}
*result = cf;
return NULL;
return nullptr;
}
const char* ffCfDictGetDateAsEpoch(CFDictionaryRef dict, CFStringRef key, uint64_t* result) {
CFTypeRef cf = (CFTypeRef) CFDictionaryGetValue(dict, key);
if (cf == NULL) {
if (cf == nullptr) {
FF_DEBUG("The dictionary has no value for the key");
return "CFDictionaryGetValue() failed";
}
+3 -3
View File
@@ -4,7 +4,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
// Return error info if failed, NULL otherwise
// Return error info if failed, nullptr otherwise
const char* ffCfStrGetString(CFTypeRef cf, FFstrbuf* result);
const char* ffCfNumGetInt(CFTypeRef cf, int32_t* result);
const char* ffCfNumGetInt64(CFTypeRef cf, int64_t* result);
@@ -32,7 +32,7 @@ static inline void cfReleaseWrapper(void* type) {
}
}
#define FF_CFTYPE_AUTO_RELEASE FF_A_CLEANUP(cfReleaseWrapper)
#define FF_CFTYPE_AUTO_RELEASE [[gnu::cleanup(cfReleaseWrapper)]]
static inline void wrapIoObjectRelease(io_object_t* service) {
assert(service);
@@ -40,4 +40,4 @@ static inline void wrapIoObjectRelease(io_object_t* service) {
IOObjectRelease(*service);
}
}
#define FF_IOOBJECT_AUTO_RELEASE FF_A_CLEANUP(wrapIoObjectRelease)
#define FF_IOOBJECT_AUTO_RELEASE [[gnu::cleanup(wrapIoObjectRelease)]]
+74 -13
View File
@@ -1,6 +1,7 @@
#include "smc_temps.h"
#include "common/apple/cf_helpers.h"
#include "common/stringUtils.h"
#include "common/debug.h"
#include "common/strutil.h"
#include <stdint.h>
#include <IOKit/IOKitLib.h>
@@ -83,10 +84,13 @@ static void smcUltostr(char* str, uint32_t val) {
static const char* smcCall(io_connect_t conn, uint32_t selector, SmcKeyData_t* inputStructure, SmcKeyData_t* outputStructure) {
size_t size = sizeof(SmcKeyData_t);
if (IOConnectCallStructMethod(conn, selector, inputStructure, size, outputStructure, &size) != kIOReturnSuccess) {
const IOReturn callStatus = IOConnectCallStructMethod(conn, selector, inputStructure, size, outputStructure, &size);
if (callStatus != kIOReturnSuccess) {
FF_DEBUG("IOConnectCallStructMethod(selector=%u, command=%u) failed: IOReturn 0x%08x",
selector, (uint32_t) (unsigned char) inputStructure->data8, (unsigned) callStatus);
return "IOConnectCallStructMethod(conn) failed";
}
return NULL;
return nullptr;
}
// Provides key info, using a cache to dramatically improve the energy impact of smcFanControl
@@ -103,7 +107,7 @@ static const char* smcGetKeyInfo(io_connect_t conn, const uint32_t key, SmcKeyDa
}
*key_info = outputStructure.keyInfo;
return NULL;
return nullptr;
}
static const char* smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcVal_t* val) {
@@ -130,29 +134,33 @@ static const char* smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcV
memcpy(val->bytes, outputStructure.bytes, sizeof(outputStructure.bytes));
return NULL;
return nullptr;
}
static const char* smcOpen(io_connect_t* conn) {
FF_IOOBJECT_AUTO_RELEASE io_object_t device = IOServiceGetMatchingService(MACH_PORT_NULL, IOServiceMatching("AppleSMC"));
if (!device) {
FF_DEBUG("IOKit has no AppleSMC service");
return "No SMC device found";
}
if (IOServiceOpen(device, mach_task_self(), 0, conn) != kIOReturnSuccess) {
const IOReturn openStatus = IOServiceOpen(device, mach_task_self(), 0, conn);
if (openStatus != kIOReturnSuccess) {
FF_DEBUG("IOServiceOpen(AppleSMC) failed: IOReturn 0x%08x", (unsigned) openStatus);
return "IOServiceOpen() failed";
}
return NULL;
return nullptr;
}
static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, double* value) {
SmcVal_t val = { 0 };
const char* error = smcReadSmcVal(conn, key, &val);
if (error != NULL) {
if (error != nullptr) {
return error;
}
if (val.dataSize == 0) {
FF_DEBUG("The SMC key %s reported a data size of 0", key);
return "Empty SMC result";
}
@@ -173,9 +181,12 @@ static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl
*value = (double) ntohll(*(uint64_t*) (val.bytes));
break;
default:
FF_DEBUG("SMC key %s: unsigned type %s has an unsupported size of %u bytes",
key, val.dataType, val.dataSize);
return "Unsupported SMC unsigned integer data size";
}
} else {
FF_DEBUG("SMC key %s: unsupported unsigned type %s", key, val.dataType);
return "Unsupported SMC unsigned data type";
}
break;
@@ -204,9 +215,13 @@ static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl
} else if (ffStrEquals(val.dataType, "fpe2")) {
*value = ntohs(*(uint16_t*) (val.bytes)) / 4.0;
} else {
FF_DEBUG("SMC key %s: unsupported fixed point type %s of %u bytes",
key, val.dataType, val.dataSize);
return "Unsupported SMC floating point data type";
}
} else {
FF_DEBUG("SMC key %s: unsupported floating point type %s of %u bytes",
key, val.dataType, val.dataSize);
return "Unsupported SMC floating point data type";
}
break;
@@ -227,6 +242,8 @@ static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl
*value = (double) ntohll(*(int64_t*) (val.bytes));
break;
default:
FF_DEBUG("SMC key %s: signed type %s has an unsupported size of %u bytes",
key, val.dataType, val.dataSize);
return "Unsupported SMC signed integer data size";
}
} else if (val.dataType[1] == 'p' && val.dataSize == 2) // signed fixed point types
@@ -252,9 +269,12 @@ static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl
} else if (ffStrEquals(val.dataType, "spf0")) {
*value = (int16_t) ntohs(*(int16_t*) (val.bytes)) / 1.0;
} else {
FF_DEBUG("SMC key %s: unsupported signed fixed point type %s of %u bytes",
key, val.dataType, val.dataSize);
return "Unsupported SMC signed integer data type";
}
} else {
FF_DEBUG("SMC key %s: unsupported signed type %s", key, val.dataType);
return "Unsupported SMC signed data type";
}
break;
@@ -263,14 +283,18 @@ static const char* smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl
if (ffStrEquals(val.dataType, "{pwm") && val.dataSize == 2) {
*value = (double) ntohs(*(uint16_t*) (val.bytes)) * 100 / 65536.0;
} else {
FF_DEBUG("SMC key %s: unsupported special type %s of %u bytes", key, val.dataType, val.dataSize);
return "Unsupported SMC special data type";
}
break;
default:
FF_DEBUG("SMC key %s: unknown data type '%c%c' (%s) of %u bytes",
key, val.dataType[0] ? val.dataType[0] : '?', val.dataType[1] ? val.dataType[1] : '?',
val.dataType, val.dataSize);
return "Unsupported SMC data type";
}
return NULL;
return nullptr;
}
static bool detectTemp(io_connect_t conn, const char* sensor, double* sum) {
@@ -291,7 +315,7 @@ static io_connect_t conn;
const char* ffDetectSmcSpecificTemp(const char* sensor, double* result) {
if (!conn) {
if (smcOpen(&conn) != NULL) {
if (smcOpen(&conn) != nullptr) {
conn = (io_connect_t) -1;
}
}
@@ -300,15 +324,16 @@ const char* ffDetectSmcSpecificTemp(const char* sensor, double* result) {
}
if (!detectTemp(conn, sensor, result)) {
FF_DEBUG("The SMC sensor %s could not be read, or read a value outside 10..120", sensor);
return "Could not read SMC temperature";
}
return NULL;
return nullptr;
}
const char* ffDetectSmcTemps(enum FFTempType type, double* result) {
if (!conn) {
if (smcOpen(&conn) != NULL) {
if (smcOpen(&conn) != nullptr) {
conn = (io_connect_t) -1;
}
}
@@ -392,6 +417,27 @@ const char* ffDetectSmcTemps(enum FFTempType type, double* result) {
count += detectTemp(conn, "Tp0e", result); // CPU performance core 8
break;
case FF_TEMP_CPU_M5X:
count += detectTemp(conn, "Tp00", result); // CPU super core 1
count += detectTemp(conn, "Tp04", result); // CPU super core 2
count += detectTemp(conn, "Tp08", result); // CPU super core 3
count += detectTemp(conn, "Tp0C", result); // CPU super core 4
count += detectTemp(conn, "Tp0G", result); // CPU super core 5
count += detectTemp(conn, "Tp0K", result); // CPU super core 6
count += detectTemp(conn, "Tp0O", result); // CPU performance core 1
count += detectTemp(conn, "Tp0R", result); // CPU performance core 2
count += detectTemp(conn, "Tp0U", result); // CPU performance core 3
count += detectTemp(conn, "Tp0X", result); // CPU performance core 4
count += detectTemp(conn, "Tp0a", result); // CPU performance core 5
count += detectTemp(conn, "Tp0d", result); // CPU performance core 6
count += detectTemp(conn, "Tp0g", result); // CPU performance core 7
count += detectTemp(conn, "Tp0j", result); // CPU performance core 8
count += detectTemp(conn, "Tp0m", result); // CPU performance core 9
count += detectTemp(conn, "Tp0p", result); // CPU performance core 10
count += detectTemp(conn, "Tp0u", result); // CPU performance core 11
count += detectTemp(conn, "Tp0y", result); // CPU performance core 12
break;
case FF_TEMP_GPU_INTEL:
count += detectTemp(conn, "TCGC", result); // GPU Intel Graphics
goto gpu_unknown;
@@ -442,6 +488,17 @@ const char* ffDetectSmcTemps(enum FFTempType type, double* result) {
count += detectTemp(conn, "Tg0k", result); // GPU 8
break;
case FF_TEMP_GPU_M5X:
count += detectTemp(conn, "Tg0U", result); // GPU 1
count += detectTemp(conn, "Tg0X", result); // GPU 2
count += detectTemp(conn, "Tg0d", result); // GPU 3
count += detectTemp(conn, "Tg0g", result); // GPU 4
count += detectTemp(conn, "Tg0j", result); // GPU 5
count += detectTemp(conn, "Tg1Y", result); // GPU 6
count += detectTemp(conn, "Tg1c", result); // GPU 7
count += detectTemp(conn, "Tg1g", result); // GPU 8
break;
case FF_TEMP_BATTERY:
count += detectTemp(conn, "TB1T", result); // Battery
count += detectTemp(conn, "TB2T", result); // Battery
@@ -452,14 +509,18 @@ const char* ffDetectSmcTemps(enum FFTempType type, double* result) {
count += detectTemp(conn, "Tm06", result); // Memory 2
count += detectTemp(conn, "Tm08", result); // Memory 3
count += detectTemp(conn, "Tm09", result); // Memory 4
count += detectTemp(conn, "Tm0p", result); // Memory Proximity 1 (M4)
count += detectTemp(conn, "Tm1p", result); // Memory Proximity 2 (M4)
count += detectTemp(conn, "Tm2p", result); // Memory Proximity 3 (M4)
break;
}
FF_DEBUG("None of the SMC sensors for temp type %d reported a usable reading", (int) type);
if (count == 0) {
return "No temperatures detected";
}
*result /= count;
return NULL;
return nullptr;
}
+3 -1
View File
@@ -8,12 +8,13 @@ typedef struct FFTempValue {
double value;
} FFTempValue;
enum FFTempType {
enum FFTempType: uint8_t {
FF_TEMP_CPU_X64,
FF_TEMP_CPU_M1X,
FF_TEMP_CPU_M2X,
FF_TEMP_CPU_M3X,
FF_TEMP_CPU_M4X,
FF_TEMP_CPU_M5X,
FF_TEMP_GPU_INTEL,
FF_TEMP_GPU_AMD,
@@ -22,6 +23,7 @@ enum FFTempType {
FF_TEMP_GPU_M2X,
FF_TEMP_GPU_M3X,
FF_TEMP_GPU_M4X,
FF_TEMP_GPU_M5X,
FF_TEMP_BATTERY,
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include "fastfetch.h"
bool ffGetAppNameAndVersion(const char* exePath, FFstrbuf* retName, FFstrbuf* retVersion);
+43
View File
@@ -0,0 +1,43 @@
#include "common/apple/version.h"
#include "common/strutil.h"
#import <Foundation/Foundation.h>
#define APP_CONTENTS_MACOS ".app/Contents/MacOS"
bool ffGetAppNameAndVersion(const char* exePath, FFstrbuf* retName, FFstrbuf* retVersion) {
char* lastSlash = strrchr(exePath, '/');
if (!lastSlash) {
return false;
}
if ((size_t) (lastSlash - exePath) > strlen("X" APP_CONTENTS_MACOS) && memcmp(lastSlash - strlen(APP_CONTENTS_MACOS), APP_CONTENTS_MACOS, strlen(APP_CONTENTS_MACOS)) != 0) {
return false;
}
lastSlash -= strlen("MacOS");
char infoPlistPath[PATH_MAX];
memcpy(infoPlistPath, exePath, (size_t) (lastSlash - exePath));
memcpy(infoPlistPath + (lastSlash - exePath), "Info.plist", sizeof("Info.plist")); // X.app/Contents/Info.plist
NSError* error;
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL fileURLWithPath:@(infoPlistPath)]
error:&error];
if (!dict) {
return false;
}
if (retName) {
NSString* bundleName = dict[@"CFBundleDisplayName"] ?: dict[@"CFBundleName"];
if (bundleName) {
ffStrbufSetS(retName, bundleName.UTF8String);
}
}
if (retVersion) {
NSString* bundleVersion = dict[@"CFBundleShortVersionString"];
if (bundleVersion) {
ffStrbufSetS(retVersion, bundleVersion.UTF8String);
}
}
return true;
}
+1 -1
View File
@@ -10,7 +10,7 @@ typedef struct FFArgBuffer {
uint32_t length;
} FFArgBuffer;
typedef enum FF_A_PACKED FFArgType {
typedef enum FFArgType: uint8_t {
FF_ARG_TYPE_NULL = 0,
FF_ARG_TYPE_UINT,
FF_ARG_TYPE_UINT64,
@@ -6,9 +6,9 @@
#if !__cplusplus && FF_SUPPORTS_COUNT_OF
#define ARRAY_SIZE(x) _Countof(x)
#elif __has_builtin(__is_array)
#define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
#define ARRAY_SIZE(x) ({ static_assert(__is_array(typeof(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
#elif __has_builtin(__builtin_types_compatible_p)
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(typeof(x), typeof(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
#endif
#endif
#ifndef ARRAY_SIZE
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#ifndef __has_attribute
#error Unsupported compiler
#define __attribute__(x)
#endif
#define FF_A_FALLTHROUGH __attribute__((__fallthrough__))
#define FF_A_DEPRECATED __attribute__((__deprecated__))
#define FF_A_CLEANUP(func) __attribute__((__cleanup__(func)))
#define FF_A_NODISCARD __attribute__((__warn_unused_result__))
#define FF_A_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex)))
#define FF_A_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex)))
#define FF_A_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
#define FF_A_RETURNS_NONNULL __attribute__((__returns_nonnull__))
#define FF_A_UNUSED __attribute__((__unused__))
#define FF_A_PACKED __attribute__((__packed__))
#define FF_A_WEAK_IMPORT __attribute__((__weak_import__))
+5 -4
View File
@@ -2,8 +2,9 @@
#include "fastfetch.h"
void ffBase64EncodeRaw(uint32_t size, const char* str, uint32_t* out_size, char* output);
static inline FFstrbuf ffBase64EncodeStrbuf(const FFstrbuf* in) {
// `str`, `out_size` and `output` are dereferenced unconditionally
[[gnu::nonnull(2, 3, 4)]] void ffBase64EncodeRaw(uint32_t size, const char* str, uint32_t* out_size, char* output);
[[gnu::nonnull(1), nodiscard]] static inline FFstrbuf ffBase64EncodeStrbuf(const FFstrbuf* in) {
FFstrbuf out = ffStrbufCreateA(10 + in->length * 4 / 3);
ffBase64EncodeRaw(in->length, in->chars, &out.length, out.chars);
assert(out.length < out.allocated);
@@ -11,8 +12,8 @@ static inline FFstrbuf ffBase64EncodeStrbuf(const FFstrbuf* in) {
return out;
}
bool ffBase64DecodeRaw(uint32_t size, const char* str, uint32_t* out_size, char* output);
static inline FFstrbuf ffBase64DecodeStrbuf(const FFstrbuf* in) {
[[gnu::nonnull(2, 3, 4)]] void ffBase64DecodeRaw(uint32_t size, const char* str, uint32_t* out_size, char* output);
[[gnu::nonnull(1), nodiscard]] static inline FFstrbuf ffBase64DecodeStrbuf(const FFstrbuf* in) {
FFstrbuf out = ffStrbufCreateA(10 + in->length * 3 / 4);
ffBase64DecodeRaw(in->length, in->chars, &out.length, out.chars);
assert(out.length < out.allocated);

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