Compare commits

...

431 Commits

Author SHA1 Message Date
李通洲 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
Linus Dierheimer 4b612461b8 Merge pull request #233 from ceamac/bugs/bash-completions
Fix bash completions file
2022-09-15 18:41:25 +02:00
Viorel 38013450ae Fix bash completions file 2022-09-15 19:34:14 +03:00
Linus Dierheimer ddb0c344f5 Release 1.7.1
second try
2022-09-15 16:11:05 +02:00
Linus Dierheimer 67e433750a Release 1.7.1 2022-09-15 16:02:55 +02:00
Linus Dierheimer c4b024ec6c Update bash completion 2022-09-15 15:41:24 +02:00
Linus Dierheimer e98c18a64b Fix two compiler warnings 2022-09-15 12:10:48 +02:00
Linus Dierheimer acba1d29d9 Enable multithreading on macos 2022-09-15 11:59:06 +02:00
Linus Dierheimer dd0f6354ef MacOS custom WM support 2022-09-15 01:58:31 -07:00
Linus Dierheimer 0e2d353500 Merge pull request #232 from CarterLi/master
Improve local-ip detection on macOS and print vulkan detection failing reason
2022-09-15 09:39:14 +02:00
李通洲 f9695f4148 Vulkan: print detailed reason of why failing
instead of the general message `Failed to detect vulkan`
2022-09-15 13:32:08 +08:00
李通洲 8fdbadfbb2 LocalIp: fix --localip-show-loop on macOS
loop on macOS is `lo0`
2022-09-15 13:27:27 +08:00
Linus Dierheimer 5c43119836 Fix used disk space calculation 2022-09-14 22:35:07 +02:00
Linus Dierheimer 545210e25e Don't require FF_HAVE_OPENCL on Apple 2022-09-14 22:03:23 +02:00
Linus Dierheimer 6f60423c60 Unified gh actions for pull and push 2022-09-14 19:23:19 +02:00
Linus Dierheimer 6e6847a66b Set more values in CMake project() 2022-09-14 19:12:51 +02:00
Linus Dierheimer 47c9fb9f6c Refactore some macros 2022-09-14 19:03:50 +02:00
Linus Dierheimer 5e5c144582 Fix build on apple 2022-09-14 09:51:08 -07:00
Linus Dierheimer ac330430bf Link apple frameworks at compile time 2022-09-14 14:55:28 +02:00
Linus Dierheimer 52275b89dc Try to unify linux and apple code paths 2022-09-14 12:41:43 +02:00
Linus Dierheimer 50bb06535c Merge pull request #230 from CarterLi/master
OpenGL / OpenCL: add macOS support
2022-09-13 06:19:40 -07:00
李通洲 a8b0e77189 OpenGL / OpenCL: add macOS support
Note: FF_LIBRARY_LOAD and friends are not used because loading framework
bundles are not supported by FF_LIBRARY_LOAD and support it is not easy.
Since CGL is guaranteed to be supported by macOS system, we simply use
static linking in this case.
2022-09-13 17:03:26 +08:00
Linus Dierheimer b815464704 Merge pull request #226 from CarterLi/master
OpenGL: add macOS support with SDL2
2022-09-12 06:24:43 -07:00
李通洲 93ac3f1971 Library: simplify macros 2022-09-12 21:10:05 +08:00
Carter Li 7c43e4b8e7 ci: show everything with fastfetch 2022-09-12 21:10:05 +08:00
Linus Dierheimer d8e7588fc3 Merge pull request #229 from Evo112358/master
Issue 223 pull request
2022-09-12 00:42:16 -07:00
Evo112358 9ea5de5efc updated --help terminal-format 2022-09-12 15:57:05 +10:00
Evo112358 728759d38e pull request to implement enhancement referenced in issue 223. 2022-09-12 15:51:53 +10:00
Linus Dierheimer b0426828ab Slackware logos
#228
2022-09-11 21:10:32 +02:00
Linus Dierheimer 6de8153207 Make media detection more robust 2022-09-11 13:09:33 +02:00
Linus Dierheimer 2c4b80a093 Fix ENABLE_ZLIB requirements 2022-09-11 12:03:01 +02:00
Linus Dierheimer c51903da35 GH Actions: share version as output 2022-09-11 11:56:00 +02:00
Linus Dierheimer 8b7092e4d4 gpu_apple.c: Use Ascii encoding 2022-09-11 02:44:19 -07:00
Linus Dierheimer c54b7fbd57 Restore permissions after artifact upload 2022-09-11 11:10:02 +02:00
Linus Dierheimer 820854a2fa Fix release action 2022-09-11 10:56:54 +02:00
Linus Dierheimer ad4a71a2d5 Github actions: package for all platforms 2022-09-11 10:47:47 +02:00
Linus Dierheimer 22075e2d28 CMake: keep sysconfdir in cache 2022-09-09 22:43:53 +02:00
Linus Dierheimer a926c9cf7e Use vulkan as gpu fallback on all platforms 2022-09-09 20:43:24 +02:00
Linus Dierheimer 60c735d1a4 Enable Vulkan on MacOS 2022-09-09 20:37:56 +02:00
Linus Dierheimer 9466ee3e51 Even better GPU names 2022-09-09 17:53:19 +02:00
Linus Dierheimer 126c1a10bb Correctly handle GPU names with multiple ']' 2022-09-09 17:48:55 +02:00
Linus Dierheimer 425e135bd8 Reintroduce gpu name modification 2022-09-09 17:47:16 +02:00
Linus Dierheimer 0a675fec8c Give libpci a bigger buffer to work with
#224
2022-09-09 17:40:08 +02:00
Linus Dierheimer 2c5b079b97 Apple M1 GPU support 2022-09-09 05:40:27 -07:00
Linus Dierheimer 0be1a41b5c Update gpu_apple.c 2022-09-08 17:33:29 +02:00
Linus Dierheimer 883e0450b0 Correct intendation 2022-09-08 15:27:53 +02:00
Linus Dierheimer 2fc8a7e70b Better brew package detection 2022-09-08 06:26:26 -07:00
Linus Dierheimer be7f8f4117 Swap module
#225
2022-09-08 14:51:31 +02:00
Linus Dierheimer dd60e8aa75 fix build on macos 2022-09-08 01:50:18 -07:00
Linus Dierheimer 851899397e Improve brew package detection 2022-09-08 10:45:56 +02:00
Linus Dierheimer 60a30d888f GitHub actions: don't try to build deb on macos second try 2022-09-07 21:00:13 +02:00
Linus Dierheimer 999c8208b7 GitHub actions: don't try to build deb on macos 2022-09-07 20:58:14 +02:00
Linus Dierheimer 9143b6dbec GitHub actions: build on macos too 2022-09-07 20:56:19 +02:00
Linus Dierheimer 16a706d3c5 Seperate color config of title and keys 2022-09-07 19:50:10 +02:00
Linus Dierheimer 58f436d8a2 Apple GPU: Set length of name buffer 2022-09-07 06:40:47 -07:00
Linus Dierheimer 47d1f2e673 Try to fix gpu_apple
#222
2022-09-07 06:37:35 -07:00
Linus Dierheimer 8be4921bd0 Release 1.7.0 2022-09-06 18:59:03 +02:00
Linus Dierheimer b22bcba220 Don't use LC_CTYPE for locale detection 2022-09-06 09:17:26 -07:00
Linus Dierheimer 5ee7ea46e7 Better variable naming 2022-09-06 18:03:31 +02:00
Linus Dierheimer d93c934269 MacOS Resolution support 2022-09-06 08:04:45 -07:00
Linus Dierheimer 5c1ac33df2 MacOS WM & DE support 2022-09-06 06:52:50 -07:00
Linus Dierheimer 0b3bf3c273 Only build display server code on linux 2022-09-06 15:42:37 +02:00
Linus Dierheimer 7fd98829b0 Fix unused variable 2022-09-06 14:23:07 +02:00
Linus Dierheimer 282271a65a MacOS disk support 2022-09-06 05:19:21 -07:00
Linus Dierheimer 9ef4b82cb9 Refactor disk module 2022-09-06 13:24:57 +02:00
Linus Dierheimer 10973dd9d1 Better MacOS GPU support 2022-09-06 02:28:32 -07:00
Linus Dierheimer dfdffec1c9 MacOS GPU support 2022-09-05 13:41:05 -07:00
Linus Dierheimer 2283700a99 Refactor CMakeLists.txt 2022-09-05 19:56:00 +02:00
Linus Dierheimer 7b647e09da Only enable library features on linux by default 2022-09-05 18:30:30 +02:00
Linus Dierheimer 54cb74c999 Separate gpu detection and printing logic 2022-09-05 17:42:42 +02:00
Linus Dierheimer 0f70cb408f Updated presets 2022-09-05 16:11:35 +02:00
Linus Dierheimer c80b1761dd brew package support 2022-09-05 05:15:19 -07:00
Linus Dierheimer a1fde6f922 MacOS memory support 2022-09-05 02:46:53 -07:00
Linus Dierheimer 6a44515cf2 Separate memory detection and printing logic 2022-09-05 10:57:09 +02:00
Linus Dierheimer cfcc4c8375 MacOS cpu support 2022-09-04 14:12:04 -07:00
Linus Dierheimer ea60fd0a0d Separate cpu detection and printing logic 2022-09-04 22:20:12 +02:00
Linus Dierheimer a4e0275263 Update README.md 2022-09-04 18:07:15 +02:00
Linus Dierheimer 71779fa4b1 Basic MacOS support 2022-09-04 09:02:11 -07:00
Linus Dierheimer 475099696f MacOS logo 2022-09-04 16:32:45 +02:00
Linus Dierheimer 14670b6144 Always cast to right tv_usec type 2022-09-04 14:41:00 +02:00
Linus Dierheimer 327b1b142e guard get_nproc with FF_HAVE_SYSCONF_H 2022-09-04 14:37:57 +02:00
Linus Dierheimer 9d106c6672 Enable build on MacOS
Note that this commit just makes fastfetch compile, not work properly
2022-09-04 14:30:52 +02:00
Linus Dierheimer df0e13b198 Fix possible segfault 2022-09-04 13:56:14 +02:00
Linus Dierheimer 6d0675820e Fix build on Android 2022-09-04 13:36:56 +02:00
Linus Dierheimer 08b0bac2b9 Refactor os detection code 2022-09-04 13:33:18 +02:00
Linus Dierheimer d387800bda Separate host detection and printing logic 2022-09-04 12:43:30 +02:00
Linus Dierheimer 542ad5eab6 Small fixes to gpu code 2022-09-03 10:53:30 +02:00
Linus Dierheimer 99f42d0953 Fix build with old libpci versions 2022-09-01 17:22:35 +02:00
Linus Dierheimer 3b316bdd3f Refactor pci code 2022-09-01 17:14:50 +02:00
Linus Dierheimer f011f8851e recache between commits too 2022-09-01 17:14:10 +02:00
Linus Dierheimer 8f23a52f53 Fix typos 2022-08-30 19:46:36 +02:00
Linus Dierheimer 8f53d33f29 Fix --file option 2022-08-29 11:01:29 +02:00
Linus Dierheimer e6fa269f52 Update README.md 2022-08-29 09:24:03 +02:00
Linus Dierheimer ca4a327de4 Update README.md 2022-08-28 18:42:53 +02:00
Linus Dierheimer f4e777f3d2 Update README.md 2022-08-28 18:34:54 +02:00
Linus Dierheimer 136f73ea0b Updated screenshots 2022-08-28 17:39:01 +02:00
Linus Dierheimer 28270541e6 use pci_read_byte to support older libpci versions 2022-08-28 16:01:34 +02:00
Linus Dierheimer 8197eddea8 Much better AMD gpu names 2022-08-28 15:51:28 +02:00
Linus Dierheimer 23bccc4802 MSYS2 logo
#219
2022-08-27 16:15:31 +02:00
Linus Dierheimer 873c7d93b6 Fix ffStrSet 2022-08-27 12:22:03 +02:00
Linus Dierheimer f4ee8667b1 Binary prefix option 2022-08-26 16:02:04 +02:00
Linus Dierheimer 50d3d4cdf4 Merge pull request #220 from sirlucjan/patch-1
Add CachyOS small logo
2022-08-25 12:41:51 +02:00
Piotr Gorski df048035b5 Add CachyOS small logo
Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
2022-08-24 20:44:36 +02:00
Linus Dierheimer 952989c1e8 Show huge ram values in GiB
#218
2022-08-23 13:53:12 +02:00
Linus Dierheimer aa1237b0fd Simplified config file loading logic 2022-08-22 12:45:20 +02:00
Linus Dierheimer b87983c86b Fix parsing quoted values in config files 2022-08-22 12:14:08 +02:00
Linus Dierheimer 779dbab647 Release 1.6.4 2022-08-22 00:13:13 +02:00
Linus Dierheimer 47373998d5 replace gethostbyname with getaddrinfo
#217
2022-08-21 23:35:22 +02:00
Linus Dierheimer 11809e30b5 Parse config files faster 2022-08-21 21:08:11 +02:00
Linus Dierheimer 35253e085c Unified storage of --set and --set-keyless values 2022-08-20 18:17:00 +02:00
Linus Dierheimer 112e83b7c3 Provide apk count to package format string 2022-08-18 22:02:21 +02:00
Linus Dierheimer c74b34aa39 Merge pull request #216 from mxkrsv/apk-support
Add APK (Alpine Package Keeper) support
2022-08-18 21:56:20 +02:00
Maxim Karasev b2e0034c34 Add APK (Alpine Package Keeper) support 2022-08-18 22:28:40 +03:00
Linus Dierheimer e3cdf9d9fd Reset color after custom module 2022-08-18 11:45:44 +02:00
Linus Dierheimer 6cdb694e33 Do simple \ replacement in user strings 2022-08-18 11:36:30 +02:00
Linus Dierheimer 83016289e9 --set-keyless option 2022-08-18 10:44:21 +02:00
Linus Dierheimer f9562d7132 Merge pull request #214 from jonathanspw/master
add AlmaLinux logo
2022-08-17 09:19:38 +02:00
jonathanspw 2f66bc2c95 add AlmaLinux logo 2022-08-16 20:10:47 -05:00
Linus Dierheimer d7c848225c Update CHANGELOG.md 2022-08-12 21:52:29 +02:00
Linus Dierheimer 8404ae8e70 Merge pull request #212 from ceamac/bugs/install-presets
Fix installation of presets/ directory
2022-08-12 21:50:49 +02:00
Viorel d75f72c8fe Fix installation of presets/ directory 2022-08-12 22:35:31 +03:00
Linus Dierheimer 9fa00081e3 Release 1.6.2 2022-08-12 16:01:52 +02:00
Linus Dierheimer fca37b59c8 Print xbps package count once again
#209
2022-08-12 09:40:02 +02:00
Linus Dierheimer 2fe7476c67 Better xbps package count
#209
2022-08-07 19:42:16 +02:00
Linus Dierheimer 03cbd64d8a Merge pull request #208 from hervyqa/langitketujuh
Add LangitKetujuh Linux logo
2022-08-03 13:03:06 +02:00
Hervy Qurrotul Ainur Rozi f65aeed96f Add LangitKetujuh Linux logo 2022-08-03 16:46:14 +07:00
Linus Dierheimer b63f419cde Merge pull request #207 from draumaz/master
Add KISS Linux logo
2022-08-02 15:14:41 +02:00
draumaz 99aa2f7b45 swap order 2022-08-02 12:29:44 +00:00
draumaz b251c32c12 fix colors, update README 2022-08-02 12:24:15 +00:00
draumaz 034e23d7e3 Merge branch 'LinusDierheimer:master' into master 2022-08-02 05:13:30 -07:00
Linus Dierheimer bba912d42e Add missing include 2022-08-02 10:24:54 +02:00
draumaz 597652c35a one more backslash 2022-08-02 05:56:20 +00:00
draumaz 7f67846ad9 add KISS Linux logo 2022-08-02 05:51:15 +00:00
Linus Dierheimer bc2e292e22 Update issue templates 2022-07-31 17:44:07 +02:00
Linus Dierheimer 75dc228120 Update issue templates 2022-07-31 17:39:54 +02:00
Linus Dierheimer bc783f6efd Update issue templates 2022-07-31 17:33:03 +02:00
Linus Dierheimer 85e1d2b40c Add logo request template 2022-07-31 17:31:30 +02:00
Linus Dierheimer 3338189354 Rosa Linux logo 2022-07-31 17:22:03 +02:00
Linus Dierheimer d4c836fd25 Handle empty xdg env vars better 2022-07-30 23:30:46 +02:00
Linus Dierheimer 6787f1eba8 Merge branches 'master' and 'master' of github.com:LinusDierheimer/fastfetch 2022-07-27 21:56:42 +02:00
Linus Dierheimer eedc277bcf Respect target dir config during installation 2022-07-27 21:56:28 +02:00
Linus Dierheimer d4b32eaaec Merge pull request #205 from licy183/fix-android-header
Fix build error on Android
2022-07-27 19:31:29 +02:00
Linus Dierheimer 910f63f0ad Update changelog 2022-07-27 19:31:14 +02:00
Linus Dierheimer 9a0aa2ac72 Fix compilation issues
1) when building for android
2) when building without wayland
2022-07-27 19:28:55 +02:00
Chongyun Lee dce81055fe Release 1.6.1 2022-07-28 01:28:17 +08:00
Chongyun Lee 66a4fc1600 Fix build error on Android
host.c has an #elif, but actually #else is needed.
2022-07-27 22:50:11 +08:00
Linus Dierheimer 159a114bb7 Release 1.6.0
tag correctly
2022-07-26 22:38:40 +02:00
Linus Dierheimer ac08b46e71 Release 1.6.0
this time with correct packaging the second
2022-07-26 22:27:13 +02:00
Linus Dierheimer ceb92dafd7 Release 1.6.0
this time with correct packaging
2022-07-26 22:13:09 +02:00
Linus Dierheimer 31eeb6dd08 Release 1.6.0 2022-07-26 20:35:15 +02:00
Linus Dierheimer c021689a2b Better nix package sorting
#195
2022-07-26 19:15:00 +02:00
Linus Dierheimer 2ac2762c9f Print nix-default packages
#195
2022-07-26 19:03:15 +02:00
Linus Dierheimer 27dd097671 Improved Nix package detection
#195
2022-07-26 18:36:10 +02:00
Linus Dierheimer c7bf471e29 Refactor: move vulkan detection to own header 2022-07-26 18:18:14 +02:00
Linus Dierheimer 298bc10e5f Refactor: move media detection to own header 2022-07-26 18:15:45 +02:00
Linus Dierheimer 676485ef74 Refactor: move temps detection to own header 2022-07-26 18:13:12 +02:00
Linus Dierheimer fb6da20b0c Refactor: move date/time detection to own header 2022-07-26 18:09:25 +02:00
Linus Dierheimer 0c81d3e894 Refactor: move terminal/shell detection to own header 2022-07-26 18:06:30 +02:00
Linus Dierheimer 5c1aa20042 Refactor: move wm/de detection to own header 2022-07-26 17:56:42 +02:00
Linus Dierheimer 46a27c4e39 Refactor: move gtk detection to own header 2022-07-26 17:47:08 +02:00
Linus Dierheimer 128302596e Refactor: move qt detection to own header 2022-07-26 17:42:28 +02:00
Linus Dierheimer 7a15dee2be Refactor: move os detection to own header 2022-07-26 17:33:51 +02:00
Linus Dierheimer 000bd37f1d Refactor: move title detection to own header 2022-07-26 17:29:09 +02:00
Linus Dierheimer 707e0f930d Refactor: don't include FFvaluestore global 2022-07-25 19:54:33 +02:00
Linus Dierheimer 7676a313c5 Refactor: move threading functions to init 2022-07-25 15:01:11 +02:00
Linus Dierheimer 6e0d76a2fb Refactor: move networking functions to own header 2022-07-25 14:48:59 +02:00
Linus Dierheimer 4c7b7e4a4d Refactor: move processing functions to own header 2022-07-25 14:45:41 +02:00
Linus Dierheimer 4d34091573 Refactor: move format functions to own header 2022-07-25 14:26:08 +02:00
Linus Dierheimer c971e28aca Refactor: move setting functions to own header 2022-07-25 14:20:07 +02:00
Linus Dierheimer c41a29a5c1 Refactor: move parsing functions to own header 2022-07-25 13:59:19 +02:00
Linus Dierheimer 5c73125693 Refactor: move font functions to own header 2022-07-25 13:44:55 +02:00
Linus Dierheimer cea48474a1 Refactor: move caching functions to own header 2022-07-25 13:36:58 +02:00
Linus Dierheimer 536f914f3e Refactor: move printing functions to own header 2022-07-25 13:15:01 +02:00
Linus Dierheimer 778856dd57 Refactor: move property functions to own header 2022-07-25 12:24:23 +02:00
Linus Dierheimer 4a43144991 Refactor: move io functions to own header 2022-07-25 11:48:48 +02:00
Linus Dierheimer ac96cfc748 Refactor: move FFInitState to settings.c 2022-07-25 11:24:50 +02:00
Linus Dierheimer f18ffe3239 Refactor: move library functions and macros to own header 2022-07-25 11:20:38 +02:00
Linus Dierheimer 986bbeebb3 Don't segfault if invalid structure is given
#204
2022-07-25 11:00:41 +02:00
Linus Dierheimer b9d360af97 --title-fqdn option
#203
2022-07-22 19:36:00 +02:00
Linus Dierheimer ec1981c545 Use [QT] instead of [Plasma]
#198 #199
2022-07-22 17:18:36 +02:00
Linus Dierheimer f7e7d8e9f2 Update README.md 2022-07-22 13:42:26 +02:00
Linus Dierheimer ad9fc5845a GTK: Fix detection on XFCE DE
#198 #199
2022-07-22 12:23:35 +02:00
Linus Dierheimer a6b169f3e2 Disk: Print one decimal point if < 100GiB
#202
2022-07-22 11:47:20 +02:00
Linus Dierheimer 8aff9939bc GTK: prefer dconf over config files on certain DEs
#198 #199
2022-07-22 11:24:29 +02:00
Linus Dierheimer 0b8f51188b gh actions: configure correct path for packaging
the follow up
2022-07-21 22:58:38 +02:00
Linus Dierheimer 3c99a82619 gh actions: configure correct path for packaging 2022-07-21 22:55:47 +02:00
Linus Dierheimer d5f3ff1cfe Update README.md 2022-07-21 20:20:40 +02:00
Linus Dierheimer 011c033091 Update README.md 2022-07-21 20:18:34 +02:00
Linus Dierheimer 63bf22fb00 Load system config
#196
2022-07-21 14:37:13 +02:00
Linus Dierheimer f74973db65 Special NixOS OS output
#194
2022-07-21 11:33:19 +02:00
Linus Dierheimer 85656fd515 Fix Mutter detection
#200
2022-07-20 21:32:17 +02:00
Linus Dierheimer 23bf7a407b Fix alacritty term font size
#197
2022-07-20 20:56:02 +02:00
Linus Dierheimer e570cacbc9 Fix typos
#201
2022-07-20 20:44:16 +02:00
Linus Dierheimer a96f79795b Merge pull request #193 from Izorkin/update-nixos-logo
Update old nixos logo
2022-07-19 12:09:25 +02:00
Izorkin 2d51d935c8 update old nixos logo 2022-07-19 12:57:15 +03:00
Linus Dierheimer 9d395f7235 don't print GPU in WSL 2022-07-17 16:11:08 +02:00
Linus Dierheimer 5f16394916 Add alacritty to readme 2022-07-12 16:49:39 +02:00
Linus Dierheimer 6581c9d378 Merge pull request #191 from x-zvf/alacritty-term-support
[enhancement] Add best effort terminal font detection for alacritty.
2022-07-12 16:46:22 +02:00
Péter Bohner (xzvf) 67ac7eef59 buxfix: missing fontSize/fontName would overwrite the other 2022-07-12 16:43:21 +02:00
Péter Bohner (xzvf) b95e83e9e5 Use ffStrbufAppend instead of ffStrbugInitCopy 2022-07-12 16:41:20 +02:00
Péter Bohner (xzvf) e9d9b942fa Cleanup diff 2022-07-12 16:34:35 +02:00
Péter Bohner (xzvf) c95ad74ea2 Refactor to use ffFontInitCopy and detect font size
printAlacritty now usese ffFontInitCopy instead of ffFontInitPango
and also detects font size.
2022-07-12 16:31:19 +02:00
Péter Bohner (xzvf) 85b0be5213 Add best effort terminal font detection for alacritty.
Alacritty's config files are technically YML files, so
simply looking for a prop value "family:" may break some of the time,
but is in fact better than what neofetch does and much easier
to implement then writing a YML parser :)
2022-07-12 14:38:06 +02:00
Linus Dierheimer da671d6cfe Start cleaning up of config struct 2022-07-10 18:28:17 +02:00
Linus Dierheimer 18af9ab902 Wayland: don't destroy proxies our self 2022-07-08 11:48:43 +02:00
Linus Dierheimer 558fbc20e2 Don't detect guake-wrapped as terminal 2022-07-08 11:24:11 +02:00
Linus Dierheimer d9bbbd4fa8 Merge pull request #189 from x-zvf/alacritty-term-support
Fix memory leak in ffParsePropFileValues
2022-07-08 10:46:11 +02:00
Péter Bohner (xzvf) 292a809703 ffParsePropValues: Hoisted fopen call to simplify error handling 2022-07-08 09:09:59 +02:00
Péter Bohner (xzvf) fa13826043 Revert "Coalesce cleanup in ffParsePropFileValues"
This reverts commit 7bc85b2397.
2022-07-08 09:05:00 +02:00
Péter Bohner (xzvf) 7bc85b2397 Coalesce cleanup in ffParsePropFileValues 2022-07-07 15:19:56 +02:00
Péter Bohner (xzvf) 1863d8377a Fix memory leak in ffParseProfFileValues, if more than 4 queries are passed (unsetValues is on the heap) and the file
is not found.
2022-07-07 14:35:59 +02:00
xzvf f9e17f44b1 Merge branch 'LinusDierheimer:master' into master 2022-07-04 20:10:01 +02:00
xzvf fa9b38eb2d Merge pull request #1 from LinusDierheimer/master
build temps file
2022-06-16 12:54:28 +02:00
264 changed files with 12445 additions and 4443 deletions
+1 -1
View File
@@ -1 +1 @@
custom: paypal.me/linusdierheimer
github: LinusDierheimer
-1
View File
@@ -41,4 +41,3 @@ 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`.
-->
+18
View File
@@ -0,0 +1,18 @@
---
name: Logo request
about: Request a new logo
title: ''
labels: logo request
assignees: ''
---
# OS
```
paste content of /etc/os-release here. If this file doesn't exist, describe a way to identify the distro.
```
# Ascii
```
paste ascii art here. If you leave this empty, i will try to find the logo myself.
```
-37
View File
@@ -1,37 +0,0 @@
name: manage pull requests
on: pull_request
jobs:
check:
name: manage pull request
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: checkout repository
uses: actions/checkout@v2
- 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
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
- name: configure project
run: cmake -DBUILD_TESTS=On .
- name: build project
run: cmake --build . -j$(nproc) --target package
- name: run fastfetch
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true
- name: run flashfetch
run: ./flashfetch
- name: run tests
run: ctest
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v1
+114 -21
View File
@@ -1,36 +1,41 @@
name: manage pushes
on:
push:
branches: [ master ]
- push
- pull_request
jobs:
manage:
name: manage push
linux:
name: Linux
runs-on: ubuntu-latest
permissions:
contents: write
security-events: write
contents: read
outputs:
ffversion: ${{ steps.ffversion.outputs.ffversion }}
steps:
- name: checkout repository
uses: actions/checkout@v2
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@v1
uses: github/codeql-action/init@v2
with:
languages: c
- name: configure project
# We reuse the build binary only for the releases.
# We set tweak version to off, because it is wrong, as git tag will happen after this step. Releases don't have a tweak, so this is ok.
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
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
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: ./flashfetch
@@ -38,12 +43,99 @@ jobs:
- name: run tests
run: ctest
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v1
- name: get fastfetch version
id: get_version_fastfetch
run: echo "::set-output name=release::$(./fastfetch --version-raw)"
id: ffversion
run: echo "::set-output name=ffversion::$(./fastfetch --version-raw)"
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-linux
path: ./fastfetch-*.*
macos:
name: MacOS
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 molten-vk
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c
- name: configure project
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
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
- name: run flashfetch
run: ./flashfetch
- name: run tests
run: ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-macos
path: ./fastfetch-*.*
bsd:
name: BSD
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
./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
./flashfetch
ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-bsd
path: ./fastfetch-*.*
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'LinusDierheimer/fastfetch'
name: Release
runs-on: ubuntu-latest
needs:
- linux
- macos
- bsd
permissions:
contents: write
steps:
- name: download artifacts
uses: actions/download-artifact@v3
- name: get latest release version
id: get_version_release
@@ -52,9 +144,10 @@ jobs:
repository: ${{ github.repository }}
- name: create release
if: steps.get_version_fastfetch.outputs.release != steps.get_version_release.outputs.release
if: needs.linux.outputs.ffversion != steps.get_version_release.outputs.release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.get_version_fastfetch.outputs.release }}
tag: ${{ needs.linux.outputs.ffversion }}
commit: ${{ github.sha }}
artifacts: ./fastfetch-*.*
artifactErrorsFailBuild: true
artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-bsd/*
+1
View File
@@ -2,6 +2,7 @@
**/.vscode/
**/.cache/
**/.kdev4/
**/.DS_Store
cscope.*
tags
fastfetch.kdev4
+114
View File
@@ -0,0 +1,114 @@
# 1.7.2
Fixes the bash completions
# 1.7.1
This release brings a lot of bug fixes and improvements for MacOS. Big thanks to @CarterLi for the help on this!
Features:
* The color of the title and the keys can now be configured individually, using `--color-keys` and `--color-title` respectively. Some distros have different defaults now, similar to neofetch
* Swap module, similar to the Memory module, but for swap. Add `Swap` to your structure to enable it (#225)
Logos:
* Slackware (#227)
Bugfixes:
* Used disk space is now calculated much more accurately
* On Linux, GPU names are no longer truncated, if they are longer than 32 characters (#224)
* On Linux, NVIDIA GPUs once again have a proper name
* On M1 platforms, showing the GPU name no longer crashes the program (#222)
* Brew package count does now work on M1 platforms too
* The Vulkan module now does work on MacOS too
* The OpenGL and OpenCL modules now work on MacOS too (@CarterLi, #226)
* The LocalIp module now works on MacOS too (@CarterLi, #232)
* Detecting custom WMs on MacOS does now work
Other:
* GitHub actions now builds a dmg file for MacOS, as you can see in the release page
# 1.7.0
This release brings support for MacOS!
The basics things are working, but it is far from feature parity with Linux.
I developed this in a VM, so bugs on real hardware are likely.
If you have a Mac and no idea what to do with your free time, i am very happy to accept pull requests / work on issues.
A lot of things were changed under the hood to make this possible, which should bring better performance and stability on all platforms.
Besides that, the following things have changed:
Features:
* The binary prefix used can now be configured, and is used consistently across all modules. Set `--binary-prefix` to `iec` (default), `si` or `jedec`.
* AMD GPUs now have a much better name, if the file `/usr/share/libdrm/amdgpu.ids` exists. For example my dedicated GPU, which was displayed as `AMD/ATI Radeon RX 5600 OEM/5600 XT / 5700/5700 XT`, is now `AMD Radeon RX 5600M`.
Logos:
* MacOS
* CachyOS small (@sirlucjan, #220)
* MSYS2 (#219)
Bugfixes:
* the `--file` option, which can be used to display the contents of a file as the logo, is now working again.
# 1.6.5
Fixes parsing quoted values in config files
# 1.6.4
Releasing this, so fedora can package fastfetch. Thanks to @jonathanspw for doing that!
Features:
* --set-keyless option (#215)
* Replace `\n`, `\t`, `\e` and `\\` in user provided strings, just like c would do it (#215)
* APK (Alpine Package Keeper) support (@mxkrsv, #216)
Logos:
* Alma Linux (@jonathanspw, #214)
Bugfixes:
* replace deprecated gethostbyname call with getaddrinfo (#217)
# 1.6.3
Fixes installing presets in their own directory (@ceamac, #212)
# 1.6.2
Releasing this, so void linux can package fastfetch.
Logos:
* Rosa linux (#206)
* KISS linux (@draumaz, #207)
* LangitKetujuh (@hervyqa, #208)
Bugfixes:
* Using musl as libc does work now (#210)
* XBPS packages are once again printed (#209)
* configured target dirs are applied to install directories too
* empty XDG_* env vars don't cause a crash anymore
# 1.6.1
Fixes build on android (#205)
# 1.6.0
Features:
* Detect QT on more DEs than just KDE Plasma. The [Plasma] category was therefore renamed to [QT]
* Alacritty font detection
* Load `/etc/fastfetch/config.conf` before user config
* Disk: print one decimal point if size < 100GB
* `--title-fqdn` option, to print fully qualified domain name instead of host name in title
Logos:
* updated old NixOS logo
Bugfixes:
* Correctly detect GTK on DEs that store their settings in dconf
* Correctly detect NixOS packages
* Mutter WM detected once again
* Show full NixOS version in OS output
* Don't segfault if an invalid structure is given
* WSL doesn't output GPU anymore, as the name is always meaningless
+341 -268
View File
@@ -1,38 +1,58 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 1.5.6
LANGUAGES C
VERSION 1.7.2
LANGUAGES C CXX # Windows part requires C++ compiler
DESCRIPTION "Fast system information tool"
HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch"
)
###################
# Target Platform #
###################
if("${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 "MSYS|Windows")
set(WIN_MSYS TRUE CACHE BOOL "..." FORCE) # Windows on msys2
elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Bb][Ss][Dd].*")
set(BSD TRUE CACHE BOOL "..." FORCE)
elseif(NOT APPLE AND NOT ANDROID)
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
#####################
# Configure options #
#####################
OPTION(ENABLE_LIBPCI "Enable libpci" ON)
OPTION(ENABLE_VULKAN "Enable vulkan" ON)
OPTION(ENABLE_WAYLAND "Enable wayland-client" ON)
OPTION(ENABLE_XCB_RANDR "Enable xcb-randr" ON)
OPTION(ENABLE_XCB "Enable xcb" ON)
OPTION(ENABLE_XRANDR "Enable xrandr" ON)
OPTION(ENABLE_X11 "Enable x11" ON)
OPTION(ENABLE_GIO "Enable gio-2.0" ON)
OPTION(ENABLE_DCONF "Enable dconf" ON)
OPTION(ENABLE_DBUS "Enable dbus-1" ON)
OPTION(ENABLE_XFCONF "Enable libxfconf-0" ON)
OPTION(ENABLE_SQLITE3 "Enable sqlite3" ON)
OPTION(ENABLE_RPM "Enable rpm" ON)
OPTION(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON)
OPTION(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON)
OPTION(ENABLE_ZLIB "Enable zlib" ON)
OPTION(ENABLE_CHAFA "Enable chafa" ON)
OPTION(ENABLE_EGL "Enable egl" ON)
OPTION(ENABLE_GLX "Enable glx" ON)
OPTION(ENABLE_OSMESA "Enable osmesa" ON)
OPTION(ENABLE_OPENCL "Enable opencl" ON)
include(CMakeDependentOption)
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
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 WIN_MSYS" 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 OR BSD" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR BSD" 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 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 WIN_MSYS" OFF)
cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR WIN_MSYS" OFF)
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" 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 #
@@ -43,6 +63,8 @@ find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
include(CheckIncludeFile)
####################
# Compiler options #
####################
@@ -51,9 +73,29 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion")
if(WIN_MSYS)
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 WIN_MSYS)
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")
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED)
@@ -81,13 +123,28 @@ if(NOT TARGET_DIR_USR)
endif()
if(NOT TARGET_DIR_HOME)
if(NOT ANDROID)
set(TARGET_DIR_HOME "${TARGET_DIR_ROOT}/home")
else()
if(APPLE)
set(TARGET_DIR_HOME "${TARGET_DIR_ROOT}/Users")
elseif(ANDROID)
set(TARGET_DIR_HOME "/data/data/com.termux/files/home")
else()
set(TARGET_DIR_HOME "${TARGET_DIR_ROOT}/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 #
#################
@@ -115,7 +172,8 @@ function(fastfetch_load_text FILENAME OUTVAR)
endfunction(fastfetch_load_text)
fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
fastfetch_load_text(src/data/config.txt DATATEXT_CONFIG)
fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM)
fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER)
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
@@ -132,18 +190,16 @@ configure_file(src/fastfetch_config.h.in fastfetch_config.h)
# libfastfetch target #
#######################
add_library(libfastfetch OBJECT
set(LIBFASTFETCH_SRC
src/util/FFstrbuf.c
src/util/FFlist.c
src/util/FFvaluestore.c
src/common/init.c
src/common/threading.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
@@ -154,25 +210,27 @@ add_library(libfastfetch OBJECT
src/logo/image/image.c
src/logo/image/im7.c
src/logo/image/im6.c
src/detection/os.c
src/detection/plasma.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/displayserver/displayServer.c
src/detection/displayserver/wayland.c
src/detection/displayserver/xcb.c
src/detection/displayserver/xlib.c
src/detection/displayserver/wmde.c
src/detection/title.c
src/detection/host/host.c
src/detection/os/os.c
src/detection/cpu/cpu.c
src/detection/cpuUsage/cpuUsage.c
src/detection/gpu/gpu.c
src/detection/memory/memory.c
src/detection/font/font.c
src/detection/displayserver/displayserver.c
src/detection/terminalfont/terminalfont.c
src/detection/media/media.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/bios.c
src/modules/board.c
src/modules/kernel.c
src/modules/uptime.c
src/modules/processes.c
@@ -194,10 +252,12 @@ add_library(libfastfetch OBJECT
src/modules/memory.c
src/modules/disk.c
src/modules/battery.c
src/modules/poweradapter.c
src/modules/locale.c
src/modules/vulkan.c
src/modules/localip.c
src/modules/publicip.c
src/modules/weather.c
src/modules/player.c
src/modules/song.c
src/modules/datetime.c
@@ -206,247 +266,241 @@ add_library(libfastfetch OBJECT
src/modules/colors.c
src/modules/opengl.c
src/modules/opencl.c
src/modules/users.c
)
if(ENABLE_LIBPCI)
pkg_check_modules(LIBPCI libpci)
if(LIBPCI_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LIBPCI=1)
else()
message(WARNING "Package libpci not found. Building without support.")
endif()
if(LINUX OR APPLE OR ANDROID OR BSD)
list(APPEND LIBFASTFETCH_SRC
src/detection/users/users_linux.c
src/common/processing_linux.c
src/detection/disk/disk.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/packages/packages_linux.c
src/detection/kernel/kernel_linux.c
src/detection/localip/localip_linux.c
)
endif()
if(ENABLE_VULKAN)
pkg_check_modules(VULKAN vulkan)
if(VULKAN_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_VULKAN=1)
else()
message(WARNING "Package vulkan not found. Building without support.")
endif()
if(BSD OR APPLE)
list(APPEND LIBFASTFETCH_SRC
src/common/sysctl.c
)
endif()
if(ENABLE_WAYLAND)
pkg_check_modules (WAYLAND wayland-client)
if(WAYLAND_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WAYLAND=1)
else()
message(WARNING "Package wayland-client not found. Building without support.")
endif()
if(LINUX OR ANDROID)
list(APPEND LIBFASTFETCH_SRC
src/detection/cpu/cpu_linux.c
src/detection/memory/memory_linux.c
)
endif()
if(ENABLE_XCB_RANDR)
pkg_check_modules(XCB_RANDR xcb-randr)
if(XCB_RANDR_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_XCB_RANDR=1)
else()
message(WARNING "Package xcb-randr not found. Building without support.")
endif()
if(LINUX OR ANDROID OR BSD)
list(APPEND LIBFASTFETCH_SRC
src/detection/cpuUsage/cpuUsage_linux.c
src/detection/disk/disk_linux.c
src/detection/poweradapter/poweradapter_linux.c
src/detection/temps/temps_linux.c
src/detection/opengl/opengl_linux.c
src/detection/processes/processes_linux.c
)
endif()
if(ENABLE_XCB)
pkg_check_modules (XCB xcb)
if(XCB_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_XCB=1)
else()
message(WARNING "Package xcb not found. Building without support.")
endif()
if(LINUX OR BSD)
list(APPEND LIBFASTFETCH_SRC
src/detection/host/host_linux.c
src/detection/bios/bios_linux.c
src/detection/board/board_linux.c
src/detection/os/os_linux.c
src/detection/gpu/gpu_linux.c
src/detection/battery/battery_linux.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/wayland.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/displayserver/linux/wmde.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/media/media_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/detection/font/font_linux.c
src/detection/qt.c
src/detection/gtk.c
)
endif()
if(ENABLE_XRANDR)
pkg_check_modules(XRANDR xrandr)
if(XRANDR_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_XRANDR=1)
else()
message(WARNING "Package xrandr not found. Building without support.")
endif()
if(WIN_MSYS)
list(APPEND LIBFASTFETCH_SRC
src/common/processing_linux.c
src/detection/host/host_windows.cpp
src/detection/bios/bios_windows.cpp
src/detection/board/board_windows.cpp
src/detection/cpu/cpu_windows.cpp
src/detection/gpu/gpu_windows.cpp
src/detection/battery/battery_windows.cpp
src/detection/displayserver/displayserver_windows.c
src/detection/wmtheme/wmtheme_windows.c
src/detection/opengl/opengl_windows.c
src/detection/users/users_windows.cpp
src/detection/os/os_windows.cpp
src/detection/processes/processes_windows.cpp
src/detection/disk/disk_windows.c
src/detection/cpuUsage/cpuUsage_windows.c
src/detection/cpuUsage/cpuUsage_nowait_windows.cpp
src/detection/memory/memory_windows.cpp
src/detection/font/font_windows.cpp
src/detection/terminalshell/terminalshell_linux.c
src/detection/terminalshell/terminalshell_windows.cpp
src/detection/packages/packages_linux.c
src/detection/packages/packages_windows.c
src/detection/kernel/kernel_windows.cpp
src/detection/localip/localip_windows.c
src/util/windows/wmi.cpp
# Shared
src/detection/terminalfont/terminalfont_linux.c
src/detection/poweradapter/poweradapter_linux.c
src/detection/media/media_linux.c
src/detection/temps/temps_linux.c
)
endif()
if(ENABLE_X11)
pkg_check_modules(X11 x11)
if(X11_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_X11=1)
else()
message(WARNING "Package x11 not found. Building without support.")
endif()
if(APPLE)
list(APPEND LIBFASTFETCH_SRC
src/detection/cpuUsage/cpuUsage_apple.c
src/util/apple/cf_helpers.c
src/util/apple/osascript.m
src/detection/host/host_apple.c
src/detection/bios/bios_apple.c
src/detection/board/board_apple.c
src/detection/os/os_apple.m
src/detection/cpu/cpu_apple.c
src/detection/gpu/gpu_apple.c
src/detection/battery/battery_apple.c
src/detection/poweradapter/poweradapter_apple.c
src/detection/memory/memory_apple.c
src/detection/displayserver/displayserver_apple.c
src/detection/terminalfont/terminalfont_apple.m
src/detection/media/media_apple.m
src/detection/disk/disk_apple.m
src/detection/wmtheme/wmtheme_apple.m
src/detection/temps/temps_apple.c
src/detection/font/font_apple.m
src/detection/opengl/opengl_apple.c
src/detection/processes/processes_apple.c
)
endif()
if(ENABLE_GIO)
pkg_check_modules(GIO gio-2.0)
if(GIO_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GIO=1)
else()
message(WARNING "Package gio-2.0 not found. Building without support.")
endif()
if(BSD)
list(APPEND LIBFASTFETCH_SRC
src/detection/cpu/cpu_bsd.c
src/detection/memory/memory_bsd.c
)
endif()
if(ENABLE_DCONF)
pkg_check_modules(DCONF dconf)
if(DCONF_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_DCONF=1)
else()
message(WARNING "Package dconf not found. Building without support.")
endif()
if(ANDROID)
list(APPEND LIBFASTFETCH_SRC
src/detection/host/host_android.c
src/detection/bios/bios_android.c
src/detection/board/board_android.c
src/detection/os/os_android.c
src/detection/gpu/gpu_android.c
src/detection/battery/battery_android.c
src/detection/displayserver/displayserver_android.c
src/detection/terminalfont/terminalfont_android.c
src/detection/media/media_android.c
src/detection/wmtheme/wmtheme_android.c
src/detection/font/font_android.c
)
endif()
if(ENABLE_DBUS)
pkg_check_modules(DBUS dbus-1)
if(DBUS_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_DBUS=1)
else()
message(WARNING "Package dbus-1 not found. Building without support.")
endif()
add_library(libfastfetch OBJECT
${LIBFASTFETCH_SRC}
)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
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)
endif()
if(ENABLE_XFCONF)
pkg_check_modules(XFCONF libxfconf-0)
if(XFCONF_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_XFCONF=1)
else()
message(WARNING "Package libxfconf-0 not found. Building without support.")
endif()
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX_H)
if(HAVE_UTMPX_H)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX_H)
endif()
if(ENABLE_SQLITE3)
pkg_check_modules(SQLITE3 sqlite3)
if(SQLITE3_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_SQLITE3=1)
else()
message(WARNING "Package sqlite3 not found. Building without support.")
endif()
endif()
if(ENABLE_RPM)
pkg_check_modules(RPM rpm)
if(RPM_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_RPM=1)
else()
message(WARNING "Package rpm not found. Building without support.")
endif()
endif()
if(ENABLE_IMAGEMAGICK7)
pkg_check_modules(IMAGEMAGICK7 MagickCore-7.Q16HDRI)
if(NOT IMAGEMAGICK7_FOUND)
pkg_check_modules(IMAGEMAGICK7 /usr/lib/imagemagick7/pkgconfig/MagickCore-7.Q16HDRI.pc)
endif()
if(NOT IMAGEMAGICK7_FOUND)
pkg_check_modules(IMAGEMAGICK7 MagickCore-7.Q16)
endif()
if(NOT IMAGEMAGICK7_FOUND)
pkg_check_modules(IMAGEMAGICK7 /usr/lib/imagemagick7/pkgconfig/MagickCore-7.Q16.pc)
function(ff_lib_enable VARNAME)
if(NOT ENABLE_${VARNAME})
return()
endif()
if(IMAGEMAGICK7_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_IMAGEMAGICK7=1)
else()
message(WARNING "Package MagickCore-7.Q16HDRI or MagickCore-7.Q16 not found. Building without support.")
endif()
endif()
if(ENABLE_IMAGEMAGICK6)
pkg_check_modules(IMAGEMAGICK6 MagickCore-6.Q16HDRI)
if(NOT IMAGEMAGICK6_FOUND)
pkg_check_modules(IMAGEMAGICK6 /usr/lib/imagemagick6/pkgconfig/MagickCore-6.Q16HDRI.pc)
endif()
if(NOT IMAGEMAGICK6_FOUND)
pkg_check_modules(IMAGEMAGICK6 MagickCore-6.Q16)
endif()
if(NOT IMAGEMAGICK6_FOUND)
pkg_check_modules(IMAGEMAGICK6 /usr/lib/imagemagick6/pkgconfig/MagickCore-6.Q16.pc)
pkg_search_module(${VARNAME} ${ARGN})
if(NOT ${VARNAME}_FOUND)
message(WARNING "Package ${ARGV1} not found, building without support.")
return()
endif()
if(IMAGEMAGICK6_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_IMAGEMAGICK6=1)
else()
message(WARNING "Package MagickCore-6.Q16HDRI or MagickCore-6.Q16 not found. Building without support.")
endif()
endif()
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})
if(ENABLE_ZLIB)
pkg_check_modules(ZLIB zlib)
if(ZLIB_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_ZLIB=1)
else()
message(WARNING "Package zlib not found. Building without support")
endif()
endif()
if(ENABLE_CHAFA)
if(IMAGEMAGICK6_FOUND OR IMAGEMAGICK7_FOUND)
pkg_check_modules(CHAFA chafa>=1.10)
if(CHAFA_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_CHAFA=1)
else()
message(WARNING "Package chafa>=1.10 not found. Building without support.")
foreach(FLAG ${${VARNAME}_CFLAGS_OTHER})
if(FLAG MATCHES "-D.*")
string(SUBSTRING ${FLAG} 2 -1 FLAG)
target_compile_definitions(libfastfetch PRIVATE ${FLAG})
endif()
else()
message(WARNING "Chafa not enabled, because neither ImageMagick6 nor ImageMagick7 were found. Building without support.")
endif()
endif()
endforeach()
endfunction()
if(ENABLE_EGL)
pkg_check_modules(EGL egl)
if(EGL_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EGL=1)
else()
message(WARNING "Package egl not found. Building without support.")
endif()
endif()
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 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)
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)
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(LIBCJSON libcjson)
ff_lib_enable(FREETYPE freetype2)
if(ENABLE_GLX)
pkg_check_modules(GLX glx)
if(GLX_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GLX=1)
else()
message(WARNING "Package glx not found. Building without support.")
endif()
endif()
if(ENABLE_OSMESA)
pkg_check_modules(OSMESA osmesa)
if(OSMESA_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_OSMESA=1)
else()
message(WARNING "Package osmesa not found. Building without support.")
endif()
endif()
if(ENABLE_OPENCL)
pkg_check_modules(OPENCL OpenCL)
if(OPENCL_FOUND)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_OPENCL=1)
else()
message(WARNING "Package opencl not found. Building without support.")
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 "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks"
)
elseif(WIN_MSYS)
target_link_libraries(libfastfetch
PRIVATE "-lwbemuuid"
PRIVATE "-lole32"
PRIVATE "-loleaut32"
PRIVATE "-ldwmapi"
PRIVATE "-lopengl32"
PRIVATE "-lgdi32"
PRIVATE "-liphlpapi"
)
endif()
target_include_directories(libfastfetch
PUBLIC ${PROJECT_BINARY_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}/src
PRIVATE ${LIBPCI_INCLUDE_DIRS}
PRIVATE ${VULKAN_INCLUDE_DIRS}
PRIVATE ${WAYLAND_INCLUDE_DIRS}
PRIVATE ${XCB_RANDR_INCLUDE_DIRS}
PRIVATE ${XCB_INCLUDE_DIRS}
PRIVATE ${XRANDR_INCLUDE_DIRS}
PRIVATE ${X11_INCLUDE_DIRS}
PRIVATE ${GIO_INCLUDE_DIRS}
PRIVATE ${DCONF_INCLUDE_DIRS}
PRIVATE ${DBUS_INCLUDE_DIRS}
PRIVATE ${XFCONF_INCLUDE_DIRS}
PRIVATE ${SQLITE3_INCLUDE_DIRS}
PRIVATE ${RPM_INCLUDE_DIRS}
PRIVATE ${IMAGEMAGICK7_INCLUDE_DIRS}
PRIVATE ${IMAGEMAGICK6_INCLUDE_DIRS}
PRIVATE ${ZLIB_INCLUDE_DIRS}
PRIVATE ${CHAFA_INCLUDE_DIRS}
PRIVATE ${VULKAN_INCLUDE_DIRS}
PRIVATE ${EGL_INCLUDE_DIRS}
PRIVATE ${GLX_INCLUDE_DIRS}
PRIVATE ${OSMESA_INCLUDE_DIRS}
PRIVATE ${OPENCL_INCLUDE_DIRS}
)
target_link_libraries(libfastfetch
@@ -484,8 +538,16 @@ 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()
##################
@@ -495,49 +557,60 @@ endif()
include(GNUInstallDirs)
install(
TARGETS fastfetch
DESTINATION ${CMAKE_INSTALL_BINDIR}
TARGETS fastfetch flashfetch
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
install(
TARGETS flashfetch
DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES "${CMAKE_SOURCE_DIR}/src/data/config_system.txt"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}"
RENAME "config.conf"
)
install(
FILES completions/bash
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions
RENAME ${CMAKE_PROJECT_NAME}
FILES "${CMAKE_SOURCE_DIR}/completions/bash"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"
RENAME "${CMAKE_PROJECT_NAME}"
)
install(
DIRECTORY presets
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}
DIRECTORY "${CMAKE_SOURCE_DIR}/presets"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}"
)
install(
FILES ./LICENSE
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}
FILES "${CMAKE_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${CMAKE_PROJECT_NAME}"
)
##################
# package target #
##################
set(CPACK_GENERATOR "DEB;RPM;TGZ;ZIP")
set(CPACK_GENERATOR "TGZ;ZIP")
if(LINUX)
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB;RPM")
set(CPACK_DEBIAN_PACKAGE_SECTION, "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
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)
elseif(BSD)
set(CPACK_GENERATOR "${CPACK_GENERATOR};FreeBSD")
endif()
set(CPACK_SET_DESTDIR ON)
set(CPACK_PACKAGE_CONTACT "Linus Dierheimer <Linus@Dierheimer.de>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Neofetch clone written in C")
set(CPACK_PACKAGE_DESCRIPTION "\
fastfetch is a neofetch-like tool for fetching system information and displaying them in a pretty way. \
It is written in c to achieve much better performance.\
")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/LinusDierheimer")
set(CPACK_DEBIAN_PACKAGE_SECTION, "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
include(CPack)
-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
+30 -19
View File
@@ -1,9 +1,14 @@
# fastfetch
# 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 c to achieve much better performance, in return only Linux and Android are supported. It also uses mechanisms like multithreading and caching to finish as fast as possible.
The output on my personal machine with default configurations looks like this:
<img src="screenshots/example.png" alt="example output" width="100%"/>
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, BSD, MacOS and Windows on [MSYS2](https://www.msys2.org/) 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" />
<img src="screenshots/example4.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" />
<img src="screenshots/example2.png" width="48%" align="top" />
<img src="screenshots/example3.png" width="48%" align="top" />
<img src="screenshots/example5.png" height="15%" align="top" />
## Customization
@@ -11,8 +16,8 @@ With customization and speed being two competing goals, this project actually bu
The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `~/.config/fastfetch/config.conf`. To view the available options run `fastfetch --help`.
The second executable being built is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c).
At the moment the performance difference is measurable, but too small to be human recognizable. But the leap will get bigger with more and more options coming, and on slow machines this might actually make a difference.
There are some presets defined for fastfech in [`presets`](presets), you can can load them with `--load-config`. They may also serve as a good example for format arguments.
There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config <filename>`. They may also serve as a good example for format arguments.
## Dependencies
@@ -37,35 +42,37 @@ 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 ( Windows, WSL ).
* [`freetype`](https://www.freetype.org/): Needed for Termux font detection ( Android ).
## 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, Disk, Battery, Player, Song, 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, DateTime, Date, Time, Locale, Colors, Break, Custom
```
##### Logos
```
Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Debian, Devuan, Deepin, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, Kubuntu, Linux, Manjaro, Mint, NixOS, OpenSUSE, OpenSUSE Tumbleweed, OpenSUSE LEAP, Pop!_OS, RebornOS, RedstarOS, Rocky, Ubuntu, Void, Zorin
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, Crystal, Debian, Devuan, Deepin, Endeavour, Fedora, FreeBSD, 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, 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 graphics protocol or chafas image to text conversion.
##### Package managers
```
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap
Pacman, dpkg, rpm, emerge, xbps, nix, Flatpak, Snap, apk, pkg, brew, MacPorts, scoop
```
##### 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
@@ -75,7 +82,7 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt
##### Terminal fonts
```
konsole, gnome-terminal-server, tilix, xfce4-terminal, lxterminal, TTY
Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, LXTerminal, iTerm2, Apple Terminal, TTY, Windows Terminal, Termux, mintty
```
## Building
@@ -90,6 +97,12 @@ 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.
### Building on Windows
Currently [MSYS2](https://www.msys2.org/) is required to build fastfetch. Running fastfetch requires msys2 runtime library (`msys-2.0.dll`) but not full MSYS2 environment.
Full native Windows executable is planned.
## Packaging
### Repositories
@@ -98,10 +111,8 @@ If pkg-config fails to find the headers for a library listed in [dependencies](#
### Manual
Build: Follow the [build instructions](#building).
* Create DEB / RPM: Run `cmake --build . --target package`.
* Install directly: Run `sudo cmake --install . --prefix /usr/local`
* DEB / RPM package: `cmake --build . --target package`
* Install directly: `cmake --install . --prefix /usr/local`
## FAQ
+168 -76
View File
@@ -9,28 +9,39 @@ __fastfetch_complete_help()
"os-format"
"host-format"
"kernel-format"
"uptime-format"
"processes-format"
"packages-format"
"shell-format"
"resolution-format"
"de-format"
"wm-format"
"wm-theme-format"
"theme-format"
"icons-format"
"font-format"
"cursor-format"
"terminal-format"
"terminal-font-format"
"cpu-format"
"cpu-usage-format"
"gpu-format"
"memory-format"
"swap-format"
"disk-format"
"battery-format"
"poweradapter-format"
"locale-format"
"local-ip-format"
"public-ip-format"
"player-format"
"media-format"
"datetime-format"
"date-format"
"time-format"
"vulkan-format"
"opengl-format"
"opencl-format"
)
COMPREPLY=($(compgen -W "${__ff_helps[*]}" -- "$CURRENT_WORD"))
}
@@ -57,6 +68,41 @@ __fastfetch_complete_logo()
COMPREPLY=($(compgen -W "$(fastfetch --list-logos-autocompletion)" -- "$CURRENT_WORD"))
}
__fastfetch_complete_logo_type()
{
local __ff_logo_types=(
"auto"
"builtin"
"file"
"raw"
"sixel"
"kitty"
"chafa"
)
COMPREPLY=($(compgen -W "${__ff_logo_types[*]}" -- "$CURRENT_WORD"))
}
__fastfetch_complete_binary_prefix()
{
local __ff_binary_prefixes=(
"iec"
"si"
"jedec"
)
COMPREPLY=($(compgen -W "${__ff_binary_prefixes[*]}" -- "$CURRENT_WORD"))
}
__fastfetch_complete_gl()
{
local __ff_gl_types=(
"auto"
"egl"
"glx"
"osmesa"
)
COMPREPLY=($(compgen -W "${__ff_gl_types[*]}" -- "$CURRENT_WORD"))
}
__fastfetch_complete_option()
{
local FF_OPTIONS_ALL=(
@@ -64,6 +110,9 @@ __fastfetch_complete_option()
"${FF_OPTIONS_STRING[@]}"
"${FF_OPTIONS_PATH[@]}"
"${FF_OPTIONS_LOGO[@]}"
"${FF_OPTIONS_LOGO_TYPE[@]}"
"${FF_OPTIONS_BINARY_PREFIX[@]}"
"${FF_OPTIONS_GL[@]}"
)
if [[ $WORD_COUND -lt 3 ]]; then
@@ -108,7 +157,8 @@ __fastfetch_completion()
"--list-presets"
"--list-features"
"--print-logos"
"--print-config"
"--print-config-system"
"--print-config-user"
"--print-structure"
)
@@ -127,11 +177,17 @@ __fastfetch_completion()
"--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"
)
local FF_OPTIONS_STRING=(
@@ -147,134 +203,153 @@ __fastfetch_completion()
"--logo-color-6"
"--logo-color-7"
"--logo-color-8"
"--logo-width"
"--logo-height"
"--logo-color-9"
"-c"
"--color"
"--color-keys"
"--color-title"
"--separator"
"-s"
"--structure"
"--set"
"--gl"
"--os-format"
"--set-keyless"
"--player-name"
"--public-ip-url"
"--public-ip-timeout"
"--weather-output-format"
"--weather-timeout"
"--os-key"
"--host-format"
"--os-format"
"--os-error"
"--host-key"
"--kernel-format"
"--host-format"
"--host-error"
"--kernel-key"
"--uptime-format"
"--kernel-format"
"--kernel-error"
"--uptime-key"
"--processes-format"
"--uptime-format"
"--uptime-error"
"--processes-key"
"--packages-format"
"--processes-format"
"--processes-error"
"--packages-key"
"--shell-format"
"--packages-format"
"--packages-error"
"--shell-key"
"--resolution-format"
"--shell-format"
"--shell-error"
"--resolution-key"
"--de-format"
"--resolution-format"
"--resolution-error"
"--de-key"
"--wm-format"
"--de-format"
"--de-error"
"--wm-key"
"--wm-theme-format"
"--wm-format"
"--wm-error"
"--wm-theme-key"
"--theme-format"
"--wm-theme-format"
"--wm-theme-error"
"--theme-key"
"--icons-format"
"--theme-format"
"--theme-error"
"--icons-key"
"--font-format"
"--icons-format"
"--icons-error"
"--font-key"
"--cursor-format"
"--font-format"
"--font-error"
"--cursor-key"
"--terminal-format"
"--cursor-format"
"--cursor-error"
"--terminal-key"
"--terminal-font-format"
"--terminal-format"
"--terminal-error"
"--terminal-font-key"
"--cpu-format"
"--terminal-font-format"
"--terminal-font-error"
"--cpu-key"
"--cpu-usage-format"
"--cpu-usage-key"
"--gpu-format"
"--cpu-format"
"--cpu-error"
"--cpu-useage-key"
"--cpu-useage-format"
"--cpu-useage-error"
"--gpu-key"
"--memory-format"
"--gpu-format"
"--gpu-error"
"--memory-key"
"--memory-format"
"--memory-error"
"--swap-key"
"--swap-format"
"--swap-error"
"--disk-key"
"--disk-format"
"--disk-key"
"--battery-format"
"--disk-error"
"--battery-key"
"--locale-format"
"--battery-format"
"--battery-error"
"--poweradapter-key"
"--poweradapter-format"
"--poweradapter-error"
"--locale-key"
"--disk-folders"
"--disk-key"
"--local-ip-format"
"--locale-format"
"--locale-error"
"--local-ip-key"
"--public-ip-format"
"--local-ip-format"
"--local-ip-error"
"--public-ip-key"
"--player-format"
"--public-ip-format"
"--public-ip-error"
"--weather-key"
"--weather-format"
"--weather-error"
"--player-key"
"--song-format"
"--song-key"
"--player-format"
"--player-error"
"--media-key"
"--media-format"
"--media-error"
"--datetime-key"
"--datetime-format"
"--date-format"
"--datetime-error"
"--date-key"
"--time-format"
"--date-format"
"--date-error"
"--time-key"
"--time-format"
"--time-error"
"--vulkan-key"
"--vulkan-format"
"--vulkan-error"
"--opengl-key"
"--opengl-format"
"--opengl-error"
"--opencl-key"
"--opencl-format"
"--os-error"
"--host-error"
"--kernel-error"
"--uptime-error"
"--processes-error"
"--packages-error"
"--shell-error"
"--resolution-error"
"--de-error"
"--wm-error"
"--wm-theme-error"
"--theme-error"
"--icons-error"
"--font-error"
"--cursor-error"
"--terminal-error"
"--terminal-font-error"
"--cpu-error"
"--cpu-usage-error"
"--gpu-error"
"--memory-error"
"--disk-error"
"--battery-error"
"--locale-error"
"--disk-error"
"--local-ip-error"
"--public-ip-error"
"--player-error"
"--song-error"
"--datetime-error"
"--date-error"
"--time-error"
"--vulkan-error"
"--opengl-error"
"--opencl-error"
"--users-key"
"--users-format"
"--users-error"
)
local FF_OPTIONS_PATH=(
"--load-config"
"--os-file"
"--lib-PCI"
"--lib-pci"
"--lib-vulkan"
"--lib-wayland"
"--lib-xcb-randr"
"--lib-xcb"
"--lib-Xrandr"
"--lib-xrandr"
"--lib-X11"
"--lib-gio"
"--lib-DConf"
"--lib-DBus"
"--lib-XFConf"
"--lib-dconf"
"--lib-dbus"
"--lib-xfconf"
"--lib-sqlite3"
"--lib-rpm"
"--lib-imagemagick"
@@ -285,7 +360,6 @@ __fastfetch_completion()
"--lib-osmesa"
"--lib-opencl"
"--battery-dir"
"--load-config"
)
local FF_OPTIONS_LOGO=(
@@ -293,6 +367,18 @@ __fastfetch_completion()
"--logo"
)
local FF_OPTIONS_LOGO_TYPE=(
"--logo-type"
)
local FF_OPTIONS_BINARY_PREFIX=(
"--binary-prefix"
)
local FF_OPTIONS_GL=(
"--gl"
)
if __fastfetch_previous_matches "${FF_OPTIONS_SINGLE[@]}"; then
return
elif [[ $WORD_COUND -gt 3 && ( ${COMP_WORDS[$COMP_CWORD - 2]} == "--help" || ${COMP_WORDS[$COMP_CWORD - 2]} == "-h" ) ]]; then
@@ -309,6 +395,12 @@ __fastfetch_completion()
__fastfetch_complete_path
elif __fastfetch_previous_matches "${FF_OPTIONS_LOGO[@]}"; then
__fastfetch_complete_logo
elif __fastfetch_previous_matches "${FF_OPTIONS_LOGO_TYPE[@]}"; then
__fastfetch_complete_logo_type
elif __fastfetch_previous_matches "${FF_OPTIONS_BINARY_PREFIX[@]}"; then
__fastfetch_complete_binary_prefix
elif __fastfetch_previous_matches "${FF_OPTIONS_GL[@]}"; then
__fastfetch_complete_gl
else
__fastfetch_complete_option
fi
+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:Disk:Battery:Player:Song:PublicIP:LocalIP:DateTime:Locale:Vulkan:OpenGL:OpenCL:Break:Colors
--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:PowerAdapter:Player:Song:PublicIP:LocalIP:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Weather:Break:Colors
+1 -1
View File
@@ -1,4 +1,4 @@
--disable-linewrap false
--multithreading false
--show-errors true
--show-errors
--recache
+2 -1
View File
@@ -1,2 +1,3 @@
--load-config verbose
--load-config devinfo
--load-config all
--load-config verbose
+1
View File
@@ -0,0 +1 @@
# Load with --load-config examples/1
+24
View File
@@ -0,0 +1,24 @@
# Load with --load-config examples/2
# Note that you must replace the image path to an existing image to display it.
--kitty /home/linus/Bilder/Gentoo.png
--logo-width 28
--separator "  "
--set-keyless HardwareStart=┌───────── \e[1mHardware Information\e[0m ─────────┐
--set-keyless SoftwareStart=├───────── \e[1mSoftware Information\e[0m ─────────┤
--set-keyless InformationEnd=└────────────────────────────────────────┘
--set-keyless Colors= \e[38m \e[37m \e[36m \e[35m \e[34m \e[33m \e[32m \e[31m
--structure HardwareStart:Host:CPU:GPU:SoftwareStart:OS:Kernel:WM:Shell:Terminal:TerminalFont:Packages:InformationEnd:Colors
--host-key " "
--cpu-key " "
--gpu-key " ﬙"
--os-key " "
--kernel-key " "
--wm-key " "
--shell-key " "
--terminal-key " "
--terminal-font-key " "
--packages-key " "
+7
View File
@@ -0,0 +1,7 @@
# Load with --load-config example/3
--logo debian_small
--structure Vulkan:OpenGL:OpenCL:Memory:Disk:LocalIP
--binary-prefix si
--localip-show-loop false
--disk-folders /:/home:/boot:/efi
+7
View File
@@ -0,0 +1,7 @@
# Load with --load-config examples/4
--color blue
--logo arch_small
--logo-padding-right 1
--separator "  "
--structure Date:Time:Break:Player:Media
+11
View File
@@ -0,0 +1,11 @@
# Load with --load-config examples/5
--logo none
--color reset_magenta
--structure Theme:Icons:Font:Cursor
--theme-key T
--theme-format {7}
--icons-key I
--icons-format {5}
--font-key F
--cursor-key C
+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"
+30 -31
View File
@@ -1,31 +1,30 @@
--load-config all
--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: {}"
--kernel-format "Sysname: {}; Release: {}; Version: {}"
--uptime-format "Days: {}; Hours: {}; Minutes: {}; Seconds: {}"
--processes-format "Count: {}"
--packages-format "All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; xbps: {}; flatpak: {}; snap: {}"
--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: {}"
--wm-format "Process name: {}; Pretty name: {}; Protocol: {}"
--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: {}"
--cursor-format "Theme: {}; Size: {}"
--terminal-format "Process: {}; Path: {}; Exe: {}"
--terminal-font-format "Raw: {}; Name: {}; Size: {}; Styles: {}; Pretty: {}"
--cpu-format "Name: {}; Pretty: {}; Vendor: {}; Logical online: {}; Logical configured: {}; Physical: {}; Cores: {}; temperature: {}; bios: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
--cpu-usage-format "Percentage: {}"
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}; Temperature: {}"
--memory-format "Used: {}; Total: {}; Percentage: {}"
--disk-format "Used: {}; Total: {}; Files: {}; Percentage: {}"
--battery-format "Manufactor: {}; Model: {}; Technology: {}; Capacaty: {}; Status: {}"
--player-format "Name: {}"
--song-format "Song: {}; Artist: {}; Album: {}"
--datetime-format "year: {}; yearShort: {}; month: {}; monthPretty: {}; monthName: {}; monthNameShort: {}; weekNumber: {}; weekday: {}; weekdayShort: {}; dayInYear: {}; dayInMonth: {}; dayInWeek: {}; hour: {}; hourPretty: {}; hour12: {}; hour12Pretty: {}; minute: {}; minutePretty: {}; second: {}; secondPretty: {}"
--vulkan-format "driver: {}; Api Version: {}; Conformance Version: {}"
--opengl-format "version: {}; renderer: {}; vendor: {}"
--opencl-format "version: {}; device: {}; vendor: {}"
--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: {}
--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: {}
--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: {}
--wm-format Process name: {}; Pretty name: {}; Protocol: {}
--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 Font1: {}; Font2: {}; Font3: {}; Font4: {}
--cursor-format Theme: {}; Size: {}
--terminal-format Process: {}; Path: {}; Exe: {}
--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: {}; CoreCount: {}
--memory-format Used: {}; Total: {}; Percentage: {}
--disk-format Used: {}; Total: {}; Files: {}; Percentage: {}
--battery-format Manufactor: {}; Model: {}; Technology: {}; Capacity: {}; Status: {}
--poweradapter-format Watts: {}; Name: {}; Manufactor: {}; Model: {}; Description: {}
--player-format Pretty: {}; Name: {}; Bus: {}; Url: {}
--media-format Pretty: {}; Name: {}; Artist: {}; Album: {}
--datetime-format year: {}; yearShort: {}; month: {}; monthPretty: {}; monthName: {}; monthNameShort: {}; weekNumber: {}; weekday: {}; weekdayShort: {}; dayInYear: {}; dayInMonth: {}; dayInWeek: {}; hour: {}; hourPretty: {}; hour12: {}; hour12Pretty: {}; minute: {}; minutePretty: {}; second: {}; secondPretty: {}
--vulkan-format driver: {}; Api Version: {}; Conformance Version: {}
--opengl-format version: {}; renderer: {}; vendor: {}
--opencl-format version: {}; device: {}; vendor: {}
+16 -5
View File
@@ -1,11 +1,22 @@
#!/bin/env sh
#!/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 "$@"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

+117 -16
View File
@@ -1,11 +1,18 @@
#include "fastfetch.h"
#include "common/caching.h"
#include "common/io.h"
#include "common/printing.h"
#include <stdlib.h>
#include <string.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"
#define FF_CACHE_EXTENSION_V1 "ffc1"
static void getCacheFilePath(const FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
{
@@ -41,9 +48,11 @@ void ffCacheValidate(FFinstance* instance)
{
FFstrbuf content;
ffStrbufInit(&content);
readCacheFile(instance, "cacheversion", "ffv", &content);
readCacheFile(instance, FF_CACHE_VERSION_NAME, FF_CACHE_VERSION_EXTENSION, &content);
bool isSameVersion = ffStrbufCompS(&content, FASTFETCH_PROJECT_VERSION) == 0;
const char exactVersion[] = FASTFETCH_PROJECT_VERSION FASTFETCH_PROJECT_VERSION_TWEAK;
bool isSameVersion = ffStrbufCompS(&content, exactVersion) == 0;
ffStrbufDestroy(&content);
if(isSameVersion)
return;
@@ -51,9 +60,9 @@ void ffCacheValidate(FFinstance* instance)
instance->config.recache = true;
FFstrbuf version;
ffStrbufInitA(&version, sizeof(FASTFETCH_PROJECT_VERSION));
ffStrbufAppendS(&version, FASTFETCH_PROJECT_VERSION);
writeCacheFile(instance, "cacheversion", "ffv", &version);
ffStrbufInitA(&version, sizeof(exactVersion));
ffStrbufAppendS(&version, exactVersion);
writeCacheFile(instance, FF_CACHE_VERSION_NAME, FF_CACHE_VERSION_EXTENSION, &version);
ffStrbufDestroy(&version);
}
@@ -90,7 +99,10 @@ static bool printCachedValue(FFinstance* instance, const char* moduleName, const
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)
{
ffStrbufDestroy(&content);
return false;
}
uint8_t moduleCounter = 1;
@@ -203,24 +215,113 @@ void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const
ffCacheClose(&cache);
}
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data)
typedef struct FFCacheRead
{
FFstrbuf path;
ffStrbufInitA(&path, 128);
getCacheFilePath(instance, moduleName, FF_CACHE_EXTENSION_DATA, &path);
ffWriteFileData(path.chars, dataSize, data);
ffStrbufDestroy(&path);
FFstrbuf data;
uint32_t position;
} FFCacheRead;
static bool cacheReadStrbuf(FFCacheRead* cacheRead, FFstrbuf* strbuf)
{
if(cacheRead->position >= cacheRead->data.length)
return false;
ffStrbufAppendS(strbuf, cacheRead->data.chars + cacheRead->position);
cacheRead->position += strbuf->length + 1; // skip the null byte too
return true;
}
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data)
static bool cacheReadData(FFCacheRead* cacheRead, size_t dataSize, void* data)
{
if(cacheRead->position + dataSize > cacheRead->data.length)
return false;
memcpy(data, cacheRead->data.chars + cacheRead->position, dataSize);
cacheRead->position += (uint32_t) dataSize;
return true;
}
static bool cacheResetStrbuf(FFCache* cache, FFstrbuf* strbuf)
{
FF_UNUSED(cache);
ffStrbufClear(strbuf);
return true;
}
static bool cacheResetData(FFCache* cacheRead, size_t dataSize, void* data)
{
FF_UNUSED(cacheRead, dataSize, data);
return true;
}
bool ffCacheRead(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback)
{
if(instance->config.recache)
return false;
FFCacheRead cache;
bool result;
FFstrbuf path;
ffStrbufInitA(&path, 128);
getCacheFilePath(instance, moduleName, FF_CACHE_EXTENSION_DATA, &path);
ssize_t result = ffReadFileData(path.chars, dataSize, data);
getCacheFilePath(instance, cacheName, FF_CACHE_EXTENSION_V1, &path);
cache.position = 0;
ffStrbufInitA(&cache.data, 256);
result = ffAppendFileBuffer(path.chars, &cache.data);
if(result)
result = callback(obj, &cache, (FFCacheMethodStrbuf) cacheReadStrbuf, (FFCacheMethodData) cacheReadData);
if(result)
result = cache.position == cache.data.length;
if(!result)
callback(obj, NULL, (FFCacheMethodStrbuf) cacheResetStrbuf, (FFCacheMethodData) cacheResetData);
ffStrbufDestroy(&cache.data);
ffStrbufDestroy(&path);
return result;
}
typedef struct FFCacheWrite
{
FFstrbuf data;
} FFCacheWrite;
static bool cacheWriteStrbuf(FFCacheWrite* cacheWrite, FFstrbuf* strbuf)
{
ffStrbufEnsureFree(&cacheWrite->data, strbuf->length);
memcpy(cacheWrite->data.chars + cacheWrite->data.length, strbuf->chars, strbuf->length +1); //Copy the nullbyte too
cacheWrite->data.length += strbuf->length + 1;
return true;
}
static bool cacheWriteData(FFCacheWrite* cacheWrite, size_t dataSize, const void* data)
{
ffStrbufEnsureFree(&cacheWrite->data, (uint32_t) dataSize);
memcpy(cacheWrite->data.chars + cacheWrite->data.length, data, dataSize);
cacheWrite->data.length += (uint32_t) dataSize;
return true;
}
void ffCacheWrite(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback)
{
if(!instance->config.cacheSave)
return;
FFCacheWrite cache;
FFstrbuf path;
ffStrbufInitA(&path, 128);
getCacheFilePath(instance, cacheName, FF_CACHE_EXTENSION_V1, &path);
ffStrbufInitA(&cache.data, 256);
callback(obj, &cache, (FFCacheMethodStrbuf) cacheWriteStrbuf, (FFCacheMethodData) cacheWriteData);
ffWriteFileBuffer(path.chars, &cache.data);
ffStrbufDestroy(&cache.data);
ffStrbufDestroy(&path);
return result > 0 && (size_t) result == dataSize;
}
+33
View File
@@ -0,0 +1,33 @@
#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);
typedef void FFCache;
typedef bool(*FFCacheMethodStrbuf)(FFCache* cache, FFstrbuf* strbuf);
typedef bool(*FFCacheMethodData)(FFCache* cache, size_t dataSize, void* data);
typedef bool(*FFCacheMethodCallback)(void* data, FFCache* cache, FFCacheMethodStrbuf strbufMethod, FFCacheMethodData dataMethod);
bool ffCacheRead(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback);
void ffCacheWrite(const FFinstance* instance, void* obj, const char* cacheName, FFCacheMethodCallback callback);
#endif
+27 -1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/font.h"
#include <string.h>
@@ -188,10 +189,35 @@ void ffFontInitPango(FFfont* font, const char* data)
fontInitPretty(font);
}
void ffFontInitCopy(FFfont* font, const char* name)
void ffFontInitValues(FFfont* font, const char* name, const char* size)
{
fontInit(font);
ffStrbufAppendS(&font->name, name);
ffStrbufAppendS(&font->size, size);
fontInitPretty(font);
}
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);
}
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#ifndef FF_INCLUDED_common_font
#define FF_INCLUDED_common_font
#include "util/FFstrbuf.h"
#include "util/FFlist.h"
typedef struct FFfont
{
FFstrbuf pretty;
FFstrbuf name;
FFstrbuf size;
FFlist styles;
} FFfont;
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
+8 -5
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/format.h"
#include "common/parsing.h"
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
{
@@ -53,20 +55,21 @@ 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)
{
return arg->value != NULL && (
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value == *(double*)arg->value) || //NaN
(arg->type == FF_FORMAT_ARG_TYPE_DOUBLE && *(double*)arg->value > 0.0) || //Also is false for NaN
(arg->type == FF_FORMAT_ARG_TYPE_INT && *(int*)arg->value > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_STRBUF && ((FFstrbuf*)arg->value)->length > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_STRING && *(const char*)arg->value != '\0') ||
(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)
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#ifndef FF_INCLUDED_common_format
#define FF_INCLUDED_common_format
typedef enum FFformatargtype
{
FF_FORMAT_ARG_TYPE_NULL = 0,
FF_FORMAT_ARG_TYPE_UINT,
FF_FORMAT_ARG_TYPE_UINT16,
FF_FORMAT_ARG_TYPE_UINT8,
FF_FORMAT_ARG_TYPE_INT,
FF_FORMAT_ARG_TYPE_STRING,
FF_FORMAT_ARG_TYPE_STRBUF,
FF_FORMAT_ARG_TYPE_DOUBLE,
FF_FORMAT_ARG_TYPE_LIST
} FFformatargtype;
typedef struct FFformatarg
{
FFformatargtype type;
const void* value;
} FFformatarg;
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
#endif
+254 -15
View File
@@ -1,9 +1,15 @@
#include "fastfetch.h"
#include "common/caching.h"
#include "common/parsing.h"
#include "detection/qt.h"
#include "detection/gtk.h"
#include "detection/displayserver/displayserver.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)
{
@@ -15,7 +21,7 @@ static void initConfigDirs(FFstate* state)
ffListInit(&state->configDirs, sizeof(FFstrbuf));
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if(xdgConfigHome != NULL)
if(ffStrSet(xdgConfigHome))
{
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
ffStrbufInitA(buffer, 64);
@@ -25,7 +31,10 @@ static void initConfigDirs(FFstate* state)
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
if(ffListFirstIndexComp(&state->configDirs, element, strbufEqualsAdapter) < state->configDirs.length - 1) \
--state->configDirs.length;
{ \
ffStrbufDestroy(ffListGet(&state->configDirs, state->configDirs.length - 1)); \
--state->configDirs.length; \
}
FFstrbuf* userConfigHome = ffListAdd(&state->configDirs);
ffStrbufInitA(userConfigHome, 64);
@@ -49,6 +58,12 @@ static void initConfigDirs(FFstate* state)
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
xdgConfigDirs.chars[colonIndex] = '\0';
if(!ffStrSet(xdgConfigDirs.chars + startIndex))
{
startIndex = colonIndex + 1;
continue;
}
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
ffStrbufInitA(buffer, 64);
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
@@ -57,15 +72,16 @@ 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)
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
@@ -98,7 +114,10 @@ static void initState(FFstate* state)
state->keysHeight = 0;
state->passwd = getpwuid(getuid());
uname(&state->utsname);
sysinfo(&state->sysinfo);
#if FF_HAVE_SYSINFO_H
sysinfo(&state->sysinfo);
#endif
initConfigDirs(state);
initCacheDir(state);
@@ -113,17 +132,19 @@ static void initModuleArg(FFModuleArgs* args)
static void defaultConfig(FFinstance* instance)
{
ffStrbufInit(&instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_AUTO;
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.logoColors[i]);
instance->config.logoWidth = 0;
instance->config.logoHeight = 0; //preserve aspect ratio
instance->config.logoPaddingLeft = 0;
instance->config.logoPaddingRight = 4;
instance->config.logoPrintRemaining = true;
ffStrbufInit(&instance->config.logo.colors[i]);
instance->config.logo.width = 0;
instance->config.logo.height = 0; //preserve aspect ratio
instance->config.logo.paddingLeft = 0;
instance->config.logo.paddingRight = 4;
instance->config.logo.printRemaining = true;
ffStrbufInit(&instance->config.colorKeys);
ffStrbufInit(&instance->config.colorTitle);
ffStrbufInit(&instance->config.mainColor);
ffStrbufInit(&instance->config.separator);
ffStrbufAppendS(&instance->config.separator, ": ");
@@ -134,11 +155,15 @@ static void defaultConfig(FFinstance* instance)
instance->config.disableLinewrap = true;
instance->config.hideCursor = true;
instance->config.escapeBedrock = true;
instance->config.binaryPrefixType = FF_BINARY_PREFIX_TYPE_IEC;
instance->config.glType = FF_GL_TYPE_AUTO;
instance->config.pipe = false;
instance->config.multithreading = true;
initModuleArg(&instance->config.os);
initModuleArg(&instance->config.host);
initModuleArg(&instance->config.bios);
initModuleArg(&instance->config.board);
initModuleArg(&instance->config.kernel);
initModuleArg(&instance->config.uptime);
initModuleArg(&instance->config.processes);
@@ -158,11 +183,14 @@ static void defaultConfig(FFinstance* instance)
initModuleArg(&instance->config.cpuUsage);
initModuleArg(&instance->config.gpu);
initModuleArg(&instance->config.memory);
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.player);
initModuleArg(&instance->config.song);
initModuleArg(&instance->config.dateTime);
@@ -171,6 +199,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);
@@ -192,8 +221,17 @@ 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);
instance->config.cpuTemp = false;
instance->config.gpuTemp = false;
instance->config.batteryTemp = false;
instance->config.titleFQDN = false;
ffStrbufInitA(&instance->config.diskFolders, 0);
instance->config.diskRemovable = false;
ffStrbufInitA(&instance->config.batteryDir, 0);
@@ -202,8 +240,13 @@ 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);
@@ -216,6 +259,88 @@ void ffInitInstance(FFinstance* instance)
defaultConfig(instance);
}
#if !defined(__ANDROID__) && !defined(_WIN32) && !defined(__MSYS__)
static void* connectDisplayServerThreadMain(void* instance)
{
ffConnectDisplayServer((FFinstance*)instance);
return NULL;
}
#if !defined(__APPLE__)
static void* detectPlasmaThreadMain(void* instance)
{
ffDetectQt((FFinstance*)instance);
return NULL;
}
static void* detectGTK2ThreadMain(void* instance)
{
ffDetectGTK2((FFinstance*)instance);
return NULL;
}
static void* detectGTK3ThreadMain(void* instance)
{
ffDetectGTK3((FFinstance*)instance);
return NULL;
}
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;
}
void startDetectionThreads(FFinstance* instance)
{
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
pthread_detach(startThreadsThread);
}
#else // !__APPLE__
void startDetectionThreads(FFinstance* instance)
{
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, connectDisplayServerThreadMain, instance);
pthread_detach(startThreadsThread);
}
#endif // __APPLE__
#else // !__ANDROID__
void startDetectionThreads(FFinstance* instance)
{
FF_UNUSED(instance);
}
#endif // __ANDROID__
static volatile bool ffDisableLinewrap = true;
static volatile bool ffHideCursor = true;
@@ -237,6 +362,9 @@ static void exitSignalHandler(int signal)
void ffStart(FFinstance* instance)
{
if(instance->config.multithreading)
startDetectionThreads(instance);
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
@@ -266,12 +394,117 @@ void ffStart(FFinstance* instance)
void ffFinish(FFinstance* instance)
{
if(instance->config.logoPrintRemaining)
if(instance->config.logo.printRemaining)
ffLogoPrintRemaining(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);
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.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.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);
ffStrbufDestroy(&instance->state.cacheDir);
}
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()
{
@@ -339,6 +572,12 @@ void ffListFeatures()
#ifdef FF_HAVE_OPENCL
"opencl\n"
#endif
#ifdef FF_HAVE_LIBCJSON
"libcjson\n"
#endif
#ifdef FF_HAVE_FREETYPE
"freetype"
#endif
""
, stdout);
}
+1 -1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/io.h"
#include <sys/stat.h>
#include <unistd.h>
@@ -22,7 +23,6 @@ static void createSubfolders(const char* fileName)
ffStrbufDestroy(&path);
}
bool ffWriteFDBuffer(int fd, const FFstrbuf* content)
{
return write(fd, content->chars, content->length) != -1;
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#ifndef FF_INCLUDED_common_io
#define FF_INCLUDED_common_io
#include "fastfetch.h"
#include <sys/types.h> //mode_t
bool ffWriteFDBuffer(int fd, const FFstrbuf* content);
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer);
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer);
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);
bool ffFileExists(const char* fileName, mode_t mode);
// Not thread safe!
void ffSuppressIO(bool suppress);
FF_C_SCANF(2, 3) void ffGetTerminalResponse(const char* request, const char* format, ...);
#endif
+30 -6
View File
@@ -1,12 +1,33 @@
#include "fastfetch.h"
#include "common/library.h"
#include <stdarg.h>
#include <dlfcn.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
#ifdef __SANITIZE_ADDRESS__
#define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
#else
#define FF_DLOPEN_FLAGS RTLD_LAZY
#endif
static void* libraryLoad(const char* path, int maxVersion)
{
void* result = dlopen(path, RTLD_LAZY);
if(result != NULL)
void* result = dlopen(path, FF_DLOPEN_FLAGS);
#if defined(_WIN32) || defined(__MSYS__)
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
FF_UNUSED(maxVersion)
#else
if(result != NULL || maxVersion < 0)
return result;
FFstrbuf pathbuf;
@@ -19,7 +40,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 +48,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);
+49
View File
@@ -0,0 +1,49 @@
#pragma once
#ifndef FF_INCLUDED_common_library
#define FF_INCLUDED_common_library
#include <dlfcn.h>
#if defined(_WIN32) || defined(__MSYS__)
#define FF_LIBRARY_EXTENSION ".dll"
#elif defined(__APPLE__)
#define FF_LIBRARY_EXTENSION ".dylib"
#else
#define FF_LIBRARY_EXTENSION ".so"
#endif
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
void* libraryObjectName = ffLibraryLoad(userLibraryName, __VA_ARGS__, NULL);\
if(libraryObjectName == NULL) \
return returnValue;
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
symbolMapping = dlsym(library, #symbolName); \
if(symbolMapping == NULL) \
{ \
dlclose(library); \
return returnValue; \
}
#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_MESSAGE(library, symbolName) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed");
#define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, varName.ff ## symbolName, symbolName, returnValue);
#define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, varName.ff ## symbolName, symbolName, "dlsym " #symbolName " failed");
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, varName->ff ## symbolName, symbolName, returnValue);
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
#endif
+38 -21
View File
@@ -1,41 +1,43 @@
#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)
int ffNetworkingSendHttpRequest(const char* host, const char* path, const char* headers, uint32_t timeout)
{
struct addrinfo hints = {0};
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
struct addrinfo hints = {
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo* addr;
if(getaddrinfo(host, "80", &hints, &addr) != 0)
return;
return -1;
int sock = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(sock == -1)
int sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(sockfd == -1)
{
freeaddrinfo(addr);
return;
return -1;
}
if(timeout > 0)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = timeout * 1000; //milliseconds to microseconds
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
timev.tv_usec = (__typeof__(timev.tv_usec)) (timeout * 1000); //milliseconds to microseconds
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
}
if(connect(sock, addr->ai_addr, addr->ai_addrlen) == -1)
if(connect(sockfd, addr->ai_addr, addr->ai_addrlen) == -1)
{
close(sock);
close(sockfd);
freeaddrinfo(addr);
return;
return -1;
}
freeaddrinfo(addr);
@@ -46,16 +48,23 @@ void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, F
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&command, host);
ffStrbufAppendS(&command, "\r\n\r\n");
ffStrbufAppendS(&command, "\r\n");
ffStrbufAppendS(&command, headers);
ffStrbufAppendS(&command, "\r\n");
if(send(sock, command.chars, command.length, 0) == -1)
if(send(sockfd, command.chars, command.length, 0) == -1)
{
ffStrbufDestroy(&command);
close(sock);
return;
close(sockfd);
return -1;
}
ffStrbufDestroy(&command);
return sockfd;
}
ssize_t received = recv(sock, buffer->chars + buffer->length, ffStrbufGetFree(buffer), 0);
bool ffNetworkingRecvHttpResponse(int sockfd, FFstrbuf* buffer)
{
ssize_t received = recv(sockfd, buffer->chars + buffer->length, ffStrbufGetFree(buffer), 0);
if(received > 0)
{
@@ -63,6 +72,14 @@ void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, F
buffer->chars[buffer->length] = '\0';
}
ffStrbufDestroy(&command);
close(sock);
close(sockfd);
return ffStrbufStartsWithS(buffer, "HTTP/1.1 200 OK\r\n");
}
bool ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, const char* headers, FFstrbuf* buffer)
{
int sockfd = ffNetworkingSendHttpRequest(host, path, headers, timeout);
if(sockfd > 0)
return ffNetworkingRecvHttpResponse(sockfd, buffer);
return false;
}
+12
View File
@@ -0,0 +1,12 @@
#pragma once
#ifndef FF_INCLUDED_common_networking
#define FF_INCLUDED_common_networking
#include "util/FFstrbuf.h"
int ffNetworkingSendHttpRequest(const char* host, const char* path, const char* headers, uint32_t timeout);
bool ffNetworkingRecvHttpResponse(int sock, FFstrbuf* buffer);
bool ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, const char* headers, FFstrbuf* buffer);
#endif
+37 -6
View File
@@ -1,17 +1,17 @@
#include "fastfetch.h"
#include "common/parsing.h"
#include <ctype.h>
#include <inttypes.h>
bool ffStrSet(const char* str)
{
if(str == NULL)
return false;
while(*str != '\0')
{
if(*str != ' ' && *str != '\t' && *str != '\n' && *str != '\r')
return true;
}
while(isspace(*str))
str++;
return false;
return *str != '\0';
}
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch)
@@ -65,6 +65,37 @@ void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty)
ffStrbufAppendF(pretty, ".%u", version->patch);
}
static void parseSize(FFstrbuf* result, uint64_t bytes, uint32_t base, uint8_t prefixesLength, const char** prefixes)
{
long double size = (long double) bytes;
uint8_t counter = 0;
while(size > base && counter < prefixesLength - 1)
{
size /= base;
counter++;
}
if(counter == 0)
ffStrbufAppendF(result, "%"PRIu64" %s", bytes, prefixes[0]);
else if(counter < 3 || (counter == 3 && size < 100.0))
ffStrbufAppendF(result, "%.2Lf %s", size, prefixes[counter]);
else
ffStrbufAppendF(result, "%.0Lf %s", size, prefixes[counter]);
}
void ffParseSize(uint64_t bytes, FFBinaryPrefixType binaryPrefix, FFstrbuf* result)
{
if(binaryPrefix == FF_BINARY_PREFIX_TYPE_IEC)
parseSize(result, bytes, 1024, 5, (const char*[]) {"B", "KiB", "MiB", "GiB", "TiB"});
else if(binaryPrefix == FF_BINARY_PREFIX_TYPE_SI)
parseSize(result, bytes, 1000, 5, (const char*[]) {"B", "kB", "MB", "GB", "TB"});
else if(binaryPrefix == FF_BINARY_PREFIX_TYPE_JEDEC)
parseSize(result, bytes, 1024, 5, (const char*[]) {"B", "KB", "MB", "GB", "TB"});
else
parseSize(result, bytes, 1024, 1, (const char*[]) {"B"});
}
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4)
{
if(gtk2->length > 0 && gtk3->length > 0 && gtk4->length > 0)
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#ifndef FF_INCLUDED_parsing_h
#define FF_INCLUDED_parsing_h
#include <stdint.h>
typedef struct FFVersion
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} FFVersion;
#define FF_VERSION_INIT ((FFVersion) {0})
bool ffStrSet(const char* str);
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty);
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
void ffParseSize(uint64_t bytes, FFBinaryPrefixType binaryPrefix, FFstrbuf* result);
#endif
+40 -3
View File
@@ -1,13 +1,18 @@
#include "fastfetch.h"
#include "common/printing.h"
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
{
ffLogoPrintLine(instance);
//This is used by --set-keyless, in this case we wan't neither the module name nor the separator
if(moduleName == NULL)
return;
if(!instance->config.pipe)
{
fputs(FASTFETCH_TEXT_MODIFIER_RESET FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
ffPrintColor(&instance->config.mainColor);
ffPrintColor(&instance->config.colorKeys);
}
//NULL check is required for modules with custom keys, e.g. disk with the folder path
@@ -25,7 +30,7 @@ void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t mod
ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
});
ffStrbufWriteTo(&key, stdout);
ffPrintUserString(key.chars);
ffStrbufDestroy(&key);
}
@@ -48,7 +53,8 @@ void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t m
if(buffer.length > 0)
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
ffStrbufPutTo(&buffer, stdout);
ffPrintUserString(buffer.chars);
putchar('\n');
}
ffStrbufDestroy(&buffer);
@@ -124,3 +130,34 @@ void ffPrintCharTimes(char c, uint32_t times)
for(uint32_t i = 0; i < times; i++)
putchar(c);
}
void ffPrintUserString(const char* value)
{
while(*value != '\0')
{
if(*value != '\\')
{
putchar(*value);
++value;
continue;
}
++value;
if(*value == 'n')
putchar('\n');
else if(*value == 't')
putchar('\t');
else if(*value == 'e')
putchar('\e');
else if(*value == '\\')
putchar('\\');
else
{
putchar('\\');
putchar(*value);
}
++value;
}
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#ifndef FF_INCLUDED_common_printing
#define FF_INCLUDED_common_printing
#include "fastfetch.h"
#include "common/format.h"
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);
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);
#endif
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_common_processing
#define FF_INCLUDED_common_processing
#include "util/FFstrbuf.h"
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
#endif
@@ -1,19 +1,21 @@
#include "fastfetch.h"
#include "common/processing.h"
#include "common/io.h"
#include <stdlib.h>
#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)
@@ -31,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,
};
FFstrbuf cmdline;
ffStrbufInit(&cmdline);
for(char* const* parg = argv; *parg; ++parg)
{
if(cmdline.length > 0)
ffStrbufAppendC(&cmdline, ' ');
ffStrbufAppendF(&cmdline, "\"%s\"", * parg);
}
BOOL 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[128];
DWORD nRead;
while(ReadFile(hChildStdoutRead, str, sizeof(str), &nRead, NULL) && nRead > 0)
{
ffStrbufAppendNS(buffer, nRead, str);
if(nRead < sizeof(str))
break;
}
CloseHandle(hChildStdoutRead);
return NULL;
}
+7 -13
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/properties.h"
#include <stdlib.h>
@@ -88,10 +89,13 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer)
// The following functions return true if the file was found, independently if start was found
// Buffers which already contain content are not overwritten
// The last occurence of start in the first file will be the one used
// The *Values methods always return true, if all properties were already found before, without testing if the file exists
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
{
FILE* file = fopen(filename, "r");
if(file == NULL)
return false;
bool valueStorage[4];
bool* unsetValues;
@@ -107,17 +111,8 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
allSet = false;
}
FILE* file = fopen(filename, "r");
if(file == NULL)
return false;
if(allSet)
{
fclose(file);
if(unsetValues != valueStorage)
free(unsetValues);
return true;
}
goto done;
char* line = NULL;
size_t len = 0;
@@ -139,11 +134,10 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
if(line != NULL)
free(line);
done:
fclose(file);
if(unsetValues != valueStorage)
free(unsetValues);
return true;
}
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#ifndef FF_INCLUDED_common_properties
#define FF_INCLUDED_common_properties
#include "util/FFstrbuf.h"
typedef struct FFpropquery
{
const char* start;
FFstrbuf* buffer;
} FFpropquery;
bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer);
bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer);
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer);
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
#endif
+23 -15
View File
@@ -1,8 +1,17 @@
#include "fastfetch.h"
#include "common/settings.h"
#include "common/library.h"
#include "common/io.h"
#include <pthread.h>
#include <string.h>
#include <dlfcn.h>
typedef enum FFInitState
{
FF_INITSTATE_UNINITIALIZED = 0,
FF_INITSTATE_SUCCESSFUL = 1,
FF_INITSTATE_FAILED = 2
} FFInitState;
#define FF_LIBRARY_DATA_LOAD_INIT(dataObject, userLibraryName, ...) \
static dataObject data; \
@@ -80,7 +89,7 @@ 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);
@@ -105,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)
@@ -134,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;
@@ -152,7 +161,7 @@ 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);
@@ -172,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)
@@ -190,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);
@@ -222,7 +231,7 @@ 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);
@@ -239,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)
@@ -262,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;
@@ -343,10 +352,9 @@ int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, cons
#ifdef __ANDROID__
#include <sys/system_properties.h>
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
uint32_t originalLength = result->length;
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) {
ffStrbufEnsureFree(result, PROP_VALUE_MAX);
result->length += (uint32_t) __system_property_get(propName, result->chars + result->length);
return result->length > originalLength;
result->chars[result->length] = '\0';
}
#endif
#endif //__ANDROID__
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#ifndef FF_INCLUDED_common_settings
#define FF_INCLUDED_common_settings
#include "fastfetch.h"
typedef enum FFvarianttype
{
FF_VARIANT_TYPE_STRING,
FF_VARIANT_TYPE_BOOL,
FF_VARIANT_TYPE_INT
} FFvarianttype;
typedef union FFvariant
{
const char* strValue;
int32_t intValue;
struct
{
bool boolValueSet;
bool boolValue;
};
} FFvariant;
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
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);
#ifdef __ANDROID__
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
#endif
#endif
+53
View File
@@ -0,0 +1,53 @@
#include "sysctl.h"
#include <stdlib.h>
void 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;
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';
}
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;
}
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#ifndef FF_INCLUDED_common_sysctl
#define FF_INCLUDED_common_sysctl
#include "fastfetch.h"
#include <sys/types.h>
#include <sys/sysctl.h>
void ffSysctlGetString(const char* propName, FFstrbuf* result);
int ffSysctlGetInt(const char* propName, int defaultValue);
int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
#endif
-72
View File
@@ -1,72 +0,0 @@
#include "fastfetch.h"
#include <pthread.h>
static inline void* detectPlasmaThreadMain(void* instance)
{
ffDetectPlasma((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK2ThreadMain(void* instance)
{
ffDetectGTK2((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK3ThreadMain(void* instance)
{
ffDetectGTK3((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK4ThreadMain(void* instance)
{
ffDetectGTK4((FFinstance*)instance);
return NULL;
}
static inline void* connectDisplayServerThreadMain(void* instance)
{
ffConnectDisplayServer((FFinstance*)instance);
return NULL;
}
static inline 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;
}
void ffStartDetectionThreads(FFinstance* instance)
{
//Android needs none of the things that are detected here
//And using gsettings sometimes hangs the program in android for some unknown reason,
//and since we don't need it we just never call it.
#ifdef __ANDROID__
return;
#endif
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
pthread_detach(startThreadsThread);
}
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#ifndef FF_INCLUDED_common_time
#define FF_INCLUDED_common_time
#include <stdint.h>
#if defined(_WIN32) || defined(__MSYS__)
#include <synchapi.h>
#include <sysinfoapi.h>
#else
#include <sys/time.h>
#include <time.h>
#endif
static inline uint64_t ffTimeGetTick() //In msec
{
#if defined(_WIN32) || defined(__MSYS__)
return GetTickCount64();
#else
struct timeval timeNow;
gettimeofday(&timeNow, NULL);
return (uint64_t)((timeNow.tv_sec * 1000) + (timeNow.tv_usec / 1000));
#endif
}
static inline void ffTimeSleep(uint32_t msec)
{
#if defined(_WIN32) || defined(__MSYS__)
SleepEx(msec, TRUE);
#else
nanosleep(&(struct timespec){ msec / 1000, (msec % 1000) * 1000000 }, NULL);
#endif
}
#endif
+16
View File
@@ -0,0 +1,16 @@
# Fastfetch system configuration
# This file sets the default config for all users of the system.
# For more information about how configuration files work,
# see ~/.config/fastfetch/config.conf, generated during first run.
# All options that can be put there (or passed as argument) can be put here too.
# Use fastfetch --print-config-system > /etc/fastfetch/config.conf
# to overwrite this file with the current default file.
# User config option
# Sets if fastfetch should load user provided configuration.
# If this is off, fastfetch ignores the user config file and any passed arguments
# Must be true or false
# Default is true.
#--load-user-config true
@@ -5,8 +5,8 @@
# Whitespaces are trimmed at the beginning and the end.
# Empty lines or lines starting with # are ignored.
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
# Use fastfetch --print-config > ~/.config/fastfetch/config.conf to overwrite this with the current defaults
# 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.
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
@@ -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.
@@ -113,12 +113,31 @@
# Default is true.
#--logo-print-remaining true
# Color option:
# Color keys option:
# Sets the color of the keys.
# Must be linux console color codes or the name of a color.
# Default is the primary color of the logo.
# Default is the key color of the logo.
# Use "fastfetch --help color" to learn more and see examples.
#--color magenta
#--color-keys magenta
# Color title option:
# Sets the color of the title.
# Must be linux console color codes or the name of a color.
# Default is the title color of the logo.
# Use "fastfetch --help color" to learn more and see examples.
#--color-title magenta
# Binary prefix option:
# Sets the binary prefix to use.
# Must be a IEC, SI or JEDEC.
# Default is IEC.
#--binary-prefix IEC
# Title FQDN option:
# Sets if the title should use the fully qualified domain name.
# Must be true or false.
# Default is false.
#--title-fqdn false
# Separator option:
# Sets the string placed between a key and its value.
@@ -132,12 +151,30 @@
# 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.
@@ -187,17 +224,21 @@
#--cpu-usage-key CPU Usage
#--gpu-key GPU {1}
#--memory-key Memory
#--swap-key Swap
#--disk-key Disk ({1})
#--battery-key Battery {1}
#--poweradapter-key Power Adapter {1}
#--locale-key Locale
#--local-ip-key Local IP ({1})
#--public-ip-key Public IP
#--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.
@@ -225,17 +266,21 @@
#--cpu-usage-format
#--gpu-format
#--memory-format
#--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
@@ -263,17 +308,21 @@
#--cpu-usage-error
#--gpu-error
#--memory-error
#--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.
@@ -297,4 +346,6 @@
#--lib-egl /usr/lib/libEGL.so
#--lib-glx /usr/lib/libGLX.so
#--lib-osmesa /usr/lib/libOSMesa.so
#--lib-opencl /usr/lib/libOpenCL.so
#--lib-opencl /usr/lib/libOpenCL.so
#--lib-cjson /usr/lib/libcjson.so
#--lib-freetype /data/data/com.termux/files/usr/lib
+27 -12
View File
@@ -1,16 +1,17 @@
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: prints the default config and exits
--print-structure: prints the default stucture and exits
-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
General options:
-r,--recache <?value>: generate new cached values
@@ -39,12 +40,16 @@ Logo options:
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.
-c,--color <color>: sets the color of the keys. Must be a linux console color code or the name of a color (+)
--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
General module options:
--<module>-format <format>: Sets the format string to use for each specific module.
@@ -79,16 +84,26 @@ 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"
--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-removable <?value>: Sets if removable volume 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>: Sets the opengl context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
+3 -1
View File
@@ -15,6 +15,7 @@ Icons
Kernel
Locale
LocalIP
Media
Memory
OS
OpenCL
@@ -23,10 +24,11 @@ Packages
Player
Processes
PublicIP
PowerAdapter
Resolution
Separator
Shell
Song
Swap
Terminal
TerminalFont
Theme
+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;
FFstrbuf capacity;
FFstrbuf status;
double temperature;
} BatteryResult;
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results);
#endif
+8
View File
@@ -0,0 +1,8 @@
#include "fastfetch.h"
#include "battery.h"
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
FF_UNUSED(instance, results)
return "Unimplemented";
}
+109
View File
@@ -0,0 +1,109 @@
#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()
{
FFlist 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;
ffListDestroy(&temps);
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);
ffStrbufInit(&battery->capacity);
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";
ffStrbufAppendF(&battery->capacity, "%.0f", 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;
}
ffStrbufDestroy(&testBatteryBuffer);
BatteryResult* result = ffListAdd(results);
//capacity must exist and be not empty
ffStrbufInit(&result->capacity);
ffStrbufAppendS(dir, "/capacity");
ffReadFileBuffer(dir->chars, &result->capacity);
ffStrbufSubstrBefore(dir, dirLength);
if(result->capacity.length == 0)
{
ffStrbufDestroy(&result->capacity);
--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;
}
+70
View File
@@ -0,0 +1,70 @@
extern "C" {
#include "battery.h"
}
#include "util/windows/wmi.hpp"
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
FF_UNUSED(instance);
//https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-battery
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT SystemName, Name, Chemistry, EstimatedChargeRemaining, BatteryStatus FROM Win32_Battery", nullptr);
if(!pEnumerator)
return "Query WMI service failed";
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;
while(SUCCEEDED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) && uReturn != 0)
{
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->manufacturer);
ffGetWmiObjString(pclsObj, L"SystemName", &battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffGetWmiObjString(pclsObj, L"Name", &battery->modelName);
uint64_t chemistry;
ffGetWmiObjUnsigned(pclsObj, L"Chemistry", &chemistry);
switch(chemistry)
{
case 1: ffStrbufInitS(&battery->technology, "Other"); break;
case 2: ffStrbufInitS(&battery->technology, "Unknown"); break;
case 3: ffStrbufInitS(&battery->technology, "Lead Acid"); break;
case 4: ffStrbufInitS(&battery->technology, "Nickel Cadmium"); break;
case 5: ffStrbufInitS(&battery->technology, "Nickel Metal Hydride"); break;
case 6: ffStrbufInitS(&battery->technology, "Lithium-ion"); break;
case 7: ffStrbufInitS(&battery->technology, "Zinc air"); break;
case 8: ffStrbufInitS(&battery->technology, "Lithium Polymer"); break;
}
uint64_t capacity;
ffGetWmiObjUnsigned(pclsObj, L"EstimatedChargeRemaining", &capacity);
ffStrbufInitF(&battery->capacity, "%d", (int)capacity);
uint64_t batteryStatus;
ffGetWmiObjUnsigned(pclsObj, L"BatteryStatus", &batteryStatus);
switch(batteryStatus)
{
case 1: ffStrbufInitS(&battery->status, "Discharging"); break;
case 2: ffStrbufInitS(&battery->status, "AC Connected"); break;
case 3: ffStrbufInitS(&battery->status, "Fully Charged"); break;
case 4: ffStrbufInitS(&battery->status, "Low"); break;
case 5: ffStrbufInitS(&battery->status, "Critical"); break;
case 6: ffStrbufInitS(&battery->status, "Charging"); break;
case 7: ffStrbufInitS(&battery->status, "Charging and High"); break;
case 8: ffStrbufInitS(&battery->status, "Charging and Low"); break;
case 9: ffStrbufInitS(&battery->status, "Charging and Critical"); break;
case 10: ffStrbufInitS(&battery->status, "Undefined"); break;
case 11: ffStrbufInitS(&battery->status, "Partially Charged"); break;
}
battery->temperature = FF_BATTERY_TEMP_UNSET;
}
pclsObj->Release();
pEnumerator->Release();
return nullptr;
}
+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
+11
View File
@@ -0,0 +1,11 @@
#include "bios.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInitS(&bios->error, "Not supported on Android");
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
}
+11
View File
@@ -0,0 +1,11 @@
#include "bios.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInitS(&bios->error, "Not supported on macOS");
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&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);
}
+38
View File
@@ -0,0 +1,38 @@
extern "C" {
#include "bios.h"
}
#include "util/windows/wmi.hpp"
extern "C" void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT Name, ReleaseDate, Version, Manufacturer FROM Win32_BIOS", &bios->error);
if(!pEnumerator)
return;
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;
pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
if(uReturn == 0)
{
ffStrbufInitS(&bios->error, "No Wmi result returned");
pEnumerator->Release();
return;
}
ffGetWmiObjString(pclsObj, L"Name", &bios->biosRelease);
ffGetWmiObjString(pclsObj, L"ReleaseDate", &bios->biosDate);
ffGetWmiObjString(pclsObj, L"Version", &bios->biosVersion);
ffGetWmiObjString(pclsObj, L"Manufacturer", &bios->biosVendor);
pclsObj->Release();
pEnumerator->Release();
}
+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
+10
View File
@@ -0,0 +1,10 @@
#include "board.h"
void ffDetectBoard(FFBoardResult* board)
{
ffStrbufInitS(&board->error, "Not supported on Android");
ffStrbufInit(&board->boardName);
ffStrbufInit(&board->boardVendor);
ffStrbufInit(&board->boardVersion);
}
+10
View File
@@ -0,0 +1,10 @@
#include "board.h"
void ffDetectBoard(FFBoardResult* board)
{
ffStrbufInitS(&board->error, "Not supported on macOS");
ffStrbufInit(&board->boardName);
ffStrbufInit(&board->boardVendor);
ffStrbufInit(&board->boardVersion);
}
+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);
}
+36
View File
@@ -0,0 +1,36 @@
extern "C" {
#include "board.h"
}
#include "util/windows/wmi.hpp"
extern "C" void ffDetectBoard(FFBoardResult* board)
{
ffStrbufInit(&board->error);
ffStrbufInit(&board->boardName);
ffStrbufInit(&board->boardVendor);
ffStrbufInit(&board->boardVersion);
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT Product, Version, Manufacturer FROM Win32_BaseBoard", &board->error);
if(!pEnumerator)
return;
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;
pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
if(uReturn == 0)
{
ffStrbufInitS(&board->error, "No Wmi result returned");
pEnumerator->Release();
return;
}
ffGetWmiObjString(pclsObj, L"Product", &board->boardName);
ffGetWmiObjString(pclsObj, L"Manufacturer", &board->boardVendor);
ffGetWmiObjString(pclsObj, L"Version", &board->boardVersion);
pclsObj->Release();
pEnumerator->Release();
}
+52
View File
@@ -0,0 +1,52 @@
#include "cpu.h"
#include "common/caching.h"
#include "detection/internal.h"
#define FF_CPU_CACHE_NAME "cpu"
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached);
static bool cacheCallback(FFCPUResult* cpu, FFCache* cache, FFCacheMethodStrbuf strbufMethod, FFCacheMethodData dataMethod)
{
return
strbufMethod(cache, &cpu->vendor) &&
strbufMethod(cache, &cpu->name) &&
dataMethod(cache, sizeof(cpu->coresPhysical), &cpu->coresPhysical) &&
dataMethod(cache, sizeof(cpu->coresLogical), &cpu->coresLogical) &&
dataMethod(cache, sizeof(cpu->coresOnline), &cpu->coresOnline) &&
dataMethod(cache, sizeof(cpu->frequencyMin), &cpu->frequencyMin) &&
dataMethod(cache, sizeof(cpu->frequencyMax), &cpu->frequencyMax);
}
static void detectCPU(const FFinstance* instance, FFCPUResult* cpu)
{
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
bool cached = ffCacheRead(instance, cpu, FF_CPU_CACHE_NAME, (FFCacheMethodCallback) cacheCallback);
ffDetectCPUImpl(instance, cpu, cached);
if(cached)
return;
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(&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
ffCacheWrite(instance, cpu, FF_CPU_CACHE_NAME, (FFCacheMethodCallback) cacheCallback);
}
const FFCPUResult* ffDetectCPU(const FFinstance* instance)
{
FF_DETECTION_INTERNAL_GUARD(FFCPUResult,
detectCPU(instance, &result);
);
}
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#ifndef FF_INCLUDED_detection_cpu_cpu
#define FF_INCLUDED_detection_cpu_cpu
#include "fastfetch.h"
#define FF_CPU_TEMP_UNSET (0/0.0)
typedef struct FFCPUResult
{
FFstrbuf name;
FFstrbuf vendor;
uint16_t coresPhysical;
uint16_t coresLogical;
uint16_t coresOnline;
double frequencyMin;
double frequencyMax;
double temperature;
} FFCPUResult;
const FFCPUResult* ffDetectCPU(const FFinstance* instance);
#endif
+76
View File
@@ -0,0 +1,76 @@
#include "cpu.h"
#include "common/sysctl.h"
#include "detection/temps/temps_apple.h"
static double getFrequency(const char* propName)
{
double herz = (double) ffSysctlGetInt64(propName, 0);
if(herz <= 0.0)
return herz;
herz /= 1000.0; //to KHz
herz /= 1000.0; //to MHz
return herz / 1000.0; //to GHz
}
static double detectCpuTemp(const FFstrbuf* cpuName)
{
FFlist temps;
ffListInit(&temps, sizeof(FFTempValue));
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);
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;
ffListDestroy(&temps);
return result;
}
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
{
FF_UNUSED(instance);
if(!cached)
{
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) ffSysctlGetInt("hw.physicalcpu", 1);
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.logicalcpu_max", 1);
if(cpu->coresLogical == 1)
cpu->coresLogical = (uint16_t) ffSysctlGetInt("hw.ncpu", 1);
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.logicalcpu", 1);
if(cpu->coresOnline == 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");
}
if (instance->config.cpuTemp)
cpu->temperature = detectCpuTemp(&cpu->name);
else
cpu->temperature = FF_CPU_TEMP_UNSET;
}
+21
View File
@@ -0,0 +1,21 @@
#include "cpu.h"
#include "common/sysctl.h"
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
{
FF_UNUSED(instance);
cpu->temperature = FF_CPU_TEMP_UNSET;
if(cached)
return;
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;
}
+111
View File
@@ -0,0 +1,111 @@
#include "cpu.h"
#include "common/io.h"
#include "common/properties.h"
#include "detection/temps/temps_linux.h"
#include <stdlib.h>
#include <unistd.h>
static void parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer)
{
FILE* cpuinfo = fopen("/proc/cpuinfo", "r");
if(cpuinfo == NULL)
return;
char* line = NULL;
size_t len = 0;
while(getline(&line, &len, cpuinfo) != -1)
{
//Stop after the first CPU
if(cpu->name.length > 0 && (*line == '\0' || *line == '\n'))
break;
(void)(
ffParsePropLine(line, "model name :", &cpu->name) ||
ffParsePropLine(line, "vendor_id :", &cpu->vendor) ||
ffParsePropLine(line, "cpu cores :", physicalCoresBuffer) ||
(cpu->name.length == 0 && ffParsePropLine(line, "Hardware :", &cpu->name)) //For Android devices
);
}
if(line != NULL)
free(line);
fclose(cpuinfo);
}
static double getGHz(const char* file)
{
FFstrbuf content;
ffStrbufInit(&content);
ffReadFileBuffer(file, &content);
double herz = ffStrbufToDouble(&content);
ffStrbufDestroy(&content);
//ffStrbufToDouble failed
if(herz != herz)
return 0;
herz /= 1000.0; //to MHz
return herz / 1000.0; //to GHz
}
static double getFrequency(const char* info, const char* scaling)
{
double frequency = getGHz(info);
if(frequency > 0.0)
return frequency;
return getGHz(scaling);
}
static double detectCPUTemp(const FFinstance* instance)
{
const FFTempsResult* temps = ffDetectTemps(instance);
for(uint32_t i = 0; i < temps->values.length; i++)
{
FFTempValue* value = ffListGet(&temps->values, i);
if(
ffStrbufFirstIndexS(&value->name, "cpu") < value->name.length ||
ffStrbufCompS(&value->name, "k10temp") == 0 ||
ffStrbufCompS(&value->name, "coretemp") == 0
) return value->value;
}
return FF_CPU_TEMP_UNSET;
}
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
{
if(instance->config.cpuTemp)
cpu->temperature = detectCPUTemp(instance);
else
cpu->temperature = FF_CPU_TEMP_UNSET;
if(cached)
return;
FFstrbuf physicalCoresBuffer;
ffStrbufInit(&physicalCoresBuffer);
parseCpuInfo(cpu, &physicalCoresBuffer);
cpu->coresPhysical = ffStrbufToUInt16(&physicalCoresBuffer, 1);
#ifdef FF_HAVE_SYSINFO_H
cpu->coresLogical = (uint16_t) get_nprocs_conf();
cpu->coresOnline = (uint16_t) get_nprocs();
#else
cpu->coresLogical = 1;
cpu->coresOnline = 1;
#endif
#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");
ffStrbufDestroy(&physicalCoresBuffer);
}
+51
View File
@@ -0,0 +1,51 @@
extern "C" {
#include "cpu.h"
}
#include "util/windows/wmi.hpp"
extern "C"
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu, bool cached)
{
FF_UNUSED(instance);
cpu->temperature = FF_CPU_TEMP_UNSET;
if(cached)
return;
cpu->coresPhysical = cpu->coresLogical = cpu->coresOnline = 0;
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT Name, Manufacturer, NumberOfCores, NumberOfLogicalProcessors, ThreadCount, CurrentClockSpeed, MaxClockSpeed FROM Win32_Processor WHERE ProcessorType = 3", nullptr);
if(!pEnumerator)
return;
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;
if(FAILED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) || uReturn == 0)
{
pEnumerator->Release();
return;
}
ffGetWmiObjString(pclsObj, L"Name", &cpu->name);
ffGetWmiObjString(pclsObj, L"Manufacturer", &cpu->vendor);
uint64_t value;
ffGetWmiObjUnsigned(pclsObj, L"NumberOfCores", &value);
cpu->coresPhysical = (uint16_t)value;
ffGetWmiObjUnsigned(pclsObj, L"NumberOfLogicalProcessors", &value);
cpu->coresLogical = (uint16_t)value;
ffGetWmiObjUnsigned(pclsObj, L"ThreadCount", &value);
cpu->coresOnline = (uint16_t)value;
ffGetWmiObjUnsigned(pclsObj, L"CurrentClockSpeed", &value); //There's no MinClockSpeed in Win32_Processor
cpu->frequencyMin = (double)value / 1000.0;
ffGetWmiObjUnsigned(pclsObj, L"MaxClockSpeed", &value);
cpu->frequencyMax = (double)value / 1000.0;
pclsObj->Release();
pEnumerator->Release();
}
+58
View File
@@ -0,0 +1,58 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#if FF_DETECTION_CPUUSAGE_NOWAIT
const char* ffGetCpuUsageResultNoWait(double* result);
void ffPrepareCPUUsage() {}
const char* ffGetCpuUsageResult(double* result) {
return ffGetCpuUsageResultNoWait(result);
}
#else //FF_DETECTION_CPUUSAGE_NOWAIT
#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, startTime;
void ffPrepareCPUUsage()
{
startTime = ffTimeGetTick();
ffGetCpuUsageInfo(&inUseAll1, &totalAll1);
}
const char* ffGetCpuUsageResult(double* result)
{
const char* error = NULL;
if(startTime == 0)
{
error = ffGetCpuUsageInfo(&inUseAll1, &totalAll1);
if(error)
return error;
ffTimeSleep(1000);
}
else
{
uint64_t duration = ffTimeGetTick() - startTime;
if(duration < 1000)
ffTimeSleep(1000 - (uint32_t) duration);
}
uint64_t inUseAll2, totalAll2;
error = ffGetCpuUsageInfo(&inUseAll2, &totalAll2);
if(error)
return error;
*result = (double)(inUseAll2 - inUseAll1) / (double)(totalAll2 - totalAll1) * 100;
return NULL;
}
#endif //FF_DETECTION_CPUUSAGE_NOWAIT
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#ifndef FF_INCLUDED_detection_cpu_cpuUsage
#define FF_INCLUDED_detection_cpu_cpuUsage
#if defined(_WIN32) || defined(__MSYS__)
// Disabled by default because the result does need some time to generate
#define FF_DETECTION_CPUUSAGE_NOWAIT 0
#endif
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;
}
+26
View File
@@ -0,0 +1,26 @@
#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)
return "fopen(\"""/proc/stat\", \"r\") == NULL";
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;
}
@@ -0,0 +1,26 @@
extern "C" {
#include "cpuUsage.h"
}
#include "util/windows/wmi.hpp"
extern "C" const char* ffGetCpuUsageResultNoWait(double* result)
{
IEnumWbemClassObject* pEnumerator = ffQueryWmi(L"SELECT LoadPercentage FROM Win32_Processor", nullptr);
if(!pEnumerator)
return "Query WMI service failed";
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;
if(FAILED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) || uReturn == 0)
{
pEnumerator->Release();
return "No WMI result returned";
}
ffGetWmiObjReal(pclsObj, L"LoadPercentage", result);
pclsObj->Release();
pEnumerator->Release();
return NULL;
}
+20
View File
@@ -0,0 +1,20 @@
#include "fastfetch.h"
#include "cpuUsage.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.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) == 0)
return "GetSystemTimes() failed";
*inUseAll = fileTimeToUint64(&userTime) + fileTimeToUint64(&kernelTime);
*totalAll = *inUseAll + fileTimeToUint64(&idleTime);
return NULL;
}
+10 -9
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "detection/datetime.h"
#include <time.h>
#include <pthread.h>
@@ -26,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);
@@ -49,22 +50,22 @@ 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);
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#ifndef FF_INCLUDED_detection_datetime
#define FF_INCLUDED_detection_datetime
#include "fastfetch.h"
typedef struct FFDateTimeResult
{
//Examples for 21.02.2022 - 15:18:37
uint16_t year; //2022
uint8_t yearShort; //22
uint8_t month; //2
FFstrbuf monthPretty; //02
FFstrbuf monthName; //February
FFstrbuf monthNameShort; //Feb
uint8_t week; //8
FFstrbuf weekday; //Monday
FFstrbuf weekdayShort; //Mon
uint16_t dayInYear; //52
uint8_t dayInMonth; //21
uint8_t dayInWeek; //1
uint8_t hour; //15
FFstrbuf hourPretty; //15
uint8_t hour12; //3
FFstrbuf hour12Pretty; //03
uint8_t minute; //18
FFstrbuf minutePretty; //18
uint8_t second; //37
FFstrbuf secondPretty; //37
} FFDateTimeResult;
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance);
#endif
+56
View File
@@ -0,0 +1,56 @@
#include "fastfetch.h"
#include "disk.h"
#include <sys/statvfs.h>
void ffDetectDiskWithStatvfs(const char* folderPath, struct statvfs* fs, FFDiskResult* result)
{
ffStrbufInitS(&result->path, folderPath);
result->used = result->total = 0;
ffStrbufInit(&result->error);
struct statvfs newFs;
if(fs == NULL)
{
fs = &newFs;
int ret = statvfs(folderPath, fs);
if(ret != 0)
{
ffStrbufAppendF(&result->error, "statvfs(\"%s\", &fs) != 0 (%i)", folderPath, ret);
return;
}
}
result->total = fs->f_blocks * fs->f_frsize;
if(result->total == 0)
{
ffStrbufAppendF(&result->error, "statvfs for %s returned size 0", folderPath);
return;
}
result->used = result->total - (fs->f_bavail * fs->f_frsize);
result->files = (uint32_t) (fs->f_files - fs->f_ffree);
result->removable = false; //To be set at other place
}
bool ffDiskDetectDiskFolders(FFinstance* instance, FFlist* folders)
{
ffStrbufTrim(&instance->config.diskFolders, ':');
if(instance->config.diskFolders.length == 0)
return false;
uint32_t startIndex = 0;
while(startIndex < instance->config.diskFolders.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&instance->config.diskFolders, startIndex, ':');
instance->config.diskFolders.chars[colonIndex] = '\0';
ffDetectDiskWithStatvfs(instance->config.diskFolders.chars + startIndex, NULL, (FFDiskResult*)ffListAdd(folders));
startIndex = colonIndex + 1;
}
return true;
}
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#ifndef FF_INCLUDED_detection_disk_disk
#define FF_INCLUDED_detection_disk_disk
#include "fastfetch.h"
typedef struct FFDiskResult
{
FFstrbuf path;
uint64_t used;
uint64_t total;
uint32_t files;
bool removable;
FFstrbuf error;
} FFDiskResult;
const char* ffDiskAutodetectFolders(FFinstance* instance, FFlist* folders);
bool ffDiskDetectDiskFolders(FFinstance* instance, FFlist* folders);
#endif
+29
View File
@@ -0,0 +1,29 @@
#include "disk.h"
#import <Foundation/Foundation.h>
void ffDetectDiskWithStatvfs(const char* folderPath, struct statvfs* fs, FFDiskResult* result);
const char* ffDiskAutodetectFolders(FFinstance* instance, FFlist* folders)
{
NSArray *keys = [NSArray arrayWithObjects:NSURLVolumeNameKey, nil];
NSArray *urls = [NSFileManager.defaultManager mountedVolumeURLsIncludingResourceValuesForKeys:keys
options:NSVolumeEnumerationSkipHiddenVolumes];
if(urls == nil)
return "[NSFileManager.defaultManager mountedVolumeURLsIncludingResourceValuesForKeys] failed";
for (NSURL *url in urls) {
NSError *error;
NSNumber* removable;
if([url getResourceValue:&removable forKey:NSURLVolumeIsRemovableKey error:&error] == NO)
continue;
if(removable.boolValue && !instance->config.diskRemovable)
continue;
FFDiskResult* folder = (FFDiskResult*)ffListAdd(folders);
ffDetectDiskWithStatvfs([url.relativePath cStringUsingEncoding:NSUTF8StringEncoding], NULL, folder);
folder->removable = removable.boolValue;
}
return NULL;
}
+24
View File
@@ -0,0 +1,24 @@
#include "disk.h"
#include <sys/statvfs.h>
void ffDetectDiskWithStatvfs(const char* folderPath, struct statvfs* fs, FFDiskResult* result);
const char* ffDiskAutodetectFolders(FFinstance* instance, FFlist* folders)
{
FF_UNUSED(instance);
struct statvfs fsRoot;
int rootRet = statvfs(FASTFETCH_TARGET_DIR_ROOT"/", &fsRoot);
if(rootRet != 0)
return "statvfs(\"/\") failed";
ffDetectDiskWithStatvfs(FASTFETCH_TARGET_DIR_ROOT"/", &fsRoot, (FFDiskResult*)ffListAdd(folders));
struct statvfs fsHome;
int homeRet = statvfs(FASTFETCH_TARGET_DIR_HOME, &fsHome);
if(homeRet == 0 && (fsRoot.f_fsid != fsHome.f_fsid))
ffDetectDiskWithStatvfs(FASTFETCH_TARGET_DIR_HOME, &fsHome, (FFDiskResult*)ffListAdd(folders));
return NULL;
}
+66
View File
@@ -0,0 +1,66 @@
#include "disk.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
static void detectDrive(const char* folderPath, uint32_t pathLen, FFDiskResult* result)
{
ffStrbufInitNS(&result->path, pathLen, folderPath);
result->removable = false; //To be set at other place
result->files = 0; //Unsupported
//According to https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexa
//GetDiskFreeSpaceExA does not have to specify the root directory on a disk. The function accepts any directory on a disk.
uint64_t freeBytes;
if(GetDiskFreeSpaceExA(folderPath, NULL, (PULARGE_INTEGER)&result->total, (PULARGE_INTEGER)&freeBytes)) {
result->used = result->total - freeBytes;
ffStrbufInit(&result->error);
}
else
ffStrbufInitS(&result->error, "GetDiskFreeSpaceExA() failed");
}
const char* ffDiskAutodetectFolders(FFinstance* instance, FFlist* folders)
{
FF_UNUSED(instance);
char buf[128]; // "C:\\\0D:\\\0"
uint32_t length = GetLogicalDriveStringsA(sizeof(buf) / sizeof(*buf), buf);
for(size_t i = 0; i < length;)
{
const char* drive = buf + i;
uint32_t driveLen = (uint32_t) strlen(drive);
i += driveLen + 1;
bool removable = GetDriveTypeA(drive) == DRIVE_REMOVABLE;
if(removable && !instance->config.diskRemovable)
continue;
FFDiskResult* folder = (FFDiskResult*)ffListAdd(folders);
detectDrive(drive, driveLen, folder);
folder->removable = removable;
}
return NULL;
}
bool ffDiskDetectDiskFolders(FFinstance* instance, FFlist* folders)
{
ffStrbufTrim(&instance->config.diskFolders, ';');
if(instance->config.diskFolders.length == 0)
return false;
uint32_t startIndex = 0;
while(startIndex < instance->config.diskFolders.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&instance->config.diskFolders, startIndex, ';');
instance->config.diskFolders.chars[colonIndex] = '\0';
detectDrive(instance->config.diskFolders.chars + startIndex, colonIndex - startIndex, (FFDiskResult*)ffListAdd(folders));
startIndex = colonIndex + 1;
}
return true;
}
-133
View File
@@ -1,133 +0,0 @@
#include "displayServer.h"
#include <pthread.h>
#include <dirent.h>
uint32_t ffdsParseRefreshRate(int32_t refreshRate)
{
if(refreshRate <= 0)
return 0;
int remainder = refreshRate % 5;
if(remainder >= 3)
refreshRate += (5 - remainder);
else
refreshRate -= remainder;
//All other typicall refresh rates are dividable by 5
if(refreshRate == 145)
refreshRate = 144;
return (uint32_t) refreshRate;
}
bool ffdsAppendResolution(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate)
{
if(width == 0 || height == 0)
return false;
FFResolutionResult* resolution = ffListAdd(&result->resolutions);
resolution->width = width;
resolution->height = height;
resolution->refreshRate = refreshRate;
return true;
}
static void parseDRM(FFDisplayServerResult* result)
{
const char* drmDirPath = "/sys/class/drm/";
DIR* dirp = opendir(drmDirPath);
if(dirp == NULL)
return;
FFstrbuf drmDir;
ffStrbufInitA(&drmDir, 64);
ffStrbufAppendS(&drmDir, drmDirPath);
uint32_t drmDirLength = drmDir.length;
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
ffStrbufAppendS(&drmDir, entry->d_name);
ffStrbufAppendS(&drmDir, "/modes");
FILE* modeFile = fopen(drmDir.chars, "r");
if(modeFile == NULL)
{
ffStrbufSubstrBefore(&drmDir, drmDirLength);
continue;
}
FFResolutionResult* resolution = ffListAdd(&result->resolutions);
resolution->width = 0;
resolution->height = 0;
resolution->refreshRate = 0;
int scanned = fscanf(modeFile, "%ix%i", &resolution->width, &resolution->height);
if(scanned < 2 || resolution->width == 0 || resolution->height == 0)
--result->resolutions.length;
fclose(modeFile);
ffStrbufSubstrBefore(&drmDir, drmDirLength);
}
closedir(dirp);
ffStrbufDestroy(&drmDir);
}
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance)
{
static FFDisplayServerResult result;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static bool init = false;
pthread_mutex_lock(&mutex);
if(init)
{
pthread_mutex_unlock(&mutex);
return &result;
}
init = true;
ffStrbufInit(&result.wmProcessName);
ffStrbufInit(&result.wmPrettyName);
ffStrbufInit(&result.wmProtocolName);
ffStrbufInit(&result.deProcessName);
ffStrbufInit(&result.dePrettyName);
ffStrbufInit(&result.deVersion);
ffListInitA(&result.resolutions, sizeof(FFResolutionResult), 4);
//We try wayland as our prefered display server, as it supports the most features.
//This method can't detect the name of our WM / DE
ffdsConnectWayland(instance, &result);
//Try the x11 libs, from most feature rich to least.
//We use the resolution list to detect if a connection is needed.
//They respect wmProtocolName, and only detect resolution if it is set.
if(result.resolutions.length == 0)
ffdsConnectXcbRandr(instance, &result);
if(result.resolutions.length == 0)
ffdsConnectXrandr(instance, &result);
if(result.resolutions.length == 0)
ffdsConnectXcb(instance, &result);
if(result.resolutions.length == 0)
ffdsConnectXlib(instance, &result);
//This resolution detection method is display server independent.
//Use it if all connections failed
if(result.resolutions.length == 0)
parseDRM(&result);
//This fills in missing information about WM / DE by using env vars and iterating processes
ffdsDetectWMDE(instance, &result);
pthread_mutex_unlock(&mutex);
return &result;
}
@@ -0,0 +1,42 @@
#include "displayserver.h"
#include "detection/internal.h"
uint32_t ffdsParseRefreshRate(int32_t refreshRate)
{
if(refreshRate <= 0)
return 0;
int remainder = refreshRate % 5;
if(remainder >= 3)
refreshRate += (5 - remainder);
else
refreshRate -= remainder;
//All other typicall refresh rates are dividable by 5
if(refreshRate == 145)
refreshRate = 144;
return (uint32_t) refreshRate;
}
bool ffdsAppendResolution(FFDisplayServerResult* result, uint32_t width, uint32_t height, uint32_t refreshRate)
{
if(width == 0 || height == 0)
return false;
FFResolutionResult* resolution = ffListAdd(&result->resolutions);
resolution->width = width;
resolution->height = height;
resolution->refreshRate = refreshRate;
return true;
}
void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* instance);
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance)
{
FF_DETECTION_INTERNAL_GUARD(FFDisplayServerResult,
ffConnectDisplayServerImpl(&result, instance);
);
}

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