Compare commits

...

543 Commits

Author SHA1 Message Date
Linus Dierheimer e829589875 Merge pull request #363 from LinusDierheimer/dev
Bump CMakeList version
2022-12-29 13:47:18 +01:00
李通洲 98acd516b8 CMake: bump version 2022-12-29 20:24:30 +08:00
李通洲 584d792f5a Bios: try supporting FreeBSD
It prints nothing on my VM. Don't know if it works on a physical machine.
2022-12-29 20:23:44 +08:00
Carter Li e6db860861 Merge pull request #362 from LinusDierheimer/dev
Merge macOS Bios module support for 1.8.0
2022-12-29 12:54:32 +08:00
李通洲 f0ec3cb9ec README: update building instructions for Windows
Fixes #336
2022-12-29 12:51:20 +08:00
Carter Li 0801e22dce Bios: support macOS 2022-12-29 11:03:33 +08:00
李通洲 5efd7b9ac4 FFstrbuf: add ffStrbufContainC 2022-12-29 11:03:33 +08:00
Linus Dierheimer f2bae200d3 Merge pull request #361 from LinusDierheimer/dev
Release 1.8.0
2022-12-28 15:26:12 +01:00
李通洲 fd14513aef Changelog: add changes for 1.8.0 2022-12-28 21:28:23 +08:00
李通洲 6becc8f334 Swap: improve performance on Linux
We can't do the same thing with memory because there is no `cachedram` in `struct sysinfo`
2022-12-28 17:27:35 +08:00
李通洲 90359d227e Global: don't require sysinfo.h globally
... which is Linux specific
2022-12-28 17:20:20 +08:00
李通洲 6ff67e87eb Memory: refactor, don't cache results 2022-12-28 17:20:20 +08:00
李通洲 0a83423731 Packages: support eopkg for Solus (#360)
UNTESTED
2022-12-27 17:36:58 +08:00
李通洲 5160644016 Logo: add Solus logo (#360) 2022-12-27 17:32:19 +08:00
李通洲 d956bd2643 Image: update cache folder's name 2022-12-27 17:25:19 +08:00
Carter Li 7a6a2ad530 Chassis: fix compiler warnings
My fault
2022-12-25 23:24:50 +08:00
李通洲 21c76f31c4 Chassis: fix compiler warnings 2022-12-25 12:43:48 +08:00
李通洲 cb48c1277a Chassis: seperate module
It's only supported on Linux
2022-12-24 23:00:38 +08:00
Carter Li 3c18fd8920 Merge pull request #358 from doubletimedan/dev
Spelling and grammer fixes
2022-12-24 20:58:59 +08:00
Daniel Coughlan 83c6e809c6 Correct Windows version 2022-12-24 12:09:11 +00:00
李通洲 dc35fedd74 TerminalShell: detect Windows Terminal Preview 2022-12-24 13:00:43 +08:00
李通洲 947923567f TerminalShell: fix mintty detection (Windows) 2022-12-24 12:52:13 +08:00
Daniel Coughlan 3d19388086 Spelling and grammer fixes 2022-12-23 22:17:40 +00:00
李通洲 051f6643a6 Image: fix build 2022-12-23 15:23:37 +08:00
李通洲 47e01a7157 Image: print more debug info when errored 2022-12-23 12:51:37 +08:00
李通洲 a336145ed9 Image: add fast path for kitty protocol 2022-12-23 12:45:57 +08:00
李通洲 ecc6b477dc TerminalFont: support Kitty 2022-12-23 11:11:27 +08:00
李通洲 e0c6c462a6 README: update document of Windows 10- and image logo support 2022-12-22 22:10:49 +08:00
李通洲 3e607680e2 Image: dont leak memories 2022-12-22 21:47:30 +08:00
李通洲 89347b7bee Image: add dirty support of iTerm image protocol
iTerm image protocol supports most commonly used image formats so we don't need image magick to convert image format.
However, since we don't know anything about the image, `--logo-width` `--logo-height` must be specified to make sure that logo will not be covered by texts.
2022-12-22 21:37:16 +08:00
李通洲 c45ef08926 Image: expose more chafa settings 2022-12-22 11:36:13 +08:00
Linus Dierheimer 8d40b2cd0e Merge pull request #355 from kojq/dev
Update help.txt
2022-12-21 21:37:24 +01:00
kojq 14e318c273 Merge branch 'dev' into dev 2022-12-21 15:20:20 -05:00
李通洲 f50b478966 Image: try fixing caching 2022-12-22 02:40:56 +08:00
李通洲 0cacedfc5d Image: enable Chafa on Windows
It's not built by default, as imagemagick requires too many dlls.
2022-12-22 02:07:57 +08:00
Linus Dierheimer 5283f10189 Merge pull request #357 from AloneER0/dev
Added OpenMandriva
2022-12-21 18:42:22 +01:00
AloneER0 c9c2526f08 Added OpenMandriva 2022-12-21 17:27:00 +01:00
kojq fba4bca46e Merge branch 'dev' into dev 2022-12-21 07:51:49 -05:00
Carter Li a95eb65faa Merge pull request #352 from CarterLi/dev
Global: remove caching functions except image caching
2022-12-21 19:29:55 +08:00
kojq bcc7b630ae Update help.txt 2022-12-21 04:38:28 -05:00
kojq a247a8d6ba Update help.txt 2022-12-21 04:23:57 -05:00
kojq 620adc0ec6 Update help.txt 2022-12-21 04:10:33 -05:00
kojq d5b3ae9056 Update help.txt 2022-12-21 04:02:02 -05:00
kojq afe56a36c9 Update help.txt 2022-12-21 03:52:16 -05:00
kojq 265b98311a Update help.txt 2022-12-21 03:51:02 -05:00
kojq 89983a28b4 Update help.txt 2022-12-21 03:44:48 -05:00
kojq c9918035ed Update help.txt 2022-12-21 03:31:23 -05:00
李通洲 225d1dd4d2 Init: don't try to find config files in XDG folders on platforms other than Linux and BSD 2022-12-20 23:29:23 +08:00
李通洲 985fc991e8 Revert "Image: tidy"
This reverts commit d21ce9b10f.
2022-12-20 22:44:45 +08:00
李通洲 8f3900a9df Windows: add manifest file to indicate that we use UTF-8 and support Windows 10+ 2022-12-20 22:40:06 +08:00
李通洲 d21ce9b10f Image: tidy 2022-12-20 22:37:15 +08:00
李通洲 1153d29099 TerminalFont: improve conhost font detection (Windows) 2022-12-20 12:03:05 +08:00
李通洲 75341e8172 Image: make it compile on Windows
Doesn't work yet.
2022-12-20 11:37:54 +08:00
李通洲 2f5cbfb03a Image: enable im7 on macOS 2022-12-20 11:04:57 +08:00
李通洲 01d2d77efd Image: fix resource leaks 2022-12-20 11:01:42 +08:00
李通洲 1b2a61ed49 Image: init MagickCore environment before using it
I don't know why im6 works without initialization, but im7 doesn't.
2022-12-20 11:01:13 +08:00
李通洲 10584eb01a Image: document macOS support; update CI 2022-12-19 22:34:29 +08:00
李通洲 d4ec500b1b Image: fix compile error when building with chafa enabled
It should be `#include <chafa.h>` because `pkg-config chafa --cflags` prints `-I/usr/include/chafa` even in Linux. It was working because `chafa` folder was installed in the standard `/usr/include` directory, but it was not the case for macOS (brew)
2022-12-19 22:34:29 +08:00
李通洲 c7bec3d0c9 Image: enable imagemagick 6 on macOS
Program crashed when imagemagick 7 used, for some reason.
2022-12-19 22:34:29 +08:00
李通洲 ff6e982050 Global: remove caching except image caching 2022-12-17 12:41:11 +08:00
李通洲 6a49ae60a1 Locale: silence warnings (Windows) 2022-12-17 12:34:21 +08:00
李通洲 27fb0c6c06 Battery: improve performance (Windows) 2022-12-17 12:31:37 +08:00
李通洲 047b32e7d9 CpuUsage: make the result more accurate 2022-12-17 12:31:31 +08:00
李通洲 eeb008f505 Global: replace all ".so" to FF_LIBRARY_EXTENSION
... no matter whether the libraries are linux specific or not
2022-12-17 12:22:11 +08:00
Linus Dierheimer 704834b370 Merge pull request #350 from JackGannonUK/dev
Add Enso Logo
2022-12-16 19:06:53 +01:00
李通洲 a3cb6608ce Locale: refactor 2022-12-16 11:51:32 +08:00
Jack Gannon 7640042905 add enso logo
Added Enso Logo in `src/logo/builtin.c`
Added Enso in `README.md`
2022-12-15 16:57:45 +00:00
李通洲 d601cc823c DisplayServer: make 3rd party window manager plugin detection a slow operation (macOS)
The display server of macOS is [Quartz Compositor](https://en.wikipedia.org/wiki/Quartz_Compositor), not other 3rd party apps.
2022-12-14 19:03:01 +08:00
李通洲 338cc1db40 Add back trailing white spaces which are unexpectedly removed by IDE
This partially reverts commit 6710967d19.
2022-12-14 16:51:45 +08:00
李通洲 6710967d19 README: update notes for Windows 10- 2022-12-14 16:46:52 +08:00
李通洲 e4a5194115 Rework stdout buffering on Windows.
Windows doesn't support line-buffering. We enable full-buffering instead and flush buffers per module.
2022-12-14 16:27:04 +08:00
李通洲 d151901049 Common: improve resolution of ffTimeGetTick 2022-12-14 15:43:53 +08:00
李通洲 c9e9ec3a80 CI: print time usage 2022-12-14 14:10:42 +08:00
李通洲 54912df237 Option: enable --show-errors if --stat is set 2022-12-14 13:52:16 +08:00
李通洲 b09aa3240a Global: support --stat option for benchmark 2022-12-14 11:30:50 +08:00
李通洲 c9bc1f8306 Vulkan: build with vulkan-loader (macOS)
... so cmake can find it
2022-12-13 13:12:13 +08:00
李通洲 7e98fa8626 Vulkan: don't require vulkan-loader (macOS)
Which also avoids requiring portability_enumeration extension
2022-12-13 11:21:26 +08:00
李通洲 3b2c189083 Packages: split brew-cellar and brew-cask (macOS)
`brew info` shows number of `brew-cellar` packages only. Split `brew-cellar` out of `brew` to avoid users from confusion.
2022-12-13 11:13:00 +08:00
Linus Dierheimer c242001a77 Fix build without chafa 2022-12-12 13:58:16 +01:00
Linus Dierheimer b21cfc127a Termialshell: ignore sh 2022-12-12 13:55:19 +01:00
Linus Dierheimer 3a5af1bbb3 Logo: data source option
#345
2022-12-12 13:43:10 +01:00
李通洲 68b98c1bd2 Windows: disable stdout buffer 2022-12-10 22:47:53 +08:00
李通洲 24ae7ec6e0 Windows: build msvcrt version for Windows 10-
However we don't include it in release package to prevent users from confusion.

Also clarify we only support FreeBSD
2022-12-10 22:47:44 +08:00
李通洲 e3590bc673 Wmtheme: fix detection on Windows 10- 2022-12-10 22:22:09 +08:00
李通洲 72dcc5223d Global: rename --disable-stdout-buffer to --unbuffered 2022-12-10 13:11:41 +08:00
李通洲 4558af2e43 Windows: fix build 2022-12-10 13:10:06 +08:00
李通洲 ed259fad9c Windows: tweaks 2022-12-08 18:33:43 +08:00
李通洲 b4e2997389 Tests: don't include fastfetch.h 2022-12-08 18:29:24 +08:00
李通洲 d946a46d3f TerminalFont: fix memleaks (Linux) 2022-12-08 18:27:04 +08:00
李通洲 983bd50a09 FFstrbuf: improve performance of InitF 2022-12-06 16:27:00 +08:00
李通洲 4f0be4f72c Wifi: silence compiler warnings 2022-12-05 18:02:10 +08:00
李通洲 58aa3e94e4 Init: add --disable-stdout-buffer option 2022-12-03 22:21:24 +08:00
李通洲 19ec59cca5 Wifi: init basic support for Linux 2022-12-02 22:43:46 +08:00
李通洲 911780ba3c Cursor: silence compiler warnings 2022-12-02 22:20:23 +08:00
李通洲 8b0d034a94 FFstrbuf: fix bug of AppendF when string len == ffStrbufGetFree 2022-12-02 22:20:01 +08:00
李通洲 2a8235ae38 Host: improve performance (macOS) 2022-12-02 22:18:39 +08:00
李通洲 15a98a83cd Linux: fix some memleaks 2022-12-02 16:39:02 +08:00
李通洲 1dc578badb Wifi: silence warnings 2022-12-02 01:20:06 +08:00
李通洲 be698bd806 Processes: don't hard code magic numbers (Windows) 2022-12-02 01:12:56 +08:00
李通洲 0cad657ce2 Swap: correct implementation (Windows) 2022-12-02 01:12:48 +08:00
李通洲 7991abab0b TerminalFont: support deepin-terminal 2022-12-01 17:45:17 +08:00
李通洲 b3e635a923 Wifi: support macOS 2022-11-28 16:59:11 +08:00
李通洲 57b794cbd9 macOS: fix build 2022-11-28 16:29:51 +08:00
李通洲 974dc96259 Wifi: support multiple interfaces 2022-11-28 16:29:30 +08:00
李通洲 db33d246cb common/io: improve performance for large files 2022-11-28 01:57:45 +08:00
李通洲 5e5442426c Wifi: load wlanapi.dll dynamically
Windows Server doesn't support it
2022-11-27 16:22:30 +08:00
李通洲 a55add190c Wifi: add new module
Only Windows is supported currently
2022-11-27 12:21:53 +08:00
李通洲 5c381460ce util: rename register -> registry 2022-11-27 12:21:53 +08:00
李通洲 4cf1d5bf94 util: rename unicode helper function names 2022-11-27 12:21:32 +08:00
李通洲 4316ba988b CpuUsage: optimise performance further 2022-11-25 23:14:41 +08:00
李通洲 c6a9217c74 Windows: silense compiler warnings 2022-11-25 23:13:57 +08:00
李通洲 34d3021b80 Build: fix Android is incorrectly detected as Linux 2022-11-25 19:17:37 +08:00
李通洲 c57417e834 Logo: adjust ubuntu logo style 2022-11-25 18:09:49 +08:00
Linus Dierheimer 00f86c6346 CMake: Don't require pkg-config 2022-11-24 18:10:49 +01:00
李通洲 0ab38bb4d7 CPU: fix cpu freq detection in WSL
`/sys/devices/system/cpu/cpufreq/policy0/` doesn't exist in WSL
2022-11-24 23:30:54 +08:00
李通洲 7da45d6c2c DE: fix detection for Windows Server 2022-11-24 23:30:54 +08:00
Linus Dierheimer 3c7f02bee3 Merge pull request #338 from CarterLi/dev
Improve performance and various fixes
2022-11-24 14:14:03 +01:00
Linus Dierheimer 686a66e5f1 Merge pull request #340 from draumaz/dev
add CRUX logo
2022-11-24 14:12:08 +01:00
李通洲 c50d7bf974 Logo: remove Windows 11 Old, add Windows 11 Small 2022-11-24 21:06:08 +08:00
李通洲 d70b3100f2 BSD: fix build 2022-11-24 18:59:40 +08:00
李通洲 d500bdff96 WmTheme: convert known color values to readable strings 2022-11-24 17:38:40 +08:00
draumaz 8de88adc0b add CRUX logo, update README.md 2022-11-23 23:31:11 -08:00
李通洲 4b3ed67877 TerminalShell: detect Clink 2022-11-24 11:24:12 +08:00
李通洲 11258c0d8d TerminalShell: code cleanup (Windows) 2022-11-24 11:23:45 +08:00
李通洲 325aa536c4 Font: improve performance (Windows) 2022-11-23 20:01:41 +08:00
李通洲 31863baee2 CpuUsage: remove unused code (Windows) 2022-11-23 20:01:41 +08:00
李通洲 0f08233581 Users: improve performance (Windows) 2022-11-23 20:01:40 +08:00
李通洲 b28da1057c WmTheme: detect accent color (Windows) 2022-11-23 20:01:40 +08:00
李通洲 4fa3ca98a2 util/register: fix crashing when value string contains non-ascii chars
We can't use RegGetValueA because RegGetValueA converts wide string to non UTF-8 string, which results in crashing when printing
2022-11-23 17:44:57 +08:00
李通洲 66f8a8cdd0 TerminalFont: fix Windows Terminal font detection when running inside msys2 2022-11-23 17:44:57 +08:00
李通洲 051423e75e util: add mallocHelper and use it 2022-11-23 17:44:57 +08:00
李通洲 ae562ac962 Cursor: support Windows (not working yet) 2022-11-23 17:44:57 +08:00
李通洲 772dd1e294 GPU: improve performance (Windows) 2022-11-23 15:38:59 +08:00
李通洲 27212e8b98 Battery: improve performance (Windows) 2022-11-23 15:38:59 +08:00
李通洲 629c2de253 util: add a helper function to convert wide strings (Windows) 2022-11-23 15:38:59 +08:00
李通洲 9ef95e43a3 CPU: improve performance (Windows) 2022-11-22 19:40:57 +08:00
李通洲 6a304dbb4d OS: improve performance (Windows) 2022-11-22 19:40:57 +08:00
李通洲 4355039329 Host: improve performance (Windows) 2022-11-22 19:40:56 +08:00
李通洲 5aebb400da Board: improve performance (Windows) 2022-11-22 19:40:56 +08:00
李通洲 fbd8c0237f BIOS: improve performance (Windows) 2022-11-22 19:40:56 +08:00
李通洲 04c9d16c16 util: introduce register helpers and use them (Windows) 2022-11-22 19:40:56 +08:00
李通洲 308408a962 Processes: improve performance (Windows) 2022-11-22 19:40:56 +08:00
李通洲 19c5904561 Memory: improve performance by not querying WMI (Windows) 2022-11-21 15:45:53 +08:00
Linus Dierheimer c0037c99e4 Refactor CMakeLists.txt 2022-11-20 18:14:32 +01:00
Linus Dierheimer b85c1c44b8 Merge pull request #332 from CarterLi/dev
Various improvements
2022-11-20 12:51:51 +01:00
李通洲 1c69d6c788 Disk: use statvfs64 only when __USE_LARGEFILE64 is defined 2022-11-20 19:43:02 +08:00
李通洲 b6b95581cd Windows: partially revert a5306d60ee to fix crashes on Windows 7
Very strange behavior. Needs further investigation
2022-11-20 02:18:06 +08:00
李通洲 55c6374949 WmTheme: support Windows 7 2022-11-20 00:57:32 +08:00
李通洲 0a65867937 Windows: fix memleaks 2022-11-20 00:52:52 +08:00
李通洲 859f645fe5 Disk: fix size detection on 32bit Linux
Ref: #337
2022-11-18 00:10:16 +08:00
李通洲 f1cc94207e Host: detect WSL version 2022-11-17 22:36:49 +08:00
李通洲 70847857f7 GPU: remove special handling for WSL
WSL2 is VM, which can only provide virtual GPUs, like other VMs do. We should honor it.

As of WSL 1.0, it prints `Microsoft Corporation Basic Render Driver`
2022-11-17 22:36:49 +08:00
李通洲 2a34978487 Thread: silence compiler warnings 2022-11-17 22:36:49 +08:00
李通洲 fde9379bb2 Android: simplify code; fix mistakes in terminal font detection code 2022-11-17 20:19:27 +08:00
李通洲 e8e586ce7c Windows / macOS: simplify code
1. simplify resource management by using C++ RAII like GCC attribute extension `cleanup`
2. simplify HEKY reading

Actually `__attribute__((__cleanup__(cleanupFn)))` is supported on all major C compiler ( gcc, clang and icc ) except MSVC I only used it on Windows and macOS for now. Let's see if the project author like it.
2022-11-17 19:54:36 +08:00
李通洲 fb78d9bbb9 TerminalFont: support Warp; improve performance of Apple Terminal (macOS) 2022-11-17 19:53:12 +08:00
李通洲 a498e9e142 CPU: don't remove (R) in CPU name to be consistant with GPU name 2022-11-17 10:33:50 +08:00
李通洲 d0d6f48751 osascript: simplify code (macOS) 2022-11-17 10:18:29 +08:00
李通洲 0361a30c40 Font: simplify code; fix memleaks (macOS) 2022-11-17 10:18:13 +08:00
李通洲 d0c18c4679 DisplayServer: don't use private API (macOS) 2022-11-17 10:18:13 +08:00
李通洲 8aca8a2229 Temps: silence compiler warnings 2022-11-17 10:18:13 +08:00
李通洲 0bbecb3b33 Thread: silence compiler warnings 2022-11-17 00:13:25 +08:00
李通洲 3f008c4b6d CpuUsage: improve performance 2022-11-15 17:48:57 +08:00
李通洲 227eb707d2 CpuUsage: fix calucation on Windows 2022-11-15 17:30:16 +08:00
李通洲 a5306d60ee Windows: enable console processing, disable output buffer
UCRT doesn't support line buffering, which makes modules being not printed ASAP
2022-11-15 14:50:57 +08:00
李通洲 e3de39d3ab Windows: add version info in binaries 2022-11-12 21:33:31 +08:00
李通洲 f4666fcb0a README: document Windows 10- support 2022-11-12 21:33:31 +08:00
李通洲 85a554b60d CPU: support Windows 7 2022-11-12 21:33:31 +08:00
李通洲 1ea44417d0 TerminalFont: add support for ConEmu 2022-11-12 21:33:31 +08:00
李通洲 0605cb754b OS: fix Windows 7 detection 2022-11-12 21:33:31 +08:00
李通洲 f889d919f8 TerminalShell: add basic support for ConEmu 2022-11-12 21:33:31 +08:00
李通洲 d670a9a584 Kernel: support Windows 7 2022-11-12 21:33:31 +08:00
Linus Dierheimer e51b8276cd Merge pull request #333 from kbdharun/dev
Add Vanilla OS logo
2022-11-10 18:01:03 +01:00
K.B.Dharun Krishna 67feba6171 Add Vanilla OSlogo
Adding logo for Vanilla OS a new and upcoming Ubuntu based distribution that uses Vanilla GNOME and uses on-demand immutability.

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2022-11-08 10:50:04 +05:30
Linus Dierheimer 922de3755b Merge pull request #330 from CarterLi/dev
Networking: support nowait connection
2022-11-04 11:51:55 +01:00
李通洲 9da7bb3f30 Networking: support nowait connection (Posix)
Thread was used for now.
It's possible to do nonblocking connect & send with io_uring on Linux, but it requires newer kernel and linking to liburing. I don't think it is worth the effort.
2022-11-03 20:25:09 +08:00
李通洲 46ebb52afa Thread: split ffThreadCreateAndDetach; add ffThreadJoin 2022-11-03 20:25:09 +08:00
李通洲 4f97692245 Networking: support nowait connection (Windows) 2022-11-03 20:25:09 +08:00
Linus Dierheimer 25a833207e Merge pull request #329 from wvlab/dev
Add Nobara logo
2022-11-02 19:36:47 +01:00
WVlab 8224f8c4c6 README: Add Nobara to avaliable logos section 2022-11-02 16:27:03 +00:00
WVlab c455718ada add nobara logo 2022-11-02 16:00:00 +00:00
Linus Dierheimer 37b1d24575 Merge pull request #328 from jumps-are-op/fix_cpu_format_setting
Fix setting `cpu-format`
2022-11-01 16:34:40 +01:00
jumps 449d121f19 Fix setting cpu-format
`--cpu-format` set `terminal-format` instead of `cpu-format` because of
a typo in fastfetch.c
2022-11-01 18:25:42 +03:00
Linus Dierheimer 9a51d203de Merge pull request #327 from jumps-are-op/add_parabola_logo
Logo: Add Parabola GNU/Linux-libre logo (instead of #324)
2022-11-01 16:11:15 +01:00
jumps 0e92fc2289 README: Add Parabola to logos sections 2022-11-01 18:08:06 +03:00
jumps 54c649e76e Add Parabola GNU/Linux-libre logo 2022-11-01 17:53:59 +03:00
Linus Dierheimer 45f8b86f13 Don't segfault if 0 is given as argument index
#326
2022-11-01 14:54:27 +01:00
Linus Dierheimer a8a1f98a8f Merge pull request #323 from CarterLi/dev
Improve detection on Android
2022-11-01 14:34:38 +01:00
李通洲 b8f14c964a Disk: detect Windows volumes on WSL 2022-10-28 16:29:31 +08:00
李通洲 de964d3e77 Disk: only prints useful mount points on Android
fix #322
2022-10-28 16:29:31 +08:00
李通洲 4634606a36 CpuUsage: clearify the restriction on Android 2022-10-28 16:29:31 +08:00
Linus Dierheimer 5d306ed9f3 Don't print vulkan driver info, if it contains new lines
#316
2022-10-27 13:23:24 +02:00
Linus Dierheimer ba1fc7a03e Merge pull request #319 from CarterLi/dev
Improvements for FreeBSD and a small fix for macOS
2022-10-27 11:37:02 +02:00
李通洲 8b43605abf README: document Chocolatey support 2022-10-27 17:03:53 +08:00
李通洲 2ee5b3b7a5 TerminalShell: add support for tcsh
which is the default shell for freebsd
2022-10-27 16:45:59 +08:00
李通洲 302a588812 TerminalShell: fix shellExe detection on macOS
`proc_pidpath()` works only if bufsize >= PROC_PIDPATHINFO_MAXSIZE
2022-10-27 16:45:59 +08:00
李通洲 2a1330dea3 README: clearify we support FreeBSD only, not OpenBSD or NetBSD 2022-10-27 16:45:59 +08:00
李通洲 5472621ac0 Disk: support freebsd
Also rewrite macOS detection to share code with bsd
2022-10-27 16:45:59 +08:00
李通洲 9ad7ba7144 CpuTemp: support freebsd
Untested
2022-10-27 11:15:53 +08:00
李通洲 895d151e2e Host: support freebsd 2022-10-27 11:15:53 +08:00
李通洲 3ee15d0401 CpuUsage: add to presets/all 2022-10-27 10:17:29 +08:00
李通洲 60ad6792ba CpuUsage: support freebsd 2022-10-27 10:17:29 +08:00
Linus Dierheimer b878d3ccf6 Merge pull request #315 from CarterLi/dev
Improvements and bug fix for terminal font detection
2022-10-26 15:18:07 +02:00
李通洲 f93bd9e28b TerminalFont: fix platform font detection
my bad...
2022-10-26 20:02:15 +08:00
李通洲 9c73f6b787 TerminalShell: support freebsd 2022-10-26 19:49:25 +08:00
李通洲 64b9f69fb1 Swap: support freebsd 2022-10-26 17:43:08 +08:00
李通洲 aca2c01c9e Processes: support freebsd 2022-10-26 17:43:08 +08:00
李通洲 470d160346 Uptime: support freebsd 2022-10-26 17:43:08 +08:00
李通洲 e225b496b1 Disk: don't print hidden removable volumes (macOS) 2022-10-25 20:02:26 +08:00
李通洲 f470744e44 Kernel: improve performance, detect code name (Windows) 2022-10-25 20:02:26 +08:00
李通洲 42fec6e61f Logo: add new Windows 11 logo
Ref: https://github.com/dylanaraps/neofetch/pull/2187
2022-10-24 22:20:59 +08:00
李通洲 883a535441 Packages: support Chocolatey (Windows) 2022-10-23 23:28:49 +08:00
Linus Dierheimer 65b342cac7 Merge pull request #314 from CarterLi/dev
Improve performance on Windows
2022-10-23 15:55:33 +02:00
李通洲 1395abcf09 TerminalFont: improve Windows Terminal terminal font detection on Windows 2022-10-23 18:48:31 +08:00
李通洲 e59d64513f Silence warnings 2022-10-23 17:54:19 +08:00
李通洲 ed85b8249a Init: enable buffering on Windows 2022-10-23 17:54:02 +08:00
Linus Dierheimer bddf1c67bf Merge pull request #313 from CarterLi/fix
Fixes and performance improvements
2022-10-23 09:48:11 +02:00
李通洲 62ab091350 Printing: improve performace of ffPrintCharTimes 2022-10-23 10:46:09 +08:00
李通洲 1588f58726 Windows: silence warnings when building with clang 2022-10-23 10:11:54 +08:00
李通洲 688a16c941 Disk: fix --disk-folder parsing on Windows 2022-10-23 10:11:53 +08:00
李通洲 69b3a6871f Init: improve option parsing performance 2022-10-23 10:11:53 +08:00
李通洲 0aac358e33 Init: simplify module arg parsing code 2022-10-23 10:08:02 +08:00
Linus Dierheimer 7f82f8d679 Merge pull request #312 from CarterLi/android
Android: add vulkan support for GPU detection
2022-10-22 18:19:32 +02:00
Linus Dierheimer 5fb96223a8 Merge pull request #308 from CarterLi/bar
Global: support bar output for percentage value #294
2022-10-22 18:18:44 +02:00
李通洲 e13c88cea6 Global: support bar output for percentage value #294 2022-10-22 16:15:12 +08:00
李通洲 fbc76714f5 Android: add vulkan support for GPU detection
Termux does have package pciutils, but it's put inside of root-repo and
and doesn't provide libpci.pc. So I think use vulkan can be a better
option than libpci because vulkan.so is provided by Android system.

To build with android support, install `vulkan-headers` and
`vulkan-loader-android` (for `vulkan.pc`).
2022-10-20 17:42:01 +08:00
Linus Dierheimer c7adbc1309 Merge pull request #311 from LinusDierheimer/revert-306-dev
Revert "Add Univalent GNU/Linux's logo"
2022-10-19 08:29:53 +02:00
Linus Dierheimer b27453d275 Revert "Add Univalent GNU/Linux's logo" 2022-10-19 08:29:39 +02:00
Linus Dierheimer aa0501b853 Merge pull request #306 from Jin-Asanami/dev
Add Univalent GNU/Linux's logo
2022-10-19 08:23:12 +02:00
Jin Asanami 596c776463 fix univalent's colours 2022-10-19 12:18:39 +09:00
Linus Dierheimer eb1738b1c6 Merge pull request #309 from CarterLi/swap
Swap: split code out from memory detection
2022-10-18 20:34:03 +02:00
Linus Dierheimer 0505926c75 Merge pull request #307 from CarterLi/dev
Disk: add volume name detection; don't print 0B / 0B (0%)
2022-10-18 20:25:13 +02:00
李通洲 581c6f547d Swap: split code out from memory detection
1. Since swap module is disabled by default, swap detection is unnecessary in most cases.
2. On platform other than Linux, swap detection doesn't share code with memory.
3. Swap detection can be expensive. On Windows, it requires another WMI query which can lag heavily in some cases. Don't pay for you don't use.
2022-10-19 00:24:17 +08:00
李通洲 3d5ef186ba Disk: don't convert NAN to integer; don't print 0B / 0B (0%)
fix ASAN warning: `runtime error: nan is outside the range of representable values of type 'unsigned char'`
2022-10-18 21:23:29 +08:00
李通洲 e3ea39afaa Disk: add volume name detection 2022-10-18 21:23:29 +08:00
Jin Asanami 7f9269cff2 Update builtin.c 2022-10-18 11:30:48 +09:00
Jin Asanami bbcc040dc4 Update README.md 2022-10-18 11:27:54 +09:00
Jin Asanami 727a6988c2 Update builtin.c 2022-10-18 11:26:31 +09:00
Linus Dierheimer 7bbd2aee94 Merge pull request #305 from LinusDierheimer/work/disk_refactor
Work/disk refactor
2022-10-17 18:24:29 +02:00
Linus Dierheimer b812f1dcb4 Disk: Fix build on windows 2022-10-17 17:52:43 +02:00
Linus Dierheimer fb2dca2eaf Merge pull request #303 from CarterLi/win
Windows: fix kernel detection; simplify WMI query code
2022-10-17 17:48:15 +02:00
Linus Dierheimer a03eaed4e2 Disk: add options# 2022-10-17 17:35:06 +02:00
Linus Dierheimer ee705363c1 Disk: Don't always build apple code 2022-10-17 17:13:45 +02:00
Linus Dierheimer c1fec9b411 Disk: Apple implementation working 2022-10-17 08:10:58 -07:00
Linus Dierheimer 19a9b18c69 Disk: Linux impl working 2022-10-17 13:19:48 +02:00
李通洲 38b3aae1e3 Windows: simplify WMI query code
by making C++ code more C++
2022-10-17 00:17:26 +08:00
李通洲 5d5663e2a7 Kernel: fix detection on Windows
According to MSDN, GetVersionExA is not reliable. We have to query WMI instead.
2022-10-17 00:17:19 +08:00
Linus Dierheimer 973eb8127e Merge pull request #302 from VitoFe/dev
Add Garuda small variant
2022-10-15 23:04:03 +02:00
VitoFe 2499cbdab8 Add Garuda small variant 2022-10-15 18:05:21 +00:00
Linus Dierheimer ec80a41871 Merge pull request #298 from CarterLi/dev
TerminalShell: improve speed on Windows
2022-10-15 19:49:44 +02:00
李通洲 a829e85ef5 LocalIP: support --localip-name-prefix on Windows 2022-10-16 01:34:26 +08:00
李通洲 a090bed6c0 Logo: try printing logo on Windows Server
Completely untested
2022-10-15 23:46:00 +08:00
李通洲 76684e49ca TerminalShell: speed up PowerShell version detection by querying the version of pwsh.exe file
Also add cmd version detection
2022-10-15 22:45:30 +08:00
李通洲 c1fc6e2762 Processing: handle a possible error 2022-10-15 21:59:50 +08:00
李通洲 437431a821 TerminalShell: support Windows PowerShell version detection 2022-10-15 21:44:28 +08:00
李通洲 5749a8f7c1 TerminalShell: improve speed on Windows
[NtQueryInformationProcess](https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntqueryinformationprocess) is an internal NT syscall which may change in the future. However, unlike other NT syscalls NtQueryInformationProcess is well documented on MSDN, so I think it's safe to use.

Boost shell detection by 0.3s on my machine. Note querying PowerShell's version `pwsh --version` costs another 0.2s
2022-10-15 21:20:58 +08:00
Linus Dierheimer 54e271c985 Merge pull request #297 from CarterLi/dev
Update information on different platforms
2022-10-15 12:21:43 +02:00
李通洲 b042b90d9b TerminalShell: improve shell detection on Windows 2022-10-15 11:36:24 +08:00
李通洲 a99ca9a1a1 macOS: remove unneeded dependencies 2022-10-15 01:02:46 +08:00
李通洲 f05d036023 README: update description on different platforms 2022-10-15 01:02:16 +08:00
Linus Dierheimer 5a55691358 Merge pull request #296 from CarterLi/dev
TerminalShell: fix bash version detection on Windows
2022-10-14 17:43:00 +02:00
李通洲 4f0dd51761 TerminalShell: fix bash version detection on Windows
Currently we use `env -i /path/to/bash --norc --noprofile -c printf "%s" "$BASH_VERSION"` to detect bash version.
This is problematic on Windows because there is no `env` in $PATH ( there is env in $PATH of msys2 but not in $PATH of Windows )
With this modification the detection is also faster because 1 process is created only
2022-10-14 22:58:56 +08:00
Linus Dierheimer 0ca6f76e88 Merge pull request #295 from CarterLi/dev
Remove msys target and other improvements
2022-10-14 13:56:04 +02:00
李通洲 869f544bab ci: fix errors 2022-10-14 19:40:13 +08:00
李通洲 4f67ed2b77 TerminalShell: add some pretty names 2022-10-14 19:16:55 +08:00
李通洲 3f4926cbd5 TerminalShell: detect platform specific terminal on correct system only 2022-10-14 19:16:55 +08:00
李通洲 af93157a76 TerminalShell: handle nested shell 2022-10-14 19:16:55 +08:00
李通洲 220a7d24bc TerminalShell: detect first shell we found only.
Previously we always detect login shell as current shell, which seems duplicate with userShell
2022-10-14 18:33:11 +08:00
李通洲 3b541d3670 Thread: fix compile errors 2022-10-14 18:33:11 +08:00
李通洲 4bd6f2da89 TerminalShell: add lock ( Windows ) 2022-10-14 18:33:11 +08:00
李通洲 d5e00c3517 ci: package Windows artifacts; run tests on Windows 2022-10-14 18:33:11 +08:00
李通洲 1b7a2c2ed5 MSYS2: remove support
MSYS2 version was built for smooth transition from POSIX api to Win32 api. It has almost identical output as Windows native version, except requiring msys runtime dll and being a bit slower.
2022-10-14 18:33:11 +08:00
李通洲 11ad7a8a3d TerminalShell: unify shell version detection code 2022-10-14 18:33:11 +08:00
李通洲 622f84c971 Kernel: remove special handling for Windows
Since we have an implementation for it
2022-10-14 17:39:07 +08:00
李通洲 779a33349a OS: don't print msys2 logo for native Windows 2022-10-14 17:39:07 +08:00
李通洲 135ca1eeba Packages: don't rely on environment variables 2022-10-14 17:38:53 +08:00
Linus Dierheimer 2dee7f5982 Update CI 2022-10-14 10:49:08 +02:00
Linus Dierheimer 1513b8c0db Fix more build errors 2022-10-13 22:12:31 +02:00
Linus Dierheimer 693cc1e730 Fix build errors 2022-10-13 22:02:58 +02:00
Linus Dierheimer e18980be9f Require sucessfull windows and msys build for release 2022-10-13 21:47:28 +02:00
Linus Dierheimer cf048bc723 Refactor package detection code 2022-10-13 21:43:31 +02:00
Linus Dierheimer 3004d8c9dc Merge pull request #293 from CarterLi/dev
Support Native Windows
2022-10-13 18:01:10 +02:00
李通洲 6f66b87262 Windows: support --list-presets 2022-10-13 23:49:09 +08:00
李通洲 79cfa96616 Processing: fix Windows impl 2022-10-13 23:49:09 +08:00
李通洲 952cacf3ff ci: build with Windows native 2022-10-13 23:49:09 +08:00
李通洲 3cc6611614 Windows: support native Windows 2022-10-13 23:49:09 +08:00
李通洲 457c2da67d Packages: silence warnings 2022-10-13 23:49:08 +08:00
李通洲 13769e0e52 Disk: removes unnecessary #includes 2022-10-13 23:49:08 +08:00
李通洲 b33e042cd4 Library: support Windows 2022-10-13 23:49:08 +08:00
李通洲 2689a20889 Uptime: support Windows 2022-10-13 23:49:08 +08:00
Linus Dierheimer d769fd32f0 Merge pull request #292 from Edsploration/logofix
Fix Alpine, EndeavourOS, Rocky, and Rosa logos
2022-10-13 11:15:29 +02:00
Edward Piper 2c82c9a6dc Fixed Alpine, EndeavourOS, Rocky, and Rosa logos 2022-10-12 10:26:38 -07:00
Linus Dierheimer 3850130583 Merge pull request #291 from CarterLi/dev
Windows: improve Win32 API compatibility
2022-10-12 16:00:45 +02:00
李通洲 06262c078d TerminaFont: move windows specific code into its own file 2022-10-12 21:59:21 +08:00
李通洲 b64a234f8a Networking: support Windows 2022-10-12 21:59:21 +08:00
李通洲 dfed3812ce Title: don't include unnecessary headers 2022-10-12 21:59:21 +08:00
李通洲 1b594d9ed1 Thread: add common thread abstraction layer, and make threading optional 2022-10-12 21:59:21 +08:00
李通洲 d0f589bb3e Disk: silence warning on macOS 2022-10-12 14:03:03 +08:00
Linus Dierheimer bc72f3cd64 Don't build dmg 2022-10-11 19:41:37 +02:00
Linus Dierheimer de8f1a86c6 Merge pull request #289 from CarterLi/dev
Make CI actually work on Windows
2022-10-11 19:22:48 +02:00
李通洲 4bae08c159 OS: detect Windows Server 2022-10-12 01:12:58 +08:00
李通洲 34cd81b4d9 ci: run fastfetch on Windows 2022-10-12 00:19:31 +08:00
李通洲 8c127a175c TerminalShell: try detecting more shells 2022-10-12 00:19:31 +08:00
李通洲 5e3e2b6137 Windows: fix possible crashes 2022-10-12 00:19:31 +08:00
Linus Dierheimer 88a16d4c7d Merge pull request #286 from CarterLi/dev
Improvements, see commit list
2022-10-11 16:00:45 +02:00
Linus Dierheimer 296674cfd6 Merge branch 'master' into dev 2022-10-11 14:35:36 +02:00
Linus Dierheimer 875174e2e0 Release 1.7.5 2022-10-11 14:29:13 +02:00
Linus Dierheimer 4393fa1a47 ffStrbufLastIndexC: account for empty strings
#285
2022-10-11 14:28:35 +02:00
Linus Dierheimer 5ae2031bcf Manually cherry pick shell process name detection 2022-10-11 14:28:21 +02:00
Linus Dierheimer 779266e61e Release 1.7.5 2022-10-11 14:26:00 +02:00
李通洲 8e8d283959 Windows: fix crashing 2022-10-11 20:13:44 +08:00
李通洲 2cb7be67bd ci: add Windows 2022-10-11 19:44:43 +08:00
李通洲 9bc5c99fc8 Font: fix memleak on Linux 2022-10-11 19:44:43 +08:00
李通洲 424fbfc9c9 TerminalShell: actually support macOS 2022-10-11 19:44:43 +08:00
李通洲 3d2497f963 macOS: fix compile warnings 2022-10-11 19:19:43 +08:00
李通洲 2e42bbb1a2 Don't enable LTO on Debug mode
which breaks debuging on macOS
2022-10-11 19:19:43 +08:00
李通洲 9879a95570 Packages: fix scoop detection when it's not installed 2022-10-11 19:19:43 +08:00
Linus Dierheimer d54f14a14c ffStrbufLastIndexC: account for empty strings
#285
2022-10-11 12:37:54 +02:00
Linus Dierheimer cdcac06dbf Merge pull request #284 from LinusDierheimer/master
Print the last element of the default structure
2022-10-10 10:49:54 +02:00
Linus Dierheimer 6b81223002 Print the last element of the default structure
#283
2022-10-10 10:30:52 +02:00
Linus Dierheimer df986d36a2 Print the last element of the default structure
#283
2022-10-10 10:16:43 +02:00
Linus Dierheimer 173c9043e3 Merge pull request #282 from CarterLi/msys2
Introduce Windows support
2022-10-09 22:24:19 +02:00
Linus Dierheimer 488986e42e Release 1.7.3 2022-10-09 21:36:53 +02:00
李通洲 f2540f00a5 Address some feedbacks 2022-10-09 23:23:46 +08:00
李通洲 643aa7c156 TerminalFont: add conhost detection 2022-10-09 22:29:00 +08:00
李通洲 0381d88e2d TerminalShell: detect cmd ( Windows ) 2022-10-09 22:29:00 +08:00
李通洲 6a9fd7a84d TerminalShell: silence compiler warnings 2022-10-09 21:12:27 +08:00
李通洲 2a491a8da9 Merge remote-tracking branch 'origin/master' into msys2 2022-10-09 21:10:43 +08:00
李通洲 983669019e README: clearify Windows support 2022-10-09 21:07:35 +08:00
李通洲 553f90a7c4 Logo: add support for Windows 2022-10-09 21:07:34 +08:00
李通洲 00f5b84660 Disk: improve performance; support --disk-folders option 2022-10-09 21:07:34 +08:00
Linus Dierheimer b548c6405b Destroy everything
#276
2022-10-09 13:34:55 +02:00
李通洲 6e190c6f7c Fix some mistakes 2022-10-09 17:47:30 +08:00
李通洲 661c174348 Merge remote-tracking branch 'origin/master' into msys2 2022-10-09 16:55:51 +08:00
李通洲 034f444fca Terminal / Shell: fix name printing 2022-10-09 16:51:53 +08:00
Linus Dierheimer 1dd942a7b1 TARGET_DIR_ETC 2022-10-09 10:39:57 +02:00
Linus Dierheimer 2f6613cb50 Merge pull request #274 from CarterLi/master
macOS: respect CMAKE_INSTALL_SYSCONFDIR; use Cocoa API to parse plist files
2022-10-09 10:25:38 +02:00
李通洲 7c98450acc OpenCL / Vulkan: enable support for Windows 2022-10-09 15:37:15 +08:00
李通洲 510d57e7dd Fix huge compiler warnings when compiling C++ code
C++ requires a white space between two string literals
2022-10-09 15:37:15 +08:00
李通洲 da797ecb33 Cursor / Icons / Theme / GTK / Qt: don't compile on Windows / macOS / Android 2022-10-09 15:37:15 +08:00
李通洲 7080449a8c DE: add support for Windows 2022-10-09 15:37:15 +08:00
李通洲 2c51252396 LocalIP: add support for Windows 2022-10-09 15:37:15 +08:00
李通洲 5114051725 TerminalShell: fix nested shells detection, add more error checks 2022-10-09 15:37:15 +08:00
李通洲 959371d1ea CpuUsage: Disable no wait detection by default because the result does need some time to generate 2022-10-09 15:37:15 +08:00
李通洲 f7ba00746b Fix compiling on Linux 2022-10-09 15:37:15 +08:00
李通洲 8387d8651e Kernel: add support for Windows 2022-10-09 15:37:15 +08:00
李通洲 af6b7dd81b Packages: add support for Windows 2022-10-09 15:37:15 +08:00
李通洲 89850535ae Windows: replace __CYGWIN__ with __MSYS__ 2022-10-09 15:37:14 +08:00
李通洲 09a2f96cf0 TerminalShell: add support for Windows 2022-10-09 15:37:14 +08:00
李通洲 8246c6e61d Windows: builds without exceptions and RTTI
which removes libstdc++ dependency
2022-10-09 15:37:14 +08:00
李通洲 cc490294e9 Font: add support for Windows 2022-10-09 15:37:14 +08:00
李通洲 0a55071f88 Memory: add support for Windows 2022-10-09 15:37:14 +08:00
李通洲 a57e334d73 CpuUsage: support no wait detection on Windows 2022-10-09 15:37:14 +08:00
李通洲 174d885649 CpuUsage: add support for Windows 2022-10-09 15:37:14 +08:00
李通洲 32d3edc690 CPU: add support for Windows 2022-10-09 15:37:14 +08:00
李通洲 a7e93faac8 Disk: print if a folder removable; improve performance 2022-10-09 15:37:14 +08:00
李通洲 49921f5ed1 Disk: add support for Windows
Also major refactoring of util/windows/wmi
2022-10-09 15:37:14 +08:00
李通洲 8849107260 Processes: add support for Windows 2022-10-09 15:37:13 +08:00
李通洲 ad03c42a28 OS: add support for Windows 2022-10-09 15:37:13 +08:00
李通洲 015ad4a307 Fix possible memleaks 2022-10-09 15:37:13 +08:00
李通洲 c0daeb16df Users: add support for Windows 2022-10-09 15:37:13 +08:00
李通洲 a0a46ab73f WMTheme: add support for WIndows 2022-10-09 15:37:13 +08:00
李通洲 bedd6a1d5d Battery: add support for Windows 2022-10-09 15:37:13 +08:00
李通洲 8ea2014baf OpenGL: add support for Windows 2022-10-09 15:37:13 +08:00
李通洲 e59f4e7e45 Resolution: add support for Windows 2022-10-09 15:37:13 +08:00
李通洲 0d3d881c24 GPU: add support for Windows 2022-10-06 23:03:19 +08:00
李通洲 230d2ac39d Board: split out from host; add support for Windows 2022-10-06 23:03:15 +08:00
李通洲 c7e6e45078 Host: split Bios module; init support for Windows 2022-10-06 23:02:39 +08:00
李通洲 db88d413c3 TerminalFont: print error on failing 2022-10-06 23:01:19 +08:00
李通洲 eaa4230bf5 Windows: add basic support for msys2 2022-10-06 23:01:19 +08:00
Carter Li 145e09d164 OS: simplify macOS OS detection code; print BuildID on macOS ( to match neofetch ) 2022-10-02 01:54:43 +08:00
Carter Li 01dbd0c266 macOS: completely drop libplist dependency 2022-10-02 01:54:43 +08:00
Carter Li 11f3dc3ea0 WMTheme: use Cocoa API to parse plist file
drop libplist dependency ( macOS )
2022-10-02 01:54:24 +08:00
Carter Li 87de3f1c4a TerminalFont: use Cocoa API to parse plist file
drop libplist dependency ( macOS )
2022-10-02 01:54:02 +08:00
Carter Li 03511bd014 Config: respect CMAKE_INSTALL_SYSCONFDIR 2022-10-01 23:25:15 +08:00
Linus Dierheimer b0ad1294e4 Merge pull request #273 from CarterLi/master
Temps: test & fix temp detection on Intel ( macOS )
2022-09-30 18:38:01 +02:00
Carter Li fcbeecb0d5 Temps: test & fix temp detection on Intel ( macOS ) 2022-10-01 00:29:51 +08:00
Linus Dierheimer b3c501516a Merge pull request #271 from CarterLi/master
Improvements
2022-09-30 14:00:03 +02:00
李通洲 9418138892 Networking: ensure server returns 200 OK 2022-09-30 17:43:23 +08:00
Linus Dierheimer 265254ddf7 Merge pull request #270 from CarterLi/master
Font: suppress IO when detecting fonts on macOS
2022-09-29 16:23:17 +02:00
李通洲 946154dbac Font: suppress IO when detecting fonts on macOS
Removes

* 2022-09-29 07:06:58.649 flashfetch[92995:31447779] XType: com.apple.fonts is not accessible.
* 2022-09-29 07:06:58.649 flashfetch[92995:31447779] XType: XTFontStaticRegistry is enabled.
2022-09-29 22:19:08 +08:00
Linus Dierheimer 287ba33d12 Merge pull request #269 from CarterLi/master
Font: fix compiling on Android; detect more fonts on macOS
2022-09-29 16:15:44 +02:00
李通洲 ca75b6b55b Font: fix compiling on Android; detect more fonts on macOS 2022-09-29 22:13:27 +08:00
Linus Dierheimer 666b596f63 Update FreeBSD action 2022-09-29 16:04:18 +02:00
Linus Dierheimer 5b68cdc0dd Fix compilation warning on linux 2022-09-29 15:53:28 +02:00
Linus Dierheimer 0f47a27d09 Install some more packages for freebsd build 2022-09-29 15:45:13 +02:00
Linus Dierheimer e6e189497d Refactor font output 2022-09-29 14:15:11 +02:00
Linus Dierheimer 32d3b265bb Fix compilation warning on linux 2022-09-29 12:51:46 +02:00
Linus Dierheimer ca318431f5 Merge pull request #266 from CarterLi/master
Improve performance of PublicIP; add module Weather; fix compiling for Linux
2022-09-29 12:41:19 +02:00
李通洲 8a52836afc Init: don't pay for unused module
Networking can be very slow
2022-09-29 18:33:37 +08:00
李通洲 9cf95620a9 Weather: add new module 2022-09-29 18:33:37 +08:00
李通洲 c72c6c4a27 PublicIp: add option to set public IP server URL 2022-09-29 18:33:37 +08:00
李通洲 e289db184c PublicIp: improve performance 2022-09-29 18:33:37 +08:00
李通洲 e7c9b80d85 Fix building on Linux
It seems that glibc doesn't support strnstr, and strcasestr requires
_GNU_SOURCE to be defined
2022-09-29 18:33:37 +08:00
Linus Dierheimer b8656d5e12 Fix build on BSD 2022-09-29 12:24:00 +02:00
Linus Dierheimer c8486610f6 Don't build multithreaded 2022-09-29 12:15:52 +02:00
Linus Dierheimer d727f8acde Use hw.ncpu in bsd action 2022-09-29 12:08:40 +02:00
Linus Dierheimer 8c64e0c275 Try to add a FreeBSD action 2022-09-29 11:37:52 +02:00
Linus Dierheimer 40588e1a39 Fix build on MacOS
#261
2022-09-29 11:35:59 +02:00
Linus Dierheimer 6c024d29ce Merge pull request #263 from CarterLi/master
Support terminal font detection on Android and other fixes
2022-09-27 17:44:47 +02:00
李通洲 db6ad5a268 CpuUsage: improve performance
by moving the first `/proc/stat` query earlier
2022-09-27 23:41:39 +08:00
李通洲 5096b4a81d Common: add missing features 2022-09-27 23:30:55 +08:00
李通洲 5c64ce3b89 Users: add missing module settings 2022-09-27 23:30:55 +08:00
李通洲 38a6d07c85 TerminalFont: support Termux 2022-09-27 23:30:55 +08:00
李通洲 4632fe8cd9 Android: fix compiling 2022-09-27 23:30:55 +08:00
Linus Dierheimer d8bfebfc0f Update readme 2022-09-27 15:05:41 +02:00
Linus Dierheimer 48300429af Keep detected colors when using none logo
#264
2022-09-27 15:02:35 +02:00
Linus Dierheimer 218dffadd3 Merge pull request #258 from CarterLi/master
[macOS] support Temps, Font; Host pretty print; other improvements
2022-09-26 10:45:14 +02:00
李通洲 f324794f54 LocalIp: add option --localip-name-prefix
eg: --localip-name-prefix en
2022-09-26 16:20:51 +08:00
李通洲 6e3a329d3b Users: add new module
I don't think it's very useful but neofetch support it
2022-09-26 15:29:11 +08:00
李通洲 b2da8bac41 Font: add option to display fonts inline ( enabled by default ) 2022-09-26 15:29:11 +08:00
李通洲 100e59fd49 Temps: add options to enable detection ( disabled by default ) 2022-09-26 15:29:11 +08:00
李通洲 5fdb0719f2 Host: pretty printing hardware model ( macOS ) 2022-09-26 15:29:11 +08:00
李通洲 d4368f56fd Datetime: fix pretty printing 2022-09-26 15:29:11 +08:00
李通洲 55c939a8ef macOS: don't build cursor / icons / theme 2022-09-26 15:29:11 +08:00
李通洲 0be2410925 Font: support macOS
The original result format was too Linux specific to make it portable, so I simplified it.
2022-09-26 15:29:11 +08:00
李通洲 0f824536f9 Temps: open SMC service only once ( macOS ) 2022-09-26 15:29:11 +08:00
李通洲 51c70bc44a Temps: support macOS 2022-09-26 15:29:11 +08:00
李通洲 47a0b8969f FFstrbuf: more inline fns and more tests 2022-09-26 14:57:54 +08:00
李通洲 8df95224ed Android: fix build 2022-09-26 10:21:38 +08:00
Linus Dierheimer 4481d983a9 Merge pull request #260 from AloneER0/master
Fixed formatting
2022-09-25 21:11:47 +02:00
AloneER0 24e8158116 Fixed formatting 2022-09-25 16:05:06 +02:00
Linus Dierheimer 5239223ad5 Merge pull request #259 from AloneER0/master
New Ubuntu logo
2022-09-25 15:56:46 +02:00
AloneER0 1d9a938ff3 Restored Older Ubuntu Logo 2022-09-25 15:41:42 +02:00
AloneER0 cd01d16eb9 New Ubuntu logo 2022-09-25 13:31:59 +02:00
Linus Dierheimer 8e856c3dd6 Wayland: don't leak memory
#256
2022-09-24 16:34:03 +02:00
Linus Dierheimer b6dc436e03 Merge pull request #257 from CarterLi/master
Various improvements, see commits history for detail
2022-09-24 16:24:32 +02:00
李通洲 3f80fafc09 Android: fix build 2022-09-24 22:22:20 +08:00
李通洲 8e922abf73 TerminalFont: split code of different implementations 2022-09-24 22:18:48 +08:00
李通洲 737b36e799 FFstrbuf / FFlist: add some improvements
1. make some short fns inlinable
2. simplify implementation
3. fix possible crashes with non-allocated strbuf
4. make the default init fn allocates no memory
5. add more tests
2022-09-24 22:18:48 +08:00
Linus Dierheimer f5ac85c4e3 Only detect temps if --allow-slow-operations is given 2022-09-24 15:59:36 +02:00
Linus Dierheimer 0250d11d97 Merge pull request #255 from dr460nf1r3/master
Fix GiB MiB format RAM units due to value being hardcoded in some presets
2022-09-24 15:14:00 +02:00
dr460nf1r3 e88472e9f6 Oops, typo 2022-09-24 15:11:33 +02:00
dr460nf1r3 2907a26adf Fix GiBMiB format RAM units due to value being hardcoded in some presets 2022-09-24 15:09:53 +02:00
Linus Dierheimer d337126c80 Fix possible crash in strbuf 2022-09-24 00:43:55 +02:00
Linus Dierheimer 099fb1a43a Enable running workflow in private repository 2022-09-24 00:42:21 +02:00
Linus Dierheimer 6efe186df1 Merge pull request #254 from CarterLi/master
TerminalFont: support Windows Terminal on WSL
2022-09-23 19:59:17 +02:00
Linus Dierheimer f33f172734 Revert "Revert some changes"
This reverts commit 64d64d5050.
2022-09-23 19:54:18 +02:00
李通洲 d6a1caa89f TerminalFont: fix resource leaks on macOS 2022-09-24 01:49:08 +08:00
李通洲 ed5d7292ba TerminalFont: support Windows Terminal detection 2022-09-24 01:49:08 +08:00
Linus Dierheimer 4b0b6c9000 Merge branch 'master' of github.com:LinusDierheimer/fastfetch 2022-09-23 19:49:06 +02:00
Linus Dierheimer 64d64d5050 Revert some changes 2022-09-23 19:48:55 +02:00
Linus Dierheimer 1a996c3d67 Merge pull request #253 from CarterLi/master
[macOS] Disk & Media improvements
2022-09-23 16:08:52 +02:00
李通洲 ee7231d87c Media: fix detecting songs with CJK chars 2022-09-23 21:23:48 +08:00
李通洲 371b3a2d75 Disk: better folder detection, support removable devices ( macOS ) 2022-09-23 21:23:48 +08:00
Linus Dierheimer 007ded2883 Revert "Don't inline strbuf methods on macos"
This reverts commit c32f2f2f2b.
2022-09-23 12:11:04 +02:00
Linus Dierheimer c32f2f2f2b Don't inline strbuf methods on macos 2022-09-23 12:05:07 +02:00
Linus Dierheimer 98c94b01e5 Some more standard comformance 2022-09-23 11:51:16 +02:00
Linus Dierheimer 0dda4efa8d Merge pull request #251 from CarterLi/master
PowerAdapter: make it a seperated module ( macOS )
2022-09-23 10:46:56 +02:00
Linus Dierheimer 877ed94187 Fix possible crash if giving invalid format string
#252
2022-09-23 10:43:11 +02:00
李通洲 484264027c FFstrbuf: don't free string literals 2022-09-23 15:33:23 +08:00
李通洲 5498b0b042 PowerAdapter: make it a seperated module 2022-09-23 15:33:23 +08:00
Linus Dierheimer 8f30d0cdd8 Move inline functions to end of header 2022-09-23 01:27:25 +02:00
Linus Dierheimer 80f18e2473 Don't force inline 2022-09-23 00:49:43 +02:00
Linus Dierheimer 1700d23c26 Always inline some strbuf methods 2022-09-23 00:10:48 +02:00
Linus Dierheimer 195675f078 run.sh: add env to build as debug 2022-09-22 23:10:34 +02:00
Linus Dierheimer 0115b638de Destroy instance in flashfetch too 2022-09-22 22:04:32 +02:00
Linus Dierheimer 3d0653025e Leak sanitizer: no false positives 2022-09-22 22:02:58 +02:00
Linus Dierheimer 991d02e2c0 Merge pull request #249 from CarterLi/master
[macOS] add power adapter module
2022-09-22 20:50:03 +02:00
李通洲 cbab8d7f70 Fix some memleaks 2022-09-22 21:28:20 +08:00
李通洲 6e09157235 Battery: add power adapter support ( macOS ) 2022-09-22 19:07:18 +08:00
李通洲 464a57b319 Locale: simply 2022-09-22 17:51:30 +08:00
Linus Dierheimer d31d157b00 New caching mechanism for CPU 2022-09-21 17:26:10 +02:00
Linus Dierheimer 07231ffbbc Merge pull request #247 from CarterLi/master
[macOS] support cpuUsage and other improvements
2022-09-21 12:15:38 +02:00
李通洲 f9fa482b83 Locale: try detecting with locale command
in case $LC_* envs are not set ( macOS )
2022-09-21 18:10:50 +08:00
李通洲 65ed48a1bc Swap: prints Disabled instead of 0 B / 0 B (0%) which seems a bug 2022-09-21 18:10:50 +08:00
李通洲 3068b5bcb2 Memory: fix percentage calculation 2022-09-21 18:10:50 +08:00
李通洲 9da97f5860 WMTheme: fix detection on macOS; metion macOS support in README 2022-09-21 18:10:50 +08:00
李通洲 fa065c1040 Terminal: fix Alacritty detection on macOS 2022-09-21 18:10:50 +08:00
李通洲 664017ba81 OS: print codename ( macOS ) 2022-09-21 18:10:50 +08:00
李通洲 1d6fefd40b CpuUsage: support macOS 2022-09-21 18:10:50 +08:00
Linus Dierheimer fea4a9dfd5 Fix build with ancient libpci versions
#248
2022-09-21 12:02:14 +02:00
Linus Dierheimer 183c8d7904 Merge pull request #246 from CarterLi/master
WMTheme: support macOS
2022-09-20 18:14:22 +02:00
李通洲 e5b110375f FFlist: add tests 2022-09-20 23:56:43 +08:00
李通洲 6eed53217d FFstrbuf: fix bugs in ffStrbufAppendS; add more tests 2022-09-20 23:56:43 +08:00
李通洲 254c4e5f50 WMTheme: support macOS 2022-09-20 21:49:11 +08:00
Linus Dierheimer 01a917982c Fix build on macos 2022-09-20 15:21:39 +02:00
Linus Dierheimer a9cb178315 Better error messages for memory & swap 2022-09-20 15:12:24 +02:00
Linus Dierheimer ec4bd5d3a2 Merge pull request #245 from CarterLi/master
[macOS] add player detection
2022-09-20 13:18:26 +02:00
李通洲 7f19cb1d21 Battery: print error info instead of nan% ( macOS ) 2022-09-20 18:26:50 +08:00
李通洲 e60537512e Media: add playing status 2022-09-20 18:07:46 +08:00
李通洲 431f570f05 Media: support player detection ( macOS ) 2022-09-20 18:07:46 +08:00
李通洲 482e5a5eff util/cf_helpers: rename; return error info if failed 2022-09-20 17:50:14 +08:00
Linus Dierheimer c282384dab CPack: Build pkg on free bsd 2022-09-20 11:40:42 +02:00
Linus Dierheimer 81bddbf182 Update README.md 2022-09-20 11:23:49 +02:00
Linus Dierheimer b8fc471678 Better BSD support 2022-09-20 11:16:08 +02:00
Linus Dierheimer fd34811c81 Merge pull request #244 from draumaz/master
Add FreeBSD logo
2022-09-20 09:47:04 +02:00
draumaz 67c5a6b7cc add missing comma, update README 2022-09-20 01:42:51 +00:00
draumaz 6b02e1a0ca add to ffLogoBuiltinGetAll 2022-09-20 01:38:48 +00:00
draumaz 92f1604e6a add preliminary FreeBSD logo 2022-09-20 01:37:48 +00:00
Linus Dierheimer f0cee064bd Basic BSD support 2022-09-19 23:16:43 +02:00
Linus Dierheimer 6bd933eba2 Enable BSD support in CMake 2022-09-19 22:23:31 +02:00
Linus Dierheimer f3e6d04c8e Fix build on macos the second 2022-09-19 21:45:39 +02:00
Linus Dierheimer d5846d94ca Fix build on macos 2022-09-19 21:37:01 +02:00
Linus Dierheimer 2a61d29be9 sysctl utils 2022-09-19 21:31:50 +02:00
Linus Dierheimer 49cdacd5a9 Build cpu on free bsd 2022-09-19 19:31:29 +02:00
Linus Dierheimer ce6d7e386d Build wayland on free bsd 2022-09-19 19:29:13 +02:00
Linus Dierheimer fe1ad0da16 Build local ip on free bsd 2022-09-19 19:26:53 +02:00
Linus Dierheimer 6157de60e6 Processes: fail if neither apple nor sysinfo is present 2022-09-19 19:23:19 +02:00
Linus Dierheimer 61e71ed658 run.sh: only use -j$(nproc) on linux 2022-09-19 19:19:09 +02:00
Linus Dierheimer 381cba2612 Refactor ff_lib_enable 2022-09-19 18:30:00 +02:00
Linus Dierheimer 34b273186a FF_LIBRARY_LOAD: don't implicit create pointer 2022-09-19 18:00:19 +02:00
Linus Dierheimer e3acd8c155 Share more code between media detection on different platforms 2022-09-19 17:53:00 +02:00
Linus Dierheimer 55f28ae8ff Fix build with older libpci versions the second 2022-09-19 16:58:25 +02:00
Linus Dierheimer 6f2748e208 Merge pull request #242 from CarterLi/master
Media: support song detection on macOS
2022-09-19 16:46:20 +02:00
Linus Dierheimer fb3eb9666e Fix build with older libpci versions 2022-09-19 16:43:43 +02:00
Linus Dierheimer 8d663300c7 Detect FQDN only on linux 2022-09-19 15:57:52 +02:00
Linus Dierheimer d29d99bd6d Use pci_fill_info when possible 2022-09-19 15:54:27 +02:00
李通洲 bbdeb668d6 Media: support song detection on macOS 2022-09-19 20:05:23 +08:00
Linus Dierheimer 85578c6807 Don't use url for vlc or spotify player name 2022-09-18 17:32:15 +02:00
Linus Dierheimer 93871c1e98 Fix build on android 2022-09-18 17:16:45 +02:00
AloneER0 bcacaa9401 Add the Crystal Linux Logo (#239) 2022-09-18 17:06:37 +02:00
Linus Dierheimer d079e25a43 Fix some memory leaks 2022-09-18 16:30:26 +02:00
Linus Dierheimer b4306b944e Fix build on MacOS 2022-09-18 16:05:39 +02:00
Linus Dierheimer fd75f0b7e7 GH actions: build with libplist enabled 2022-09-18 16:00:28 +02:00
Linus Dierheimer 87c3459f5d Moved terminal font detection logic to detection folder 2022-09-18 15:53:51 +02:00
Linus Dierheimer 051a043a4b Merge pull request #237 from CarterLi/master
[macOS] Implement `swap` `processes` `Terminalfont`
2022-09-17 17:18:18 +02:00
Linus Dierheimer 913a3e79d4 Fixed a memory leak in config dirs init 2022-09-17 16:44:59 +02:00
Carter Li 59557e06fd CI: disable release job on fork repo 2022-09-17 21:09:37 +08:00
Carter Li 6d0d916861 CMake: enable AddressSanitizer in Debug mode 2022-09-17 21:09:37 +08:00
Carter Li a0a1c04011 Terminalfont: add Apple Terminal support ( macOS ) 2022-09-17 21:09:37 +08:00
Carter Li b59227e49f Terminalfont: add iTerm2 support ( macOS ) 2022-09-17 21:09:36 +08:00
Carter Li c64e2c14c2 Processes: add macOS support 2022-09-17 16:23:04 +08:00
Carter Li 8c6cf2ccda Swap: add macOS support 2022-09-17 11:21:05 +08:00
Linus Dierheimer bd657328d2 Merge pull request #236 from CarterLi/master
Various fixes
2022-09-17 01:29:04 +02:00
Carter Li 45d6f21402 GPU: better support Intel GPUs 2022-09-17 03:02:03 +08:00
Carter Li 4d569db0fd refactor: use MACH_PORT_NULL instead of magic number 0 2022-09-17 03:02:03 +08:00
Carter Li d46f9ab4dc util/cfdict_helpers: code improvements
1. simplify CFString usage
2. support get string from CFDataRef
2022-09-17 03:01:24 +08:00
Carter Li 3d4ce07892 Vulkan: set gpu->coreCount 2022-09-17 01:49:00 +08:00
Carter Li bb3689b348 GPU: fix Intel compatibility 2022-09-17 01:49:00 +08:00
Carter Li d5500ad4f7 Battery: fix Intel compatibility
`MaxCapacity` on Intel MBP is not 100
2022-09-17 01:49:00 +08:00
Carter Li 9e4a55d285 util/cfdict_helpers: fix stupid copy & paste errors 2022-09-17 01:49:00 +08:00
Linus Dierheimer 999b9187a0 Merge pull request #234 from SladeGetz/macports_expansion
Added support for MacPorts package manager
2022-09-16 19:24:34 +02:00
Slade Getz 73095ef9e9 Increased FF_PACKAGE_NUM_FORMAT_ARGS by 1 in src/modules/packages.c. Modified the help output in src/fastfetch.c. Added MacPorts pkg mngr to the README.md. 2022-09-16 11:13:02 -06:00
Slade Getz f4fc9692eb Merge branch 'LinusDierheimer:master' into macports_expansion 2022-09-16 10:57:50 -06:00
Linus Dierheimer 59ebc745c0 Merge pull request #235 from CarterLi/master
macOS: add battery info support; fix GPU detection; various improvements
2022-09-16 18:02:38 +02:00
李通洲 09f3bd5a79 GPU: correct detection of Apple M1 GPU
Don't cheat
2022-09-16 23:43:08 +08:00
李通洲 413d126bcc Battery: add dirty support for macOS 2022-09-16 23:43:08 +08:00
李通洲 9eeb216b70 util: add check macros to avoid possible mistakes 2022-09-16 23:43:08 +08:00
李通洲 f362fdb01d Battery: move detection code into src/detection
Prepare for macOS implementation
2022-09-16 23:43:08 +08:00
李通洲 155d4e90ae FFlist: support static init
Also fix possible memory corruption bug in ffListAdd
2022-09-16 18:39:27 +08:00
Linus Dierheimer df9aec6e86 Small updates 2022-09-16 09:56:21 +02:00
Slade Getz d903ccb6f6 Added support for MacPorts package manager 2022-09-15 14:17:33 -06:00
276 changed files with 14094 additions and 4894 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ trim_trailing_whitespace = true
[*.{md,fflogo}]
trim_trailing_whitespace = false
[*.{txt,fflogo}]
[*.{fflogo}]
insert_final_newline = false
[*.yml]
+1 -1
View File
@@ -1 +1 @@
custom: paypal.me/linusdierheimer
github: LinusDierheimer
+1 -1
View File
@@ -39,5 +39,5 @@ Output of `fastfetch --list-features`:
<!--
If you get the following error: `Error: couldn't find config: [...]`, copy the files in [presets](../../presets/) to `/usr/share/fastfetch/presets/` or `~/.local/share/fastfetch/presets/`.
If this isn't possible (or too much work) for you, post the output of `fastfetch --show-errors --recache --multithreading false --disable-linewrap false`.
If this isn't possible (or too much work) for you, post the output of `fastfetch --show-errors --multithreading false --disable-linewrap false`.
-->
+191 -11
View File
@@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read
outputs:
ffversion: ${{ steps.ffversion.outputs.ffversion }}
steps:
@@ -17,7 +18,7 @@ jobs:
uses: actions/checkout@v3
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libcjson-dev
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -28,23 +29,23 @@ jobs:
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
- name: build project
run: cmake --build . -j$(nproc) --target package
run: cmake --build . --target package
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: run fastfetch
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: ./flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: get fastfetch version
id: ffversion
run: echo "::set-output name=ffversion::$(./fastfetch --version-raw)"
run: echo "ffversion=$(./fastfetch --version-raw)" >> $GITHUB_OUTPUT
- name: upload artifacts
uses: actions/upload-artifact@v3
@@ -57,12 +58,13 @@ jobs:
runs-on: macos-latest
permissions:
security-events: write
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: install required packages
run: brew install vulkan-loader
run: brew install vulkan-loader molten-vk imagemagick chafa
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -73,16 +75,16 @@ jobs:
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build . -j$(sysctl -n hw.logicalcpu) --target package
run: cmake --build . --target package
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: run fastfetch
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: ./flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
@@ -93,13 +95,191 @@ jobs:
name: fastfetch-macos
path: ./fastfetch-*.*
freebsd:
name: FreeBSD
runs-on: macos-12
permissions:
security-events: write
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: run VM
uses: vmactions/freebsd-vm@v0
with:
prepare: |
pkg install -y cmake git pkgconf pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd
run: |
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
cmake --build . --target package
time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
time ./flashfetch
ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-freebsd
path: ./fastfetch-*.*
windows:
name: Windows
runs-on: windows-latest
permissions:
security-events: write
contents: read
defaults:
run:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: CLANG64
update: true
install: git mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
- name: print msys version
run: uname -a
# https://github.com/msys2/MINGW-packages/issues/13524#event-7555720785
- name: create OpenCL.pc
run: |
cat > /clang64/lib/pkgconfig/OpenCL.pc << EOF
prefix=/clang64
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenCL
Description: Open Computing Language generic Installable Client Driver Loader
Version: 2022.09.30-1
Libs: -L${libdir} -lOpenCL.dll
Cflags: -I${includedir}
EOF
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/clang64/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: copy necessary dlls
run: cp /clang64/bin/{libcjson,libOpenCL,vulkan-1}.dll .
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-windows
path: |
./*.dll
./fastfetch.exe
./flashfetch.exe
windows-old:
name: Windows-old
runs-on: windows-latest
permissions:
security-events: write
contents: read
defaults:
run:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-cjson mingw-w64-x86_64-vulkan-loader mingw-w64-x86_64-opencl-icd
- name: print msys version
run: uname -a
# https://github.com/msys2/MINGW-packages/issues/13524#event-7555720785
- name: create OpenCL.pc
run: |
cat > /mingw64/lib/pkgconfig/OpenCL.pc << EOF
prefix=/mingw64
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenCL
Description: Open Computing Language generic Installable Client Driver Loader
Version: 2022.09.30-1
Libs: -L${libdir} -lOpenCL.dll
Cflags: -I${includedir}
EOF
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/mingw64/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_BUFFER=Off .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: copy necessary dlls
run: cp /mingw64/bin/{libcjson,libOpenCL,vulkan-1}.dll .
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-windows-old
path: |
./*.dll
./fastfetch.exe
./flashfetch.exe
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'LinusDierheimer/fastfetch'
name: Release
runs-on: ubuntu-latest
needs:
- linux
- macos
- freebsd
- windows
permissions:
contents: write
steps:
@@ -119,4 +299,4 @@ jobs:
tag: ${{ needs.linux.outputs.ffversion }}
commit: ${{ github.sha }}
artifactErrorsFailBuild: true
artifacts: fastfetch-linux/*,fastfetch-macos/*
artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-freebsd/*,fastfetch-windows/*
+1
View File
@@ -3,6 +3,7 @@
**/.cache/
**/.kdev4/
**/.DS_Store
/.vs
cscope.*
tags
fastfetch.kdev4
+95
View File
@@ -1,3 +1,98 @@
# 1.8.0
This release introduces Windows support! Fastfetch now fully support all major desktop OSes (Linux, macOS, Windows and FreeBSD)
Notable Changes:
* Bios / Board / Chassis modules are splitted against Host module for performance reasons
* Caching is removed. Option `--nocache` is removed accordingly
Features:
* Windows (7 and newer) is officially and fully supported
* FreeBSD support is improved greatly (Bios, Cpu Temp, Cpu Usage, Disk, Host, Processes, Swap, Terminal / Shell, Uptime)
* Adds a new flag `--stat`, which prints time usage for individual modules
* Adds Wifi module which supports Windows and macOS
* Adds data source option for logo printing
* Detects Homebrew Cellar and Cask seperately
* Detects WSL version
* Detects disk based on mount point
* Exposes more chafa configs
* Improves performance for Cpu Usage, Public IP, Weather modules
* Improves performance for Kitty image protocol when both image width / height specified
* Improves performance for large file loading
* Improves performance for macOS WM and Host detection
* Improves shell and terminal detection on macOS
* Supports Deepin Terminal terminal font
* Supports GPU detection on Android
* Supports Kitty Terminal terminal font
* Supports bar output for percentage values
* Supports Bios module on macOS
* Supports eopkg package manager detection
* Supports iTerm image logo protocol
* Supports image logo printing on macOS
* Supports tcsh version detection
* Vulkan module on macOS no longer requires vulkan-loader to work
Logos:
* Alpine
* CRUX
* EndeavourOS
* Enso
* Garuda small
* Nobara
* OpenMandriva
* Parabola GNU/Linux-libre
* Rocky
* Rosa
* Solus
* Univalent
* Vanilla OS
Bugfixes:
* Fixes disk size detection on 32bit Linux (#337)
* Fixes cpu freq detection in WSL
* Fixes internal bug of FFstrbuf
* Fixes some memory leaks
* Fixes segfault if 0 is given as argument index
* Lots of code refactors
# 1.7.5
Fixes a crash on linux that could happen when getting zsh version (#285)
# 1.7.4
The last element in the default structure (currently the color blocks) is now printed again (#283)
# 1.7.3
A lot of small improvements for MacOS & BSD platforms.
Features:
* BSD is now officially supported (#228)
* MacPorts package manager support (@SladeGetz, #234)
* Battery support for MacOS (@CarterLi, #235)
* Processes, swap & terminal font support for MacOS(@CarterLi, #237)
* Song support for MacOS (@CarterLi, #242)
* Player support for MacOS (@CarterLi, #245)
* WM theme support for MacOS (@CarterLi, #246)
* CPU usage support for MacOS (@CarterLi, #247)
* Power Adapter module (@CarterLi, #249)
* Windows terminal font for WSL (@CarterLi, #254)
* Temps & Font support for MacOS (@CarterLi, #258)
* Terminal font support for Termux (@CarterLi, #263)
* Weather module (@CarterLi, #266)
Logos
* Crystal linux (@AloneER0, #239)
* FreeBSD (@draumaz, #244)
* New Ubuntu (@AloneER0, #259)
Bugfixes:
* Don't segfault in GPU code on Intel Macs (@CarterLi, #236)
* Don't use hardcoded size units in presets (@dr460nf1r3, #255)
* Don't crash with some format strings (#252)
* --logo-none keeps key color now (#264)
# 1.7.2
Fixes the bash completions
+544 -181
View File
@@ -1,66 +1,82 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 1.7.2
VERSION 1.8.0
LANGUAGES C
DESCRIPTION "Fast system information tool"
HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch"
)
set(PROJECT_LICENSE "MIT license")
###################
# Target Platform #
###################
if(APPLE OR ANDROID)
set(LINUX FALSE CACHE BOOL "..." FORCE) # Linux true means we have full linux userland, not just the kernel
elseif(UNIX)
set(LINUX TRUE CACHE BOOL "..." FORCE)
else()
message(FATAL_ERROR "Unsupported platform")
if(ANDROID)
set(LINUX FALSE)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Ll]inux.*")
set(LINUX TRUE CACHE BOOL "..." FORCE) # LINUX means GNU/Linux, not just the kernel
elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Bb][Ss][Dd].*")
set(BSD TRUE CACHE BOOL "..." FORCE)
elseif(NOT APPLE AND NOT WIN32)
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
if(WIN32)
enable_language(CXX)
endif()
#############################
# Compile time dependencies #
#############################
set(THREADS_PREFER_PTHREAD_FLAG NOT WIN32)
find_package(Threads)
find_package(PkgConfig)
if(NOT PKG_CONFIG_FOUND)
message(WARNING "pkg-config not found, library detection might be limited")
endif()
include(CheckIncludeFile)
#####################
# Configure options #
#####################
include(CMakeDependentOption)
cmake_dependent_option(ENABLE_LIBPCI "Enable libpci" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE" OFF)
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_LIBPCI "Enable libpci" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XRANDR "Enable xrandr" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_X11 "Enable x11" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR BSD OR APPLE OR WIN32" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR BSD OR APPLE" OFF)
cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" OFF)
cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR WIN32" OFF)
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND AND NOT ANDROID" OFF)
cmake_dependent_option(ENABLE_BUFFER "Enable stdout buffer" ON "LINUX OR APPLE OR BSD OR WIN32 OR ANDROID" OFF)
cmake_dependent_option(USE_WIN_NTAPI "Allow using internal NTAPI" ON "WIN32" OFF)
cmake_dependent_option(USE_WIN_GPU_DXGI "Use DXGI to detect GPUs instead of WMI. Faster, but may ignore GPUs that only support DX9" ON "WIN32" OFF)
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
#############################
# Compile time dependencies #
#############################
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
include(CheckIncludeFile)
####################
# Compiler options #
####################
@@ -69,18 +85,44 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion")
if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
# Used for dlopen finding dylibs installed by homebrew, reversed for future usage
# `/opt/homebrew/lib` is not on dlopen search path by default
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,$ENV{HOMEBREW_PREFIX}/lib")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if(ENABLE_THREADS)
if(CMAKE_USE_WIN32_THREADS_INIT)
message(STATUS "Threads type: Win32 thread")
elseif(CMAKE_USE_PTHREADS_INIT)
message(STATUS "Threads type: pthread")
endif()
else()
message(STATUS "Threads type: disabled")
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion")
if(WIN32)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -fno-exceptions -fno-rtti")
endif()
# Used for dlopen finding dylibs installed by homebrew
# `/opt/homebrew/lib` is not on in dlopen search path by default
if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ENV{HOMEBREW_PREFIX}/lib")
endif()
set(FASTFETCH_FLAGS_DEBUG "-fno-omit-frame-pointer")
if(NOT WIN32)
set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address -fsanitize=undefined")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG} -rdynamic")
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
endif()
#######################
@@ -113,6 +155,19 @@ if(NOT TARGET_DIR_HOME)
endif()
endif()
if(NOT TARGET_DIR_ETC)
set(TARGET_DIR_ETC "${TARGET_DIR_ROOT}/etc")
endif()
#https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${TARGET_DIR_USR}" CACHE PATH "..." FORCE)
endif()
if(NOT CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "${TARGET_DIR_ETC}" CACHE PATH "..." FORCE)
endif()
#################
# Tweak version #
#################
@@ -126,6 +181,11 @@ if (SET_TWEAK AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
)
string(REGEX MATCH "-[0-9]+" PROJECT_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}")
endif()
if(PROJECT_VERSION_TWEAK)
string(REGEX MATCH "[0-9]+" PROJECT_VERSION_TWEAK_NUM "${PROJECT_VERSION_TWEAK}")
else()
set(PROJECT_VERSION_TWEAK_NUM 0)
endif()
#############
# Text data #
@@ -133,9 +193,10 @@ endif()
function(fastfetch_load_text FILENAME OUTVAR)
file(READ "${FILENAME}" TEMP)
string(REPLACE "\n" "\\n" TEMP "${TEMP}")
string(REPLACE "\"" "\\\"" TEMP "${TEMP}")
string(REPLACE "$\\" "" TEMP "${TEMP}")
string(REGEX REPLACE "\n$" "" TEMP "${TEMP}") # Remove trailing newline
string(REPLACE "\n" "\\n" TEMP "${TEMP}") # Replace newlines with \n
string(REPLACE "\"" "\\\"" TEMP "${TEMP}") # Replace quotes with \"
string(REPLACE "$\\" "" TEMP "${TEMP}") # Remove $\, so we can unescape some things
set("${OUTVAR}" "${TEMP}" PARENT_SCOPE)
endfunction(fastfetch_load_text)
@@ -159,111 +220,274 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h)
#######################
set(LIBFASTFETCH_SRC
src/util/FFstrbuf.c
src/util/FFlist.c
src/util/FFvaluestore.c
src/common/bar.c
src/common/font.c
src/common/format.c
src/common/init.c
src/common/io.c
src/common/printing.c
src/common/caching.c
src/common/properties.c
src/common/font.c
src/common/processing.c
src/common/format.c
src/common/parsing.c
src/common/settings.c
src/common/library.c
src/common/networking.c
src/logo/logo.c
src/logo/builtin.c
src/logo/image/image.c
src/logo/image/im7.c
src/logo/image/im6.c
src/detection/qt.c
src/detection/gtk.c
src/detection/terminalShell.c
src/detection/vulkan.c
src/detection/media.c
src/detection/datetime.c
src/detection/temps.c
src/detection/title.c
src/detection/host/host.c
src/detection/os/os.c
src/common/parsing.c
src/common/printing.c
src/common/properties.c
src/common/settings.c
src/detection/cpu/cpu.c
src/detection/gpu/gpu.c
src/detection/memory/memory.c
src/detection/cpuUsage/cpuUsage.c
src/detection/datetime.c
src/detection/disk/disk.c
src/detection/displayserver/displayserver.c
src/detection/font/font.c
src/detection/gpu/gpu.c
src/detection/host/host.c
src/detection/locale/locale.c
src/detection/media/media.c
src/detection/os/os.c
src/detection/packages/packages.c
src/detection/terminalfont/terminalfont.c
src/detection/terminalshell/terminalshell.c
src/detection/title.c
src/detection/vulkan.c
src/logo/builtin.c
src/logo/image/im6.c
src/logo/image/im7.c
src/logo/image/image.c
src/logo/logo.c
src/modules/battery.c
src/modules/bios.c
src/modules/board.c
src/modules/break.c
src/modules/custom.c
src/modules/title.c
src/modules/separator.c
src/modules/os.c
src/modules/host.c
src/modules/kernel.c
src/modules/uptime.c
src/modules/processes.c
src/modules/packages.c
src/modules/shell.c
src/modules/resolution.c
src/modules/de.c
src/modules/wm.c
src/modules/wmtheme.c
src/modules/theme.c
src/modules/icons.c
src/modules/font.c
src/modules/cursor.c
src/modules/terminal.c
src/modules/terminalfont.c
src/modules/chassis.c
src/modules/colors.c
src/modules/cpu.c
src/modules/cpuUsage.c
src/modules/gpu.c
src/modules/memory.c
src/modules/disk.c
src/modules/battery.c
src/modules/locale.c
src/modules/vulkan.c
src/modules/localip.c
src/modules/publicip.c
src/modules/player.c
src/modules/song.c
src/modules/datetime.c
src/modules/cursor.c
src/modules/custom.c
src/modules/date.c
src/modules/time.c
src/modules/colors.c
src/modules/opengl.c
src/modules/datetime.c
src/modules/de.c
src/modules/disk.c
src/modules/font.c
src/modules/gpu.c
src/modules/host.c
src/modules/icons.c
src/modules/kernel.c
src/modules/locale.c
src/modules/localip.c
src/modules/memory.c
src/modules/opencl.c
src/modules/opengl.c
src/modules/os.c
src/modules/packages.c
src/modules/player.c
src/modules/poweradapter.c
src/modules/processes.c
src/modules/publicip.c
src/modules/resolution.c
src/modules/separator.c
src/modules/shell.c
src/modules/song.c
src/modules/terminal.c
src/modules/terminalfont.c
src/modules/theme.c
src/modules/time.c
src/modules/title.c
src/modules/uptime.c
src/modules/users.c
src/modules/vulkan.c
src/modules/weather.c
src/modules/wifi.c
src/modules/wm.c
src/modules/wmtheme.c
src/util/FFlist.c
src/util/FFstrbuf.c
src/util/FFvaluestore.c
)
if(APPLE)
if(LINUX)
list(APPEND LIBFASTFETCH_SRC
src/detection/host/host_apple.c
src/detection/os/os_apple.c
src/detection/cpu/cpu_apple.c
src/detection/gpu/gpu_apple.c
src/detection/memory/memory_apple.c
src/detection/displayserver/displayserver_apple.c
src/common/networking_linux.c
src/common/processing_linux.c
src/detection/battery/battery_linux.c
src/detection/bios/bios_linux.c
src/detection/board/board_linux.c
src/detection/chassis/chassis_linux.c
src/detection/cpu/cpu_linux.c
src/detection/cpuUsage/cpuUsage_linux.c
src/detection/cursor/cursor_linux.c
src/detection/disk/disk_linux.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/wayland.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/font/font_linux.c
src/detection/gpu/gpu_linux.c
src/detection/gtk.c
src/detection/host/host_linux.c
src/detection/localip/localip_linux.c
src/detection/media/media_linux.c
src/detection/memory/memory_linux.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
src/detection/packages/packages_linux.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_linux.c
src/detection/qt.c
src/detection/swap/swap_linux.c
src/detection/temps/temps_linux.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/uptime/uptime_linux.c
src/detection/users/users_linux.c
src/detection/wifi/wifi_linux.c
src/detection/wmtheme/wmtheme_linux.c
)
elseif(ANDROID)
list(APPEND LIBFASTFETCH_SRC
src/common/networking_linux.c
src/common/processing_linux.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_nosupport.c
src/detection/board/board_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_linux.c
src/detection/cursor/cursor_nosupport.c
src/detection/cpuUsage/cpuUsage_linux.c
src/detection/disk/disk_linux.c
src/detection/displayserver/displayserver_nosupport.c
src/detection/font/font_nosupport.c
src/detection/gpu/gpu_nosupport.c
src/detection/host/host_android.c
src/detection/localip/localip_linux.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_linux.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_android.c
src/detection/cpu/cpu_linux.c
src/detection/gpu/gpu_android.c
src/detection/memory/memory_linux.c
src/detection/displayserver/displayserver_android.c
src/detection/packages/packages_linux.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_linux.c
src/detection/swap/swap_linux.c
src/detection/temps/temps_linux.c
src/detection/terminalfont/terminalfont_android.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/uptime/uptime_linux.c
src/detection/users/users_linux.c
src/detection/wifi/wifi_nosupport.c
src/detection/wmtheme/wmtheme_nosupport.c
)
else()
elseif(BSD)
list(APPEND LIBFASTFETCH_SRC
src/detection/host/host_linux.c
src/detection/os/os_linux.c
src/detection/cpu/cpu_linux.c
src/detection/gpu/gpu_linux.c
src/detection/memory/memory_linux.c
src/common/networking_linux.c
src/common/processing_linux.c
src/common/sysctl.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_bsd.c
src/detection/board/board_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_bsd.c
src/detection/cpuUsage/cpuUsage_bsd.c
src/detection/cursor/cursor_linux.c
src/detection/disk/disk_bsd.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/wayland.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/displayserver/linux/wmde.c
src/detection/font/font_linux.c
src/detection/gpu/gpu_linux.c
src/detection/gtk.c
src/detection/host/host_bsd.c
src/detection/localip/localip_linux.c
src/detection/media/media_linux.c
src/detection/memory/memory_bsd.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
src/detection/packages/packages_linux.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_bsd.c
src/detection/qt.c
src/detection/swap/swap_bsd.c
src/detection/temps/temps_linux.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/uptime/uptime_bsd.c
src/detection/users/users_linux.c
src/detection/wifi/wifi_nosupport.c
src/detection/wmtheme/wmtheme_linux.c
)
elseif(APPLE)
list(APPEND LIBFASTFETCH_SRC
src/common/networking_linux.c
src/common/processing_linux.c
src/common/sysctl.c
src/detection/battery/battery_apple.c
src/detection/bios/bios_apple.c
src/detection/board/board_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_apple.c
src/detection/cpuUsage/cpuUsage_apple.c
src/detection/cursor/cursor_nosupport.c
src/detection/disk/disk_apple.m
src/detection/disk/disk_bsd.c
src/detection/displayserver/displayserver_apple.c
src/detection/font/font_apple.m
src/detection/gpu/gpu_apple.c
src/detection/host/host_apple.c
src/detection/localip/localip_linux.c
src/detection/media/media_apple.m
src/detection/memory/memory_apple.c
src/detection/opengl/opengl_apple.c
src/detection/os/os_apple.m
src/detection/packages/packages_apple.c
src/detection/poweradapter/poweradapter_apple.c
src/detection/processes/processes_bsd.c
src/detection/swap/swap_apple.c
src/detection/temps/temps_apple.c
src/detection/terminalfont/terminalfont_apple.m
src/detection/terminalshell/terminalshell_linux.c
src/detection/uptime/uptime_bsd.c
src/detection/users/users_linux.c
src/detection/wifi/wifi_apple.m
src/detection/wmtheme/wmtheme_apple.m
src/util/apple/cf_helpers.c
src/util/apple/osascript.m
)
elseif(WIN32)
list(APPEND LIBFASTFETCH_SRC
src/common/networking_windows.c
src/common/processing_windows.c
src/detection/battery/battery_windows.c
src/detection/bios/bios_windows.c
src/detection/board/board_windows.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_windows.c
src/detection/cpuUsage/cpuUsage_windows.c
src/detection/cursor/cursor_windows.c
src/detection/disk/disk_windows.c
src/detection/displayserver/displayserver_windows.c
src/detection/font/font_windows.c
src/detection/gpu/gpu_windows.cpp
src/detection/host/host_windows.c
src/detection/localip/localip_windows.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_windows.c
src/detection/opengl/opengl_windows.c
src/detection/os/os_windows.cpp
src/detection/packages/packages_windows.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_windows.cpp
src/detection/swap/swap_windows.cpp
src/detection/terminalfont/terminalfont_windows.c
src/detection/terminalshell/terminalshell_windows.cpp
src/detection/uptime/uptime_windows.c
src/detection/users/users_windows.c
src/detection/wifi/wifi_windows.c
src/detection/wmtheme/wmtheme_windows.c
src/util/windows/getline.c
src/util/windows/pwd.c
src/util/windows/registry.c
src/util/windows/unicode.c
src/util/windows/utsname.c
src/util/windows/wmi.cpp
)
endif()
@@ -271,60 +495,187 @@ add_library(libfastfetch OBJECT
${LIBFASTFETCH_SRC}
)
CHECK_INCLUDE_FILE("sys/sysinfo.h" HAVE_SYSINFO_H)
if(HAVE_SYSINFO_H)
# needs to be public, because changes fastfech.h ABI
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_SYSINFO_H)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX_H)
if(HAVE_UTMPX_H)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX_H)
endif()
function(ff_lib_enable VARNAME)
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
if(NOT ENABLE_${VARNAME})
return()
endif()
foreach(LIBNAME ${ARGN})
pkg_check_modules(${VARNAME} ${LIBNAME})
if(${VARNAME}_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_${VARNAME}=1)
target_include_directories(libfastfetch PRIVATE ${${VARNAME}_INCLUDE_DIRS})
target_link_directories(libfastfetch PRIVATE ${${VARNAME}_LIBRARY_DIRS})
return()
if(PKG_CONFIG_FOUND)
pkg_search_module(${VARNAME} QUIET ${PKGCONFIG_NAMES})
endif()
if(NOT ${VARNAME}_FOUND)
find_package(${CMAKE_NAME} QUIET)
set(${VARNAME}_FOUND ${${CMAKE_NAME}_FOUND})
set(${VARNAME}_INCLUDE_DIRS ${${CMAKE_NAME}_INCLUDE_DIRS})
set(${VARNAME}_LIBRARIES ${${CMAKE_NAME}_LIBRARIES})
set(${VARNAME}_CFLAGS_OTHER ${${CMAKE_NAME}_CFLAGS_OTHER})
endif()
if(NOT ${VARNAME}_FOUND)
message(STATUS "Library: missing: ${VARNAME}")
return()
endif()
message(STATUS "Library: found ${VARNAME}")
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_${VARNAME}=1)
target_include_directories(libfastfetch PRIVATE ${${VARNAME}_INCLUDE_DIRS})
foreach(FLAG ${${VARNAME}_CFLAGS_OTHER})
if(FLAG MATCHES "-D.*")
string(SUBSTRING ${FLAG} 2 -1 FLAG)
target_compile_definitions(libfastfetch PRIVATE ${FLAG})
endif()
endforeach()
message(WARNING "Package ${ARGV1} not found, building without support.")
endfunction()
ff_lib_enable(LIBPCI libpci)
ff_lib_enable(VULKAN vulkan)
ff_lib_enable(WAYLAND wayland-client)
ff_lib_enable(XCB_RANDR xcb-randr)
ff_lib_enable(XCB xcb)
ff_lib_enable(XRANDR xrandr)
ff_lib_enable(X11 x11)
ff_lib_enable(GIO gio-2.0)
ff_lib_enable(DCONF dconf)
ff_lib_enable(DBUS dbus-1)
ff_lib_enable(XFCONF libxfconf-0)
ff_lib_enable(SQLITE3 sqlite3)
ff_lib_enable(RPM rpm)
ff_lib_enable(IMAGEMAGICK7 MagickCore-7.Q16HDRI MagickCore-7.Q16 /usr/lib/imagemagick7/pkgconfig/MagickCore-7.Q16HDRI.pc /usr/lib/imagemagick7/pkgconfig/MagickCore-7.Q16.pc)
ff_lib_enable(IMAGEMAGICK6 MagickCore-6.Q16HDRI MagickCore-6.Q16 /usr/lib/imagemagick6/pkgconfig/MagickCore-6.Q16HDRI.pc /usr/lib/imagemagick6/pkgconfig/MagickCore-6.Q16.pc)
ff_lib_enable(ZLIB zlib)
ff_lib_enable(CHAFA chafa>=1.10)
ff_lib_enable(EGL egl)
ff_lib_enable(GLX glx)
ff_lib_enable(OSMESA osmesa)
ff_lib_enable(OPENCL OpenCL)
ff_lib_enable(LIBPCI
"libpci"
"Pci"
)
ff_lib_enable(VULKAN
"vulkan"
"Vulkan"
)
ff_lib_enable(WAYLAND
"wayland-client"
"WaylandClient"
)
ff_lib_enable(XCB_RANDR
"xcb-randr"
"XcbRandr"
)
ff_lib_enable(XCB
"xcb"
"Xcb"
)
ff_lib_enable(XRANDR
"xrandr"
"XRandr"
)
ff_lib_enable(X11
"x11"
"X11"
)
ff_lib_enable(GIO
"gio-2.0"
"GIO"
)
ff_lib_enable(DCONF
"dconf"
"DConf"
)
ff_lib_enable(DBUS
"dbus-1"
"DBus"
)
ff_lib_enable(XFCONF
"libxfconf-0"
"XFConf"
)
ff_lib_enable(SQLITE3
"sqlite3"
"SQLite3"
)
ff_lib_enable(RPM
"rpm"
"RPM"
)
ff_lib_enable(IMAGEMAGICK7
"MagickCore-7.Q16HDRI;MagickCore-7.Q16;MagickCore-7;/usr/lib/imagemagick7/pkgconfig/MagickCore-7.Q16HDRI.pc;/usr/lib/imagemagick7/pkgconfig/MagickCore-7.Q16.pc;/usr/lib/imagemagick7/pkgconfig/MagickCore-7.pc"
"ImageMagick7"
)
ff_lib_enable(IMAGEMAGICK6
"MagickCore-6.Q16HDRI;MagickCore-6.Q16;MagickCore-6;/usr/lib/imagemagick6/pkgconfig/MagickCore-6.Q16HDRI.pc;/usr/lib/imagemagick6/pkgconfig/MagickCore-6.Q16.pc;/usr/lib/imagemagick6/pkgconfig/MagickCore-6.pc"
"ImageMagick6"
)
ff_lib_enable(ZLIB
"zlib"
"ZLIB"
)
ff_lib_enable(CHAFA
"chafa>=1.10"
"Chafa"
)
ff_lib_enable(EGL
"egl"
"EGL"
)
ff_lib_enable(GLX
"glx"
"GLX"
)
ff_lib_enable(OSMESA
"osmesa"
"OSMesa"
)
ff_lib_enable(OPENCL
"OpenCL"
"OpenCL"
)
ff_lib_enable(LIBCJSON
"libcjson"
"CJson"
)
ff_lib_enable(FREETYPE
"freetype2"
"FreeType2"
)
if(ENABLE_THREADS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS)
if(CMAKE_USE_PTHREADS_INIT) #Threads::Threads is not set for WIN32
target_link_libraries(libfastfetch PRIVATE Threads::Threads)
endif()
endif()
if(ENABLE_BUFFER)
target_compile_definitions(libfastfetch PRIVATE FF_ENABLE_BUFFER)
endif()
if(APPLE)
target_link_libraries(libfastfetch
PRIVATE "-framework CoreFoundation"
PRIVATE "-framework IOKit"
PRIVATE "-framework CoreGraphics"
PRIVATE "-framework OpenGL"
PRIVATE "-framework OpenCL"
PRIVATE "-framework Cocoa"
PRIVATE "-framework CoreWLAN"
PRIVATE "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks"
)
elseif(WIN32)
target_link_libraries(libfastfetch
PRIVATE "dwmapi"
PRIVATE "gdi32"
PRIVATE "iphlpapi"
PRIVATE "ole32"
PRIVATE "oleaut32"
PRIVATE "opengl32"
PRIVATE "wbemuuid"
PRIVATE "ws2_32"
PRIVATE "ntdll"
PRIVATE "version"
PRIVATE "setupapi"
PRIVATE "dxgi"
PRIVATE "wtsapi32"
PRIVATE "powrprof"
)
if(USE_WIN_NTAPI)
target_compile_definitions(libfastfetch PRIVATE FF_USE_WIN_NTAPI)
endif()
if(USE_WIN_GPU_DXGI)
target_compile_definitions(libfastfetch PRIVATE FF_USE_WIN_GPU_DXGI)
endif()
endif()
target_include_directories(libfastfetch
@@ -334,7 +685,6 @@ target_include_directories(libfastfetch
target_link_libraries(libfastfetch
PRIVATE ${CMAKE_DL_LIBS}
PRIVATE Threads::Threads
)
######################
@@ -344,6 +694,9 @@ target_link_libraries(libfastfetch
add_executable(fastfetch
src/fastfetch.c
)
target_compile_definitions(fastfetch
PRIVATE FASTFETCH_TARGET_BINARY_NAME=fastfetch
)
target_link_libraries(fastfetch
PRIVATE libfastfetch
)
@@ -351,10 +704,25 @@ target_link_libraries(fastfetch
add_executable(flashfetch
src/flashfetch.c
)
target_compile_definitions(flashfetch
PRIVATE FASTFETCH_TARGET_BINARY_NAME=flashfetch
)
target_link_libraries(flashfetch
PRIVATE libfastfetch
)
if(WIN32)
set(TARGET_NAME fastfetch)
target_sources(fastfetch
PRIVATE src/util/windows/version.rc
)
set(TARGET_NAME flashfetch)
target_sources(flashfetch
PRIVATE src/util/windows/version.rc
)
endif()
###################
# Testing targets #
###################
@@ -367,23 +735,22 @@ if (BUILD_TESTS)
PRIVATE libfastfetch
)
add_executable(fastfetch-test-list
tests/list.c
)
target_link_libraries(fastfetch-test-list
PRIVATE libfastfetch
)
enable_testing()
add_test(NAME test-strbuf COMMAND fastfetch-test-strbuf)
add_test(NAME test-list COMMAND fastfetch-test-list)
endif()
##################
# install target #
##################
#https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${TARGET_DIR_USR}" CACHE PATH "..." FORCE)
endif()
if(NOT CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "${TARGET_DIR_ROOT}/etc" CACHE PATH "..." FORCE)
endif()
include(GNUInstallDirs)
install(
@@ -427,10 +794,6 @@ if(LINUX)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
elseif(APPLE)
set(CPACK_GENERATOR "${CPACK_GENERATOR};DragNDrop")
set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK TRUE)
endif()
set(CPACK_SET_DESTDIR ON)
-2
View File
@@ -11,8 +11,6 @@ Here i just add things that are easy to forget.
- `libffdetect`: contains all the detection stuff. To be used by anything that needs system information
- `libffprint`: contains the printing functions, logos, format etc
- `fastfetch` and `flashfetch`: Executables, that initialize the config of libffprint. Fist one at runtime, second one at compile time
- [ ] Better OS output for all possible combinations of /etc/os-release variables.
- [ ] Find wayland compositor by looking at \${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}
- [ ] Make LocalIP module more configurable
- [ ] Automatic migrate old config files to newer versions
- [ ] ZSH completions
+61 -16
View File
@@ -1,6 +1,6 @@
# <center> Fastfetch </center>
# Fastfetch
Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in pure c, with performance and customizability in mind. Currently Linux, Android and MacOS are supported.
Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in pure c, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported.
<img src="screenshots/example1.png" width="49%" align="left" />
<img src="https://upload.wikimedia.org/wikipedia/commons/2/24/Transparent_Square_Tiles_Texture.png" width="49%" height="16px" align="left" />
@@ -21,9 +21,13 @@ There are some premade config files in [`presets`](presets), including the ones
## Dependencies
Fastfetch dynamically loads needed libraries if they are available. Therefore its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and `libpthread`. They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions, so you probably don't have to worry about it.
Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions.
The following libraries are used if present at runtime:
### Linux and FreeBSD
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
* [`libvulkan`](https://www.vulkan.org/): Vulkan module & fallback for GPU output.
* [`libxcb-randr`](https://xcb.freedesktop.org/),
@@ -42,35 +46,64 @@ The following libraries are used if present at runtime:
[`libOSMesa`](https://docs.mesa3d.org/osmesa.html): At least one of them is needed by the OpenGL module for gl context creation.
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for rpm package count.
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count.
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Needed for Windows Terminal font ( WSL ).
### macOS
* [`MediaRemote`](https://iphonedev.wiki/index.php/MediaRemote.framework): Need for Media detection. It's a private framework provided by newer macOS system.
* [`MoltenVK`](https://github.com/KhronosGroup/MoltenVK): Vulkan driver for macOS. [`molten-vk`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/molten-vk.rb)
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel graphics protocol. [`imagemagick`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/imagemagick.rb)
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art. [`chafa`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/chafa.rb)
For the image logo, iTerm with iterm image protocol should work. Apple Terminal is not supported.
### Windows
* [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection.
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Used for Windows Terminal font detection. [`cjson`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-cjson)
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers)
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd)
Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, special build `fastfetch-windows-old` in [Github Actions](https://github.com/LinusDierheimer/fastfetch/actions) is provided to support these old systems, which
1. Build with the ancient MSVCRT C runtime library, instead of the modern [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library
2. Disable stdout application buffer, which seems to problematic for ConEmu.
For the image logo, only chafa is supported due to [the design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not built by default due to the massive dependencies of imagemagick. You must built it yourself.
### Android
* [`freetype`](https://www.freetype.org/): Used for Termux font detection. [`freetype`](https://github.com/termux/termux-packages/tree/master/packages/freetype)
* [`libvulkan`](https://www.vulkan.org/): Vulkan module, also used for GPU detection. Usually has been provided by Android system. [`vulkan-loader-android`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-loader-android) [`vulkan-headers`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-headers)
## Support status
All categories not listed here should work without needing a specific implementation.
##### Available Modules
```
Title, Separator, OS, Host, Kernel, Uptime, Processes, Packages, Shell, Resolution, DE, WM, WMTheme, Theme, Icons, Font, Cursor, Terminal, Terminal Font, CPU, CPUUsage, GPU, Memory, Swap, Disk, Battery, Player, Media, Vulkan, OpenGL, OpenCL, LocalIP, PublicIP, DateTime, Date, Time, Locale, Colors, Break, Custom
Title, Separator, OS, Host, Bios, Board, Kernel, Uptime, Processes, Packages, Shell, Resolution, DE, WM, WMTheme, Theme, Icons, Font, Cursor, Terminal, Terminal Font, CPU, CPUUsage, GPU, Memory, Swap, Disk, Battery, Power Adapter, Player, Media, Vulkan, OpenGL, OpenCL, LocalIP, PublicIP, Wifi, DateTime, Date, Time, Locale, Colors, Break, Custom
```
##### Logos
```
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Debian, Devuan, Deepin, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Pop!_OS, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Ubuntu, Void, Zorin
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, CRUX, Crystal, Debian, Devuan, Deepin, Endeavour, Enso, Fedora, FreeBSD, Garuda, Gentoo, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Parabola, Pop!_OS, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, Ubuntu, Vanilla, Void, Windows 11, Windows 8, Windows, Zorin
```
* Most of the logos have a small variant. Access it by appending _small to the logo name.
* Some logos have an old variant. Access it by appending _old to the logo name.
* Unknown/unsupported logos will be replaced with a generic linux logo when running fastfetch.
* To disable the logo, use `--logo none`.
* Get a list of all available logos with `fastfetch --print-logos`.
* Printing images as logo is supported using Sixel or Kitty graphics protocol.
* Printing images as logo is supported using Sixel / Kitty / iTerm graphics protocol or chafas image to text conversion.
##### Package managers
```
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap, apk, brew
Pacman, dpkg, rpm, emerge, eopkg, xbps, nix, Flatpak, Snap, apk, pkg, brew, MacPorts, scoop, Chocolatey
```
##### WM themes
```
KWin, Mutter, Muffin, Marco, XFWM, Openbox (LXDE, LXQT & without DE)
KWin, Mutter, Muffin, Marco, XFWM, Openbox (LXDE, LXQT & without DE), Quartz Compositor (macOS), DWM (Windows)
```
##### DE versions
@@ -80,12 +113,12 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt
##### Terminal fonts
```
konsole, gnome-terminal-server, tilix, xfce4-terminal, alacritty, lxterminal, TTY
Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, Kitty, LXTerminal, Deepin Terminal, iTerm2, Apple Terminal, Warp, TTY, Windows Terminal, Termux, mintty, ConEmu
```
## Building
fastfetch uses [`cmake`](https://cmake.org/) and [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) for building. The simplest steps to build the fastfetch and flashfetch binaries are:
fastfetch uses [`cmake`](https://cmake.org/) for building. [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) is recommended for better library detection. The simplest steps to build the fastfetch and flashfetch binaries are:
```bash
mkdir -p build
cd build
@@ -93,7 +126,19 @@ cmake ..
cmake --build . --target fastfetch --target flashfetch
```
If pkg-config fails to find the headers for a library listed in [dependencies](#dependencies), fastfetch will simply build without support for that specific feature. This means, it won't look for it at runtime and just act like it isn't available.
If the build process fails to find the headers for a library listed in [dependencies](#dependencies), fastfetch will simply build without support for that specific feature. This means, it won't look for it at runtime and just act like it isn't available.
### Building on Windows
Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 subsystem (or CLANGARM64 if needed) is suggested (and tested) to build fastfetch. If you need Windows 7 / 8.x support, using MINGW64 is suggested.
1. Install [MSYS2](https://www.msys2.org/#installation)
1. Open `MSYS2 CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime)
1. Install dependencies
```bash
pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
```
1. Follow building instructions of Linux
## Packaging
@@ -109,7 +154,7 @@ If pkg-config fails to find the headers for a library listed in [dependencies](#
## FAQ
Q: Why do you need a very performant version of neofetch?
> I like putting neofetch in my ~/.bashrc to have a system overwiew whenever i use the terminal, but the slow speed annoyed me, so i created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
> I like putting neofetch in my ~/.bashrc to have a system overwiew whenever I use the terminal, but the slow speed annoyed me, so I created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
Q: It does not display [*] correctly for me, what can i do?
> This is most likely because your system is not implemented (yet). At the moment i am focusing more on making the core app better, than adding more configurations. Feel free to open a pull request if you want to add support for your configuration
Q: It does not display [*] correctly for me, what can I do?
> This is most likely because your system is not implemented (yet). At the moment I am focusing more on making the core app better, than adding more configurations. Feel free to open a pull request if you want to add support for your configuration
+24 -2
View File
@@ -30,6 +30,7 @@ __fastfetch_complete_help()
"swap-format"
"disk-format"
"battery-format"
"poweradapter-format"
"locale-format"
"local-ip-format"
"public-ip-format"
@@ -168,21 +169,26 @@ __fastfetch_completion()
local FF_OPTIONS_BOOL=(
"-r"
"--recache"
"--nocache"
"--show-errors"
"--logo-print-remaining"
"--multithreading"
"--stat"
"--allow-slow-operations"
"--disable-linewrap"
"--hide-cursor"
"--cpu-temp"
"--gpu-temp"
"--battery-temp"
"--localip-show-ipv4"
"--localip-show-ipv6"
"--localip-show-loop"
"--localip-name-prefix"
"--escape-bedrock"
"--pipe"
"--title-fqdn"
"--escape-bedrock"
"--disk-show-removable"
"--disk-show-hidden"
)
local FF_OPTIONS_STRING=(
@@ -211,7 +217,11 @@ __fastfetch_completion()
"--set"
"--set-keyless"
"--player-name"
"--percent-type"
"--public-ip-url"
"--public-ip-timeout"
"--weather-output-format"
"--weather-timeout"
"--os-key"
"--os-format"
"--os-error"
@@ -284,6 +294,9 @@ __fastfetch_completion()
"--battery-key"
"--battery-format"
"--battery-error"
"--poweradapter-key"
"--poweradapter-format"
"--poweradapter-error"
"--locale-key"
"--locale-format"
"--locale-error"
@@ -293,6 +306,12 @@ __fastfetch_completion()
"--public-ip-key"
"--public-ip-format"
"--public-ip-error"
"--wifi-key"
"--wifi-format"
"--wifi-error"
"--weather-key"
"--weather-format"
"--weather-error"
"--player-key"
"--player-format"
"--player-error"
@@ -317,6 +336,9 @@ __fastfetch_completion()
"--opencl-key"
"--opencl-format"
"--opencl-error"
"--users-key"
"--users-format"
"--users-error"
)
local FF_OPTIONS_PATH=(
+1 -1
View File
@@ -1 +1 @@
--structure Title:Separator:OS:Host:Kernel:Uptime:Processes:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Swap:Disk:Battery:Player:Song:PublicIP:LocalIP:DateTime:Locale:Vulkan:OpenGL:OpenCL:Break:Colors
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Song:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Weather:Break:Colors
-1
View File
@@ -1,4 +1,3 @@
--disable-linewrap false
--multithreading false
--show-errors
--recache
-1
View File
@@ -8,5 +8,4 @@
--icons-key I
--icons-format {5}
--font-key F
--font-format {21}
--cursor-key C
+2 -2
View File
@@ -1,4 +1,4 @@
--structure Host:Resolution:CPU:GPU:Memory:Disk:Battery
--memory-format "{?2}{2}MiB{?}"
--disk-format "{?2}{2}GB{?}"
--memory-format "{?2}{2}{?}"
--disk-format "{?2}{2}{?}"
--battery-format "{?1}{1} {?}{?2}{2} {?}{?3}({3}){?}"
+1 -1
View File
@@ -5,6 +5,6 @@
--de-format "{2} {3}"
--theme-format "{?1}{1}{?3} {3}{?} [Plasma], {?}{7}"
--terminal-font-format "{/2}{-}{/}{2}{?3} {3}{?}"
--memory-format "{/1}{-}{/}{/2}{-}{/}{}MiB / {}MiB"
--memory-format "{/1}{-}{/}{/2}{-}{/}{} / {}"
--gpu-key "GPU"
--resolution-key "Resolution"
+7 -6
View File
@@ -1,9 +1,9 @@
--os-format System: {}; Name: {}; Pretty name: {}; ID: {}; ID like: {}; Variant: {}; Variant ID: {}; Version: {}; Version ID: {}; Version codename: {}; Build ID: {}; Architecture: {}
--host-format Family: product_family: {}; product_name: {}; product_version: {}; product_sku: {}; bios_date: {}; bios_release: {}; bios_vendor: {}; bios_version: {}; board_name: {}; board_vendor: {}; board_version: {}; chassis_type: {}; chassis_vendor: {}; chassis_version: {}; sys_vendor: {}
--host-format Family: product_family: {}; product_name: {}; product_version: {}; product_sku: {}; sys_vendor: {}
--kernel-format Sysname: {}; Release: {}; Version: {}
--uptime-format Days: {}; Hours: {}; Minutes: {}; Seconds: {}
--processes-format Count: {}
--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; xbps: {}; apk: {}; flatpak: {}; snap: {}; brew: {}
--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}
--shell-format Process name: {}; Process path: {}; Process exe: {}; Process version: {}; User path: {}; User exe: {}; User version: {}
--resolution-format Width: {}; Height: {}; Refresh rate: {}
--de-format Process name: {}; Pretty name: {}; Version: {}
@@ -11,16 +11,17 @@
--wm-theme-format Name: {}
--theme-format Plasma: {}; Plasma colors: {}; Plasma colors pretty: {}; GTK2: {}; GTK3: {}; GTK4: {}; GTK: {}
--icons-format Plasma: {}; GTK2: {}; GTK3: {}; GTK4: {}; GTK: {}
--font-format Plasma raw: {}; Plasma name: {}; Plasma size: {}; Plasma styles: {}; Plasma pretty: {}; GTK2 raw: {}; GTK2 name: {}; GTK2 size: {}; GTK2 styles: {}; GTK2 pretty: {}; GTK3 raw: {}; GTK3 name: {}; GTK3 size: {}; GTK3 styles: {}; GTK3 pretty: {}; GTK4 raw: {}; GTK4 name: {}; GTK4 size: {}; GTK4 styles: {}; GTK4 pretty: {}; GTK: {}
--font-format Font1: {}; Font2: {}; Font3: {}; Font4: {}
--cursor-format Theme: {}; Size: {}
--terminal-format Process: {}; Path: {}; Exe: {}
--terminal-font-format Raw: {}; Name: {}; Size: {}; Styles: {}; Pretty: {}
--terminal-font-format Pretty: {}; Name: {}; Size: {}; Styles: {}
--cpu-format Name: {}, Vendor: {}, CoresPhysical: {}, CoresLogical: {}, CoresOnline: {}, FrequencyMin: {}, FrequencyMax: {}, Temperature: {}
--cpu-usage-format Percentage: {}
--gpu-format Vendor: {}; Name: {}; Driver: {}; Temperature: {}
--gpu-format Vendor: {}; Name: {}; Driver: {}; Temperature: {}; CoreCount: {}
--memory-format Used: {}; Total: {}; Percentage: {}
--disk-format Used: {}; Total: {}; Files: {}; Percentage: {}
--disk-format SizeUsed: {}; SizeTotal: {}; SizePercentage: {}; FilesUsed: {}; FilesTotal: {}; FilesPercentage: {}; Removable: {}; Hidden: {}; Filesystem: {}; Name: {}
--battery-format Manufactor: {}; Model: {}; Technology: {}; Capacity: {}; Status: {}
--poweradapter-format Watts: {}; Name: {}; Manufactor: {}; Model: {}; Description: {}
--player-format Pretty: {}; Name: {}; Bus: {}; Url: {}
--media-format Pretty: {}; Name: {}; Artist: {}; Album: {}
--datetime-format year: {}; yearShort: {}; month: {}; monthPretty: {}; monthName: {}; monthNameShort: {}; weekNumber: {}; weekday: {}; weekdayShort: {}; dayInYear: {}; dayInMonth: {}; dayInWeek: {}; hour: {}; hourPretty: {}; hour12: {}; hour12Pretty: {}; minute: {}; minutePretty: {}; second: {}; secondPretty: {}
+15 -4
View File
@@ -1,11 +1,22 @@
#!/usr/bin/env sh
# make the script exit if any of the commands fail,
# making fastfetch not run if the build failed.
set -e
mkdir -p build/
cd build/
cmake ..
cmake --build . --target fastfetch -j$(nproc)
if [ -z "${CMAKE_BUILD_TYPE}" ]; then
CMAKE_BUILD_TYPE=Release
fi
cmake "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" ..
if [ -z "$OSTYPE" ] || [ "$OSTYPE" = "linux-gnu" ]; then
cmake_build_args="-j$(nproc)"
elif [ "$OSTYPE" = "darwin" ]; then
cmake_build_args="-j$(sysctl -n hw.ncpu)"
else
cmake_build_args=""
fi
cmake --build . --target fastfetch ${cmake_build_args}
./fastfetch "$@"
+49
View File
@@ -0,0 +1,49 @@
#include "util/textModifier.h"
#include "bar.h"
// green, yellow, red: print the color on nth (0~9) block
// set its value == 10 means the color will not be printed
void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red)
{
assert(green <= 10 && yellow <= 10 && red <= 10);
// [ 0%, 5%) prints 0 blocks
// [ 5%, 15%) prints 1 block;
// ...
// [85%, 95%) prints 9 blocks;
// [95%,100%] prints 10 blocks
percent = (uint8_t)(percent + 5) / 10;
assert(percent <= 10);
if(!instance->config.pipe)
ffStrbufAppendS(buffer, "\033[97m[ ");
else
ffStrbufAppendS(buffer, "[ ");
for (uint8_t i = 0; i < percent; ++i)
{
if(!instance->config.pipe)
{
if (i == green)
ffStrbufAppendS(buffer, "\033[32m");
else if (i == yellow)
ffStrbufAppendS(buffer, "\033[93m");
else if (i == red)
ffStrbufAppendS(buffer, "\033[91m");
}
ffStrbufAppendS(buffer, "");
}
if (percent < 10)
{
if(!instance->config.pipe)
ffStrbufAppendS(buffer, "\033[97m");
for (uint8_t i = percent; i < 10; ++i)
ffStrbufAppendS(buffer, "-");
}
if(!instance->config.pipe)
ffStrbufAppendS(buffer, "\033[97m ]" FASTFETCH_TEXT_MODIFIER_RESET);
else
ffStrbufAppendS(buffer, " ]");
}
+16
View File
@@ -0,0 +1,16 @@
#pragma once
#ifndef FF_INCLUDED_common_bar
#define FF_INCLUDED_common_bar
#include "fastfetch.h"
enum
{
FF_PERCENTAGE_TYPE_NUM_BIT = 1,
FF_PERCENTAGE_TYPE_BAR_BIT = 2,
};
void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red);
#endif
-234
View File
@@ -1,234 +0,0 @@
#include "fastfetch.h"
#include "common/caching.h"
#include "common/io.h"
#include "common/printing.h"
#include <stdlib.h>
#define FF_CACHE_VERSION_NAME "cacheversion"
#define FF_CACHE_VERSION_EXTENSION "ffv"
#define FF_CACHE_VALUE_EXTENSION "ffcv"
#define FF_CACHE_SPLIT_EXTENSION "ffcs"
#define FF_CACHE_EXTENSION_DATA "ffcd"
static void getCacheFilePath(const FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
{
ffStrbufAppend(buffer, &instance->state.cacheDir);
ffStrbufAppendS(buffer, moduleName);
if(extension != NULL)
{
ffStrbufAppendC(buffer, '.');
ffStrbufAppendS(buffer, extension);
}
}
static void readCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
{
FFstrbuf path;
ffStrbufInitA(&path, 64);
getCacheFilePath(instance, moduleName, extension, &path);
ffAppendFileBuffer(path.chars, buffer);
ffStrbufDestroy(&path);
}
static void writeCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* content)
{
FFstrbuf path;
ffStrbufInitA(&path, 64);
getCacheFilePath(instance, moduleName, extension, &path);
ffWriteFileBuffer(path.chars, content);
ffStrbufDestroy(&path);
}
void ffCacheValidate(FFinstance* instance)
{
FFstrbuf content;
ffStrbufInit(&content);
readCacheFile(instance, FF_CACHE_VERSION_NAME, FF_CACHE_VERSION_EXTENSION, &content);
const char exactVersion[] = FASTFETCH_PROJECT_VERSION FASTFETCH_PROJECT_VERSION_TWEAK;
bool isSameVersion = ffStrbufCompS(&content, exactVersion) == 0;
ffStrbufDestroy(&content);
if(isSameVersion)
return;
instance->config.recache = true;
FFstrbuf version;
ffStrbufInitA(&version, sizeof(exactVersion));
ffStrbufAppendS(&version, exactVersion);
writeCacheFile(instance, FF_CACHE_VERSION_NAME, FF_CACHE_VERSION_EXTENSION, &version);
ffStrbufDestroy(&version);
}
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache)
{
FFstrbuf cacheFileValue;
ffStrbufInitA(&cacheFileValue, 64);
getCacheFilePath(instance, moduleName, FF_CACHE_VALUE_EXTENSION, &cacheFileValue);
cache->value = fopen(cacheFileValue.chars, "w");
ffStrbufDestroy(&cacheFileValue);
FFstrbuf cacheFileSplit;
ffStrbufInitA(&cacheFileSplit, 64);
getCacheFilePath(instance, moduleName, FF_CACHE_SPLIT_EXTENSION, &cacheFileSplit);
cache->split = fopen(cacheFileSplit.chars, "w");
ffStrbufDestroy(&cacheFileSplit);
}
void ffCacheClose(FFcache* cache)
{
if(cache->value != NULL)
fclose(cache->value);
if(cache->split != NULL)
fclose(cache->split);
}
static bool printCachedValue(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs)
{
FFstrbuf content;
ffStrbufInitA(&content, 512);
readCacheFile(instance, moduleName, FF_CACHE_VALUE_EXTENSION, &content);
ffStrbufTrimRight(&content, '\0'); //Strbuf always appends a '\0' at the end. We want the last null byte to be at the position of the length
if(content.length == 0)
return false;
uint8_t moduleCounter = 1;
uint32_t startIndex = 0;
while(startIndex < content.length)
{
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
ffPrintLogoAndKey(instance, moduleName, moduleIndex, &moduleArgs->key);
puts(content.chars + startIndex);
startIndex = nullByteIndex + 1;
++moduleCounter;
}
ffStrbufDestroy(&content);
return moduleCounter > 1;
}
static bool printCachedFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs)
{
FFstrbuf content;
ffStrbufInitA(&content, 512);
readCacheFile(instance, moduleName, FF_CACHE_SPLIT_EXTENSION, &content);
ffStrbufTrimRight(&content, '\0'); //Strbuf always appends a '\0' at the end. We want the last null byte to be at the position of the length
if(content.length == 0)
return false;
uint8_t moduleCounter = 1;
FFformatarg* arguments = calloc(numArgs, sizeof(FFformatarg));
uint32_t argumentCounter = 0;
uint32_t startIndex = 0;
while(startIndex < content.length)
{
arguments[argumentCounter].type = FF_FORMAT_ARG_TYPE_STRING;
arguments[argumentCounter].value = &content.chars[startIndex];
++argumentCounter;
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
if(argumentCounter == numArgs)
{
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
++moduleCounter;
argumentCounter = 0;
}
startIndex = nullByteIndex + 1;
}
free(arguments);
ffStrbufDestroy(&content);
return moduleCounter > 1;
}
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs)
{
if(instance->config.recache)
return false;
if(moduleArgs->outputFormat.length == 0)
return printCachedValue(instance, moduleName, moduleArgs);
else
return printCachedFormat(instance, moduleName, moduleArgs, numArgs);
}
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments)
{
if(moduleArgs->outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, &moduleArgs->key);
ffStrbufPutTo(value, stdout);
}
else
{
ffPrintFormat(instance, moduleName, moduleIndex, moduleArgs, numArgs, arguments);
}
if(cache->value != NULL)
{
ffStrbufWriteTo(value, cache->value);
fputc('\0', cache->value);
}
if(cache->split == NULL)
return;
for(uint32_t i = 0; i < numArgs; i++)
{
FFstrbuf buffer;
ffStrbufInitA(&buffer, 64);
ffFormatAppendFormatArg(&buffer, &arguments[i]);
ffStrbufWriteTo(&buffer, cache->split);
ffStrbufDestroy(&buffer);
fputc('\0', cache->split);
}
}
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments)
{
FFcache cache;
ffCacheOpenWrite(instance, moduleName, &cache);
ffPrintAndAppendToCache(instance, moduleName, 0, moduleArgs, &cache, value, numArgs, arguments);
ffCacheClose(&cache);
}
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data)
{
FFstrbuf path;
ffStrbufInitA(&path, 128);
getCacheFilePath(instance, moduleName, FF_CACHE_EXTENSION_DATA, &path);
ffWriteFileData(path.chars, dataSize, data);
ffStrbufDestroy(&path);
}
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data)
{
if(instance->config.recache)
return false;
FFstrbuf path;
ffStrbufInitA(&path, 128);
getCacheFilePath(instance, moduleName, FF_CACHE_EXTENSION_DATA, &path);
ssize_t result = ffReadFileData(path.chars, dataSize, data);
ffStrbufDestroy(&path);
return result > 0 && (size_t) result == dataSize;
}
-27
View File
@@ -1,27 +0,0 @@
#pragma once
#ifndef FF_INCLUDED_common_caching
#define FF_INCLUDED_common_caching
#include "fastfetch.h"
#include "common/format.h"
typedef struct FFcache
{
FILE* value;
FILE* split;
} FFcache;
void ffCacheValidate(FFinstance* instance);
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache);
void ffCacheClose(FFcache* cache);
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs);
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data);
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data);
#endif
+17
View File
@@ -204,6 +204,23 @@ void ffFontInitCopy(FFfont* font, const char* name)
ffFontInitValues(font, name, NULL);
}
void ffFontInitWithSpace(FFfont* font, const char* rawName)
{
const char* pspace = strrchr(rawName, ' ');
if(pspace == NULL)
{
ffFontInitCopy(font, rawName);
return;
}
fontInit(font);
ffStrbufAppendNS(&font->name, (uint32_t)(pspace - rawName), rawName);
ffStrbufAppendS(&font->size, pspace + 1);
fontInitPretty(font);
}
void ffFontDestroy(FFfont* font)
{
ffStrbufDestroy(&font->pretty);
+1
View File
@@ -18,6 +18,7 @@ void ffFontInitQt(FFfont* font, const char* data);
void ffFontInitPango(FFfont* font, const char* data);
void ffFontInitCopy(FFfont* font, const char* name);
void ffFontInitValues(FFfont* font, const char* name, const char* size);
void ffFontInitWithSpace(FFfont* font, const char* rawName);
void ffFontDestroy(FFfont* font);
#endif
+23 -7
View File
@@ -1,23 +1,28 @@
#include "fastfetch.h"
#include "common/format.h"
#include "common/parsing.h"
#include "util/textModifier.h"
#include <inttypes.h>
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
{
if(formatarg->type == FF_FORMAT_ARG_TYPE_INT)
ffStrbufAppendF(buffer, "%i", *(int*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT)
ffStrbufAppendF(buffer, "%u", *(uint32_t*)formatarg->value);
ffStrbufAppendF(buffer, "%" PRIu32, *(uint32_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT16)
ffStrbufAppendF(buffer, "%hu", *(uint16_t*)formatarg->value);
ffStrbufAppendF(buffer, "%" PRIu16, *(uint16_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT8)
ffStrbufAppendF(buffer, "%hhu", *(uint8_t*)formatarg->value);
ffStrbufAppendF(buffer, "%" PRIu8, *(uint8_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_STRING)
ffStrbufAppendS(buffer, (const char*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_STRBUF)
ffStrbufAppend(buffer, (FFstrbuf*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_DOUBLE)
ffStrbufAppendF(buffer, "%g", *(double*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_BOOL)
ffStrbufAppendS(buffer, formatarg->value != NULL ? "true" : "false");
else if(formatarg->type == FF_FORMAT_ARG_TYPE_LIST)
{
const FFlist* list = formatarg->value;
@@ -34,6 +39,14 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
}
}
/**
* @brief parses a string to a uint32_t
*
* If the string can't be parsed, or is < 1, uint32_t max is returned.
*
* @param placeholderValue the string to parse
* @return uint32_t the parsed value
*/
static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
{
uint32_t result = UINT32_MAX;
@@ -41,7 +54,7 @@ static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
if(placeholderValue->chars[0] != '-')
sscanf(placeholderValue->chars, "%u", &result);
return result;
return result == 0 ? UINT32_MAX : result;
}
static inline void appendInvalidPlaceholder(FFstrbuf* buffer, const char* start, const FFstrbuf* placeholderValue, uint32_t index, uint32_t formatStringLength)
@@ -55,10 +68,12 @@ static inline void appendInvalidPlaceholder(FFstrbuf* buffer, const char* start,
static inline void appendEmptyPlaceholder(FFstrbuf* buffer, const char* placeholder, uint32_t* argCounter, uint32_t numArgs, const FFformatarg* arguments)
{
if(*argCounter > numArgs)
if(*argCounter >= numArgs)
ffStrbufAppendS(buffer, placeholder);
else
ffFormatAppendFormatArg(buffer, &arguments[(*argCounter)++]);
ffFormatAppendFormatArg(buffer, arguments + *argCounter);
(*argCounter)++;
}
static inline bool formatArgSet(const FFformatarg* arg)
@@ -70,7 +85,8 @@ static inline bool formatArgSet(const FFformatarg* arg)
(arg->type == FF_FORMAT_ARG_TYPE_STRING && ffStrSet(arg->value)) ||
(arg->type == FF_FORMAT_ARG_TYPE_UINT8 && *(uint8_t*)arg->value > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_UINT16 && *(uint16_t*)arg->value > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_UINT && *(uint32_t*)arg->value > 0)
(arg->type == FF_FORMAT_ARG_TYPE_UINT && *(uint32_t*)arg->value > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_BOOL && arg->value != NULL)
);
}
+4 -1
View File
@@ -13,7 +13,8 @@ typedef enum FFformatargtype
FF_FORMAT_ARG_TYPE_STRING,
FF_FORMAT_ARG_TYPE_STRBUF,
FF_FORMAT_ARG_TYPE_DOUBLE,
FF_FORMAT_ARG_TYPE_LIST
FF_FORMAT_ARG_TYPE_LIST,
FF_FORMAT_ARG_TYPE_BOOL
} FFformatargtype;
typedef struct FFformatarg
@@ -25,4 +26,6 @@ typedef struct FFformatarg
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
#define FF_FORMAT_ARG_VALUE_BOOL(xpr) ((xpr) ? (const void*) 1 : NULL)
#endif
+226 -118
View File
@@ -1,25 +1,27 @@
#include "fastfetch.h"
#include "common/caching.h"
#include "common/parsing.h"
#include "common/thread.h"
#include "detection/qt.h"
#include "detection/gtk.h"
#include "detection/displayserver/displayserver.h"
#include "util/textModifier.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <signal.h>
#include <pthread.h>
static bool strbufEqualsAdapter(const void* first, const void* second)
{
return ffStrbufComp(second, first) == 0;
}
#ifdef _WIN32
#include <wincon.h>
#include <locale.h>
#else
#include <signal.h>
#endif
static void initConfigDirs(FFstate* state)
{
ffListInit(&state->configDirs, sizeof(FFstrbuf));
#if !(defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__))
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if(ffStrSet(xdgConfigHome))
{
@@ -29,9 +31,14 @@ static void initConfigDirs(FFstate* state)
ffStrbufEnsureEndsWithC(buffer, '/');
}
#endif
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
if(ffListFirstIndexComp(&state->configDirs, element, strbufEqualsAdapter) < state->configDirs.length - 1) \
--state->configDirs.length;
if(ffListFirstIndexComp(&state->configDirs, element, (bool(*)(const void*, const void*))ffStrbufEqual) < state->configDirs.length - 1) \
{ \
ffStrbufDestroy(ffListGet(&state->configDirs, state->configDirs.length - 1)); \
--state->configDirs.length; \
}
FFstrbuf* userConfigHome = ffListAdd(&state->configDirs);
ffStrbufInitA(userConfigHome, 64);
@@ -45,6 +52,8 @@ static void initConfigDirs(FFstate* state)
ffStrbufEnsureEndsWithC(userHome, '/');
FF_ENSURE_ONLY_ONCE_IN_LIST(userHome)
#if !(defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__))
FFstrbuf xdgConfigDirs;
ffStrbufInitA(&xdgConfigDirs, 64);
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
@@ -69,66 +78,53 @@ static void initConfigDirs(FFstate* state)
startIndex = colonIndex + 1;
}
ffStrbufDestroy(&xdgConfigDirs);
FFstrbuf* systemConfigHome = ffListAdd(&state->configDirs);
ffStrbufInitA(systemConfigHome, 64);
ffStrbufAppendS(systemConfigHome, FASTFETCH_TARGET_DIR_ROOT"/etc/xdg/");
ffStrbufAppendS(systemConfigHome, FASTFETCH_TARGET_DIR_ETC"/xdg/");
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfigHome)
#endif
FFstrbuf* systemConfig = ffListAdd(&state->configDirs);
ffStrbufInitA(systemConfig, 64);
ffStrbufAppendS(systemConfig, FASTFETCH_TARGET_DIR_ROOT"/etc/");
ffStrbufAppendS(systemConfig, FASTFETCH_TARGET_DIR_ETC"/");
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfig)
#undef FF_ENSURE_ONLY_ONCE_IN_LIST
}
static void initCacheDir(FFstate* state)
{
ffStrbufInitA(&state->cacheDir, 64);
ffStrbufAppendS(&state->cacheDir, getenv("XDG_CACHE_HOME"));
if(state->cacheDir.length == 0)
{
ffStrbufAppendS(&state->cacheDir, state->passwd->pw_dir);
ffStrbufAppendS(&state->cacheDir, "/.cache/");
}
else
ffStrbufEnsureEndsWithC(&state->cacheDir, '/');
mkdir(state->cacheDir.chars, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); //I hope everybody has a cache folder, but who knows
ffStrbufAppendS(&state->cacheDir, "fastfetch/");
mkdir(state->cacheDir.chars, S_IRWXU | S_IRGRP | S_IROTH);
}
static void initState(FFstate* state)
{
#ifdef WIN32
//https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendations&view=msvc-170#utf-8-support
setlocale(LC_ALL, ".UTF8");
#endif
state->logoWidth = 0;
state->logoHeight = 0;
state->keysHeight = 0;
state->passwd = getpwuid(getuid());
#ifndef WIN32
state->passwd = getpwuid(getuid());
#else
state->passwd = ffGetPasswd();
#endif
uname(&state->utsname);
#if FF_HAVE_SYSINFO_H
sysinfo(&state->sysinfo);
#endif
initConfigDirs(state);
initCacheDir(state);
}
static void initModuleArg(FFModuleArgs* args)
{
ffStrbufInitA(&args->key, 0);
ffStrbufInitA(&args->outputFormat, 0);
ffStrbufInitA(&args->errorFormat, 0);
ffStrbufInit(&args->key);
ffStrbufInit(&args->outputFormat);
ffStrbufInit(&args->errorFormat);
}
static void defaultConfig(FFinstance* instance)
{
ffStrbufInit(&instance->config.logo.source);
ffStrbufInitA(&instance->config.logo.source, 0);
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufInit(&instance->config.logo.colors[i]);
@@ -137,6 +133,13 @@ static void defaultConfig(FFinstance* instance)
instance->config.logo.paddingLeft = 0;
instance->config.logo.paddingRight = 4;
instance->config.logo.printRemaining = true;
instance->config.logo.preserveAspectRadio = false;
instance->config.logo.chafaFgOnly = false;
ffStrbufInitS(&instance->config.logo.chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
instance->config.logo.chafaCanvasMode = UINT32_MAX;
instance->config.logo.chafaColorSpace = UINT32_MAX;
instance->config.logo.chafaDitherMode = UINT32_MAX;
ffStrbufInit(&instance->config.colorKeys);
ffStrbufInit(&instance->config.colorTitle);
@@ -146,7 +149,6 @@ static void defaultConfig(FFinstance* instance)
instance->config.showErrors = false;
instance->config.recache = false;
instance->config.cacheSave = true;
instance->config.allowSlowOperations = false;
instance->config.disableLinewrap = true;
instance->config.hideCursor = true;
@@ -155,9 +157,13 @@ static void defaultConfig(FFinstance* instance)
instance->config.glType = FF_GL_TYPE_AUTO;
instance->config.pipe = false;
instance->config.multithreading = true;
instance->config.stat = false;
initModuleArg(&instance->config.os);
initModuleArg(&instance->config.host);
initModuleArg(&instance->config.bios);
initModuleArg(&instance->config.board);
initModuleArg(&instance->config.chassis);
initModuleArg(&instance->config.kernel);
initModuleArg(&instance->config.uptime);
initModuleArg(&instance->config.processes);
@@ -180,9 +186,12 @@ static void defaultConfig(FFinstance* instance)
initModuleArg(&instance->config.swap);
initModuleArg(&instance->config.disk);
initModuleArg(&instance->config.battery);
initModuleArg(&instance->config.powerAdapter);
initModuleArg(&instance->config.locale);
initModuleArg(&instance->config.localIP);
initModuleArg(&instance->config.publicIP);
initModuleArg(&instance->config.weather);
initModuleArg(&instance->config.wifi);
initModuleArg(&instance->config.player);
initModuleArg(&instance->config.song);
initModuleArg(&instance->config.dateTime);
@@ -191,6 +200,7 @@ static void defaultConfig(FFinstance* instance)
initModuleArg(&instance->config.vulkan);
initModuleArg(&instance->config.openGL);
initModuleArg(&instance->config.openCL);
initModuleArg(&instance->config.users);
ffStrbufInitA(&instance->config.libPCI, 0);
ffStrbufInitA(&instance->config.libVulkan, 0);
@@ -212,10 +222,19 @@ static void defaultConfig(FFinstance* instance)
ffStrbufInitA(&instance->config.libGLX, 0);
ffStrbufInitA(&instance->config.libOSMesa, 0);
ffStrbufInitA(&instance->config.libOpenCL, 0);
ffStrbufInitA(&instance->config.libcJSON, 0);
ffStrbufInitA(&instance->config.libfreetype, 0);
ffStrbufInit(&instance->config.libwlanapi);
instance->config.cpuTemp = false;
instance->config.gpuTemp = false;
instance->config.batteryTemp = false;
instance->config.titleFQDN = false;
ffStrbufInitA(&instance->config.diskFolders, 0);
instance->config.diskShowRemovable = true;
instance->config.diskShowHidden = false;
ffStrbufInitA(&instance->config.batteryDir, 0);
@@ -224,12 +243,19 @@ static void defaultConfig(FFinstance* instance)
instance->config.localIpShowIpV4 = true;
instance->config.localIpShowIpV6 = false;
instance->config.localIpShowLoop = false;
ffStrbufInit(&instance->config.localIpNamePrefix);
instance->config.publicIpTimeout = 0;
ffStrbufInit(&instance->config.publicIpUrl);
instance->config.weatherTimeout = 0;
ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)");
ffStrbufInitA(&instance->config.osFile, 0);
ffStrbufInitA(&instance->config.playerName, 0);
instance->config.percentType = 1;
}
void ffInitInstance(FFinstance* instance)
@@ -238,87 +264,39 @@ void ffInitInstance(FFinstance* instance)
defaultConfig(instance);
}
#if !defined(__ANDROID__)
#ifdef FF_HAVE_THREADS
static void* connectDisplayServerThreadMain(void* instance)
{
ffConnectDisplayServer((FFinstance*)instance);
return NULL;
}
FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*)
#if !defined(__APPLE__)
#if !(defined(__APPLE__) || defined(_WIN32))
static void* detectPlasmaThreadMain(void* instance)
{
ffDetectQt((FFinstance*)instance);
return NULL;
}
#define FF_DETECT_QT_GTK 1
static void* detectGTK2ThreadMain(void* instance)
{
ffDetectGTK2((FFinstance*)instance);
return NULL;
}
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectQt, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK2, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK3, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK4, FFinstance*)
static void* detectGTK3ThreadMain(void* instance)
{
ffDetectGTK3((FFinstance*)instance);
return NULL;
}
#endif //!(defined(__APPLE__) || defined(_WIN32))
static void* detectGTK4ThreadMain(void* instance)
{
ffDetectGTK4((FFinstance*)instance);
return NULL;
}
static void* startThreadsThreadMain(void* instance)
{
pthread_t dsThread;
pthread_create(&dsThread, NULL, connectDisplayServerThreadMain, instance);
pthread_detach(dsThread);
pthread_t gtk2Thread;
pthread_create(&gtk2Thread, NULL, detectGTK2ThreadMain, instance);
pthread_detach(gtk2Thread);
pthread_t gtk3Thread;
pthread_create(&gtk3Thread, NULL, detectGTK3ThreadMain, instance);
pthread_detach(gtk3Thread);
pthread_t gtk4Thread;
pthread_create(&gtk4Thread, NULL, detectGTK4ThreadMain, instance);
pthread_detach(gtk4Thread);
pthread_t plasmaThread;
pthread_create(&plasmaThread, NULL, detectPlasmaThreadMain, instance);
pthread_detach(plasmaThread);
return NULL;
}
#endif //FF_HAVE_THREADS
void startDetectionThreads(FFinstance* instance)
{
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
pthread_detach(startThreadsThread);
}
#ifdef FF_HAVE_THREADS
ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, instance));
#else // !__APPLE__
void startDetectionThreads(FFinstance* instance)
{
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, connectDisplayServerThreadMain, instance);
pthread_detach(startThreadsThread);
}
#endif // __APPLE__
#ifdef FF_DETECT_QT_GTK
ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, instance));
#endif
#else // !__ANDROID__
void startDetectionThreads(FFinstance* instance)
{
#else
FF_UNUSED(instance);
#endif
}
#endif // __ANDROID__
static volatile bool ffDisableLinewrap = true;
static volatile bool ffHideCursor = true;
@@ -332,12 +310,21 @@ static void resetConsole()
fputs("\033[?25h", stdout);
}
#ifdef _WIN32
BOOL WINAPI consoleHandler(DWORD signal)
{
FF_UNUSED(signal);
resetConsole();
exit(0);
}
#else
static void exitSignalHandler(int signal)
{
FF_UNUSED(signal);
resetConsole();
exit(0);
}
#endif
void ffStart(FFinstance* instance)
{
@@ -347,16 +334,25 @@ void ffStart(FFinstance* instance)
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
struct sigaction action = {};
action.sa_handler = exitSignalHandler;
#ifdef _WIN32
#ifdef FF_ENABLE_BUFFER
setvbuf(stdout, NULL, _IOFBF, 4096);
#endif
SetConsoleCtrlHandler(consoleHandler, TRUE);
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
GetConsoleMode(hStdout, &mode);
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
SetConsoleOutputCP(CP_UTF8);
#else
#ifndef FF_ENABLE_BUFFER
setvbuf(stdout, NULL, _IONBF, 0);
#endif
struct sigaction action = { .sa_handler = exitSignalHandler };
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);
sigaction(SIGQUIT, &action, NULL);
//We do the cache validation here, so we can skip it if --recache is given
if(!instance->config.recache)
ffCacheValidate(instance);
#endif
//reset everything to default before we start printing
if(!instance->config.pipe)
@@ -379,6 +375,112 @@ void ffFinish(FFinstance* instance)
resetConsole();
}
static void destroyModuleArg(FFModuleArgs* args)
{
ffStrbufDestroy(&args->key);
ffStrbufDestroy(&args->outputFormat);
ffStrbufDestroy(&args->errorFormat);
}
static void destroyConfig(FFinstance* instance)
{
ffStrbufDestroy(&instance->config.logo.source);
ffStrbufDestroy(&instance->config.logo.chafaSymbols);
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufDestroy(&instance->config.logo.colors[i]);
ffStrbufDestroy(&instance->config.colorKeys);
ffStrbufDestroy(&instance->config.colorTitle);
ffStrbufDestroy(&instance->config.separator);
destroyModuleArg(&instance->config.os);
destroyModuleArg(&instance->config.host);
destroyModuleArg(&instance->config.bios);
destroyModuleArg(&instance->config.board);
destroyModuleArg(&instance->config.kernel);
destroyModuleArg(&instance->config.uptime);
destroyModuleArg(&instance->config.processes);
destroyModuleArg(&instance->config.packages);
destroyModuleArg(&instance->config.shell);
destroyModuleArg(&instance->config.resolution);
destroyModuleArg(&instance->config.de);
destroyModuleArg(&instance->config.wm);
destroyModuleArg(&instance->config.wmTheme);
destroyModuleArg(&instance->config.theme);
destroyModuleArg(&instance->config.icons);
destroyModuleArg(&instance->config.font);
destroyModuleArg(&instance->config.cursor);
destroyModuleArg(&instance->config.terminal);
destroyModuleArg(&instance->config.terminalFont);
destroyModuleArg(&instance->config.cpu);
destroyModuleArg(&instance->config.cpuUsage);
destroyModuleArg(&instance->config.gpu);
destroyModuleArg(&instance->config.memory);
destroyModuleArg(&instance->config.swap);
destroyModuleArg(&instance->config.disk);
destroyModuleArg(&instance->config.battery);
destroyModuleArg(&instance->config.powerAdapter);
destroyModuleArg(&instance->config.locale);
destroyModuleArg(&instance->config.localIP);
destroyModuleArg(&instance->config.publicIP);
destroyModuleArg(&instance->config.weather);
destroyModuleArg(&instance->config.wifi);
destroyModuleArg(&instance->config.player);
destroyModuleArg(&instance->config.song);
destroyModuleArg(&instance->config.dateTime);
destroyModuleArg(&instance->config.date);
destroyModuleArg(&instance->config.time);
destroyModuleArg(&instance->config.vulkan);
destroyModuleArg(&instance->config.openGL);
destroyModuleArg(&instance->config.openCL);
destroyModuleArg(&instance->config.users);
ffStrbufDestroy(&instance->config.libPCI);
ffStrbufDestroy(&instance->config.libVulkan);
ffStrbufDestroy(&instance->config.libWayland);
ffStrbufDestroy(&instance->config.libXcbRandr);
ffStrbufDestroy(&instance->config.libXcb);
ffStrbufDestroy(&instance->config.libXrandr);
ffStrbufDestroy(&instance->config.libX11);
ffStrbufDestroy(&instance->config.libGIO);
ffStrbufDestroy(&instance->config.libDConf);
ffStrbufDestroy(&instance->config.libDBus);
ffStrbufDestroy(&instance->config.libXFConf);
ffStrbufDestroy(&instance->config.libSQLite3);
ffStrbufDestroy(&instance->config.librpm);
ffStrbufDestroy(&instance->config.libImageMagick);
ffStrbufDestroy(&instance->config.libZ);
ffStrbufDestroy(&instance->config.libChafa);
ffStrbufDestroy(&instance->config.libEGL);
ffStrbufDestroy(&instance->config.libGLX);
ffStrbufDestroy(&instance->config.libOSMesa);
ffStrbufDestroy(&instance->config.libOpenCL);
ffStrbufDestroy(&instance->config.libcJSON);
ffStrbufDestroy(&instance->config.libfreetype);
ffStrbufDestroy(&instance->config.libwlanapi);
ffStrbufDestroy(&instance->config.diskFolders);
ffStrbufDestroy(&instance->config.batteryDir);
ffStrbufDestroy(&instance->config.separatorString);
ffStrbufDestroy(&instance->config.localIpNamePrefix);
ffStrbufDestroy(&instance->config.publicIpUrl);
ffStrbufDestroy(&instance->config.weatherOutputFormat);
ffStrbufDestroy(&instance->config.osFile);
ffStrbufDestroy(&instance->config.playerName);
}
static void destroyState(FFinstance* instance)
{
for(uint32_t i = 0; i < instance->state.configDirs.length; ++i)
ffStrbufDestroy((FFstrbuf*)ffListGet(&instance->state.configDirs, i));
ffListDestroy(&instance->state.configDirs);
}
void ffDestroyInstance(FFinstance* instance)
{
destroyConfig(instance);
destroyState(instance);
}
//Must be in a file compiled with the libfastfetch target, because the FF_HAVE* macros are not defined for the executable targets
void ffListFeatures()
{
@@ -446,6 +548,12 @@ void ffListFeatures()
#ifdef FF_HAVE_OPENCL
"opencl\n"
#endif
#ifdef FF_HAVE_LIBCJSON
"libcjson\n"
#endif
#ifdef FF_HAVE_FREETYPE
"freetype"
#endif
""
, stdout);
}
+98 -5
View File
@@ -1,11 +1,15 @@
#include "fastfetch.h"
#include "common/io.h"
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <poll.h>
#ifdef _WIN32
#include <fileapi.h>
#else
#include <termios.h>
#include <poll.h>
#endif
static void createSubfolders(const char* fileName)
{
@@ -16,7 +20,13 @@ static void createSubfolders(const char* fileName)
{
ffStrbufAppendC(&path, *fileName);
if(*fileName == '/')
mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH);
{
mkdir(path.chars
#ifndef WIN32
, S_IRWXU | S_IRGRP | S_IROTH
#endif
);
}
++fileName;
}
@@ -30,6 +40,21 @@ bool ffWriteFDBuffer(int fd, const FFstrbuf* content)
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
#ifdef _WIN32
HANDLE handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
{
createSubfolders(fileName);
handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return false;
}
DWORD written;
bool ret = !!WriteFile(handle, data, (DWORD)dataSize, &written, NULL);
CloseHandle(handle);
#else
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC;
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
@@ -45,6 +70,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
bool ret = write(fd, data, dataSize) != -1;
close(fd);
#endif
return ret;
}
@@ -54,11 +80,51 @@ bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer)
return ffWriteFileData(fileName, buffer->length, buffer->chars);
}
#ifdef _WIN32
bool ffAppendHandleBuffer(HANDLE handle, FFstrbuf* buffer)
{
DWORD readed = 0;
LARGE_INTEGER fileSize;
if(!GetFileSizeEx(handle, &fileSize))
fileSize.QuadPart = 0;
ffStrbufEnsureFree(buffer, fileSize.QuadPart > 0 ? (uint32_t)fileSize.QuadPart : 31);
uint32_t free = ffStrbufGetFree(buffer);
bool success;
while(
(success = !!ReadFile(handle, buffer->chars + buffer->length, free, &readed, NULL)) &&
(uint32_t) readed == free
) {
buffer->length += (uint32_t) readed;
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
free = ffStrbufGetFree(buffer);
}
if(readed > 0)
buffer->length += (uint32_t) readed;
buffer->chars[buffer->length] = '\0';
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
return success;
}
#endif
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
{
ssize_t readed = 0;
ffStrbufEnsureFree(buffer, 31); // 32 - 1 for the null terminator
struct stat fileInfo;
if(fstat(fd, &fileInfo) != 0)
return false;
ffStrbufEnsureFree(buffer, fileInfo.st_size > 0 ? (uint32_t)fileInfo.st_size : 31);
uint32_t free = ffStrbufGetFree(buffer);
while(
@@ -84,6 +150,17 @@ bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
{
#ifdef _WIN32
HANDLE handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return false;
DWORD readed;
if(!ReadFile(handle, data, (DWORD)dataSize, &readed, NULL))
return -1;
return (ssize_t)readed;
#else
int fd = open(fileName, O_RDONLY);
if(fd == -1)
return -1;
@@ -93,10 +170,20 @@ ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
close(fd);
return readed;
#endif
}
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
#ifdef _WIN32
HANDLE handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return false;
bool ret = ffAppendHandleBuffer(handle, buffer);
CloseHandle(handle);
#else
int fd = open(fileName, O_RDONLY);
if(fd == -1)
return false;
@@ -104,6 +191,7 @@ bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
bool ret = ffAppendFDBuffer(fd, buffer);
close(fd);
#endif
return ret;
}
@@ -151,6 +239,7 @@ bool ffFileExists(const char* fileName, mode_t mode)
void ffGetTerminalResponse(const char* request, const char* format, ...)
{
#ifndef WIN32
struct termios oldTerm, newTerm;
if(tcgetattr(STDIN_FILENO, &oldTerm) == -1)
return;
@@ -189,4 +278,8 @@ void ffGetTerminalResponse(const char* request, const char* format, ...)
va_start(args, format);
vsscanf(buffer, format, args);
va_end(args);
#else
//Unimplemented
FF_UNUSED(request, format);
#endif
}
+8 -2
View File
@@ -3,7 +3,9 @@
#ifndef FF_INCLUDED_common_io
#define FF_INCLUDED_common_io
#include <sys/types.h> //mode_t
#include "fastfetch.h"
#include <sys/stat.h> //mode_t, fstat, stat
bool ffWriteFDBuffer(int fd, const FFstrbuf* content);
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
@@ -14,11 +16,15 @@ ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data);
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer);
bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer);
#ifdef _WIN32
bool ffAppendHandleBuffer(HANDLE handle, FFstrbuf* buffer);
#endif
bool ffFileExists(const char* fileName, mode_t mode);
// Not thread safe!
void ffSuppressIO(bool suppress);
void ffGetTerminalResponse(const char* request, const char* format, ...);
FF_C_SCANF(2, 3) void ffGetTerminalResponse(const char* request, const char* format, ...);
#endif
+30 -4
View File
@@ -3,9 +3,32 @@
#include <stdarg.h>
//Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
#define __SANITIZE_ADDRESS__
#endif
#endif
#ifndef FF_DLOPEN_FLAGS
#ifdef __SANITIZE_ADDRESS__
#define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
#else
#define FF_DLOPEN_FLAGS RTLD_LAZY
#endif
#endif
static void* libraryLoad(const char* path, int maxVersion)
{
void* result = dlopen(path, RTLD_LAZY);
void* result = dlopen(path, FF_DLOPEN_FLAGS);
#ifdef _WIN32
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
FF_UNUSED(maxVersion)
#else
if(result != NULL || maxVersion < 0)
return result;
@@ -19,7 +42,7 @@ static void* libraryLoad(const char* path, int maxVersion)
uint32_t originalLength = pathbuf.length;
ffStrbufAppendF(&pathbuf, "%i", i);
result = dlopen(pathbuf.chars, RTLD_LAZY);
result = dlopen(pathbuf.chars, FF_DLOPEN_FLAGS);
if(result != NULL)
break;
@@ -27,13 +50,16 @@ static void* libraryLoad(const char* path, int maxVersion)
}
ffStrbufDestroy(&pathbuf);
#endif
return result;
}
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...)
{
if(userProvidedName->length > 0)
return dlopen(userProvidedName->chars, RTLD_LAZY);
if(userProvidedName != NULL && userProvidedName->length > 0)
return dlopen(userProvidedName->chars, FF_DLOPEN_FLAGS);
va_list defaultNames;
va_start(defaultNames, userProvidedName);
+19 -3
View File
@@ -3,9 +3,22 @@
#ifndef FF_INCLUDED_common_library
#define FF_INCLUDED_common_library
#include <dlfcn.h>
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
#ifdef __APPLE__
#if defined(_WIN32) //We don't force MSYS using LoadLibrary because dlopen also searches $LD_LIBRARY_PATH
#include <libloaderapi.h>
#define FF_DLOPEN_FLAGS 0
FF_C_NODISCARD static inline void* dlopen(const char* path, int mode) { FF_UNUSED(mode); return LoadLibraryA(path); }
FF_C_NODISCARD static inline void* dlsym(void* handle, const char* symbol) { return GetProcAddress((HMODULE)handle, symbol); }
static inline int dlclose(void* handle) { return !FreeLibrary((HMODULE)handle); }
#else
#include <dlfcn.h>
#endif
#ifdef _WIN32
#define FF_LIBRARY_EXTENSION ".dll"
#elif defined(__APPLE__)
#define FF_LIBRARY_EXTENSION ".dylib"
#else
#define FF_LIBRARY_EXTENSION ".so"
@@ -15,7 +28,7 @@
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
void* libraryObjectName = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL);\
void* libraryObjectName = ffLibraryLoad(userLibraryName, __VA_ARGS__, NULL);\
if(libraryObjectName == NULL) \
return returnValue;
@@ -30,6 +43,9 @@
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, returnValue);
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
__typeof__(&symbolName) ff ## symbolName = dlsym(library, #symbolName);
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed");
-69
View File
@@ -1,69 +0,0 @@
#include "fastfetch.h"
#include "common/networking.h"
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer)
{
struct addrinfo hints = {0};
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
struct addrinfo* addr;
if(getaddrinfo(host, "80", &hints, &addr) != 0)
return;
int sock = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(sock == -1)
{
freeaddrinfo(addr);
return;
}
if(timeout > 0)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = (__typeof__(timev.tv_usec)) (timeout * 1000); //milliseconds to microseconds
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
}
if(connect(sock, addr->ai_addr, addr->ai_addrlen) == -1)
{
close(sock);
freeaddrinfo(addr);
return;
}
freeaddrinfo(addr);
FFstrbuf command;
ffStrbufInitA(&command, 64);
ffStrbufAppendS(&command, "GET ");
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&command, host);
ffStrbufAppendS(&command, "\r\n\r\n");
if(send(sock, command.chars, command.length, 0) == -1)
{
ffStrbufDestroy(&command);
close(sock);
return;
}
ssize_t received = recv(sock, buffer->chars + buffer->length, ffStrbufGetFree(buffer), 0);
if(received > 0)
{
buffer->length += (uint32_t) received;
buffer->chars[buffer->length] = '\0';
}
ffStrbufDestroy(&command);
close(sock);
}
+30 -1
View File
@@ -3,8 +3,37 @@
#ifndef FF_INCLUDED_common_networking
#define FF_INCLUDED_common_networking
#include "common/thread.h"
#include "util/FFstrbuf.h"
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer);
#ifdef _WIN32
#include <minwindef.h>
#endif
typedef struct FFNetworkingState {
#ifdef _WIN32
uintptr_t sockfd;
OVERLAPPED overlapped;
#else
int sockfd;
FFstrbuf host;
FFstrbuf command;
#ifdef FF_HAVE_THREADS
FFThreadType thread;
#endif
#endif
} FFNetworkingState;
bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers);
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout);
static inline bool ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, const char* headers, FFstrbuf* buffer)
{
FFNetworkingState state;
if(ffNetworkingSendHttpRequest(&state, host, path, headers))
return ffNetworkingRecvHttpResponse(&state, buffer, timeout);
return false;
}
#endif
+103
View File
@@ -0,0 +1,103 @@
#include "fastfetch.h"
#include "common/networking.h"
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
static void connectAndSend(FFNetworkingState* state)
{
struct addrinfo hints = {
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo* addr;
if(getaddrinfo(state->host.chars, "80", &hints, &addr) != 0)
goto error;
state->sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(state->sockfd == -1)
{
freeaddrinfo(addr);
goto error;
}
if(connect(state->sockfd, addr->ai_addr, addr->ai_addrlen) == -1)
{
close(state->sockfd);
freeaddrinfo(addr);
goto error;
}
freeaddrinfo(addr);
if(send(state->sockfd, state->command.chars, state->command.length, 0) < 0)
{
close(state->sockfd);
goto error;
}
goto exit;
error:
state->sockfd = -1;
exit:
ffStrbufDestroy(&state->host);
ffStrbufDestroy(&state->command);
}
FF_THREAD_ENTRY_DECL_WRAPPER(connectAndSend, FFNetworkingState*);
bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers)
{
ffStrbufInitS(&state->host, host);
ffStrbufInitA(&state->command, 64);
ffStrbufAppendS(&state->command, "GET ");
ffStrbufAppendS(&state->command, path);
ffStrbufAppendS(&state->command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&state->command, host);
ffStrbufAppendS(&state->command, "\r\n");
ffStrbufAppendS(&state->command, headers);
ffStrbufAppendS(&state->command, "\r\n");
#ifdef FF_HAVE_THREADS
state->thread = ffThreadCreate(connectAndSendThreadMain, state);
return !!state->thread;
#else
connectAndSend(state);
return state->sockfd != -1;
#endif
}
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout)
{
#ifdef FF_HAVE_THREADS
ffThreadJoin(state->thread);
#endif
if(state->sockfd == -1)
return false;
if(timeout > 0)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = (__typeof__(timev.tv_usec)) (timeout * 1000); //milliseconds to microseconds
setsockopt(state->sockfd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
}
ssize_t received = recv(state->sockfd, buffer->chars + buffer->length, ffStrbufGetFree(buffer), 0);
if(received > 0)
{
buffer->length += (uint32_t) received;
buffer->chars[buffer->length] = '\0';
}
close(state->sockfd);
return ffStrbufStartsWithS(buffer, "HTTP/1.1 200 OK\r\n");
}
+125
View File
@@ -0,0 +1,125 @@
#include <mswsock.h>
#include <ws2tcpip.h>
//Must be included after <mswsock.h>
#include "fastfetch.h"
#include "common/networking.h"
static LPFN_CONNECTEX ConnectEx;
static BOOL WINAPI initWsaData(PINIT_ONCE once, PVOID param, PVOID* context)
{
(void)once;
(void)param;
static WSADATA wsaData;
*context = &wsaData;
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
return FALSE;
if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
return FALSE;
//Dummy socket needed for WSAIoctl
SOCKET sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd == INVALID_SOCKET)
return FALSE;
DWORD dwBytes;
GUID guid = WSAID_CONNECTEX;
if(WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER,
&guid, sizeof(guid),
&ConnectEx, sizeof(ConnectEx),
&dwBytes, NULL, NULL) != 0)
return FALSE;
return closesocket(sockfd) == 0;
}
bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
WSADATA* pData;
if(!InitOnceExecuteOnce(&once, initWsaData, NULL, (LPVOID*) &pData))
return false;
memset(state, 0, sizeof(*state));
struct addrinfo hints = {
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo* addr;
if(getaddrinfo(host, "80", &hints, &addr) != 0)
return false;
state->sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(state->sockfd == INVALID_SOCKET)
{
freeaddrinfo(addr);
return false;
}
{
//ConnectEx requires the socket to be initially bound
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_addr.s_addr = INADDR_ANY,
.sin_port = 0,
};
if(bind(state->sockfd, (SOCKADDR *)&addr, sizeof(addr)) != 0)
{
printf("bind %d\n", WSAGetLastError());
return false;
}
}
FF_STRBUF_AUTO_DESTROY command;
ffStrbufInitA(&command, 64);
ffStrbufAppendS(&command, "GET ");
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&command, host);
ffStrbufAppendS(&command, "\r\n");
ffStrbufAppendS(&command, headers);
ffStrbufAppendS(&command, "\r\n");
BOOL result = ConnectEx(state->sockfd, addr->ai_addr, (int)addr->ai_addrlen, command.chars, command.length, NULL, &state->overlapped);
freeaddrinfo(addr);
if(!result && WSAGetLastError() != WSA_IO_PENDING)
{
closesocket(state->sockfd);
return false;
}
return true;
}
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout)
{
DWORD transfer, flags;
if (!WSAGetOverlappedResult(state->sockfd, &state->overlapped, &transfer, TRUE, &flags))
{
closesocket(state->sockfd);
return false;
}
if(timeout > 0)
{
//https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt
setsockopt(state->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof(timeout));
}
ssize_t received = recv(state->sockfd, buffer->chars + buffer->length, (int)ffStrbufGetFree(buffer), 0);
if(received > 0)
{
buffer->length += (uint32_t) received;
buffer->chars[buffer->length] = '\0';
}
closesocket(state->sockfd);
return ffStrbufStartsWithS(buffer, "HTTP/1.1 200 OK\r\n");
}
+11 -3
View File
@@ -1,5 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "util/textModifier.h"
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
{
@@ -93,7 +94,9 @@ static void printError(FFinstance* instance, const char* moduleName, uint8_t mod
vprintf(message, arguments);
if(!instance->config.pipe)
puts(FASTFETCH_TEXT_MODIFIER_RESET);
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
putchar('\n');
}
}
@@ -127,8 +130,13 @@ void ffPrintColor(const FFstrbuf* colorValue)
void ffPrintCharTimes(char c, uint32_t times)
{
for(uint32_t i = 0; i < times; i++)
putchar(c);
char str[32];
memset(str, c, sizeof(str)); //2 instructions when compiling with AVX2 enabled
for(uint32_t i = sizeof(str); i <= times; i += sizeof(str))
fwrite(str, 1, sizeof(str), stdout);
uint32_t remaining = times % sizeof(str);
if(remaining > 0)
fwrite(str, 1, remaining, stdout);
}
void ffPrintUserString(const char* value)
+2 -2
View File
@@ -9,8 +9,8 @@
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...);
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
FF_C_PRINTF(6, 7) void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...);
FF_C_PRINTF(5, 6) void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times);
void ffPrintUserString(const char* str);
+1 -1
View File
@@ -5,6 +5,6 @@
#include "util/FFstrbuf.h"
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
#endif
@@ -6,16 +6,16 @@
#include <unistd.h>
#include <sys/wait.h>
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
{
int pipes[2];
if(pipe(pipes) == -1)
return;
return "pipe() failed";
pid_t childPid = fork();
if(childPid == -1)
return;
return "fork() failed";
//Child
if(childPid == 0)
@@ -33,4 +33,6 @@ void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
waitpid(childPid, NULL, 0);
ffAppendFDBuffer(pipes[0], buffer);
close(pipes[0]);
return NULL;
}
+69
View File
@@ -0,0 +1,69 @@
#include "fastfetch.h"
#include "common/processing.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
//We can't use this native version yet because we still use POSIX path ( eg /usr/bin/fish ) at a lot of places.
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
{
SECURITY_ATTRIBUTES saAttr = {
.nLength = sizeof(SECURITY_ATTRIBUTES),
.lpSecurityDescriptor = NULL,
.bInheritHandle = TRUE,
};
HANDLE hChildStdoutRead, hChildStdoutWrite;
if (!CreatePipe(&hChildStdoutRead, &hChildStdoutWrite, &saAttr, 0))
return "CreatePipe() failed";
if (!SetHandleInformation(hChildStdoutRead, HANDLE_FLAG_INHERIT, 0))
return "SetHandleInformation(hChildStdoutRead) failed";
PROCESS_INFORMATION piProcInfo = {0};
STARTUPINFOA siStartInfo = {
.cb = sizeof(siStartInfo),
.dwFlags = STARTF_USESTDHANDLES,
.hStdOutput = hChildStdoutWrite,
};
BOOL success;
{
FF_STRBUF_AUTO_DESTROY cmdline;
ffStrbufInitF(&cmdline, "\"%s\"", argv[0]);
for(char* const* parg = &argv[1]; *parg; ++parg)
{
ffStrbufAppendC(&cmdline, ' ');
ffStrbufAppendS(&cmdline, *parg);
}
success = CreateProcessA(
NULL, // application name
cmdline.chars, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo // receives PROCESS_INFORMATION
);
}
CloseHandle(hChildStdoutWrite);
if(!success)
{
CloseHandle(hChildStdoutRead);
return "CreateProcessA() failed";
}
char str[1024];
DWORD nRead;
while(ReadFile(hChildStdoutRead, str, sizeof(str), &nRead, NULL) && nRead > 0)
ffStrbufAppendNS(buffer, nRead, str);
CloseHandle(hChildStdoutRead);
return NULL;
}
+3
View File
@@ -2,6 +2,9 @@
#include "common/properties.h"
#include <stdlib.h>
#ifdef _WIN32
#include "util/windows/getline.h"
#endif
static bool parsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer)
{
+1 -1
View File
@@ -3,7 +3,7 @@
#ifndef FF_INCLUDED_common_properties
#define FF_INCLUDED_common_properties
#include "util/FFstrbuf.h"
#include "fastfetch.h"
typedef struct FFpropquery
{
+22 -58
View File
@@ -1,9 +1,9 @@
#include "fastfetch.h"
#include "common/settings.h"
#include "common/library.h"
#include "common/thread.h"
#include "common/io.h"
#include <pthread.h>
#include <string.h>
typedef enum FFInitState
@@ -15,18 +15,18 @@ typedef enum FFInitState
#define FF_LIBRARY_DATA_LOAD_INIT(dataObject, userLibraryName, ...) \
static dataObject data; \
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; \
static FFInitState initState = FF_INITSTATE_UNINITIALIZED; \
pthread_mutex_lock(&mutex); \
ffThreadMutexLock(&mutex); \
if(initState != FF_INITSTATE_UNINITIALIZED) {\
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return initState == FF_INITSTATE_SUCCESSFUL ? &data : NULL; \
} \
initState = FF_INITSTATE_SUCCESSFUL; \
void* libraryHandle = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL); \
if(libraryHandle == NULL) { \
initState = FF_INITSTATE_FAILED; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return NULL; \
} \
@@ -35,20 +35,20 @@ typedef enum FFInitState
if(data.ff ## symbolName == NULL) { \
dlclose(libraryHandle); \
initState = FF_INITSTATE_FAILED; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return NULL; \
}
#define FF_LIBRARY_DATA_LOAD_RETURN \
initState = FF_INITSTATE_SUCCESSFUL; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return &data;
#define FF_LIBRARY_DATA_LOAD_ERROR \
{ \
dlclose(libraryHandle); \
initState = FF_INITSTATE_FAILED; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return NULL; \
}
@@ -89,9 +89,9 @@ typedef struct GSettingsData
GVariantGetters variantGetters;
} GSettingsData;
static const GSettingsData* getGSettingsData(FFinstance* instance)
static const GSettingsData* getGSettingsData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance->config.libGIO, "libgio-2.0.so", 1);
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance->config.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_lookup)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_has_key)
@@ -114,7 +114,7 @@ static const GSettingsData* getGSettingsData(FFinstance* instance)
FF_LIBRARY_DATA_LOAD_RETURN
}
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type)
FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type)
{
const GSettingsData* data = getGSettingsData(instance);
if(data == NULL)
@@ -143,7 +143,7 @@ FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, c
return getGVariantValue(variant, type, &data->variantGetters);
}
#else //FF_HAVE_GIO
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type)
FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type)
{
FF_UNUSED(instance, schemaName, path, key, type)
return FF_VARIANT_NULL;
@@ -161,9 +161,9 @@ typedef struct DConfData
DConfClient* client;
} DConfData;
static const DConfData* getDConfData(FFinstance* instance)
static const DConfData* getDConfData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance->config.libDConf, "libdconf.so", 2);
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance->config.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2);
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_read_full)
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_new)
@@ -181,7 +181,7 @@ static const DConfData* getDConfData(FFinstance* instance)
FF_LIBRARY_DATA_LOAD_RETURN
}
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type)
FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvarianttype type)
{
const DConfData* data = getDConfData(instance);
if(data == NULL)
@@ -199,14 +199,14 @@ FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttyp
return getGVariantValue(variant, type, &data->variantGetters);
}
#else //FF_HAVE_DCONF
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type)
FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvarianttype type)
{
FF_UNUSED(instance, key, type)
return FF_VARIANT_NULL;
}
#endif //FF_HAVE_DCONF
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type)
FFvariant ffSettingsGet(const FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type)
{
FFvariant gsettings = ffSettingsGetGSettings(instance, gsettingsSchemaName, gsettingsPath, gsettingsKey, type);
@@ -231,9 +231,9 @@ typedef struct XFConfData
FF_LIBRARY_SYMBOL(xfconf_init)
} XFConfData;
static const XFConfData* getXFConfData(FFinstance* instance)
static const XFConfData* getXFConfData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance->config.libXFConf, "libxfconf-0.so", 4);
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance->config.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get)
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_has_property)
@@ -248,7 +248,7 @@ static const XFConfData* getXFConfData(FFinstance* instance)
FF_LIBRARY_DATA_LOAD_RETURN
}
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type)
FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type)
{
const XFConfData* data = getXFConfData(instance);
if(data == NULL)
@@ -271,7 +271,7 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
return FF_VARIANT_NULL;
}
#else //FF_HAVE_XFCONF
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type)
FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type)
{
FF_UNUSED(instance, channelName, propertyName, type)
return FF_VARIANT_NULL;
@@ -280,7 +280,6 @@ FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, con
#ifdef FF_HAVE_SQLITE3
#include <sqlite3.h>
#include <sys/stat.h>
typedef struct SQLiteData
{
@@ -295,7 +294,7 @@ typedef struct SQLiteData
static const SQLiteData* getSQLiteData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance->config.libSQLite3, "libsqlite3.so", 1);
FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance->config.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_open_v2)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_prepare_v2)
@@ -358,38 +357,3 @@ void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
result->chars[result->length] = '\0';
}
#endif //__ANDROID__
#ifdef __APPLE__
#include <sys/sysctl.h>
void ffSettingsGetAppleProperty(const char* propName, FFstrbuf* result)
{
size_t neededLength;
if(sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 0)
return;
ffStrbufEnsureFree(result, (uint32_t) neededLength);
if(sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) == 0)
result->length += (uint32_t) neededLength;
result->chars[result->length] = '\0';
}
int ffSettingsGetAppleInt(const char* propName, int defaultValue)
{
int result;
size_t neededLength = sizeof(result);
if(sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
int64_t ffSettingsGetAppleInt64(const char* propName, int64_t defaultValue)
{
int64_t result;
size_t neededLength = sizeof(result);
if(sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
#endif //__APPLE__
+4 -10
View File
@@ -25,10 +25,10 @@ typedef union FFvariant
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type);
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
FFvariant ffSettingsGetDConf(const FFinstance* instance, const char* key, FFvarianttype type);
FFvariant ffSettingsGetGSettings(const FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
FFvariant ffSettingsGet(const FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query);
@@ -36,10 +36,4 @@ int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, cons
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
#endif
#ifdef __APPLE__
void ffSettingsGetAppleProperty(const char* propName, FFstrbuf* result);
int ffSettingsGetAppleInt(const char* propName, int defaultValue);
int64_t ffSettingsGetAppleInt64(const char* propName, int64_t defaultValue);
#endif
#endif
+55
View File
@@ -0,0 +1,55 @@
#include "sysctl.h"
#include <stdlib.h>
const char* ffSysctlGetString(const char* propName, FFstrbuf* result)
{
size_t neededLength;
if(sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) //neededLength is 1 for empty strings, because of the null terminator
return "sysctlbyname() failed";
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
if(sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) == 0)
result->length += (uint32_t) neededLength - 1;
result->chars[result->length] = '\0';
return NULL;
}
int ffSysctlGetInt(const char* propName, int defaultValue)
{
int result;
size_t neededLength = sizeof(result);
if(sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue)
{
int64_t result;
size_t neededLength = sizeof(result);
if(sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength)
{
if(sysctl(request, requestLength, NULL, resultLength, NULL, 0) != 0)
return NULL;
void* data = malloc(*resultLength);
if(data == NULL)
return NULL;
if(sysctl(request, requestLength, data, resultLength, NULL, 0) != 0)
{
free(data);
return NULL;
}
return data;
}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#ifndef FF_INCLUDED_common_sysctl
#define FF_INCLUDED_common_sysctl
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
#include <sys/types.h>
#include <sys/sysctl.h>
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
#endif
+48
View File
@@ -0,0 +1,48 @@
#pragma once
#ifndef FF_INCLUDED_common_thread
#define FF_INCLUDED_common_thread
#include "fastfetch.h"
#ifdef FF_HAVE_THREADS
#if defined(_WIN32)
#include <handleapi.h>
#include <synchapi.h>
#include <process.h>
#define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
typedef SRWLOCK FFThreadMutex;
typedef HANDLE FFThreadType;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) { AcquireSRWLockExclusive(mutex); }
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { ReleaseSRWLockExclusive(mutex); }
static inline FFThreadType ffThreadCreate(unsigned (__stdcall* func)(void*), void* data) {
return (FFThreadType)_beginthreadex(NULL, 0, func, data, 0, NULL);
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; }
static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); }
static inline void ffThreadJoin(FFThreadType thread) { WaitForSingleObject(thread, INFINITE); }
#else
#include <pthread.h>
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
typedef pthread_mutex_t FFThreadMutex;
typedef pthread_t FFThreadType;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) { pthread_mutex_lock(mutex); }
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { pthread_mutex_unlock(mutex); }
static inline FFThreadType ffThreadCreate(void* (* func)(void*), void* data) {
FFThreadType newThread = 0;
pthread_create(&newThread, NULL, func, data);
return newThread;
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static void* fn ## ThreadMain (void* data) { fn((paramType)data); return NULL; }
static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); }
static inline void ffThreadJoin(FFThreadType thread) { pthread_join(thread, NULL); }
#endif
#else //FF_HAVE_THREADS
#define FF_THREAD_MUTEX_INITIALIZER 0
typedef char FFThreadMutex;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) { FF_UNUSED(mutex) }
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { FF_UNUSED(mutex) }
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
#endif //FF_HAVE_THREADS
#endif
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#ifndef FF_INCLUDED_common_time
#define FF_INCLUDED_common_time
#include <stdint.h>
#ifdef _WIN32
#include <synchapi.h>
#include <profileapi.h>
#else
#include <time.h>
#endif
static inline uint64_t ffTimeGetTick() //In msec
{
#ifdef _WIN32
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER start;
QueryPerformanceCounter(&start);
return (uint64_t)(start.QuadPart * 1000 / frequency.QuadPart);
#else
struct timespec timeNow;
clock_gettime(CLOCK_MONOTONIC, &timeNow);
return (uint64_t)((timeNow.tv_sec * 1000) + (timeNow.tv_nsec / 1000000));
#endif
}
static inline void ffTimeSleep(uint32_t msec)
{
#ifdef _WIN32
SleepEx(msec, TRUE);
#else
nanosleep(&(struct timespec){ msec / 1000, (msec % 1000) * 1000000 }, NULL);
#endif
}
#endif
+50 -5
View File
@@ -5,7 +5,7 @@
# Whitespaces are trimmed at the beginning and the end.
# Empty lines or lines starting with # are ignored.
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
# This file was shipped with $" FASTFETCH_PROJECT_VERSION $".
# Use fastfetch --print-config-user > ~/.config/fastfetch/config.conf to overwrite this file with the current defaults
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
@@ -25,7 +25,7 @@
# Must be a list of module names, separated by colons.
# List available modules with "fastfetch --list-modules".
# Get the default structure with "fastfetch --print-structure".
#--structure $"FASTFETCH_DATATEXT_STRUCTURE$"
#--structure $" FASTFETCH_DATATEXT_STRUCTURE $"
# Multithreading option:
# Sets if fastfetch should use multiple threads to detect the values.
@@ -33,6 +33,13 @@
# Default is true.
#--multithreading true
# Print stat option:
# Sets if fastfetch should print time usage (in ms) for individual modules
# If true, it will also enable --show-errors
# Must be true or false.
# Default is false.
#--stat true
# Slow operations option:
# Sets if fastfetch is allowed to use known slow operations to detect more / better values.
# Must be true or false.
@@ -61,7 +68,7 @@
# Logo type option:
# Sets the logo type to use.
# Must be auto, builtin, file, raw, sixel, kitty or chafa.
# Must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty or chafa.
# Default is auto.
#--logo-type auto
@@ -151,16 +158,33 @@
# Default is "-"
#--separator-string -
# Public IP URL option:
# Sets the URL of public IP detection server to be used.
# Only HTTP protocol is supported, and the value should not contain "http://" prefix.
# Default is "ipinfo.io/ip".
#--public-ip-url "ipinfo.io/ip"
# Public IP timeout option:
# Sets the time to wait for the public ip server to respond.
# Must be a positive integer.
# Default is 0 (disabled).
#--public-ip-timeout 0
# Weather output format option:
# Sets the weather format to be used. It must be URI encoded.
# See: https://github.com/chubin/wttr.in#one-line-output
# Default is "%t+-+%C+(%l)".
#--weather-output-format "%t+-+%C+(%l)"
# Weather timeout option:
# Sets the time to wait for the weather server (wttr.in) to respond.
# Must be a positive integer.
# Default is 0 (disabled).
#--weather-timeout 0
# OS file option
# Sets the path to the file containing the operating system information.
# Should be a valid path to an existing file.
# Note that you might need to run fastfetch with --recache once for it to take affect.
# Default is /etc/os-release.
#--os-file /etc/os-release
@@ -182,11 +206,18 @@
# Default is auto.
#--gl auto
# Percentage output type option
# Applies to all modules that prints percentage values. Currently memory, swap, disk, battery and CPU usage are supported.
# Only works with default format ( without --module-format option ).
# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar
#--percent-type 1
# Key options:
# Sets the displayed key of a module
# Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help.
#--os-key OS
#--host-key Host
#--chassis-key Chassis
#--kernel-key Kernel
#--uptime-key Uptime
#--processes-key Processes
@@ -209,15 +240,19 @@
#--swap-key Swap
#--disk-key Disk ({1})
#--battery-key Battery {1}
#--poweradapter-key Power Adapter {1}
#--locale-key Locale
#--local-ip-key Local IP ({1})
#--public-ip-key Public IP
#--wifi-key Wifi
#--weather-key Weather
#--player-key Media Player
#--song-key Song
#--datetime-key Date Time
#--vulkan-key Vulkan
#--opengl-key OpenGL
#--opencl-key OpenCL
#--users-key Users
# Format options:
# Sets the format string for module values.
@@ -226,6 +261,7 @@
# An empty format string (As they are currently below) will behave as if it was not set.
#--os-format
#--host-format
#--chassis-format
#--kernel-format
#--uptime-format
#--processes-format
@@ -248,15 +284,18 @@
#--swap-format
#--disk-format
#--battery-format
#--poweradapter-format
#--locale-format
#--local-ip-format
#--public-ip-format
#--weather-format
#--player-format
#--song-format
#--datetime-format
#--vulkan-format
#--opengl-format
#--opencl-format
#--users-format
# Error options:
# Sets the format string to use if an error occured
@@ -265,6 +304,7 @@
# If one of them is set, the module will appear, even if --show-errors is not given.
#--os-error
#--host-error
#--chassis-error
#--kernel-error
#--uptime-error
#--processes-error
@@ -287,21 +327,24 @@
#--swap-error
#--disk-error
#--battery-error
#--poweradapter-error
#--locale-error
#--local-ip-error
#--public-ip-error
#--weather-error
#--player-error
#--song-error
#--datetime-error
#--vulkan-error
#--opengl-error
#--opencl-error
#--users-error
# Library options:
# Sets an user specific path to a library to load.
# Must be a valid path to a library.
#--lib-PCI /usr/lib/libpci.so
#--lib-vulkan /usr/lib/libvulkan.so
#--lib-vulkan /usr/lib/libvulkan.so (libMoltenVK.dylib on macOS)
#--lib-wayland /usr/lib/libwayland-client.so
#--lib-xcb-randr /usr/lib/libxcb-randr.so
#--lib-xcb /usr/lib/libxcb.so
@@ -320,3 +363,5 @@
#--lib-glx /usr/lib/libGLX.so
#--lib-osmesa /usr/lib/libOSMesa.so
#--lib-opencl /usr/lib/libOpenCL.so
#--lib-cjson /usr/lib/libcjson.so
#--lib-freetype /data/data/com.termux/files/usr/lib
+76 -57
View File
@@ -1,65 +1,73 @@
Usage: fastfetch <options>
Informative options:
-h,--help: shows this message and exits
-h,--help <command>: shows help for a specific command and exits
-v,--version: prints the version of fastfetch and exits
--list-logos: list available logos and exits
--list-modules: lists available modules and exits
--list-presets: list presets fastfetch knows about and exits. They can be loaded with --load-config. (+)
--list-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
--print-logos: show available logos and exits
--print-config-system: prints the default system config and exits
--print-config-user: prints the default user config and exits
--print-structure: prints the default stucture and exits
-h,--help: Show this message
-h,--help <command>: Show help for a specific command
-v,--version: Show the version of fastfetch
--list-logos: List available logos
--list-modules: List available modules
--list-presets: List presets fastfetch knows about; they can be loaded with --load-config (+)
--list-features: List the supported features fastfetch was compiled with (mainly for development)
--print-logos: Print available logos
--print-config-system: Print the default system config
--print-config-user: Print the default user config
--print-structure: Print the default structure
General options:
-r,--recache <?value>: generate new cached values
--nocache <?value>: don't use cached values, but also don't overwrite existing ones
--load-config <file>: load a config file or a preset (+)
--multithreading <?value>: use multiple threads to detect values
--allow-slow-operations <?value>: allow operations that are usually very slow for more detailed output
--escape-bedrock <?value>: on bedrock linux, sets if it should escape the bedrock jail or not
--pipe <?value>: disable logo and all escape sequences
--load-config <file>: Load a config file or preset (+)
--multithreading <?value>: Use multiple threads to detect values
--stat <?value>: Show time usage (in ms) for individual modules
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
--escape-bedrock <?value>: On Bedrock Linux, whether to escape the bedrock jail
--pipe <?value>: Disable logo and all escape sequences
Logo options:
-l,--logo <logo>: set the logo to use. The type is specified by --logo-type. If default: the name of a builtin logo or a path to a file
--logo-type <type>: set the type of the logo given. Must be auto, builtin, file, raw, sixel, kitty or chafa.
--logo-width <width>: set the width of the logo (in characters), if it is an image
--logo-height <height>: set the height of the logo (in characters), if it is an image
--logo-color-[1-9] <color>: overwrite a color in the logo
--logo-padding <padding>: set the padding on the left and the right of the logo
--logo-padding-left <padding>: set the padding on the left of the logo
--logo-padding-right <padding>: set the padding on the right of the logo
--logo-print-remaining <?value>: weather to print the remaining logo, if it has more lines than modules to display
--sixel <file>: short for --logo-type sixel --logo <file>
--kitty <file>: short for --logo-type kitty --logo <file>
--chafa <file>: short for --logo-type chafa --logo <file>
--file <file>: short for --logo-type file --logo <file>
--raw <file>: short for --logo-type raw --logo <file>
-l,--logo <logo>: Set the logo; if default, the name of a builtin logo or a path to a file
--logo-type <type>: Set the type of the logo given; must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty, iterm or chafa
--logo-width <width>: Set the width of the logo (in characters), if it is an image. Required for iTerm image protocol
--logo-height <height>: Set the height of the logo (in characters), if it is an image. Required for iTerm image protocol
--logo-preserve-aspect-radio <?value>: Set if the logo should fill the specified width and height as much as possible without stretching. Supported by iTerm image protocol
--logo-color-[1-9] <color>: Overwrite a color in the logo
--logo-padding <padding>: Set the padding on the left and the right of the logo
--logo-padding-left <padding>: Set the padding on the left of the logo
--logo-padding-right <padding>: Set the padding on the right of the logo
--logo-print-remaining <?value>: Whether to print the remaining logo, if it has more lines than modules to display
--file <file>: Short for --logo-type file --logo <file>
--file-raw <file>: Short for --logo-type file-raw --logo <file>
--data <data>: Short for --logo-type data --logo <data>
--data-raw <data>: Short for --logo-type data-raw --logo <data>
--sixel <file>: Short for --logo-type sixel --logo <file>
--kitty <file>: Short for --logo-type kitty --logo <file>
--iterm <file>: Short for --logo-type iterm --logo <file>
--chafa <file>: Short for --logo-type chafa --logo <file>
--chafa-fg-only <?value>: Produce character-cell output using foreground colors only. See chafa document for detail
--chafa-symbols <str>: Specify character symbols to employ in final output. See chafa document for detail
--chafa-canvas-mode <value>: Determine how colors are used in the output. This value maps the int value of enum ChafaCanvasMode. See chafa document for detail
--chafa-color-space <value>: Set color space used for quantization. 0 for RGB; 1 for DIN99d. See chafa document for detail
--chafa-dither-mode <value>: Set output dither mode (No effect with 24-bit color). This value maps the int value of enum ChafaDitherMode. See chafa document for detail
Display options:
-s,--structure <structure>: sets the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
--color-keys <color>: sers the color of the keys
--color-title <color>: sets the color of the title
-c,--color <color>: sets the color of both the keys and the title
--separator <str>: sets the separator between key and value. Default is a colon with a space
--set <key=value>: hard set the value of a key
--set-keyless <key=value>: hard set the value of a key, but don't print the key or the separator
--show-errors <?value>: print occuring errors
--disable-linewrap <?value>: weather to disable linewrap during the run
--hide-cursor <?value>: weather to hide the cursor during the run
--binary-prefix <value>: sets the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
--color-keys <color>: Set the color of the keys
--color-title <color>: Set the color of the title
-c,--color <color>: Set the color of both the keys and title
--separator <str>: Set the separator between key and value. Default is a colon with a space
--set <key=value>: Hard set the value of a key
--set-keyless <key=value>: Hard set the value of a key, but don't print the key or the separator
--show-errors <?value>: Print occurring errors
--disable-linewrap <?value>: Whether to disable line wrap during the run
--hide-cursor <?value>: Whether to hide the cursor during the run
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC.
General module options:
--<module>-format <format>: Sets the format string to use for each specific module.
--<module>-format <format>: Set the format string to use for each specific module.
To see how a format string works, use fastfetch --help format.
To see help about a specific format string, use fastfetch --help <module>-format.
--<module>-key <key>: Sets the key to use for each specific module.
--<module>-key <key>: Set the key to use for each specific module.
For modules which print multiple lines, the string is parsed as a format string with the index as first character.
--<module>-error <format>: Sets the error format string to use for each specific module.
--<module>-error <format>: Set the error format string to use for each specific module.
The error is given as the first and only argument.
Setting this for a module will cause it to appear, even if --show-errors is not given.
@@ -84,19 +92,30 @@ Library options: Set the path of a library to load
--lib-glx <path>
--lib-osmesa <path>
--lib-opencl <path>
--lib-cjson <path>
Module specific options:
--title-fqdn <?value>: sets if the title should use fully qualified domain name. Default is false.
--separator-string <str>: Set the string printed by the separator module
--os-file <path>: Set the path to the file containing OS informations
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--localip-show-ipv4 <?value>: Show ipv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show ipv6 addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--player-name: The name of the player to use
--gl <value>: Sets the opengl context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
--title-fqdn <?value>: Set if the title should use fully qualified domain name. Default is false
--separator-string <str>: Set the string printed by the separator module
--os-file <path>: Set the path to the file containing OS information
--disk-folders <folders>: A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows)
--disk-show-removable <?value>: Set if removable volume should be printed. Default is true
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
--localip-show-ipv4 <?value>: Show IPv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show IPv6 addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--localip-name-prefix <str>: Show IPs with given name prefix only. Default is empty
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--public-ip-url: The URL of public IP detection server to be used.
--weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0)
--weather-output-format: The output weather format to be used. It must be URI encoded.
--player-name: The name of the player to use
--gl <value>: Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both. Default is 1
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
If a value starts with a ?, it is optional. "true" will be used if not set.
+8 -3
View File
@@ -1,5 +1,8 @@
Battery
Bios
Board
Break
Chassis
Colors
CPU
CPUUsage
@@ -15,18 +18,18 @@ Icons
Kernel
Locale
LocalIP
Media
Memory
OS
OpenCL
OpenGL
OS
Packages
Player
PowerAdapter
Processes
PublicIP
Resolution
Separator
Shell
Song
Swap
Terminal
TerminalFont
@@ -35,5 +38,7 @@ Time
Title
Uptime
Vulkan
Weather
Wifi
WM
WMTheme
+1 -1
View File
@@ -1 +1 @@
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:Locale:Break:Colors
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:PowerAdapter:Locale:Break:Colors
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#ifndef FF_INCLUDED_detection_battery_battery
#define FF_INCLUDED_detection_battery_battery
#include "fastfetch.h"
#define FF_BATTERY_TEMP_UNSET (0/0.0)
typedef struct BatteryResult
{
FFstrbuf manufacturer;
FFstrbuf modelName;
FFstrbuf technology;
double capacity;
FFstrbuf status;
double temperature;
} BatteryResult;
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results);
#endif
+108
View File
@@ -0,0 +1,108 @@
#include "fastfetch.h"
#include "battery.h"
#include "util/apple/cf_helpers.h"
#include "detection/temps/temps_apple.h"
#include <IOKit/IOKitLib.h>
static double detectBatteryTemp()
{
FF_LIST_AUTO_DESTROY temps;
ffListInit(&temps, sizeof(FFTempValue));
ffDetectCoreTemps(FF_TEMP_BATTERY, &temps);
if(temps.length == 0)
return FF_BATTERY_TEMP_UNSET;
double result = 0;
for(uint32_t i = 0; i < temps.length; ++i)
{
FFTempValue* tempValue = (FFTempValue*)ffListGet(&temps, i);
result += tempValue->value;
//TODO: do we really need this?
ffStrbufDestroy(&tempValue->name);
ffStrbufDestroy(&tempValue->deviceClass);
}
result /= temps.length;
return result;
}
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
FF_UNUSED(instance);
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery");
if (matchDict == NULL)
return "IOServiceMatching(\"AppleSmartBattery\") failed";
io_iterator_t iterator;
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
return "IOServiceGetMatchingServices() failed";
io_registry_entry_t registryEntry;
while((registryEntry = IOIteratorNext(iterator)) != 0)
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
{
IOObjectRelease(registryEntry);
continue;
}
bool boolValue;
const char* error;
BatteryResult* battery = ffListAdd(results);
battery->capacity = 0.0/0.0;
int currentCapacity, maxCapacity;
if ((error = ffCfDictGetInt(properties, CFSTR("MaxCapacity"), &maxCapacity)))
return error;
if (maxCapacity <= 0)
return "Querying MaxCapacity failed";
if ((error = ffCfDictGetInt(properties, CFSTR("CurrentCapacity"), &currentCapacity)))
return error;
if(currentCapacity <= 0)
return "Querying CurrentCapacity failed";
battery->capacity = currentCapacity * 100.0 / maxCapacity;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->technology);
if (!ffCfDictGetBool(properties, CFSTR("built-in"), &boolValue) && boolValue)
{
ffStrbufAppendS(&battery->manufacturer, "Apple Inc.");
ffStrbufAppendS(&battery->modelName, "Builtin");
ffStrbufAppendS(&battery->technology, "Lithium");
}
else
{
ffStrbufAppendS(&battery->manufacturer, "Unknown");
ffStrbufAppendS(&battery->modelName, "Unknown");
ffStrbufAppendS(&battery->technology, "Unknown");
}
ffStrbufInit(&battery->status);
if (!ffCfDictGetBool(properties, CFSTR("FullyCharged"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Fully charged");
else if (!ffCfDictGetBool(properties, CFSTR("IsCharging"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Charging");
else
ffStrbufAppendS(&battery->status, "");
if(instance->config.batteryTemp)
battery->temperature = detectBatteryTemp();
else
battery->temperature = FF_BATTERY_TEMP_UNSET;
CFRelease(properties);
IOObjectRelease(registryEntry);
}
IOObjectRelease(iterator);
return NULL;
}
+116
View File
@@ -0,0 +1,116 @@
#include "fastfetch.h"
#include "common/io.h"
#include "battery.h"
#include <dirent.h>
static void parseBattery(FFstrbuf* dir, FFlist* results)
{
uint32_t dirLength = dir->length;
FFstrbuf testBatteryBuffer;
ffStrbufInit(&testBatteryBuffer);
//type must exist and be "Battery"
ffStrbufAppendS(dir, "/type");
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Battery") != 0)
{
ffStrbufDestroy(&testBatteryBuffer);
return;
}
//scope may not exist or must not be "Device"
ffStrbufAppendS(dir, "/scope");
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
{
ffStrbufDestroy(&testBatteryBuffer);
return;
}
BatteryResult* result = ffListAdd(results);
//capacity must exist and be not empty
ffStrbufAppendS(dir, "/capacity");
bool available = ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(available)
result->capacity = ffStrbufToDouble(&testBatteryBuffer);
ffStrbufDestroy(&testBatteryBuffer);
if(!available)
{
result->capacity = 0.0/0.0;
--results->length;
return;
}
//At this point, we have a battery. Try to get as much values as possible.
ffStrbufInit(&result->manufacturer);
ffStrbufAppendS(dir, "/manufacturer");
ffReadFileBuffer(dir->chars, &result->manufacturer);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->modelName);
ffStrbufAppendS(dir, "/model_name");
ffReadFileBuffer(dir->chars, &result->modelName);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->technology);
ffStrbufAppendS(dir, "/technology");
ffReadFileBuffer(dir->chars, &result->technology);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->status);
ffStrbufAppendS(dir, "/status");
ffReadFileBuffer(dir->chars, &result->status);
ffStrbufSubstrBefore(dir, dirLength);
result->temperature = FF_BATTERY_TEMP_UNSET;
}
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) {
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
if(instance->config.batteryDir.length > 0)
{
ffStrbufAppend(&baseDir, &instance->config.batteryDir);
ffStrbufEnsureEndsWithC(&baseDir, '/');
}
else
{
ffStrbufAppendS(&baseDir, "/sys/class/power_supply/");
}
uint32_t baseDirLength = baseDir.length;
DIR* dirp = opendir(baseDir.chars);
if(dirp == NULL)
{
ffStrbufDestroy(&baseDir);
return "opendir(batteryDir) == NULL";
}
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
ffStrbufAppendS(&baseDir, entry->d_name);
parseBattery(&baseDir, results);
ffStrbufSubstrBefore(&baseDir, baseDirLength);
}
closedir(dirp);
if(results->length == 0) {
ffStrbufDestroy(&baseDir);
return "batteryDir doesn't contain any battery folder";
}
ffStrbufDestroy(&baseDir);
return NULL;
}
@@ -0,0 +1,8 @@
#include "fastfetch.h"
#include "battery.h"
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
FF_UNUSED(instance, results)
return "Not supported on this platform";
}
+158
View File
@@ -0,0 +1,158 @@
#include "battery.h"
#include "util/windows/unicode.h"
#include "util/mallocHelper.h"
#include <setupapi.h>
#include <batclass.h>
#include <devguid.h>
#include <winternl.h>
#include <powrprof.h>
static inline void wrapCloseHandle(HANDLE* handle)
{
if(*handle)
CloseHandle(*handle);
}
static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
{
if(*hdev)
SetupDiDestroyDeviceInfoList(*hdev);
}
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
if(instance->config.allowSlowOperations)
{
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(hdev == INVALID_HANDLE_VALUE)
return "SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY) failed";
for(DWORD idev = 0;; idev++)
{
SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) };
if(!SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did))
break;
DWORD cbRequired = 0;
SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer
SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired);
if(!pdidd)
break; //Out of memory
pdidd->cbSize = sizeof(*pdidd);
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
continue;
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
DWORD dwWait = 0;
DWORD dwOut;
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_TAG, &dwWait, sizeof(dwWait), &bqi.BatteryTag, sizeof(bqi.BatteryTag), &dwOut, NULL) && bqi.BatteryTag)
continue;
BATTERY_INFORMATION bi = {0};
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL))
continue;
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
continue;
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
ffStrbufInitS(&battery->technology, "Lead Acid");
else if(memcmp(bi.Chemistry, "LION", 4) == 0 || memcmp(bi.Chemistry, "Li-I", 4) == 0)
ffStrbufInitS(&battery->technology, "Lithium Ion");
else if(memcmp(bi.Chemistry, "NiCd", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Cadmium");
else if(memcmp(bi.Chemistry, "NiMH", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Metal Hydride");
else if(memcmp(bi.Chemistry, "NiZn", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Zinc");
else if(memcmp(bi.Chemistry, "RAM\0", 4) == 0)
ffStrbufInitS(&battery->technology, "Rechargeable Alkaline-Manganese");
else
ffStrbufInitS(&battery->technology, "Unknown");
{
ffStrbufInit(&battery->modelName);
bqi.InformationLevel = BatteryDeviceName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->modelName, name);
}
{
ffStrbufInit(&battery->manufacturer);
bqi.InformationLevel = BatteryManufactureName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->manufacturer, name);
}
battery->temperature = 0.0/0.0;
if(instance->config.batteryTemp)
{
bqi.InformationLevel = BatteryTemperature;
ULONG temp;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &temp, sizeof(temp), &dwOut, NULL))
battery->temperature = temp;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY)
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
else
battery->capacity = 0;
ffStrbufInit(&battery->status);
if(bs.PowerState & BATTERY_POWER_ON_LINE)
ffStrbufAppendS(&battery->status, "AC Connected, ");
if(bs.PowerState & BATTERY_DISCHARGING)
ffStrbufAppendS(&battery->status, "Discharging, ");
if(bs.PowerState & BATTERY_CHARGING)
ffStrbufAppendS(&battery->status, "Charging");
if(bs.PowerState & BATTERY_CRITICAL)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
}
else
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(CallNtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->temperature = 0.0/0.0;
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
{
ffStrbufAppendS(&battery->status, "AC Connected");
if(info.Charging)
ffStrbufAppendS(&battery->status, ", Charging");
}
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
}
}
return NULL;
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#ifndef FF_INCLUDED_detection_bios_bios
#define FF_INCLUDED_detection_bios_bios
#include "fastfetch.h"
typedef struct FFBiosResult
{
FFstrbuf biosDate;
FFstrbuf biosRelease;
FFstrbuf biosVendor;
FFstrbuf biosVersion;
FFstrbuf error;
} FFBiosResult;
void ffDetectBios(FFBiosResult* bios);
#endif
+70
View File
@@ -0,0 +1,70 @@
#include "bios.h"
#include "util/apple/cf_helpers.h"
#include <IOKit/IOKitLib.h>
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
io_registry_entry_t registryEntry;
#ifndef __aarch64__
//https://github.com/osquery/osquery/blob/master/osquery/tables/system/darwin/smbios_tables.cpp
//For Intel
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/rom")))
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
{
IOObjectRelease(registryEntry);
ffStrbufAppendS(&bios->error, "IORegistryEntryCreateCFProperties(registryEntry) failed");
return;
}
ffCfDictGetString(properties, CFSTR("vendor"), &bios->biosVendor);
ffCfDictGetString(properties, CFSTR("version"), &bios->biosVersion);
ffCfDictGetString(properties, CFSTR("release-date"), &bios->biosDate);
if(!ffStrbufContainC(&bios->biosDate, '-'))
ffStrbufAppendS(&bios->biosRelease, "Efi-");
ffStrbufAppend(&bios->biosRelease, &bios->biosVersion);
CFRelease(properties);
IOObjectRelease(registryEntry);
return;
}
#else
//For arm64
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/")))
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
{
ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->biosVendor);
CFRelease(properties);
}
IOObjectRelease(registryEntry);
}
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen")))
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
{
ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->biosRelease);
ffStrbufAppend(&bios->biosVersion, &bios->biosRelease);
ffStrbufSubstrAfterFirstC(&bios->biosVersion, '-');
CFRelease(properties);
}
IOObjectRelease(registryEntry);
}
#endif
}
+26
View File
@@ -0,0 +1,26 @@
#include "bios.h"
#include <kenv.h>
static void kenvLookup(const char* name, FFstrbuf* result)
{
ffStrbufEnsureFree(result, 255);
int len = kenv(KENV_GET, name, result->chars, 256);
if(len > 0)
result->length = (uint32_t) len;
}
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
//https://wiki.ghostbsd.org/index.php/Kenv
kenvLookup("smbios.bios.reldate", &bios->biosDate);
kenvLookup("smbios.system.product", &bios->biosRelease);
kenvLookup("smbios.bios.vendor", &bios->biosVendor);
kenvLookup("smbios.bios.version", &bios->biosVersion);
}
+58
View File
@@ -0,0 +1,58 @@
#include "bios.h"
#include "common/io.h"
#include <stdlib.h>
static bool hostValueSet(FFstrbuf* value)
{
return
value->length > 0 &&
ffStrbufStartsWithIgnCaseS(value, "To be filled") != true &&
ffStrbufStartsWithIgnCaseS(value, "To be set") != true &&
ffStrbufStartsWithIgnCaseS(value, "OEM") != true &&
ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true &&
ffStrbufIgnCaseCompS(value, "None") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Version") != 0 &&
ffStrbufIgnCaseCompS(value, "System Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Version") != 0 &&
ffStrbufIgnCaseCompS(value, "Default string") != 0 &&
ffStrbufIgnCaseCompS(value, "Undefined") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Specified") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 &&
ffStrbufIgnCaseCompS(value, "INVALID") != 0 &&
ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 &&
ffStrbufIgnCaseCompS(value, "All Series") != 0
;
}
static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer)
{
ffReadFileBuffer(devicesPath, buffer);
if(hostValueSet(buffer))
return;
ffReadFileBuffer(classPath, buffer);
if(hostValueSet(buffer))
return;
ffStrbufClear(buffer);
}
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
getHostValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->biosDate);
ffStrbufInit(&bios->biosRelease);
getHostValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
getHostValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
getHostValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->biosVersion);
}
+11
View File
@@ -0,0 +1,11 @@
#include "bios.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInitS(&bios->error, "Not supported on this platform");
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
}
+28
View File
@@ -0,0 +1,28 @@
#include "bios.h"
#include "util/windows/registry.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &bios->error))
return;
if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosRelease, &bios->error))
return;
ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->biosVendor, NULL);
ffRegReadStrbuf(hKey, L"BIOSReleaseDate", &bios->biosDate, NULL);
uint32_t major, minor;
if(
ffRegReadUint(hKey, L"BiosMajorRelease", &major, NULL) &&
ffRegReadUint(hKey, L"BiosMinorRelease", &minor, NULL)
)
ffStrbufAppendF(&bios->biosVersion, "%u.%u", (unsigned)major, (unsigned)minor);
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#ifndef FF_INCLUDED_detection_board_board
#define FF_INCLUDED_detection_board_board
#include "fastfetch.h"
typedef struct FFBoardResult
{
FFstrbuf boardName;
FFstrbuf boardVendor;
FFstrbuf boardVersion;
FFstrbuf error;
} FFBoardResult;
void ffDetectBoard(FFBoardResult* result);
#endif
+55
View File
@@ -0,0 +1,55 @@
#include "board.h"
#include "common/io.h"
#include <stdlib.h>
static bool hostValueSet(FFstrbuf* value)
{
return
value->length > 0 &&
ffStrbufStartsWithIgnCaseS(value, "To be filled") != true &&
ffStrbufStartsWithIgnCaseS(value, "To be set") != true &&
ffStrbufStartsWithIgnCaseS(value, "OEM") != true &&
ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true &&
ffStrbufIgnCaseCompS(value, "None") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Version") != 0 &&
ffStrbufIgnCaseCompS(value, "System Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Version") != 0 &&
ffStrbufIgnCaseCompS(value, "Default string") != 0 &&
ffStrbufIgnCaseCompS(value, "Undefined") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Specified") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 &&
ffStrbufIgnCaseCompS(value, "INVALID") != 0 &&
ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 &&
ffStrbufIgnCaseCompS(value, "All Series") != 0
;
}
static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer)
{
ffReadFileBuffer(devicesPath, buffer);
if(hostValueSet(buffer))
return;
ffReadFileBuffer(classPath, buffer);
if(hostValueSet(buffer))
return;
ffStrbufClear(buffer);
}
void ffDetectBoard(FFBoardResult* board)
{
ffStrbufInit(&board->error);
ffStrbufInit(&board->boardName);
getHostValue("/sys/devices/virtual/dmi/id/board_name", "/sys/class/dmi/id/board_name", &board->boardName);
ffStrbufInit(&board->boardVendor);
getHostValue("/sys/devices/virtual/dmi/id/board_vendor", "/sys/class/dmi/id/board_vendor", &board->boardVendor);
ffStrbufInit(&board->boardVersion);
getHostValue("/sys/devices/virtual/dmi/id/board_version", "/sys/class/dmi/id/board_version", &board->boardVersion);
}
+10
View File
@@ -0,0 +1,10 @@
#include "board.h"
void ffDetectBoard(FFBoardResult* board)
{
ffStrbufInitS(&board->error, "Not supported on this platform");
ffStrbufInit(&board->boardName);
ffStrbufInit(&board->boardVendor);
ffStrbufInit(&board->boardVersion);
}
+21
View File
@@ -0,0 +1,21 @@
#include "board.h"
#include "util/windows/registry.h"
void ffDetectBoard(FFBoardResult* board)
{
ffStrbufInit(&board->error);
ffStrbufInit(&board->boardName);
ffStrbufInit(&board->boardVendor);
ffStrbufInit(&board->boardVersion);
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &board->error))
return;
if(!ffRegReadStrbuf(hKey, L"BaseBoardProduct", &board->boardName, &board->error))
return;
ffRegReadStrbuf(hKey, L"BaseBoardManufacturer", &board->boardVendor, NULL);
ffRegReadStrbuf(hKey, L"BaseBoardVersion", &board->boardVersion, NULL);
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#ifndef FF_INCLUDED_detection_chassis_chassis
#define FF_INCLUDED_detection_chassis_chassis
#include "fastfetch.h"
typedef struct FFChassisResult
{
FFstrbuf chassisType;
FFstrbuf chassisVendor;
FFstrbuf chassisVersion;
FFstrbuf error;
} FFChassisResult;
void ffDetectChassis(FFChassisResult* result);
#endif
+55
View File
@@ -0,0 +1,55 @@
#include "chassis.h"
#include "common/io.h"
#include <stdlib.h>
static bool hostValueSet(FFstrbuf* value)
{
return
value->length > 0 &&
ffStrbufStartsWithIgnCaseS(value, "To be filled") != true &&
ffStrbufStartsWithIgnCaseS(value, "To be set") != true &&
ffStrbufStartsWithIgnCaseS(value, "OEM") != true &&
ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true &&
ffStrbufIgnCaseCompS(value, "None") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Version") != 0 &&
ffStrbufIgnCaseCompS(value, "System Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Version") != 0 &&
ffStrbufIgnCaseCompS(value, "Default string") != 0 &&
ffStrbufIgnCaseCompS(value, "Undefined") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Specified") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 &&
ffStrbufIgnCaseCompS(value, "INVALID") != 0 &&
ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 &&
ffStrbufIgnCaseCompS(value, "All Series") != 0
;
}
static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer)
{
ffReadFileBuffer(devicesPath, buffer);
if(hostValueSet(buffer))
return;
ffReadFileBuffer(classPath, buffer);
if(hostValueSet(buffer))
return;
ffStrbufClear(buffer);
}
void ffDetectChassis(FFChassisResult* result)
{
ffStrbufInit(&result->error);
ffStrbufInit(&result->chassisType);
getHostValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->chassisType);
ffStrbufInit(&result->chassisVendor);
getHostValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->chassisVendor);
ffStrbufInit(&result->chassisVersion);
getHostValue("/sys/devices/virtual/dmi/id/chassis_version", "/sys/class/dmi/id/chassis_version", &result->chassisVersion);
}
+10
View File
@@ -0,0 +1,10 @@
#include "chassis.h"
void ffDetectChassis(FFChassisResult* result)
{
ffStrbufInitS(&result->error, "Not supported on this platform");
ffStrbufInit(&result->chassisType);
ffStrbufInit(&result->chassisVendor);
ffStrbufInit(&result->chassisVersion);
}
+20 -14
View File
@@ -1,22 +1,28 @@
#include "cpu.h"
#include "detection/internal.h"
void ffDetectCPUImpl(FFCPUResult* cpu);
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu);
static void detectCPU(const FFinstance* instance, FFCPUResult* cpu)
{
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
const FFCPUResult* ffDetectCPU()
ffDetectCPUImpl(instance, cpu);
const char* removeStrings[] = {
" CPU", " FPU", " APU", " Processor",
" Dual-Core", " Quad-Core", " Six-Core", " Eight-Core", " Ten-Core",
" 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core",
" with Radeon Graphics"
};
ffStrbufRemoveStringsA(&cpu->name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings);
ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); //Cut the speed output in the name as we append our own
ffStrbufTrimRight(&cpu->name, ' '); //If we removed the @ in previous step there was most likely a space before it
}
const FFCPUResult* ffDetectCPU(const FFinstance* instance)
{
FF_DETECTION_INTERNAL_GUARD(FFCPUResult,
ffDetectCPUImpl(&result);
const char* removeStrings[] = {
"(R)", "(r)", "(TM)", "(tm)",
" CPU", " FPU", " APU", " Processor",
" Dual-Core", " Quad-Core", " Six-Core", " Eight-Core", " Ten-Core",
" 2-Core", " 4-Core", " 6-Core", " 8-Core", " 10-Core", " 12-Core", " 14-Core", " 16-Core",
" with Radeon Graphics"
};
ffStrbufRemoveStringsA(&result.name, sizeof(removeStrings) / sizeof(removeStrings[0]), removeStrings);
ffStrbufSubstrBeforeFirstC(&result.name, '@'); //Cut the speed output in the name as we append our own
ffStrbufTrimRight(&result.name, ' '); //If we removed the @ in previous step there was most likely a space before it
detectCPU(instance, &result);
);
}
+1 -1
View File
@@ -22,6 +22,6 @@ typedef struct FFCPUResult
double temperature;
} FFCPUResult;
const FFCPUResult* ffDetectCPU();
const FFCPUResult* ffDetectCPU(const FFinstance* instance);
#endif
+45 -15
View File
@@ -1,9 +1,10 @@
#include "cpu.h"
#include "common/settings.h"
#include "common/sysctl.h"
#include "detection/temps/temps_apple.h"
static double getFrequency(const char* propName)
{
double herz = (double) ffSettingsGetAppleInt64(propName, 0);
double herz = (double) ffSysctlGetInt64(propName, 0);
if(herz <= 0.0)
return herz;
@@ -12,31 +13,60 @@ static double getFrequency(const char* propName)
return herz / 1000.0; //to GHz
}
void ffDetectCPUImpl(FFCPUResult* cpu)
static double detectCpuTemp(const FFstrbuf* cpuName)
{
ffStrbufInit(&cpu->name);
ffSettingsGetAppleProperty("machdep.cpu.brand_string", &cpu->name);
FF_LIST_AUTO_DESTROY temps;
ffListInit(&temps, sizeof(FFTempValue));
ffStrbufInit(&cpu->vendor);
ffSettingsGetAppleProperty("machdep.cpu.vendor", &cpu->vendor);
if(ffStrbufStartsWithS(cpuName, "Apple M1"))
ffDetectCoreTemps(FF_TEMP_CPU_M1X, &temps);
else if(ffStrbufStartsWithS(cpuName, "Apple M2"))
ffDetectCoreTemps(FF_TEMP_CPU_M2X, &temps);
else //TODO: PPC?
ffDetectCoreTemps(FF_TEMP_CPU_X64, &temps);
cpu->coresPhysical = (uint16_t) ffSettingsGetAppleInt("hw.physicalcpu_max", 1);
if(temps.length == 0)
return FF_CPU_TEMP_UNSET;
double result = 0;
for(uint32_t i = 0; i < temps.length; ++i)
{
FFTempValue* tempValue = (FFTempValue*)ffListGet(&temps, i);
result += tempValue->value;
//TODO: do we really need this?
ffStrbufDestroy(&tempValue->name);
ffStrbufDestroy(&tempValue->deviceClass);
}
result /= temps.length;
return result;
}
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
{
FF_UNUSED(instance);
ffSysctlGetString("machdep.cpu.brand_string", &cpu->name);
ffSysctlGetString("machdep.cpu.vendor", &cpu->vendor);
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu_max", 1);
if(cpu->coresPhysical == 1)
cpu->coresPhysical = (uint16_t) ffSettingsGetAppleInt("hw.physicalcpu", 1);
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.physicalcpu", 1);
cpu->coresLogical = (uint16_t) ffSettingsGetAppleInt("hw.logicalcpu_max", 1);
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.logicalcpu_max", 1);
if(cpu->coresLogical == 1)
cpu->coresLogical = (uint16_t) ffSettingsGetAppleInt("hw.ncpu", 1);
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
cpu->coresOnline = (uint16_t) ffSettingsGetAppleInt("hw.logicalcpu", 1);
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.logicalcpu", 1);
if(cpu->coresOnline == 1)
cpu->coresOnline = (uint16_t) ffSettingsGetAppleInt("hw.activecpu", 1);
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.activecpu", 1);
cpu->frequencyMin = getFrequency("hw.cpufrequency_min");
cpu->frequencyMax = getFrequency("hw.cpufrequency_max");
if(cpu->frequencyMax == 0.0)
cpu->frequencyMax = getFrequency("hw.cpufrequency");
//TODO find a way to detect this
cpu->temperature = FF_CPU_TEMP_UNSET;
if (instance->config.cpuTemp)
cpu->temperature = detectCpuTemp(&cpu->name);
else
cpu->temperature = FF_CPU_TEMP_UNSET;
}
+28
View File
@@ -0,0 +1,28 @@
#include "cpu.h"
#include "common/sysctl.h"
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
{
FF_UNUSED(instance);
if (instance->config.cpuTemp)
{
FFstrbuf cpuTemp;
ffStrbufInit(&cpuTemp);
if(ffSysctlGetString("temperature", &cpuTemp))
cpu->temperature = FF_CPU_TEMP_UNSET;
else
cpu->temperature = ffStrbufToDouble(&cpuTemp);
}
else
cpu->temperature = FF_CPU_TEMP_UNSET;
ffSysctlGetString("hw.model", &cpu->name);
cpu->coresPhysical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
cpu->coresLogical = cpu->coresPhysical;
cpu->coresOnline = cpu->coresPhysical;
cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
cpu->frequencyMax = cpu->frequencyMin;
}
+37 -20
View File
@@ -1,12 +1,13 @@
#include "cpu.h"
#include "common/io.h"
#include "common/properties.h"
#include "detection/temps.h"
#include "detection/temps/temps_linux.h"
#include <sys/sysinfo.h>
#include <stdlib.h>
#include <unistd.h>
static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer)
static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz)
{
FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
if(cpuinfo == NULL)
@@ -25,6 +26,7 @@ static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer)
ffParsePropLine(line, "model name :", &cpu->name) ||
ffParsePropLine(line, "vendor_id :", &cpu->vendor) ||
ffParsePropLine(line, "cpu cores :", physicalCoresBuffer) ||
ffParsePropLine(line, "cpu MHz :", cpuMHz) ||
(cpu->name.length == 0 && ffParsePropLine(line, "Hardware :", &cpu->name)) //For Android devices
);
}
@@ -39,16 +41,19 @@ static double getGHz(const char* file)
{
FFstrbuf content;
ffStrbufInit(&content);
ffReadFileBuffer(file, &content);
double herz = ffStrbufToDouble(&content);
ffStrbufDestroy(&content);
if(ffAppendFileBuffer(file, &content))
{
double herz = ffStrbufToDouble(&content);
ffStrbufDestroy(&content);
//ffStrbufToDouble failed
if(herz != herz)
return 0;
//ffStrbufToDouble failed
if(herz != herz)
return 0;
herz /= 1000.0; //to MHz
return herz / 1000.0; //to GHz
herz /= 1000.0; //to MHz
return herz / 1000.0; //to GHz
}
return 0;
}
static double getFrequency(const char* info, const char* scaling)
@@ -60,9 +65,9 @@ static double getFrequency(const char* info, const char* scaling)
return getGHz(scaling);
}
static double detectCPUTemp()
static double detectCPUTemp(const FFinstance* instance)
{
const FFTempsResult *temps = ffDetectTemps();
const FFTempsResult* temps = ffDetectTemps(instance);
for(uint32_t i = 0; i < temps->values.length; i++)
{
@@ -78,25 +83,37 @@ static double detectCPUTemp()
return FF_CPU_TEMP_UNSET;
}
void ffDetectCPUImpl(FFCPUResult* cpu)
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
{
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
if(instance->config.cpuTemp)
cpu->temperature = detectCPUTemp(instance);
else
cpu->temperature = FF_CPU_TEMP_UNSET;
FFstrbuf physicalCoresBuffer;
ffStrbufInit(&physicalCoresBuffer);
parseCpuInfo(cpu, &physicalCoresBuffer);
FFstrbuf cpuMHz;
ffStrbufInit(&cpuMHz);
parseCpuInfo(cpu, &physicalCoresBuffer, &cpuMHz);
cpu->coresPhysical = ffStrbufToUInt16(&physicalCoresBuffer, 1);
cpu->coresLogical = (uint16_t) get_nprocs_conf();
cpu->coresOnline = (uint16_t) get_nprocs();
#define BP "/sys/devices/system/cpu/cpufreq/policy0/"
cpu->frequencyMin = getFrequency(BP"cpuinfo_min_freq", BP"scaling_min_freq");
cpu->frequencyMax = getFrequency(BP"cpuinfo_max_freq", BP"scaling_max_freq");
cpu->temperature = detectCPUTemp();
if(ffFileExists(BP, S_IFDIR))
{
cpu->frequencyMin = getFrequency(BP"cpuinfo_min_freq", BP"scaling_min_freq");
cpu->frequencyMax = getFrequency(BP"cpuinfo_max_freq", BP"scaling_max_freq");
}
else
{
cpu->frequencyMin = cpu->frequencyMax = ffStrbufToDouble(&cpuMHz) / 1000;
}
ffStrbufDestroy(&physicalCoresBuffer);
ffStrbufDestroy(&cpuMHz);
}
+49
View File
@@ -0,0 +1,49 @@
#include "cpu.h"
#include "util/windows/registry.h"
#include "util/mallocHelper.h"
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
{
FF_UNUSED(instance);
cpu->temperature = FF_CPU_TEMP_UNSET;
cpu->coresPhysical = cpu->coresLogical = cpu->coresOnline = 0;
cpu->frequencyMax = cpu->frequencyMin = 0;
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
{
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationProcessorCore, NULL, &length);
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pLogicalInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
if(pLogicalInfo && GetLogicalProcessorInformationEx(RelationProcessorCore, pLogicalInfo, &length))
{
for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pLogicalInfo;
(uint8_t*)ptr < ((uint8_t*)pLogicalInfo) + length;
ptr = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)(((uint8_t*)ptr) + ptr->Size)
)
{
if(ptr->Relationship == RelationProcessorCore)
++cpu->coresPhysical;
}
}
}
cpu->coresOnline = (uint16_t)GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
cpu->coresLogical = (uint16_t)GetMaximumProcessorCount(ALL_PROCESSOR_GROUPS);
FF_HKEY_AUTO_DESTROY hKey;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL))
return;
{
uint32_t mhz;
if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL))
cpu->frequencyMax = mhz / 1000.0;
}
ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);
}
+44
View File
@@ -0,0 +1,44 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#include "common/time.h"
#include <stdint.h>
// We need to use uint64_t because sizeof(long) == 4 on Windows
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll);
static uint64_t inUseAll1, totalAll1;
void ffPrepareCPUUsage()
{
ffGetCpuUsageInfo(&inUseAll1, &totalAll1);
}
const char* ffGetCpuUsageResult(double* result)
{
const char* error = NULL;
if(inUseAll1 == 0 && totalAll1 == 0)
{
error = ffGetCpuUsageInfo(&inUseAll1, &totalAll1);
if(error)
return error;
ffTimeSleep(200);
}
while(true)
{
uint64_t inUseAll2, totalAll2;
error = ffGetCpuUsageInfo(&inUseAll2, &totalAll2);
if(error)
return error;
if(inUseAll2 != inUseAll1)
{
*result = (double)(inUseAll2 - inUseAll1) / (double)(totalAll2 - totalAll1) * 100;
return NULL;
}
else
ffTimeSleep(200);
}
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
#ifndef FF_INCLUDED_detection_cpu_cpuUsage
#define FF_INCLUDED_detection_cpu_cpuUsage
const char* ffGetCpuUsageResult(double* result);
#endif
+28
View File
@@ -0,0 +1,28 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#include <mach/processor_info.h>
#include <mach/mach_host.h>
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
{
natural_t numCPUs = 0U;
processor_info_array_t cpuInfo;
mach_msg_type_number_t numCpuInfo;
*inUseAll = *totalAll = 0;
if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numCPUs, &cpuInfo, &numCpuInfo) != KERN_SUCCESS)
return "host_processor_info() failed";
if (numCPUs * CPU_STATE_MAX != numCpuInfo)
return "Unexpected host_processor_info() result";
for (natural_t i = 0U; i < numCPUs; ++i) {
integer_t inUse = cpuInfo[CPU_STATE_MAX * i + CPU_STATE_USER]
+ cpuInfo[CPU_STATE_MAX * i + CPU_STATE_SYSTEM]
+ cpuInfo[CPU_STATE_MAX * i + CPU_STATE_NICE];
integer_t total = inUse + cpuInfo[CPU_STATE_MAX * i + CPU_STATE_IDLE];
*inUseAll += (uint64_t)inUse;
*totalAll += (uint64_t)total;
}
return NULL;
}
+19
View File
@@ -0,0 +1,19 @@
#include "cpuUsage.h"
#include <sys/types.h>
#include <sys/user.h>
#include <sys/sysctl.h>
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
{
// interrupt processing, user processes, system processing, lock spinning, and idling
uint64_t cpTime[5];
size_t neededLength = sizeof(cpTime);
if(sysctlbyname("kern.cp_time", cpTime, &neededLength, NULL, 0) != 0)
return "sysctlbyname(kern.cp_time) failed";
*inUseAll = cpTime[0] + cpTime[1] + cpTime[2] + cpTime[3];
*totalAll = *inUseAll + cpTime[4];
return NULL;
}
+32
View File
@@ -0,0 +1,32 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#include <stdio.h>
#include <inttypes.h>
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
{
uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0;
FILE* procStat = fopen("/proc/stat", "r");
if(procStat == NULL)
{
#ifdef __ANDROID__
return "Accessing \"/proc/stat\" is restricted on Android O+";
#else
return "fopen(\"""/proc/stat\", \"r\") == NULL";
#endif
}
if (fscanf(procStat, "cpu%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, &user, &nice, &system, &idle, &iowait, &irq, &softirq) < 0)
{
fclose(procStat);
return "fscanf() failed";
}
*inUseAll = user + nice + system;
*totalAll = *inUseAll + idle + iowait + irq + softirq;
fclose(procStat);
return NULL;
}
+62
View File
@@ -0,0 +1,62 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#ifdef FF_USE_WIN_NTAPI
#include "util/mallocHelper.h"
#include <ntstatus.h>
#include <winternl.h>
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
{
ULONG size = 0;
if(NtQuerySystemInformation(SystemProcessorPerformanceInformation, NULL, 0, &size) != STATUS_INFO_LENGTH_MISMATCH)
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, NULL) failed";
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* FF_AUTO_FREE pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*)malloc(size);
if(!NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, pinfo, size, &size)))
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, size) failed";
*inUseAll = *totalAll = 0;
for (uint32_t i = 0; i < size / sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION); ++i)
{
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* coreInfo = pinfo + i;
// KernelTime includes idle time.
LONGLONG dpcTime = coreInfo->Reserved1[0].QuadPart;
LONGLONG interruptTime = coreInfo->Reserved1[1].QuadPart;
coreInfo->KernelTime.QuadPart -= coreInfo->IdleTime.QuadPart;
coreInfo->KernelTime.QuadPart += dpcTime + interruptTime;
LONGLONG inUse = coreInfo->UserTime.QuadPart + coreInfo->KernelTime.QuadPart;
*inUseAll += (uint64_t)inUse;
*totalAll += (uint64_t)(inUse + coreInfo->IdleTime.QuadPart);
}
return NULL;
}
#else
#include <processthreadsapi.h>
static inline uint64_t fileTimeToUint64(const FILETIME* ft) {
return (((uint64_t)ft->dwHighDateTime) << 32) | ((uint64_t)ft->dwLowDateTime);
}
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
{
FILETIME idleTime, kernelTime, userTime;
if(!GetSystemTimes(&idleTime, &kernelTime, &userTime))
return "GetSystemTimes() failed";
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getsystemtimes
// `kernelTime` also includes the amount of time the system has been idle.
*totalAll = fileTimeToUint64(&userTime) + fileTimeToUint64(&kernelTime);
*inUseAll = *totalAll - fileTimeToUint64(&idleTime);
return NULL;
}
#endif
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#ifndef FF_INCLUDED_detection_cursor_cursor
#define FF_INCLUDED_detection_cursor_cursor
#include "fastfetch.h"
typedef struct FFCursorResult
{
FFstrbuf theme;
FFstrbuf size;
FFstrbuf error;
} FFCursorResult;
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result);
#endif
+131
View File
@@ -0,0 +1,131 @@
#include "cursor.h"
#include "common/properties.h"
#include "common/parsing.h"
#include "common/settings.h"
#include "detection/gtk.h"
#include "detection/displayserver/displayserver.h"
#include <stdlib.h>
static void detectCursorGTK(const FFinstance* instance, FFCursorResult* result)
{
const FFGTKResult* gtk = ffDetectGTK4(instance);
if(gtk->cursor.length == 0)
gtk = ffDetectGTK3(instance);
if(gtk->cursor.length == 0)
gtk = ffDetectGTK2(instance);
if(gtk->cursor.length == 0)
{
ffStrbufAppendS(&result->error, "Couldn't detect GTK Cursor");
return;
}
ffStrbufAppend(&result->theme, &gtk->cursor);
ffStrbufAppend(&result->size, &gtk->cursorSize);
}
static void detectCursorXFCE(const FFinstance* instance, FFCursorResult* result)
{
ffStrbufAppendS(&result->theme, ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue);
if(result->theme.length == 0)
ffStrbufAppendS(&result->error, "Couldn't find xfce cursor in xfconf (xsettings::/Gtk/CursorThemeName)");
int cursorSizeVal = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue;
if(cursorSizeVal > 0)
ffStrbufAppendF(&result->size, "%i", cursorSizeVal);
}
static void detectCursorFromConfigFile(const FFinstance* instance, const char* relativeFilePath, const char* themeStart, const char* themeDefault, const char* sizeStart, const char* sizeDefault, FFCursorResult* result)
{
if(ffParsePropFileConfigValues(instance, relativeFilePath, 2, (FFpropquery[]) {
{themeStart, &result->theme},
{sizeStart, &result->size}
})) {
if(result->theme.length == 0)
ffStrbufAppendS(&result->theme, themeDefault);
if(result->size.length == 0)
ffStrbufAppendS(&result->size, sizeDefault);
}
if(result->theme.length == 0)
ffStrbufAppendF(&result->error, "Couldn't find cursor in %s", relativeFilePath);
}
static bool detectCursorFromXResources(const FFinstance* instance, FFCursorResult* result)
{
ffParsePropFileHomeValues(instance, ".Xresources", 2, (FFpropquery[]) {
{"Xcursor.theme :", &result->theme},
{"Xcursor.size :", &result->size}
});
return result->theme.length > 0;
}
static bool detectCursorFromXDG(const FFinstance* instance, bool user, FFCursorResult* result)
{
if(user)
ffParsePropFileHome(instance, ".icons/default/index.theme", "Inherits =", &result->theme);
else
ffParsePropFile(FASTFETCH_TARGET_DIR_USR"/share/icons/default/index.theme", "Inherits =", &result->theme);
return result->theme.length > 0;
}
static bool detectCursorFromEnv(const FFinstance* instance, FFCursorResult* result)
{
FF_UNUSED(instance);
const char* xcursor_theme = getenv("XCURSOR_THEME");
if(!ffStrSet(xcursor_theme))
return false;
ffStrbufAppendS(&result->theme, xcursor_theme);
ffStrbufAppendS(&result->size, getenv("XCURSOR_SIZE"));
return true;
}
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufCompS(&wmde->wmPrettyName, "WSLg") == 0)
{
ffStrbufAppendS(&result->error, "WSLg uses native windows cursor");
return;
}
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, "TTY") == 0)
{
ffStrbufAppendS(&result->error, "Cursor isn't supported in TTY");
return;
}
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
return detectCursorFromConfigFile(instance, "kcminputrc", "cursorTheme =", "Breeze", "cursorSize =", "24", result);
if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, "XFCE"))
return detectCursorXFCE(instance, result);
if(ffStrbufStartsWithIgnCaseS(&wmde->dePrettyName, "LXQt"))
return detectCursorFromConfigFile(instance, "lxqt/session.conf", "cursor_theme =", "Adwaita", "cursor_size =", "24", result);
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Mate") == 0)
return detectCursorGTK(instance, result);
if(
detectCursorFromEnv(instance, result) ||
detectCursorFromXDG(instance, true, result) ||
detectCursorFromXResources(instance, result) ||
detectCursorFromXDG(instance, false, result)
) return;
detectCursorGTK(instance, result);
}
+7
View File
@@ -0,0 +1,7 @@
#include "cursor.h"
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
{
FF_UNUSED(instance, result);
ffStrbufInitS(&result->error, "Not supported on this platform");
}
+12
View File
@@ -0,0 +1,12 @@
#include "cursor.h"
#include "util/windows/registry.h"
void ffDetectCursor(const FFinstance* instance, FFCursorResult* result)
{
FF_UNUSED(instance);
FF_HKEY_AUTO_DESTROY hKey;
if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Cursors", &hKey, &result->error))
ffRegReadStrbuf(hKey, NULL, &result->theme, &result->error);
}
+14 -14
View File
@@ -1,21 +1,21 @@
#include "fastfetch.h"
#include "detection/datetime.h"
#include "common/thread.h"
#include <time.h>
#include <pthread.h>
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance)
{
FF_UNUSED(instance); //We may need it later for additional configuration
static FFDateTimeResult result;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
static bool init = false;
pthread_mutex_lock(&mutex);
ffThreadMutexLock(&mutex);
if (init)
{
pthread_mutex_unlock(&mutex);
ffThreadMutexUnlock(&mutex);
return &result;
}
init = true;
@@ -27,21 +27,21 @@ const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance)
result.yearShort = (uint8_t) (result.year % 100);
result.month = (uint8_t) (tm->tm_mon + 1);
ffStrbufInit(&result.monthPretty);
ffStrbufInitA(&result.monthPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.monthPretty.length = (uint32_t) strftime(result.monthPretty.chars, ffStrbufGetFree(&result.monthPretty), "%m", tm);
ffStrbufInit(&result.monthName);
ffStrbufInitA(&result.monthName, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.monthName.length = (uint32_t) strftime(result.monthName.chars, ffStrbufGetFree(&result.monthName), "%B", tm);
ffStrbufInit(&result.monthNameShort);
ffStrbufInitA(&result.monthNameShort, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.monthNameShort.length = (uint32_t) strftime(result.monthNameShort.chars, ffStrbufGetFree(&result.monthNameShort), "%b", tm);
result.week = (uint8_t) (tm->tm_yday / 7 + 1);
ffStrbufInit(&result.weekday);
ffStrbufInitA(&result.weekday, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.weekday.length = (uint32_t) strftime(result.weekday.chars, ffStrbufGetFree(&result.weekday), "%A", tm);
ffStrbufInit(&result.weekdayShort);
ffStrbufInitA(&result.weekdayShort, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.weekdayShort.length = (uint32_t) strftime(result.weekdayShort.chars, ffStrbufGetFree(&result.weekdayShort), "%a", tm);
result.dayInYear = (uint8_t) (tm->tm_yday + 1);
@@ -50,24 +50,24 @@ const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance)
result.hour = (uint8_t) tm->tm_hour;
ffStrbufInit(&result.hourPretty);
ffStrbufInitA(&result.hourPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.hourPretty.length = (uint32_t) strftime(result.hourPretty.chars, ffStrbufGetFree(&result.hourPretty), "%H", tm);
result.hour12 = (uint8_t) (result.hour % 12);
ffStrbufInit(&result.hour12Pretty);
ffStrbufInitA(&result.hour12Pretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.hour12Pretty.length = (uint32_t) strftime(result.hour12Pretty.chars, ffStrbufGetFree(&result.hour12Pretty), "%I", tm);
result.minute = (uint8_t) tm->tm_min;
ffStrbufInit(&result.minutePretty);
ffStrbufInitA(&result.minutePretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.minutePretty.length = (uint32_t) strftime(result.minutePretty.chars, ffStrbufGetFree(&result.minutePretty), "%M", tm);
result.second = (uint8_t) tm->tm_sec;
ffStrbufInit(&result.secondPretty);
ffStrbufInitA(&result.secondPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.secondPretty.length = (uint32_t) strftime(result.secondPretty.chars, ffStrbufGetFree(&result.secondPretty), "%S", tm);
pthread_mutex_unlock(&mutex);
ffThreadMutexUnlock(&mutex);
return &result;
}
+28
View File
@@ -0,0 +1,28 @@
#include "disk.h"
#include "detection/internal.h"
void ffDetectDisksImpl(FFDiskResult* disks);
static int compareDisks(const void* disk1, const void* disk2)
{
return ffStrbufCompAlphabetically(&((const FFDisk*) disk1)->mountpoint, &((const FFDisk*) disk2)->mountpoint);
}
const FFDiskResult* ffDetectDisks()
{
FF_DETECTION_INTERNAL_GUARD(FFDiskResult,
ffStrbufInit(&result.error);
ffListInitA(&result.disks, sizeof(FFDisk), 4);
ffDetectDisksImpl(&result);
if(result.disks.length == 0 && result.error.length == 0)
ffStrbufAppendS(&result.error, "No disks found");
//We need to sort the disks, so that we can detect, which disk a path resides on
// For example for /boot/efi/bootmgr we need to check /boot/efi before /boot
//Note that we sort alphabetically here for a better ordering when printing the list,
// so the check must be done in reverse order
ffListSort(&result.disks, compareDisks);
);
}
+43
View File
@@ -0,0 +1,43 @@
#pragma once
#ifndef FF_INCLUDED_detection_disk_disk
#define FF_INCLUDED_detection_disk_disk
#include "fastfetch.h"
typedef enum FFDiskType
{
FF_DISK_TYPE_REGULAR,
FF_DISK_TYPE_HIDDEN,
FF_DISK_TYPE_EXTERNAL
} FFDiskType;
typedef struct FFDisk
{
FFstrbuf mountpoint;
FFstrbuf filesystem;
FFstrbuf name;
FFDiskType type;
uint64_t bytesUsed;
uint64_t bytesTotal;
uint32_t filesUsed;
uint32_t filesTotal;
} FFDisk;
typedef struct FFDiskResult
{
FFstrbuf error;
FFlist disks; //List of FFDisk
} FFDiskResult;
/**
* Returns a List of FFDisk, sorted alphabetically by mountpoint.
* If error is not set, disks contains at least one disk.
*
* @return const FFDiskResult*
*/
const FFDiskResult* ffDetectDisks();
#endif
+17
View File
@@ -0,0 +1,17 @@
#include "disk.h"
#include <sys/mount.h>
#import <Foundation/Foundation.h>
void detectFsInfo(struct statfs* fs, FFDisk* disk)
{
// FreeBSD doesn't support these flags
if(fs->f_flags & MNT_DONTBROWSE)
disk->type = FF_DISK_TYPE_HIDDEN;
else if(fs->f_flags & MNT_REMOVABLE)
disk->type = FF_DISK_TYPE_EXTERNAL;
else
disk->type = FF_DISK_TYPE_REGULAR;
ffStrbufInitS(&disk->name, [NSFileManager.defaultManager displayNameAtPath:@(fs->f_mntonname)].UTF8String);
}
+56
View File
@@ -0,0 +1,56 @@
#include "disk.h"
#include <sys/mount.h>
#ifdef __FreeBSD__
static void detectFsInfo(struct statfs* fs, FFDisk* disk)
{
if(
ffStrbufStartsWithS(&disk->mountpoint, "/boot") ||
ffStrbufStartsWithS(&disk->mountpoint, "/dev") ||
ffStrbufStartsWithS(&disk->mountpoint, "/var") ||
ffStrbufStartsWithS(&disk->mountpoint, "/tmp") ||
ffStrbufStartsWithS(&disk->mountpoint, "/proc") ||
ffStrbufStartsWithS(&disk->mountpoint, "/zroot")
)
disk->type = FF_DISK_TYPE_HIDDEN;
else if((fs->f_flags & MNT_NOSUID) || !(fs->f_flags & MNT_LOCAL))
disk->type = FF_DISK_TYPE_EXTERNAL;
else
disk->type = FF_DISK_TYPE_REGULAR;
ffStrbufInit(&disk->name);
}
#else
void detectFsInfo(struct statfs* fs, FFDisk* disk);
#endif
void ffDetectDisksImpl(FFDiskResult* disks)
{
struct statfs* buf;
int size = getmntinfo(&buf, MNT_WAIT);
if(size <= 0)
ffStrbufAppendS(&disks->error, "getmntinfo() failed");
for(struct statfs* fs = buf; fs < buf + size; ++fs)
{
FFDisk* disk = ffListAdd(&disks->disks);
#ifdef __FreeBSD__
// f_bavail and f_ffree are signed on FreeBSD...
if(fs->f_bavail < 0) fs->f_bavail = 0;
if(fs->f_ffree < 0) fs->f_ffree = 0;
#endif
disk->bytesTotal = fs->f_blocks * fs->f_bsize;
disk->bytesUsed = disk->bytesTotal - ((uint64_t)fs->f_bavail * fs->f_bsize);
disk->filesTotal = (uint32_t) fs->f_files;
disk->filesUsed = (uint32_t) (disk->filesTotal - (uint64_t)fs->f_ffree);
ffStrbufInitS(&disk->mountpoint, fs->f_mntonname);
ffStrbufInitS(&disk->filesystem, fs->f_fstypename);
detectFsInfo(fs, disk);
}
}
+99
View File
@@ -0,0 +1,99 @@
#include "disk.h"
#include <ctype.h>
#include <sys/statvfs.h>
void ffDetectDisksImpl(FFDiskResult* disks)
{
FILE* mountsFile = fopen("/proc/mounts", "r");
if(mountsFile == NULL)
{
ffStrbufAppendS(&disks->error, "fopen(\"/proc/mounts\", \"r\") == NULL");
return;
}
char* line = NULL;
size_t len = 0;
while(getline(&line, &len, mountsFile) != EOF)
{
//Format of the file: "<device> <mountpoint> <filesystem> <options> ..." (Same as fstab)
char* currentPos = line;
//Non pseudo filesystems have their device in /dev/
//DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem.
if(strncmp(currentPos, "/dev/", 5) != 0 && strncmp(currentPos, "drvfs", 5) != 0)
continue;
//Skip /dev/
currentPos += 5;
//Don't show loop file systems
if(strncasecmp(currentPos, "loop", 4) == 0)
continue;
FFDisk* disk = ffListAdd(&disks->disks);
//Go to mountpoint
while(!isspace(*currentPos) && *currentPos != '\0')
++currentPos;
while(isspace(*currentPos))
++currentPos;
ffStrbufInitA(&disk->mountpoint, 16);
ffStrbufAppendSUntilC(&disk->mountpoint, currentPos, ' ');
//Go to filesystem
currentPos += disk->mountpoint.length;
while(isspace(*currentPos))
++currentPos;
ffStrbufInitA(&disk->filesystem, 16);
ffStrbufAppendSUntilC(&disk->filesystem, currentPos, ' ');
//Go to options, detect type
currentPos += disk->filesystem.length;
while(isspace(*currentPos))
++currentPos;
#ifdef __ANDROID__
if(ffStrbufEqualS(&disk->mountpoint, "/") || ffStrbufEqualS(&disk->mountpoint, "/storage/emulated"))
disk->type = FF_DISK_TYPE_REGULAR;
else if(ffStrbufStartsWithS(&disk->mountpoint, "/mnt/media_rw/"))
disk->type = FF_DISK_TYPE_EXTERNAL;
else
disk->type = FF_DISK_TYPE_HIDDEN;
#else
if(strstr(currentPos, "nosuid") != NULL || strstr(currentPos, "nodev") != NULL)
disk->type = FF_DISK_TYPE_EXTERNAL;
else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi"))
disk->type = FF_DISK_TYPE_HIDDEN;
else
disk->type = FF_DISK_TYPE_REGULAR;
#endif
//Detects stats
#ifdef __USE_LARGEFILE64
struct statvfs64 fs;
if(statvfs64(disk->mountpoint.chars, &fs) != 0)
memset(&fs, 0, sizeof(struct statvfs64)); //Set all values to 0, so our values get initialized to 0 too
#else
struct statvfs fs;
if(statvfs(disk->mountpoint.chars, &fs) != 0)
memset(&fs, 0, sizeof(struct statvfs)); //Set all values to 0, so our values get initialized to 0 too
#endif
disk->bytesTotal = fs.f_blocks * fs.f_frsize;
disk->bytesUsed = disk->bytesTotal - (fs.f_bavail * fs.f_frsize);
disk->filesTotal = (uint32_t) fs.f_files;
disk->filesUsed = (uint32_t) (disk->filesTotal - fs.f_ffree);
ffStrbufInit(&disk->name); //TODO: implement this
}
if(line != NULL)
free(line);
fclose(mountsFile);
}
+70
View File
@@ -0,0 +1,70 @@
#include "disk.h"
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
void ffDetectDisksImpl(FFDiskResult* disks)
{
uint32_t length = GetLogicalDriveStringsA(0, NULL);
if(length == 0)
{
ffStrbufAppendS(&disks->error, "GetLogicalDriveStringsA failed");
return;
}
char* buf = malloc(length + 1);
GetLogicalDriveStringsA(length, buf);
for(uint32_t i = 0; i < length; i++)
{
const char* mountpoint = buf + i;
UINT driveType = GetDriveTypeA(mountpoint);
if(driveType == DRIVE_NO_ROOT_DIR)
{
i += (uint32_t)strlen(mountpoint);
continue;
}
FFDisk* disk = ffListAdd(&disks->disks);
ffStrbufInitS(&disk->mountpoint, mountpoint);
uint64_t bytesFree;
if(!GetDiskFreeSpaceExA(mountpoint, NULL, (PULARGE_INTEGER)&disk->bytesTotal, (PULARGE_INTEGER)&bytesFree))
{
disk->bytesTotal = 0;
bytesFree = 0;
}
disk->bytesUsed = disk->bytesTotal - bytesFree;
if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM)
disk->type = FF_DISK_TYPE_EXTERNAL;
else if(driveType == DRIVE_FIXED)
disk->type = FF_DISK_TYPE_REGULAR;
else
disk->type = FF_DISK_TYPE_HIDDEN;
ffStrbufInitA(&disk->filesystem, MAX_PATH + 1);
ffStrbufInitA(&disk->name, MAX_PATH + 1);
//https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getvolumeinformationa#remarks
UINT errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
GetVolumeInformationA(mountpoint,
disk->name.chars, disk->name.allocated, //Volume name
NULL, //Serial number
NULL, //Max component length
NULL, //File system flags
disk->filesystem.chars, disk->filesystem.allocated
);
SetErrorMode(errorMode);
ffStrbufRecalculateLength(&disk->name);
ffStrbufRecalculateLength(&disk->filesystem);
//TODO: implement
disk->filesUsed = 0;
disk->filesTotal = 0;
i += disk->mountpoint.length;
}
free(buf);
}
@@ -1,78 +1,46 @@
#include "displayserver.h"
#include "common/library.h"
#include "common/sysctl.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <sys/sysctl.h>
#include <ApplicationServices/ApplicationServices.h>
//Resolution code heavily inspired by displayplacer <3
typedef union
{
uint8_t rawData[0xDC];
struct
{
uint32_t mode;
uint32_t flags; // 0x4
uint32_t width; // 0x8
uint32_t height; // 0xC
uint32_t depth; // 0x10
uint32_t dc2[42];
uint16_t dc3;
uint16_t freq; // 0xBC
uint32_t dc4[4];
float density; // 0xD0
} derived;
} modes_D4;
void CGSGetCurrentDisplayMode(CGDirectDisplayID display, int* modeNum);
void CGSGetDisplayModeDescriptionOfLength(CGDirectDisplayID display, int idx, modes_D4* mode, int length);
#include <assert.h>
#include <CoreGraphics/CGDirectDisplay.h>
static void detectResolution(FFDisplayServerResult* ds)
{
CGDisplayCount screenCount;
CGGetOnlineDisplayList(INT_MAX, NULL, &screenCount);
if(screenCount == 0)
CGDirectDisplayID screens[128];
uint32_t screenCount;
if(CGGetOnlineDisplayList(sizeof(screens) / sizeof(screens[0]), screens, &screenCount) != kCGErrorSuccess)
return;
CGDirectDisplayID* screens = malloc(screenCount * sizeof(CGDirectDisplayID));
CGGetOnlineDisplayList(INT_MAX, screens, &screenCount);
for(uint32_t i = 0; i < screenCount; i++)
{
int modeID;
CGSGetCurrentDisplayMode(screens[i], &modeID);
modes_D4 mode;
CGSGetDisplayModeDescriptionOfLength(screens[i], modeID, &mode, 0xD4);
uint32_t refreshRate = ffdsParseRefreshRate(mode.derived.freq);
ffdsAppendResolution(ds, mode.derived.width, mode.derived.height, refreshRate);
CGDirectDisplayID screen = screens[i];
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(screen);
if(mode)
{
ffdsAppendResolution(ds,
(uint32_t)CGDisplayModeGetWidth(mode),
(uint32_t)CGDisplayModeGetHeight(mode),
(uint32_t)CGDisplayModeGetRefreshRate(mode)
);
CGDisplayModeRelease(mode);
}
CGDisplayRelease(screen);
}
free(screens);
}
static void detectWM(FFDisplayServerResult* ds)
static void detectWMPlugin(FFstrbuf* name)
{
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
u_int requestLength = sizeof(request) / sizeof(*request);
size_t length = 0;
if(sysctl(request, requestLength, NULL, &length, NULL, 0) != 0)
return;
struct kinfo_proc* processes = malloc(length);
struct kinfo_proc* processes = ffSysctlGetData(request, requestLength, &length);
if(processes == NULL)
return;
if(sysctl(request, requestLength, processes, &length, NULL, 0) != 0)
{
free(processes);
return;
}
for(size_t i = 0; i < length / sizeof(struct kinfo_proc); i++)
{
const char* comm = processes[i].kp_proc.p_comm;
@@ -86,9 +54,8 @@ static void detectWM(FFDisplayServerResult* ds)
strcasecmp(comm, "rectangle") != 0
) continue;
ffStrbufAppendS(&ds->wmProcessName, comm);
ffStrbufAppendS(&ds->wmPrettyName, comm);
ds->wmPrettyName.chars[0] = (char) toupper(ds->wmPrettyName.chars[0]);
ffStrbufAppendS(name, comm);
name->chars[0] = (char) toupper(name->chars[0]);
break;
}
@@ -99,19 +66,21 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
{
FF_UNUSED(instance);
ffStrbufInit(&ds->wmProcessName);
ffStrbufInit(&ds->wmPrettyName);
ffStrbufInitA(&ds->wmProtocolName, 0);
detectWM(ds);
if(ds->wmProcessName.length == 0)
ffStrbufInitS(&ds->wmProcessName, "quartz");
ffStrbufInitS(&ds->wmPrettyName, "Quartz Compositor");
ffStrbufInit(&ds->wmProtocolName);
if(instance->config.allowSlowOperations)
{
ffStrbufAppendS(&ds->wmProcessName, "quartz");
ffStrbufAppendS(&ds->wmPrettyName, "Quartz Compositor");
FF_STRBUF_AUTO_DESTROY name;
detectWMPlugin(&name);
if(name.length)
ffStrbufAppendF(&ds->wmPrettyName, " (with %s)", name.chars);
}
ffStrbufInit(&ds->deProcessName);
ffStrbufInit(&ds->dePrettyName);
ffStrbufInitA(&ds->deVersion, 0);
ffStrbufInit(&ds->deVersion);
ffStrbufAppendS(&ds->deProcessName, "aqua");
ffStrbufAppendS(&ds->dePrettyName, "Aqua");
@@ -0,0 +1,57 @@
#include "displayserver.h"
#include "detection/os/os.h"
#include <dwmapi.h>
#include <WinUser.h>
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance)
{
FF_UNUSED(instance);
BOOL enabled;
if(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled == TRUE)
{
ffStrbufInitS(&ds->wmProcessName, "dwm.exe");
ffStrbufInitS(&ds->wmPrettyName, "Desktop Window Manager");
}
else
{
ffStrbufInitS(&ds->wmProcessName, "internal");
ffStrbufInitS(&ds->wmPrettyName, "internal");
}
ffStrbufInit(&ds->wmProtocolName);
ffStrbufInit(&ds->deProcessName);
ffStrbufInit(&ds->dePrettyName);
ffStrbufInit(&ds->deVersion);
ffListInit(&ds->resolutions, sizeof(FFResolutionResult));
DISPLAY_DEVICEW displayDevice = { .cb = sizeof(DISPLAY_DEVICEW) };
for(DWORD devNum = 0; EnumDisplayDevicesW(NULL, devNum, &displayDevice, 0) != 0; ++devNum)
{
if(!(displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE))
continue;
DEVMODEW devMode = { .dmSize = sizeof(DEVMODEW) };
if(EnumDisplaySettingsW(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode) == 0)
continue;
ffdsAppendResolution(ds, devMode.dmPelsWidth, devMode.dmPelsHeight, devMode.dmDisplayFrequency);
}
//https://github.com/hykilpikonna/hyfetch/blob/master/neofetch#L2067
const FFOSResult* os = ffDetectOS(instance);
if(
ffStrbufEqualS(&os->version, "11") ||
ffStrbufEqualS(&os->version, "10") ||
ffStrbufEqualS(&os->version, "2022") ||
ffStrbufEqualS(&os->version, "2019") ||
ffStrbufEqualS(&os->version, "2016")
) ffStrbufSetS(&ds->dePrettyName, "Fluent");
else if(
ffStrbufEqualS(&os->version, "8") ||
ffStrbufEqualS(&os->version, "81.") ||
ffStrbufEqualS(&os->version, "2012 R2") ||
ffStrbufEqualS(&os->version, "2012")
) ffStrbufSetS(&ds->dePrettyName, "Metro");
else
ffStrbufSetS(&ds->dePrettyName, "Aero");
}
@@ -34,7 +34,7 @@ static void parseDRM(FFDisplayServerResult* result)
resolution->height = 0;
resolution->refreshRate = 0;
int scanned = fscanf(modeFile, "%ix%i", &resolution->width, &resolution->height);
int scanned = fscanf(modeFile, "%ux%u", &resolution->width, &resolution->height);
if(scanned < 2 || resolution->width == 0 || resolution->height == 0)
--result->resolutions.length;
+18 -10
View File
@@ -1,5 +1,3 @@
#define _GNU_SOURCE //required for struct ucred
#include "displayserver_linux.h"
#include <stdlib.h>
@@ -8,7 +6,7 @@
#ifdef FF_HAVE_WAYLAND
#include "common/library.h"
#include "common/io.h"
#include <pthread.h>
#include "common/thread.h"
#include <wayland-client.h>
#include <sys/socket.h>
@@ -17,9 +15,11 @@ typedef struct WaylandData
FFlist* results;
FF_LIBRARY_SYMBOL(wl_proxy_marshal_constructor_versioned)
FF_LIBRARY_SYMBOL(wl_proxy_add_listener)
FF_LIBRARY_SYMBOL(wl_proxy_destroy)
const struct wl_interface* ffwl_output_interface;
} WaylandData;
#ifndef __FreeBSD__
static void waylandDetectWM(int fd, FFDisplayServerResult* result)
{
struct ucred ucred;
@@ -35,6 +35,12 @@ static void waylandDetectWM(int fd, FFDisplayServerResult* result)
ffStrbufSubstrAfterLastC(&result->wmProcessName, '/'); //Trim the path
ffStrbufDestroy(&procPath);
}
#else
static void waylandDetectWM(int fd, FFDisplayServerResult* result)
{
FF_UNUSED(fd, result);
}
#endif
static void stubListener(void* data, ...)
{
@@ -43,19 +49,19 @@ static void stubListener(void* data, ...)
static void waylandOutputModeListener(void* data, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate)
{
FF_UNUSED(output);
WaylandData* wldata = data;
wldata->ffwl_proxy_destroy((struct wl_proxy*) output);
if(!(flags & WL_OUTPUT_MODE_CURRENT) || width <= 0 || height <= 0)
return;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&mutex);
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
ffThreadMutexLock(&mutex);
FFResolutionResult* result = ffListAdd(wldata->results);
pthread_mutex_unlock(&mutex);
ffThreadMutexUnlock(&mutex);
result->width = (uint32_t) width;
result->height = (uint32_t) height;
@@ -96,7 +102,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(wayland, instance->config.libWayland, false, "libwayland-client.so", 1)
FF_LIBRARY_LOAD(wayland, &instance->config.libWayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_connect, false)
FF_LIBRARY_LOAD_SYMBOL(wayland, wl_display_get_fd, false)
@@ -110,6 +116,7 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_marshal_constructor_versioned, false)
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_add_listener, false)
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_proxy_destroy, false)
FF_LIBRARY_LOAD_SYMBOL_VAR(wayland, data, wl_output_interface, false)
struct wl_display* display = ffwl_display_connect(NULL);
@@ -140,7 +147,8 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
ffwl_display_dispatch(display);
ffwl_display_roundtrip(display);
ffwl_display_disconnect(display); //This will also destroy our wl_registry and wl_output proxies
data.ffwl_proxy_destroy(registry);
ffwl_display_disconnect(display);
dlclose(wayland);
//We successfully connected to wayland and detected the resolution.
+4 -1
View File
@@ -9,7 +9,6 @@
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
static const char* parseEnv()
{
@@ -129,6 +128,10 @@ static void getKDE(FFDisplayServerResult* result)
ffParsePropFile(FASTFETCH_TARGET_DIR_USR"/share/wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion);
if(result->deVersion.length == 0)
ffParsePropFile(FASTFETCH_TARGET_DIR_USR"/share/wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion);
if(result->deVersion.length == 0)
ffParsePropFile(FASTFETCH_TARGET_DIR_USR"/local/share/xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion);
if(result->deVersion.length == 0)
ffParsePropFile(FASTFETCH_TARGET_DIR_USR"/local/share/wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion);
applyBetterWM(result, getenv("KDEWM"));
}
+2 -2
View File
@@ -91,7 +91,7 @@ static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connect
void ffdsConnectXcb(const FFinstance* instance, FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(xcb, instance->config.libXcb, , "libxcb.so", 2)
FF_LIBRARY_LOAD(xcb, &instance->config.libXcb, , "libxcb" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_connect,)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_get_setup,)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_setup_roots_iterator,)
@@ -326,7 +326,7 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
void ffdsConnectXcbRandr(const FFinstance* instance, FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(xcbRandr, instance->config.libXcbRandr, , "libxcb-randr.so", 1)
FF_LIBRARY_LOAD(xcbRandr, &instance->config.libXcbRandr, , "libxcb-randr" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_connect,)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_get_setup,)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_setup_roots_iterator,)
+12 -8
View File
@@ -9,12 +9,14 @@ typedef struct X11PropertyData
{
FF_LIBRARY_SYMBOL(XInternAtom)
FF_LIBRARY_SYMBOL(XGetWindowProperty)
FF_LIBRARY_SYMBOL(XFree)
} X11PropertyData;
static bool x11InitPropertyData(void* libraryHandle, X11PropertyData* propertyData)
{
FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XInternAtom, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XGetWindowProperty, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XFree, false)
return true;
}
@@ -29,7 +31,8 @@ static unsigned char* x11GetProperty(X11PropertyData* data, Display* display, Wi
unsigned long unused;
unsigned char* result = NULL;
data->ffXGetWindowProperty(display, window, requestAtom, 0, 64, False, AnyPropertyType, &actualType, (int*) &unused, &unused, &unused, &result);
if(data->ffXGetWindowProperty(display, window, requestAtom, 0, 64, False, AnyPropertyType, &actualType, (int*) &unused, &unused, &unused, &result) != Success)
return NULL;
return result;
}
@@ -43,19 +46,20 @@ static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDispl
if(wmWindow == NULL)
return;
const char* wmName = (const char*) x11GetProperty(data, display, *wmWindow, "_NET_WM_NAME");
char* wmName = (char*) x11GetProperty(data, display, *wmWindow, "_NET_WM_NAME");
if(wmName == NULL)
wmName = (const char*) x11GetProperty(data, display, *wmWindow, "WM_NAME");
wmName = (char*) x11GetProperty(data, display, *wmWindow, "WM_NAME");
if(!ffStrSet(wmName))
return;
if(ffStrSet(wmName))
ffStrbufSetS(&result->wmProcessName, wmName);
ffStrbufSetS(&result->wmProcessName, wmName);
data->ffXFree(wmName);
data->ffXFree(wmWindow);
}
void ffdsConnectXlib(const FFinstance* instance, FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(x11, instance->config.libX11, , "libX11.so", 7, "libX11-xcb.so", 2)
FF_LIBRARY_LOAD(x11, &instance->config.libX11, , "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL(x11, XOpenDisplay,)
FF_LIBRARY_LOAD_SYMBOL(x11, XCloseDisplay,)
@@ -259,7 +263,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
void ffdsConnectXrandr(const FFinstance* instance, FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(xrandr, instance->config.libXrandr, , "libXrandr.so", 3)
FF_LIBRARY_LOAD(xrandr, &instance->config.libXrandr, , "libXrandr" FF_LIBRARY_EXTENSION, 3)
FF_LIBRARY_LOAD_SYMBOL(xrandr, XOpenDisplay,)
FF_LIBRARY_LOAD_SYMBOL(xrandr, XCloseDisplay,)

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