Compare commits

...

1297 Commits

Author SHA1 Message Date
Carter Li 52eacd7140 Merge pull request #428 from LinusDierheimer/dev
Release: 1.10.3
2023-02-25 17:34:53 +08:00
李通洲 b19d8d6700 Release: 1.10.3 2023-02-25 16:06:16 +08:00
李通洲 6b0add44ee Init: print threads for --list-features if supported 2023-02-25 15:29:12 +08:00
李通洲 b66338494f CMake: fix compile error on Windows 2023-02-25 13:31:36 +08:00
李通洲 47cec48a49 GPU (Windows): fix uninited variables 2023-02-25 13:31:36 +08:00
李通洲 09ccbca79c WmTheme (Apple): don't depend on displayserver detection 2023-02-25 13:31:36 +08:00
李通洲 4f28ae62a7 Font: don't depend on displayserver detection on Windows and macOS. 2023-02-25 13:31:36 +08:00
李通洲 e953ea6542 Android: enable mutltithreading public-ip / weather detection 2023-02-24 17:48:20 +08:00
李通洲 de72c98a28 Init: don't create detection thread for displayserver on Windows / macOS
Displayserver (mainly resolutions) detection is cheap on win / mac, but creating an detection thread is unnecessary
2023-02-24 17:48:20 +08:00
李通洲 7f15f91bd3 Temps (Windows): dirty support
Note: https://stackoverflow.com/a/17083409
2023-02-23 21:31:33 +08:00
李通洲 c570c5bf97 IO: use FF_AUTO_CLOSE_FD 2023-02-23 13:58:39 +08:00
李通洲 52c304ecae IO (Linux): add detailed error messages for ffProcessAppendStdOut 2023-02-23 13:32:12 +08:00
Carter Li 4f4860eee8 Merge pull request #426 from LinusDierheimer/dev
Release: 1.10.2
2023-02-22 15:58:01 +08:00
李通洲 695e3cc692 Release: 1.10.2 2023-02-22 15:16:54 +08:00
李通洲 e05d9da231 Battery / Wifi: fix missing NULL for ffProcessAppendStdOut 2023-02-22 15:12:37 +08:00
Nanda H Krishna c16f9a9e20 sound_apple.c: handle kAudioObjectPropertyElementMain for macOS < 12 2023-02-22 14:19:22 +08:00
Carter Li 74b1871f18 CI: fix build (#424) 2023-02-21 22:19:17 +08:00
Carter Li 8fdb877840 Merge pull request #423 from LinusDierheimer/dev
Release 1.10.1
2023-02-21 21:43:50 +08:00
李通洲 3a7d7d79c0 CMake: more debug info 2023-02-21 21:40:55 +08:00
李通洲 28baf2596e CMake: more debug info 2023-02-21 21:38:10 +08:00
李通洲 30d1a55dde Release: 1.10.1 2023-02-21 21:28:26 +08:00
李通洲 3e068d16df Wifi / Battery (Android): more accurate checks 2023-02-21 21:25:02 +08:00
李通洲 c283e39b22 CI: update artifact name (Win32) 2023-02-21 20:44:22 +08:00
Carter Li f6702d83d0 Merge pull request #422 from LinusDierheimer/dev
Release 1.10.0
2023-02-21 18:48:33 +08:00
李通洲 b1a779c178 Release: 1.10.0; update changelog 2023-02-21 15:54:12 +08:00
李通洲 cc1260ee3c FFvaluestore: fix UB reported by clang 2023-02-21 10:21:07 +08:00
李通洲 92b1788825 Platform: refactor; remove extra / 2023-02-21 10:02:04 +08:00
李通洲 efdbeb585b Battery (Android): add temperature 2023-02-21 09:43:22 +08:00
李通洲 304f171d38 Battery / Wifi (Android): add more debug messages 2023-02-21 09:42:41 +08:00
李通洲 9a3909f8ba Memory (Windows): check for error cases 2023-02-16 17:19:43 +08:00
李通洲 6ca4b5391b Library: refactor FF_LIBRARY_LOAD to use __cleanup__ 2023-02-15 14:51:04 +08:00
李通洲 cabd36d078 CpuUsage (apple): simplify implementation 2023-02-14 19:24:29 +08:00
李通洲 64bacd2572 Vulkan: refactor directory structures 2023-02-14 17:52:58 +08:00
李通洲 47be29b89c DateTime: refactor directory structures 2023-02-14 17:49:23 +08:00
李通洲 6407bf6a1f GTK / QT: refactor directory structures 2023-02-14 17:47:39 +08:00
李通洲 e2d145cf31 Memory (Apple): use sysctl instead of sysctlbyname 2023-02-14 17:31:07 +08:00
李通洲 b634c70f80 Temp (Apple): support memory temperature detection for future use 2023-02-14 17:29:21 +08:00
李通洲 e29169711c TerminalShell (Linux): tidy 2023-02-14 16:33:58 +08:00
李通洲 662ddac050 Vulkan: detect vmem (#416) 2023-02-11 16:05:54 +08:00
李通洲 b90d543afc GPU (Windows): support vmem total / usage detection #416
vmem usage detection is guarded behind `--allow-slow-operations`
because it's really slow sometimes
2023-02-11 16:05:54 +08:00
李通洲 f05d134aa7 OpenCL: tidy 2023-02-10 11:20:27 +08:00
李通洲 74a68aa626 CMake: remove unused options 2023-02-10 11:08:05 +08:00
Linus Dierheimer fcc5170a10 Disk(Linux): Better detection of physical drives 2023-02-09 11:20:40 +01:00
李通洲 3a9403a2f1 Packages (Windows): optimise 2023-02-09 09:51:51 +08:00
李通洲 ff170caff6 GPU (Windows): fix duplicated entries. 2023-02-09 09:46:53 +08:00
李通洲 532b493c42 Doc: update changelog 2023-02-09 00:19:19 +08:00
李通洲 51cc87e0db GPU (Windows): keep WMI query as a slow operation for accurate results 2023-02-09 00:17:13 +08:00
李通洲 878d4608b1 Packages (Windows): fix scoop packages count in non-default install path 2023-02-09 00:15:35 +08:00
李通洲 03d1c62787 Packages (Windows): honor $SCOOP when detecting scoop packages
Fix #417
2023-02-08 22:49:30 +08:00
李通洲 5c46271898 GPU (Windows): fix driver version detection 2023-02-08 21:23:45 +08:00
李通洲 9a7c732555 OpenCL: fix Windows support
They changed the dll file name in the latest release
2023-02-08 21:07:36 +08:00
李通洲 8ffe6fda9b Battery: drop powrprof.dll dependency 2023-02-08 15:11:50 +08:00
Linus Dierheimer e563417166 Build test: Build as release with debug info 2023-02-07 12:21:47 +01:00
Linus Dierheimer ec3f9acd76 Cmake debug: change to exe linker only 2023-02-07 12:18:30 +01:00
李通洲 6c22fd6902 Host: update newest product name data (macOS) 2023-02-07 14:35:50 +08:00
李通洲 82b10a527b GPU: support driver version detection 2023-02-07 11:17:46 +08:00
李通洲 92c744d971 Windows: support for global config path in MSYS2 environment 2023-02-06 22:53:47 +08:00
李通洲 7a691a4286 Windows: add 32bit support 2023-02-06 16:03:38 +08:00
李通洲 e98489a74b Locale: tweaks 2023-02-06 14:55:57 +08:00
李通洲 7a5da23b0c Bluetooth: silense compiler warnings 2023-02-06 14:55:57 +08:00
李通洲 edf4837ed6 GPU: refactor vendor detection code 2023-02-06 14:55:57 +08:00
李通洲 749bd8db0e Gamepad (Windows): display attached controllers only 2023-02-05 21:42:59 +08:00
李通洲 d2460d8e85 GPU (Windows): try improving performance 2023-02-05 18:59:20 +08:00
Linus Dierheimer eead4cf70e Revert "Pipeline: debug"
This reverts commit 291f88b1e4.
2023-02-03 18:53:52 +01:00
Linus Dierheimer 291f88b1e4 Pipeline: debug 2023-02-03 18:48:40 +01:00
Linus Dierheimer 93f1a44d0f Revert "Pipeline: debug"
This reverts commit 550e107683.
2023-02-03 18:43:15 +01:00
Linus Dierheimer 550e107683 Pipeline: debug 2023-02-03 18:41:08 +01:00
Linus Dierheimer 7a8b94b6d4 Fix build with older libnm versions 2023-02-03 14:20:15 +01:00
Linus Dierheimer 2005b396fa Add missing comma 2023-02-03 13:38:37 +01:00
Linus Dierheimer 2a80b5ed36 Pipeline(Linux): Build on Ubuntu 20.04 2023-02-03 13:37:15 +01:00
Linus Dierheimer 47a32c725d X11: init scaled resolution with normal resolution 2023-02-03 11:22:34 +01:00
李通洲 fc26acd0ab DisplayServer: fix scaled resolution detection (Linux) 2023-02-03 10:34:17 +08:00
Linus Dierheimer e57f7d378a Wayland: support basic scale factors
#414
2023-02-02 18:16:56 +01:00
Linus Dierheimer 6de74587bd Update terminator font detection 2023-02-02 17:14:53 +01:00
Linus Dierheimer 6e5e7851d4 Merge pull request #415 from CSoellinger/feat/add-terminator-terminal-support
Add terminator terminal support
2023-02-02 17:01:59 +01:00
CSoellinger 84ccda45b0 feat: simplify parse prop file config 2023-02-02 16:16:24 +01:00
李通洲 ec3cd6cc68 LocalIP: support multiline compact mode 2023-02-02 22:25:31 +08:00
李通洲 cae9fee30a LocalIP (Windows): fix ipv6 detection 2023-02-02 21:01:50 +08:00
李通洲 f0111a8037 Windows: silense compiler warnings 2023-02-02 19:17:51 +08:00
CSoellinger 8fad590f8b feat: add terminator terminal support 2023-02-02 11:40:37 +01:00
CSoellinger 2ae5a9d725 Merge pull request #1 from LinusDierheimer/dev
Update dev
2023-02-02 11:25:06 +01:00
李通洲 8153c8b82c LocalIP: support --localip-compact-type option (#408) 2023-02-02 17:50:22 +08:00
Linus Dierheimer 159f4a3a3c Fix build on apple 2023-02-01 18:35:06 +01:00
Linus Dierheimer 3dbfff57e7 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-02-01 15:56:32 +01:00
Linus Dierheimer a063cd4feb Correctly handle zfs pools
#413
2023-02-01 15:56:25 +01:00
李通洲 dc5da3c3b3 Flashfetch: add missing modules 2023-02-01 21:54:45 +08:00
李通洲 79c9c19b1a Doc: document gamepad module support 2023-02-01 21:47:35 +08:00
李通洲 b49b583e64 Gamepad (Linux): add support 2023-02-01 21:46:23 +08:00
李通洲 0b8e8ad4f2 Gamepad (macOS): add support 2023-02-01 21:46:23 +08:00
李通洲 7fc2c4dcf1 Gamepad: init support for Windows 2023-02-01 21:46:23 +08:00
李通洲 a74cbc5781 Sound: fix memleak, update config file 2023-02-01 20:28:55 +08:00
Linus Dierheimer 619ec921ee Update changelog 2023-02-01 11:16:01 +01:00
Linus Dierheimer 1b23c9a030 Update changelog 2023-02-01 11:14:54 +01:00
Linus Dierheimer d4c11b9a1f Merge pull request #411 from CSoellinger/fix/detect-wm-mutter
fix: add another mutter detection for linux mint 21.1 (cinnamon)
2023-02-01 11:11:00 +01:00
CSoellinger 55da030e2a fix: move mutter(muffin) detection to get FF_WM_PRETTY_MUFFIN back 2023-02-01 10:50:31 +01:00
Linus Dierheimer c64f306550 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-02-01 10:43:32 +01:00
Linus Dierheimer 7ee4a648d0 Small fix to muffin theme detection 2023-02-01 10:43:24 +01:00
Linus Dierheimer 78ca4e7c87 Merge pull request #412 from CSoellinger/fix/spell-correction
fix: spell correction
2023-02-01 10:30:59 +01:00
CSoellinger 7a2826358b fix: spell correction 2023-02-01 10:08:08 +01:00
CSoellinger df84721b55 fix: add another mutter detection for linux mint 21.1 (cinnamon) 2023-02-01 10:01:47 +01:00
李通洲 f53a1f785d Doc: update changelog 2023-01-31 23:32:49 +08:00
李通洲 4f3b9776ae WmTheme (Windows): align output format to winfetch
Ref: https://github.com/lptstr/winfetch/commit/0358deea5e3ca03086be4984b905a0a534f8d1a5
2023-01-31 23:26:50 +08:00
李通洲 39f47d65a9 Sound: remove manufacturer detection
as it's only implemented on macOS
2023-01-31 22:39:27 +08:00
李通洲 a92e6b6d91 Sound (macOS): fix active device detection; fix memleaks; don't use deprecated properties 2023-01-31 22:37:48 +08:00
李通洲 00e044c431 Sound: change option --sound-show-all to --sound-type 2023-01-31 21:12:47 +08:00
李通洲 7132762c9c Sound (Linux): small fixes
1. treat PA_PORT_AVAILABLE_UNKNOWN as active so that the default speaker is active now
2. load `libpulse.so` as suggested in `config_user.txt`
2023-01-31 20:55:01 +08:00
李通洲 2476b44300 Global: add support for colored percentage numbers output 2023-01-31 19:42:11 +08:00
李通洲 d36e827ec9 Fastfetch: remove --nocache which has been deprecated for a while 2023-01-31 17:15:45 +08:00
Linus Dierheimer a37115cb00 Fix build on windows 2023-01-30 23:23:14 +01:00
Linus Dierheimer 7dc73c61ab WMDE: avoid the use of magick strings across the project
There are probably more, but those are all i found for now.
2023-01-30 18:46:39 +01:00
李通洲 a14ef06d14 TerminalShell (Windows): fix a rare case that fails to detect terminal 2023-01-29 23:29:53 +08:00
李通洲 212e7aa47e CI: test for memleaks 2023-01-29 13:12:50 +08:00
李通洲 ebe26eddf0 Windows: minify included headers 2023-01-29 10:21:23 +08:00
李通洲 517e3fcff9 WMI: add timeout to prevent CI from hanging
Hard coded 5 seconds
2023-01-29 10:10:31 +08:00
Linus Dierheimer 679162c762 --list-logos: list custom logos too 2023-01-28 17:19:45 +01:00
李通洲 e4973b3262 IO: fix Windows part; silense warnings 2023-01-28 22:46:59 +08:00
Linus Dierheimer a1ea7804f3 IO: Separate platform specific implementations 2023-01-28 12:40:12 +01:00
Linus Dierheimer 2c51d55ba2 IO: don't require posix specific stuff for ffPathExists 2023-01-28 11:52:23 +01:00
Linus Dierheimer 3b0e1a5833 Image: Use correct cache dir 2023-01-28 11:28:05 +01:00
Linus Dierheimer 9bb6d8fd6e Allow loading images from data dirs too
#375
2023-01-28 11:14:16 +01:00
李通洲 4afba798ba Sound: add missing command helpers 2023-01-28 13:46:40 +08:00
李通洲 f4cefe955b Sound: always initialize identifier and destroy it to avoid memleaks 2023-01-28 13:46:40 +08:00
李通洲 1c38ebb551 Parsing: only disable warning when necessary 2023-01-28 13:46:40 +08:00
Linus Dierheimer 14dcafe2ca Bluetooth(Linux): Refactor code a bit 2023-01-27 18:21:42 +01:00
Linus Dierheimer cf78216d78 Sound(Linux): Don't abuse manufactor 2023-01-27 18:03:57 +01:00
Linus Dierheimer 0c256e2908 Just try with all on and all of 2023-01-27 13:01:24 +01:00
Linus Dierheimer 00fc3f1a1d Add a workflow that tests different build config combinations 2023-01-27 12:56:36 +01:00
Linus Dierheimer 672e309d89 Small fixes 2023-01-27 11:21:01 +01:00
李通洲 b0c19256f0 Bluetooth: silense warnings 2023-01-27 13:10:06 +08:00
李通洲 205e664b4d Sound (Windows): show more detailed information 2023-01-27 13:08:07 +08:00
Linus Dierheimer cb466aec08 Linux: Fix build without dbus
#405
2023-01-26 22:08:55 +01:00
Linus Dierheimer 33f3744a63 Sound(Linux): Treat default port as always active
This fixes no shown sound devices when no audio is currently played
2023-01-26 17:25:14 +01:00
Linus Dierheimer 7adb1606f1 GH Actions: build with libpulse 2023-01-26 15:50:35 +01:00
Linus Dierheimer 184ada6ae8 Sound(linux): Implement using libpulse
Also differentiate between active and main device(s)
2023-01-26 15:48:28 +01:00
李通洲 856c9d58b8 TerminalFont: tweaks 2023-01-26 01:15:33 +08:00
李通洲 f3fba8a389 CI: build with alsa enabled 2023-01-26 01:14:22 +08:00
李通洲 10468a559a Doc: document Sound module support 2023-01-26 01:14:22 +08:00
李通洲 c4c9f02433 Sound (Linux): add dirty support 2023-01-26 01:14:22 +08:00
李通洲 f2dd288a0d Sound: don't leak memory 2023-01-26 00:36:45 +08:00
李通洲 aa36a83182 Windows: silense some warnings 2023-01-25 17:25:05 +08:00
李通洲 dd9047c4e9 Sound (Windows): add support 2023-01-25 17:17:31 +08:00
李通洲 11634b9a67 Windows: add com helper 2023-01-25 17:17:19 +08:00
李通洲 d832324306 Sound (macOS): new module 2023-01-25 14:28:13 +08:00
Linus Dierheimer a7af5c4f66 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-01-25 00:03:01 +01:00
Linus Dierheimer 0f2022bd40 Bluetooth: Don't leak memory 2023-01-25 00:02:54 +01:00
李通洲 e598598ca8 Bluetooth (macOS): add support
Limitation: no battery level
2023-01-24 22:13:53 +08:00
李通洲 85599fcf53 Bluetooth (Windows): add support
Limitation: no HLE devices, no battery level
2023-01-24 21:01:21 +08:00
Linus Dierheimer 6961488d38 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-01-24 12:02:47 +01:00
Linus Dierheimer 209d0c98d9 Bluetooth: Support multiple devices 2023-01-24 12:02:20 +01:00
Linus Dierheimer d718cc997c Merge pull request #404 from LinusDierheimer/master
Master
2023-01-24 10:51:03 +01:00
Linus Dierheimer 4967d0a222 Bluetooth: Build on unsupported platforms 2023-01-24 10:46:00 +01:00
Linus Dierheimer 17ebd5cea8 Merge 2023-01-24 10:40:29 +01:00
Linus Dierheimer 25e81b39f9 Bluetooth module 2023-01-24 10:39:33 +01:00
Linus Dierheimer 4b253aa4cf Merge pull request #403 from LinusDierheimer/dev
Release 1.9.1
2023-01-24 10:05:49 +01:00
李通洲 d7b84bed9f Doc: update changelog 2023-01-24 16:16:08 +08:00
李通洲 298d091e2e Wifi: fix the default output formatting 2023-01-24 11:30:25 +08:00
Carter Li ebe30394f2 Display (macOS): fix zero refresh rate on some monitors 2023-01-24 11:21:08 +08:00
李通洲 4c7d479e93 Release: 1.9.1 2023-01-24 10:14:59 +08:00
李通洲 d6d204ae5f Fastfetch: fix builds on unknown platform (#402) 2023-01-24 10:11:35 +08:00
Jonathan Wright ed23eb0fde Fix builds on s390x (#402)
Fixes #401
2023-01-24 10:09:26 +08:00
Linus Dierheimer fbbfc7f73c Merge pull request #399 from LinusDierheimer/dev
Release 1.9.0
2023-01-22 01:09:35 +01:00
李通洲 e0b2db17c2 Changelog: update version 2023-01-22 00:39:45 +08:00
李通洲 f360e10050 Release: 1.9.0 2023-01-22 00:32:41 +08:00
Linus Dierheimer c15f55762d Disk(Linux): Use mountpoint as last fallback for disk name 2023-01-21 14:57:30 +01:00
Linus Dierheimer 7edc715cba Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-01-21 14:43:02 +01:00
Linus Dierheimer 27f76599bc Fix subvolume detection
#396
2023-01-21 14:42:19 +01:00
李通洲 e8bde5a394 Wifi: fix compiling on macOS 2023-01-21 16:23:28 +08:00
李通洲 3b820f1145 Doc: document wifi / battery support on Android 2023-01-21 16:04:16 +08:00
李通洲 c1444c0822 Android: support Wifi & Battery by using termux-api 2023-01-21 15:23:40 +08:00
李通洲 b424c525cc Disk (Android): fix compiling errors 2023-01-21 14:09:07 +08:00
李通洲 f640102b0e CPU (Linux): fix compiler warnings 2023-01-21 14:03:57 +08:00
李通洲 d9e79a5376 Fastfetch: print more info with -v 2023-01-21 10:33:09 +08:00
Linus Dierheimer 734ee38641 Disk (Linux): partition name impl & general refactor 2023-01-20 20:25:22 +01:00
李通洲 e651633c54 Temp: detect both device/class anddevice/device/class 2023-01-21 06:54:51 +08:00
李通洲 6d4bd06ffe Fastfetch: add missing \n when printing messages 2023-01-21 06:27:39 +08:00
李通洲 2af07fee4f Changelog: doc cpu temp fix 2023-01-21 06:26:24 +08:00
李通洲 6f4bdafb0c Temp: fix severial issues. Fixes #398
1. Temp detection has been gated behind of `--*-temp`. Don't make it a slow operation
2. According to [the kernel doc](https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface), `temp1_input` is millidegree Celsius, which should be divided by 1000
3. There is no `/sys/class/hwmon/hwmon3/device/class` on my laptop, but `/sys/class/hwmon/hwmon3/device/device/class`. Need to confirm with @LinusDierheimer
4. Small code optimizations
2023-01-21 06:18:19 +08:00
Linus Dierheimer a71f2142bb Disk(Linux): Better subvolume detection
#396
2023-01-20 13:28:25 +01:00
李通洲 1e9ec5424a Global: add NO_CONFIG env variable
to disable parsing config files, for debugging purpose.
2023-01-20 16:05:03 +08:00
李通洲 068cbafe3d Packages: detect pacman package count inside MSYS2 env (Windows) 2023-01-18 23:10:28 +08:00
李通洲 4ce618c33c DisplayServer: fix win32 compatibility 2023-01-18 22:44:24 +08:00
李通洲 10b997608b Font: optimise output for Windows 2023-01-18 18:01:09 +08:00
Linus Dierheimer 5edab414d8 Cursor: prefer gtk over Xresources
#382
2023-01-17 17:49:41 +01:00
李通洲 6e904047f9 Display: document scaled resolution support 2023-01-17 23:07:20 +08:00
李通洲 fdb0cfb4df Display: detect scaled resolution (Windows) 2023-01-17 21:36:43 +08:00
李通洲 58999995f1 Display: split phycial resolution and scaled resolution 2023-01-17 19:09:18 +08:00
李通洲 f4a58036fa Resolution: rename to display 2023-01-17 18:21:53 +08:00
李通洲 65e2331979 CI: print brightness 2023-01-18 01:00:30 +08:00
李通洲 622a5c267b Wifi: fall back to ioctls if fail to loading libnm libs 2023-01-18 01:00:00 +08:00
李通洲 c746cde61e Wifi: code refactor; fix a silly copy & paste error 2023-01-17 15:52:51 +08:00
李通洲 68977be256 CI: build with libnm support; print supported features 2023-01-17 15:38:03 +08:00
李通洲 f28805fb94 Wifi: detect more information using libnm (Linux) 2023-01-17 05:36:43 +08:00
李通洲 df793c20fd Wifi: use ioctls instead of iw (Linux) 2023-01-17 10:43:55 +08:00
Linus Dierheimer a4e4e9c495 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-01-16 11:53:13 +01:00
Linus Dierheimer b1ccd2e2c0 Don't show subvolumes by default 2023-01-16 11:52:54 +01:00
李通洲 9a2687768f FFPlatform: remove extra / 2023-01-16 18:23:54 +08:00
Linus Dierheimer ab7b0571f3 Fix config files loading other config files 2023-01-15 20:03:28 +01:00
李通洲 14286e8c0f Fix typo 2023-01-16 01:20:10 +08:00
李通洲 6b41b85d4d Windows: fix sigfault 2023-01-16 01:18:13 +08:00
李通洲 cc7724dec4 FFPlatform: don't use target platform as running platform 2023-01-15 17:00:36 +08:00
李通洲 c832c7d794 Host: don't print None as product version 2023-01-15 16:55:33 +08:00
李通洲 52f36d29dc Doc: update CHANGELOG 2023-01-16 00:41:56 +08:00
李通洲 9b6dafe715 Packages: fix rpm count detection
Can't believe that this bug has existed for more than 3 months and no one found it
2023-01-16 00:41:35 +08:00
李通洲 d4ecbc6638 FFPlatform: fix memleaks 2023-01-16 00:35:48 +08:00
李通洲 1c93d68e7b Wifi: add basic Linux support using iw 2023-01-16 00:33:31 +08:00
Linus Dierheimer c1d92206f5 Third round of fixes for FFPlatform 2023-01-15 16:45:16 +01:00
Linus Dierheimer 7bef5008c2 Second round of fixes for FFPlatform 2023-01-15 16:26:08 +01:00
Linus Dierheimer 3ef3cca76b First round of fixes for FFPlatform 2023-01-15 16:06:50 +01:00
Linus Dierheimer a1d8e3e598 Introduce FFPlatform 2023-01-15 15:57:26 +01:00
Linus Dierheimer dd77ebe11e Fix GitHub code scanning alert 2023-01-14 19:59:54 +01:00
李通洲 27efc94b09 FFlist: silence compiler warnings when compiling with -m32 2023-01-15 01:02:10 +08:00
Linus Dierheimer b6abc6e326 Update logo doc 2023-01-14 17:54:21 +01:00
Linus Dierheimer f13a502123 Update logo doc 2023-01-14 17:50:14 +01:00
Linus Dierheimer f77f617bc2 Update Support Status 2023-01-14 17:20:36 +01:00
Carter Li 6ae9e0b332 Merge pull request #389 from CarterLi/command
RFC: an attempt to add a new module which can run custom shell scripts
2023-01-15 00:08:04 +08:00
Linus Dierheimer 8a054706b5 Fix build on linux 2023-01-14 17:00:56 +01:00
Linus Dierheimer 6e1d656a60 Fix budgie detection
#382
2023-01-14 16:58:09 +01:00
Linus Dierheimer 53430b9827 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-01-14 16:38:52 +01:00
Linus Dierheimer 026424ab8c Don't crash when uname fails
#385
2023-01-14 16:38:34 +01:00
李通洲 9c0fc63ee9 Windows: with cdff99, the special build for Win7 is no longer needed. Drop it. 2023-01-14 17:46:11 +08:00
李通洲 cdff99339e Windows: fix the last issue that breaks Win10- 2023-01-14 17:31:04 +08:00
李通洲 b739d94f23 Command: an attempt to add a new module which can run custom shell scripts 2023-01-14 01:27:54 +08:00
李通洲 e076097a7c FFlist: fix compiler warnings 2023-01-14 00:19:55 +08:00
李通洲 3cee8f5475 FFlist: add new functions to make it be able to work as a queue 2023-01-13 19:08:14 +08:00
李通洲 83ea189d81 GPU: simplify code 2023-01-13 15:46:29 +08:00
李通洲 dcf04aa4fe GPU: detect type based on vendor 2023-01-13 15:44:52 +08:00
李通洲 67ab7c0779 GPU: support vendor detection 2023-01-13 15:20:30 +08:00
李通洲 2b5511997c Global: support hiding other texts when printing percentage values 2023-01-12 22:46:21 +08:00
李通洲 53c6a0ec9f GPU: apply GPU type selection logic to Windows 2023-01-12 22:19:14 +08:00
Linus Dierheimer 1a710e4094 Better GPU type detection nr2
#379
2023-01-12 12:56:17 +01:00
Linus Dierheimer 5a90d8b545 Better GPU type detection
#379
2023-01-12 12:54:04 +01:00
Linus Dierheimer f794053f99 Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev 2023-01-12 11:42:23 +01:00
Linus Dierheimer 670cf6fe90 GPU selection options
#379
2023-01-12 11:41:07 +01:00
李通洲 46ed8aa87c TerminalFont: don't try to detecting kitty and tty fonts on Windows 2023-01-12 00:19:30 +08:00
李通洲 387b8298bd Windows: fix bug that line buffering doesn't work properly 2023-01-12 00:19:30 +08:00
李通洲 c4aa55d522 TerminalFont: support WezTerm on Windows 2023-01-12 00:09:42 +08:00
李通洲 c3861954dc TerminalFont: support Alacritty on Windows 2023-01-11 23:46:37 +08:00
李通洲 ebfbf108a2 TerminalShell: support Alacritty terminal version detection 2023-01-11 23:46:15 +08:00
李通洲 66ed9adcda TerminalShell: support ConEmu version detection 2023-01-11 22:14:47 +08:00
李通洲 eb02206c05 TerminalShell: support Windows Terminal version detection 2023-01-11 22:10:42 +08:00
李通洲 cd0b74b0de TerminalShell: support deepin-terminal version detection 2023-01-11 18:12:36 +08:00
李通洲 6ca3b76a42 Update README 2023-01-11 18:07:58 +08:00
李通洲 84a03e80de README: clarify that fastfetch isn't written in pure C
Ref: https://github.com/ScoopInstaller/Main/pull/4334#discussion_r1066502517
2023-01-11 17:37:49 +08:00
李通洲 a74f813df1 CHANGLOG: remove a duplicated entry
oops
2023-01-11 17:37:49 +08:00
李通洲 99fc4e76ec TerminalShell: fix build on Windows 2023-01-11 17:27:34 +08:00
李通洲 7145f5252d TerminalShell: add --shell-version and --terminal-version options to disable shell / terminal version detection
in case that users don't like it
2023-01-11 17:17:17 +08:00
李通洲 9dab23b5fc TerminalShell: code refactor 2023-01-11 16:45:34 +08:00
李通洲 09ff8d35bc TerminalShell: support xfce4-terminal version detection 2023-01-11 16:07:34 +08:00
李通洲 ee903d2d07 TerminalShell: support konsole version detection 2023-01-11 15:56:24 +08:00
李通洲 b2f978aa7c TerminalShell: support kitty version detection 2023-01-11 15:14:29 +08:00
李通洲 76d957a144 TerminalShell: support gnome-terminal version detection 2023-01-11 15:12:32 +08:00
李通洲 a0acfeed56 TermiinalShell: code refactor 2023-01-11 15:03:16 +08:00
李通洲 b1f63ab822 Global: rename FF_UNUSED_PARAM to FF_MAYBE_UNUSED since it can be used on functions too. 2023-01-11 14:47:10 +08:00
李通洲 54ea9c2386 TerminalFont: support WezTerm font detection 2023-01-11 13:58:59 +08:00
李通洲 ccdb5c54d0 Linux: enable FF_*_AUTO_DESTROY
They have been on Windows and macOS for sometime and worked well.
2023-01-11 13:55:06 +08:00
李通洲 b8393051e4 Battery: add comments for future use (FreeBSD) 2023-01-11 13:52:14 +08:00
李通洲 94a8e0339e Windows: remove outdated comments 2023-01-11 13:51:47 +08:00
李通洲 a67ba713f5 Windows: fix CLANG64 build 2023-01-11 09:37:00 +08:00
李通洲 8ffbae80b8 Windows: clarify we support Windows 7 and newer only 2023-01-11 01:23:42 +08:00
李通洲 db17f95ce8 TerminalShell: detect Termux version 2023-01-10 21:11:44 +08:00
李通洲 c6365755c7 Title: fix computer name being trancated sometime 2023-01-10 20:56:54 +08:00
李通洲 ef2a5110fe TerminalShell: detect terminal version when available 2023-01-10 19:26:33 +08:00
李通洲 7f97725d7f Disk: add --disk-show-unknown option
Ref: https://github.com/LinusDierheimer/fastfetch/issues/383#issuecomment-1376893128
2023-01-10 17:31:47 +08:00
李通洲 af03c74fba Battery: fix build on macOS 2023-01-10 16:56:56 +08:00
李通洲 bc8a7a03c3 Battery: fix bug on FreeBSD
oops
2023-01-10 12:42:15 +08:00
李通洲 d4c361ae12 Battery: support FreeBSD
Completely untested
2023-01-10 12:36:38 +08:00
李通洲 8f932ac3d6 DisplayServer: fix build (Linux) 2023-01-09 22:33:10 +08:00
李通洲 4cc5f35b04 DisplayServer: revert changes of brightness partially 2023-01-09 22:26:56 +08:00
李通洲 476b0495e0 Brightness: add support for Windows 2023-01-09 22:26:56 +08:00
李通洲 85098a6627 Brightness: add support for Linux 2023-01-09 22:26:56 +08:00
李通洲 d9a022ffff Brightness: add new module (macOS)
It turns out that merging brightness module into resolution module is a bad idea.
2023-01-09 22:26:56 +08:00
Linus Dierheimer 8db1534ef3 Merge pull request #381 from aaronfranke/cpu-riscv
Add support for displaying the ISA string on RISC-V CPUs
2023-01-09 15:22:17 +01:00
Linus Dierheimer 0aa7d646a7 Initial logo documentation 2023-01-09 15:20:30 +01:00
Carter Li 599c06e981 Merge pull request #384 from VergeDX/dev
fix[getNixPackagesImpl]: count line with `wc -l` instead, also fixes leak.
2023-01-09 19:13:05 +08:00
Vanilla 078cb6e5b7 fix[getNixPackagesImpl]: count line with wc -l instead, also fixes leak. 2023-01-09 18:58:52 +08:00
Aaron Franke 5cc17bc306 Add support for displaying the ISA string on RISC-V CPUs 2023-01-09 02:21:26 -06:00
李通洲 ef18c8e3f7 Users: remove "wtsapi32_extend" as mingw_w64 now officially supports these APIs
Ref: https://github.com/mirror/mingw-w64/commit/931ca20b233e766950e7758cff71c270937b0b64
2023-01-09 14:03:46 +08:00
李通洲 012c7552eb macOS: try fixing #380 2023-01-09 13:42:58 +08:00
李通洲 0fd63084dc Global: fix other possible bugs where enumerating directories without ignoring . and .. 2023-01-09 10:45:51 +08:00
李通洲 0b12e73eef DisplayServer: make brightness detection actually work (Linux) 2023-01-09 10:44:09 +08:00
李通洲 4daf3016f8 Global: fix memleaks 2023-01-09 10:02:48 +08:00
李通洲 9f8e256bb4 DisplayServer: support brightness detection (Linux) 2023-01-08 20:47:06 +08:00
Linus Dierheimer 1bbcd9ad0d Look for logo files in <datadir>/fastfetch/logos/ too
#375
2023-01-08 12:30:36 +01:00
Linus Dierheimer b1c0a2dc1e Better init of config & data dirs 2023-01-08 11:32:43 +01:00
Linus Dierheimer 2a092de8d8 Detect data dirs at runtime
* Respecting the current platform
* Using them where appropiate
2023-01-08 01:41:09 +01:00
Linus Dierheimer bb57714ac9 Use configDirs to look for fastfetch configs 2023-01-07 22:51:47 +01:00
Linus Dierheimer 137039f868 Initialize brightness on wayland too 2023-01-07 22:37:01 +01:00
李通洲 e7af38aa11 DisplayServer: make display brightness actually work (Windows) 2023-01-08 01:27:54 +08:00
李通洲 d0bab2ca22 Image: fix compiler warnings (Windows) 2023-01-08 01:27:54 +08:00
李通洲 2621c48f92 DisplayServer: support brightness detection (Windows) 2023-01-08 01:27:54 +08:00
李通洲 959540f17c DisplayServer: support brightness detection (macOS) 2023-01-08 01:27:54 +08:00
李通洲 3e2c344417 Android: honor $XDG_CONFIG_HOME when loading user config file 2023-01-08 01:27:34 +08:00
李通洲 a307977ec1 Image: don't try to read image file with --logo none 2023-01-08 01:26:10 +08:00
李通洲 f3db4e49b6 Windows: store config file in RoamingAppData instead of LocalAppData 2023-01-03 17:01:24 +08:00
李通洲 30f9bcbd22 TerminalFont: fix mintty terminal font detection 2023-01-03 17:01:24 +08:00
李通洲 a98c71aab4 Config: search for user config file in the order of configDirs
This is necessary to keep forward compatibility for Windows / macOS users. Since `$LOCALAPPPATH` and `~/Library/Preferences` are now the first element of `configDirs`, config files in `~/.config` won't be used in previous manner.
2023-01-02 17:27:06 +08:00
李通洲 0d722ebe0b Config: add --list-config-paths option 2023-01-02 16:51:11 +08:00
李通洲 3caa92c567 macOS: looking for config files in ~/Library/Preferences 2023-01-02 16:34:57 +08:00
李通洲 ae6d921f23 Config: don't generate a config file silently
Instead, provide a new flag `--gen-config` and print the path to the config file, so that users can know where to find the file.
2023-01-02 16:34:57 +08:00
李通洲 d692fe91fb Windows: don't try to load config file in /etc 2023-01-02 16:34:57 +08:00
李通洲 822496808d Windows: look for config files in $LOCALAPPDATA 2023-01-02 16:34:57 +08:00
Linus Dierheimer 8533dc234b Update Changelog 2023-01-01 18:33:24 +01:00
Linus Dierheimer 2193fb531f Merge pull request #378 from IamNoRobot/pi-logo
fixed formatting error
2023-01-01 18:23:28 +01:00
Linus Dierheimer c069d14af5 Merge pull request #373 from IamNoRobot/pi-logo
RaspberryPi Logo, RaspberryPi small logo
2023-01-01 18:18:32 +01:00
IamNoRobot 02abc07bc1 fixed formatting error 2023-01-01 18:18:01 +01:00
IamNoRobot 34c33dd42f RaspberryPi Logo, RaspberryPi small logo 2023-01-01 18:05:09 +01:00
Linus Dierheimer dcc22f3bd7 Merge pull request #376 from jessebot/patch-1
Fix error text typo from item to iterm
2023-01-01 15:47:59 +01:00
JesseBot 4247d15672 Fix error text typo from item to iterm 2023-01-01 15:39:03 +01:00
李通洲 39d8ebc3c9 Logo: support --logo-padding-top 2023-01-01 17:37:11 +08:00
李通洲 8e3b6280af Image: support iterm protocol with --logo-type
fixes #374
2023-01-01 17:09:30 +08:00
李通洲 4a781d8471 Logo: support raw image type
For raw image type, fastfetch nether parses the file content, nor tries to detect the image size from the file. It's useful to print pre-converted sixel image.
2023-01-01 17:06:18 +08:00
李通洲 9f93ca8019 README: document image logo support 2023-01-01 12:29:08 +08:00
IamNotARobot 4890cb641c RaspberryPi Logo, RaspberryPi small logo 2022-12-31 17:52:47 +01:00
Linus Dierheimer 90bb004940 Merge pull request #371 from LinusDierheimer/master
Merge pull request #370 from LinusDierheimer/dev
2022-12-31 13:15:21 +01:00
Linus Dierheimer 70df34caf9 Merge pull request #370 from LinusDierheimer/dev
Release 1.8.2
2022-12-31 12:45:13 +01:00
李通洲 c04b421f26 README: fix unexpectedly concated paragraphs 2022-12-31 19:33:44 +08:00
李通洲 e292470ade Release 1.8.2 2022-12-31 19:25:59 +08:00
李通洲 c0d3dc30e1 Changelog: update 1.8.2 2022-12-31 18:56:45 +08:00
李通洲 01df2ae3e4 CI: align artifact names to other platforms (Windows) 2022-12-31 18:56:45 +08:00
李通洲 f8174a67d7 Wifi: don't use libcJSON as wlanapi's dll name 2022-12-31 18:12:23 +08:00
李通洲 53265f6b7f Users: fix memleaks (Windows) 2022-12-31 18:12:23 +08:00
李通洲 f245492679 TerminalShell: fix shell detection when installed with scoop 2022-12-31 12:42:19 +08:00
Linus Dierheimer 6f92524ada Merge pull request #369 from LinusDierheimer/dev
Release 1.8.1
2022-12-30 18:51:52 +01:00
Linus Dierheimer b2ff1501aa Update Changelog 2022-12-30 18:49:58 +01:00
Linus Dierheimer fbb4ab590f Local IP: Key: Clear before reuse
#368
2022-12-30 18:42:26 +01:00
李通洲 e2cadf85f8 Changelog: credit #365 2022-12-30 22:03:53 +08:00
李通洲 b5c2c9ee7a Release 1.8.1 2022-12-30 22:00:11 +08:00
李通洲 1dabac9782 Media: remove the alias name Song to avoid confusion
So we don't have code like `#define FF_SONG_MODULE_NAME "Media"`.
Also fix the error `unknown option: --media-format`
2022-12-30 11:21:11 +08:00
Linus Dierheimer 50983f83f5 Generic decoding for mountpoints
#364
2022-12-29 23:19:44 +01:00
Linus Dierheimer 5026be2d28 Fix parsing mountpoints with backslashes
#364
2022-12-29 22:58:29 +01:00
Linus Dierheimer 70aad5c320 Fix parsing mountpoints with spaces
#364
2022-12-29 22:51:23 +01:00
Linus Dierheimer e74d21c0e5 Merge pull request #365 from IanManske/parse-color-fix
Fix color parsing.
2022-12-29 22:33:59 +01:00
Ian Manske 90d8677b7a Add missing else statement. 2022-12-29 12:51:00 -05:00
李通洲 7a5d88270e macOS: fix building with old xcode
Makes homebrew happy
https://github.com/Homebrew/homebrew-core/pull/119329
2022-12-30 01:13:04 +08:00
Linus Dierheimer 5599335965 Zip windows artifacts 2022-12-29 14:40:37 +01:00
Linus Dierheimer e829589875 Merge pull request #363 from LinusDierheimer/dev
Bump CMakeList version
2022-12-29 13:47:18 +01:00
李通洲 98acd516b8 CMake: bump version 2022-12-29 20:24:30 +08:00
李通洲 584d792f5a Bios: try supporting FreeBSD
It prints nothing on my VM. Don't know if it works on a physical machine.
2022-12-29 20:23:44 +08:00
Carter Li e6db860861 Merge pull request #362 from LinusDierheimer/dev
Merge macOS Bios module support for 1.8.0
2022-12-29 12:54:32 +08:00
李通洲 f0ec3cb9ec README: update building instructions for Windows
Fixes #336
2022-12-29 12:51:20 +08:00
Carter Li 0801e22dce Bios: support macOS 2022-12-29 11:03:33 +08:00
李通洲 5efd7b9ac4 FFstrbuf: add ffStrbufContainC 2022-12-29 11:03:33 +08:00
Linus Dierheimer f2bae200d3 Merge pull request #361 from LinusDierheimer/dev
Release 1.8.0
2022-12-28 15:26:12 +01:00
李通洲 fd14513aef Changelog: add changes for 1.8.0 2022-12-28 21:28:23 +08:00
李通洲 6becc8f334 Swap: improve performance on Linux
We can't do the same thing with memory because there is no `cachedram` in `struct sysinfo`
2022-12-28 17:27:35 +08:00
李通洲 90359d227e Global: don't require sysinfo.h globally
... which is Linux specific
2022-12-28 17:20:20 +08:00
李通洲 6ff67e87eb Memory: refactor, don't cache results 2022-12-28 17:20:20 +08:00
李通洲 0a83423731 Packages: support eopkg for Solus (#360)
UNTESTED
2022-12-27 17:36:58 +08:00
李通洲 5160644016 Logo: add Solus logo (#360) 2022-12-27 17:32:19 +08:00
李通洲 d956bd2643 Image: update cache folder's name 2022-12-27 17:25:19 +08:00
Carter Li 7a6a2ad530 Chassis: fix compiler warnings
My fault
2022-12-25 23:24:50 +08:00
李通洲 21c76f31c4 Chassis: fix compiler warnings 2022-12-25 12:43:48 +08:00
李通洲 cb48c1277a Chassis: seperate module
It's only supported on Linux
2022-12-24 23:00:38 +08:00
Carter Li 3c18fd8920 Merge pull request #358 from doubletimedan/dev
Spelling and grammer fixes
2022-12-24 20:58:59 +08:00
Daniel Coughlan 83c6e809c6 Correct Windows version 2022-12-24 12:09:11 +00:00
李通洲 dc35fedd74 TerminalShell: detect Windows Terminal Preview 2022-12-24 13:00:43 +08:00
李通洲 947923567f TerminalShell: fix mintty detection (Windows) 2022-12-24 12:52:13 +08:00
Daniel Coughlan 3d19388086 Spelling and grammer fixes 2022-12-23 22:17:40 +00:00
李通洲 051f6643a6 Image: fix build 2022-12-23 15:23:37 +08:00
李通洲 47e01a7157 Image: print more debug info when errored 2022-12-23 12:51:37 +08:00
李通洲 a336145ed9 Image: add fast path for kitty protocol 2022-12-23 12:45:57 +08:00
李通洲 ecc6b477dc TerminalFont: support Kitty 2022-12-23 11:11:27 +08:00
李通洲 e0c6c462a6 README: update document of Windows 10- and image logo support 2022-12-22 22:10:49 +08:00
李通洲 3e607680e2 Image: dont leak memories 2022-12-22 21:47:30 +08:00
李通洲 89347b7bee Image: add dirty support of iTerm image protocol
iTerm image protocol supports most commonly used image formats so we don't need image magick to convert image format.
However, since we don't know anything about the image, `--logo-width` `--logo-height` must be specified to make sure that logo will not be covered by texts.
2022-12-22 21:37:16 +08:00
李通洲 c45ef08926 Image: expose more chafa settings 2022-12-22 11:36:13 +08:00
Linus Dierheimer 8d40b2cd0e Merge pull request #355 from kojq/dev
Update help.txt
2022-12-21 21:37:24 +01:00
kojq 14e318c273 Merge branch 'dev' into dev 2022-12-21 15:20:20 -05:00
李通洲 f50b478966 Image: try fixing caching 2022-12-22 02:40:56 +08:00
李通洲 0cacedfc5d Image: enable Chafa on Windows
It's not built by default, as imagemagick requires too many dlls.
2022-12-22 02:07:57 +08:00
Linus Dierheimer 5283f10189 Merge pull request #357 from AloneER0/dev
Added OpenMandriva
2022-12-21 18:42:22 +01:00
AloneER0 c9c2526f08 Added OpenMandriva 2022-12-21 17:27:00 +01:00
kojq fba4bca46e Merge branch 'dev' into dev 2022-12-21 07:51:49 -05:00
Carter Li a95eb65faa Merge pull request #352 from CarterLi/dev
Global: remove caching functions except image caching
2022-12-21 19:29:55 +08:00
kojq bcc7b630ae Update help.txt 2022-12-21 04:38:28 -05:00
kojq a247a8d6ba Update help.txt 2022-12-21 04:23:57 -05:00
kojq 620adc0ec6 Update help.txt 2022-12-21 04:10:33 -05:00
kojq d5b3ae9056 Update help.txt 2022-12-21 04:02:02 -05:00
kojq afe56a36c9 Update help.txt 2022-12-21 03:52:16 -05:00
kojq 265b98311a Update help.txt 2022-12-21 03:51:02 -05:00
kojq 89983a28b4 Update help.txt 2022-12-21 03:44:48 -05:00
kojq c9918035ed Update help.txt 2022-12-21 03:31:23 -05:00
李通洲 225d1dd4d2 Init: don't try to find config files in XDG folders on platforms other than Linux and BSD 2022-12-20 23:29:23 +08:00
李通洲 985fc991e8 Revert "Image: tidy"
This reverts commit d21ce9b10f.
2022-12-20 22:44:45 +08:00
李通洲 8f3900a9df Windows: add manifest file to indicate that we use UTF-8 and support Windows 10+ 2022-12-20 22:40:06 +08:00
李通洲 d21ce9b10f Image: tidy 2022-12-20 22:37:15 +08:00
李通洲 1153d29099 TerminalFont: improve conhost font detection (Windows) 2022-12-20 12:03:05 +08:00
李通洲 75341e8172 Image: make it compile on Windows
Doesn't work yet.
2022-12-20 11:37:54 +08:00
李通洲 2f5cbfb03a Image: enable im7 on macOS 2022-12-20 11:04:57 +08:00
李通洲 01d2d77efd Image: fix resource leaks 2022-12-20 11:01:42 +08:00
李通洲 1b2a61ed49 Image: init MagickCore environment before using it
I don't know why im6 works without initialization, but im7 doesn't.
2022-12-20 11:01:13 +08:00
李通洲 10584eb01a Image: document macOS support; update CI 2022-12-19 22:34:29 +08:00
李通洲 d4ec500b1b Image: fix compile error when building with chafa enabled
It should be `#include <chafa.h>` because `pkg-config chafa --cflags` prints `-I/usr/include/chafa` even in Linux. It was working because `chafa` folder was installed in the standard `/usr/include` directory, but it was not the case for macOS (brew)
2022-12-19 22:34:29 +08:00
李通洲 c7bec3d0c9 Image: enable imagemagick 6 on macOS
Program crashed when imagemagick 7 used, for some reason.
2022-12-19 22:34:29 +08:00
李通洲 ff6e982050 Global: remove caching except image caching 2022-12-17 12:41:11 +08:00
李通洲 6a49ae60a1 Locale: silence warnings (Windows) 2022-12-17 12:34:21 +08:00
李通洲 27fb0c6c06 Battery: improve performance (Windows) 2022-12-17 12:31:37 +08:00
李通洲 047b32e7d9 CpuUsage: make the result more accurate 2022-12-17 12:31:31 +08:00
李通洲 eeb008f505 Global: replace all ".so" to FF_LIBRARY_EXTENSION
... no matter whether the libraries are linux specific or not
2022-12-17 12:22:11 +08:00
Linus Dierheimer 704834b370 Merge pull request #350 from JackGannonUK/dev
Add Enso Logo
2022-12-16 19:06:53 +01:00
李通洲 a3cb6608ce Locale: refactor 2022-12-16 11:51:32 +08:00
Jack Gannon 7640042905 add enso logo
Added Enso Logo in `src/logo/builtin.c`
Added Enso in `README.md`
2022-12-15 16:57:45 +00:00
李通洲 d601cc823c DisplayServer: make 3rd party window manager plugin detection a slow operation (macOS)
The display server of macOS is [Quartz Compositor](https://en.wikipedia.org/wiki/Quartz_Compositor), not other 3rd party apps.
2022-12-14 19:03:01 +08:00
李通洲 338cc1db40 Add back trailing white spaces which are unexpectedly removed by IDE
This partially reverts commit 6710967d19.
2022-12-14 16:51:45 +08:00
李通洲 6710967d19 README: update notes for Windows 10- 2022-12-14 16:46:52 +08:00
李通洲 e4a5194115 Rework stdout buffering on Windows.
Windows doesn't support line-buffering. We enable full-buffering instead and flush buffers per module.
2022-12-14 16:27:04 +08:00
李通洲 d151901049 Common: improve resolution of ffTimeGetTick 2022-12-14 15:43:53 +08:00
李通洲 c9e9ec3a80 CI: print time usage 2022-12-14 14:10:42 +08:00
李通洲 54912df237 Option: enable --show-errors if --stat is set 2022-12-14 13:52:16 +08:00
李通洲 b09aa3240a Global: support --stat option for benchmark 2022-12-14 11:30:50 +08:00
李通洲 c9bc1f8306 Vulkan: build with vulkan-loader (macOS)
... so cmake can find it
2022-12-13 13:12:13 +08:00
李通洲 7e98fa8626 Vulkan: don't require vulkan-loader (macOS)
Which also avoids requiring portability_enumeration extension
2022-12-13 11:21:26 +08:00
李通洲 3b2c189083 Packages: split brew-cellar and brew-cask (macOS)
`brew info` shows number of `brew-cellar` packages only. Split `brew-cellar` out of `brew` to avoid users from confusion.
2022-12-13 11:13:00 +08:00
Linus Dierheimer c242001a77 Fix build without chafa 2022-12-12 13:58:16 +01:00
Linus Dierheimer b21cfc127a Termialshell: ignore sh 2022-12-12 13:55:19 +01:00
Linus Dierheimer 3a5af1bbb3 Logo: data source option
#345
2022-12-12 13:43:10 +01:00
李通洲 68b98c1bd2 Windows: disable stdout buffer 2022-12-10 22:47:53 +08:00
李通洲 24ae7ec6e0 Windows: build msvcrt version for Windows 10-
However we don't include it in release package to prevent users from confusion.

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

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

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

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

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

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

* 2022-09-29 07:06:58.649 flashfetch[92995:31447779] XType: com.apple.fonts is not accessible.
* 2022-09-29 07:06:58.649 flashfetch[92995:31447779] XType: XTFontStaticRegistry is enabled.
2022-09-29 22:19:08 +08:00
Linus Dierheimer 287ba33d12 Merge pull request #269 from CarterLi/master
Font: fix compiling on Android; detect more fonts on macOS
2022-09-29 16:15:44 +02:00
李通洲 ca75b6b55b Font: fix compiling on Android; detect more fonts on macOS 2022-09-29 22:13:27 +08:00
Linus Dierheimer 666b596f63 Update FreeBSD action 2022-09-29 16:04:18 +02:00
Linus Dierheimer 5b68cdc0dd Fix compilation warning on linux 2022-09-29 15:53:28 +02:00
Linus Dierheimer 0f47a27d09 Install some more packages for freebsd build 2022-09-29 15:45:13 +02:00
Linus Dierheimer e6e189497d Refactor font output 2022-09-29 14:15:11 +02:00
Linus Dierheimer 32d3b265bb Fix compilation warning on linux 2022-09-29 12:51:46 +02:00
Linus Dierheimer ca318431f5 Merge pull request #266 from CarterLi/master
Improve performance of PublicIP; add module Weather; fix compiling for Linux
2022-09-29 12:41:19 +02:00
李通洲 8a52836afc Init: don't pay for unused module
Networking can be very slow
2022-09-29 18:33:37 +08:00
李通洲 9cf95620a9 Weather: add new module 2022-09-29 18:33:37 +08:00
李通洲 c72c6c4a27 PublicIp: add option to set public IP server URL 2022-09-29 18:33:37 +08:00
李通洲 e289db184c PublicIp: improve performance 2022-09-29 18:33:37 +08:00
李通洲 e7c9b80d85 Fix building on Linux
It seems that glibc doesn't support strnstr, and strcasestr requires
_GNU_SOURCE to be defined
2022-09-29 18:33:37 +08:00
Linus Dierheimer b8656d5e12 Fix build on BSD 2022-09-29 12:24:00 +02:00
Linus Dierheimer c8486610f6 Don't build multithreaded 2022-09-29 12:15:52 +02:00
Linus Dierheimer d727f8acde Use hw.ncpu in bsd action 2022-09-29 12:08:40 +02:00
Linus Dierheimer 8c64e0c275 Try to add a FreeBSD action 2022-09-29 11:37:52 +02:00
Linus Dierheimer 40588e1a39 Fix build on MacOS
#261
2022-09-29 11:35:59 +02:00
Linus Dierheimer 6c024d29ce Merge pull request #263 from CarterLi/master
Support terminal font detection on Android and other fixes
2022-09-27 17:44:47 +02:00
李通洲 db6ad5a268 CpuUsage: improve performance
by moving the first `/proc/stat` query earlier
2022-09-27 23:41:39 +08:00
李通洲 5096b4a81d Common: add missing features 2022-09-27 23:30:55 +08:00
李通洲 5c64ce3b89 Users: add missing module settings 2022-09-27 23:30:55 +08:00
李通洲 38a6d07c85 TerminalFont: support Termux 2022-09-27 23:30:55 +08:00
李通洲 4632fe8cd9 Android: fix compiling 2022-09-27 23:30:55 +08:00
Linus Dierheimer d8bfebfc0f Update readme 2022-09-27 15:05:41 +02:00
Linus Dierheimer 48300429af Keep detected colors when using none logo
#264
2022-09-27 15:02:35 +02:00
Linus Dierheimer 218dffadd3 Merge pull request #258 from CarterLi/master
[macOS] support Temps, Font; Host pretty print; other improvements
2022-09-26 10:45:14 +02:00
李通洲 f324794f54 LocalIp: add option --localip-name-prefix
eg: --localip-name-prefix en
2022-09-26 16:20:51 +08:00
李通洲 6e3a329d3b Users: add new module
I don't think it's very useful but neofetch support it
2022-09-26 15:29:11 +08:00
李通洲 b2da8bac41 Font: add option to display fonts inline ( enabled by default ) 2022-09-26 15:29:11 +08:00
李通洲 100e59fd49 Temps: add options to enable detection ( disabled by default ) 2022-09-26 15:29:11 +08:00
李通洲 5fdb0719f2 Host: pretty printing hardware model ( macOS ) 2022-09-26 15:29:11 +08:00
李通洲 d4368f56fd Datetime: fix pretty printing 2022-09-26 15:29:11 +08:00
李通洲 55c939a8ef macOS: don't build cursor / icons / theme 2022-09-26 15:29:11 +08:00
李通洲 0be2410925 Font: support macOS
The original result format was too Linux specific to make it portable, so I simplified it.
2022-09-26 15:29:11 +08:00
李通洲 0f824536f9 Temps: open SMC service only once ( macOS ) 2022-09-26 15:29:11 +08:00
李通洲 51c70bc44a Temps: support macOS 2022-09-26 15:29:11 +08:00
李通洲 47a0b8969f FFstrbuf: more inline fns and more tests 2022-09-26 14:57:54 +08:00
李通洲 8df95224ed Android: fix build 2022-09-26 10:21:38 +08:00
Linus Dierheimer 4481d983a9 Merge pull request #260 from AloneER0/master
Fixed formatting
2022-09-25 21:11:47 +02:00
AloneER0 24e8158116 Fixed formatting 2022-09-25 16:05:06 +02:00
Linus Dierheimer 5239223ad5 Merge pull request #259 from AloneER0/master
New Ubuntu logo
2022-09-25 15:56:46 +02:00
AloneER0 1d9a938ff3 Restored Older Ubuntu Logo 2022-09-25 15:41:42 +02:00
AloneER0 cd01d16eb9 New Ubuntu logo 2022-09-25 13:31:59 +02:00
Linus Dierheimer 8e856c3dd6 Wayland: don't leak memory
#256
2022-09-24 16:34:03 +02:00
Linus Dierheimer b6dc436e03 Merge pull request #257 from CarterLi/master
Various improvements, see commits history for detail
2022-09-24 16:24:32 +02:00
李通洲 3f80fafc09 Android: fix build 2022-09-24 22:22:20 +08:00
李通洲 8e922abf73 TerminalFont: split code of different implementations 2022-09-24 22:18:48 +08:00
李通洲 737b36e799 FFstrbuf / FFlist: add some improvements
1. make some short fns inlinable
2. simplify implementation
3. fix possible crashes with non-allocated strbuf
4. make the default init fn allocates no memory
5. add more tests
2022-09-24 22:18:48 +08:00
Linus Dierheimer f5ac85c4e3 Only detect temps if --allow-slow-operations is given 2022-09-24 15:59:36 +02:00
Linus Dierheimer 0250d11d97 Merge pull request #255 from dr460nf1r3/master
Fix GiB MiB format RAM units due to value being hardcoded in some presets
2022-09-24 15:14:00 +02:00
dr460nf1r3 e88472e9f6 Oops, typo 2022-09-24 15:11:33 +02:00
dr460nf1r3 2907a26adf Fix GiBMiB format RAM units due to value being hardcoded in some presets 2022-09-24 15:09:53 +02:00
Linus Dierheimer d337126c80 Fix possible crash in strbuf 2022-09-24 00:43:55 +02:00
Linus Dierheimer 099fb1a43a Enable running workflow in private repository 2022-09-24 00:42:21 +02:00
Linus Dierheimer 6efe186df1 Merge pull request #254 from CarterLi/master
TerminalFont: support Windows Terminal on WSL
2022-09-23 19:59:17 +02:00
Linus Dierheimer f33f172734 Revert "Revert some changes"
This reverts commit 64d64d5050.
2022-09-23 19:54:18 +02:00
李通洲 d6a1caa89f TerminalFont: fix resource leaks on macOS 2022-09-24 01:49:08 +08:00
李通洲 ed5d7292ba TerminalFont: support Windows Terminal detection 2022-09-24 01:49:08 +08:00
Linus Dierheimer 4b0b6c9000 Merge branch 'master' of github.com:LinusDierheimer/fastfetch 2022-09-23 19:49:06 +02:00
Linus Dierheimer 64d64d5050 Revert some changes 2022-09-23 19:48:55 +02:00
Linus Dierheimer 1a996c3d67 Merge pull request #253 from CarterLi/master
[macOS] Disk & Media improvements
2022-09-23 16:08:52 +02:00
李通洲 ee7231d87c Media: fix detecting songs with CJK chars 2022-09-23 21:23:48 +08:00
李通洲 371b3a2d75 Disk: better folder detection, support removable devices ( macOS ) 2022-09-23 21:23:48 +08:00
Linus Dierheimer 007ded2883 Revert "Don't inline strbuf methods on macos"
This reverts commit c32f2f2f2b.
2022-09-23 12:11:04 +02:00
Linus Dierheimer c32f2f2f2b Don't inline strbuf methods on macos 2022-09-23 12:05:07 +02:00
Linus Dierheimer 98c94b01e5 Some more standard comformance 2022-09-23 11:51:16 +02:00
Linus Dierheimer 0dda4efa8d Merge pull request #251 from CarterLi/master
PowerAdapter: make it a seperated module ( macOS )
2022-09-23 10:46:56 +02:00
Linus Dierheimer 877ed94187 Fix possible crash if giving invalid format string
#252
2022-09-23 10:43:11 +02:00
李通洲 484264027c FFstrbuf: don't free string literals 2022-09-23 15:33:23 +08:00
李通洲 5498b0b042 PowerAdapter: make it a seperated module 2022-09-23 15:33:23 +08:00
Linus Dierheimer 8f30d0cdd8 Move inline functions to end of header 2022-09-23 01:27:25 +02:00
Linus Dierheimer 80f18e2473 Don't force inline 2022-09-23 00:49:43 +02:00
Linus Dierheimer 1700d23c26 Always inline some strbuf methods 2022-09-23 00:10:48 +02:00
Linus Dierheimer 195675f078 run.sh: add env to build as debug 2022-09-22 23:10:34 +02:00
Linus Dierheimer 0115b638de Destroy instance in flashfetch too 2022-09-22 22:04:32 +02:00
Linus Dierheimer 3d0653025e Leak sanitizer: no false positives 2022-09-22 22:02:58 +02:00
Linus Dierheimer 991d02e2c0 Merge pull request #249 from CarterLi/master
[macOS] add power adapter module
2022-09-22 20:50:03 +02:00
李通洲 cbab8d7f70 Fix some memleaks 2022-09-22 21:28:20 +08:00
李通洲 6e09157235 Battery: add power adapter support ( macOS ) 2022-09-22 19:07:18 +08:00
李通洲 464a57b319 Locale: simply 2022-09-22 17:51:30 +08:00
Linus Dierheimer d31d157b00 New caching mechanism for CPU 2022-09-21 17:26:10 +02:00
Linus Dierheimer 07231ffbbc Merge pull request #247 from CarterLi/master
[macOS] support cpuUsage and other improvements
2022-09-21 12:15:38 +02:00
李通洲 f9fa482b83 Locale: try detecting with locale command
in case $LC_* envs are not set ( macOS )
2022-09-21 18:10:50 +08:00
李通洲 65ed48a1bc Swap: prints Disabled instead of 0 B / 0 B (0%) which seems a bug 2022-09-21 18:10:50 +08:00
李通洲 3068b5bcb2 Memory: fix percentage calculation 2022-09-21 18:10:50 +08:00
李通洲 9da97f5860 WMTheme: fix detection on macOS; metion macOS support in README 2022-09-21 18:10:50 +08:00
李通洲 fa065c1040 Terminal: fix Alacritty detection on macOS 2022-09-21 18:10:50 +08:00
李通洲 664017ba81 OS: print codename ( macOS ) 2022-09-21 18:10:50 +08:00
李通洲 1d6fefd40b CpuUsage: support macOS 2022-09-21 18:10:50 +08:00
Linus Dierheimer fea4a9dfd5 Fix build with ancient libpci versions
#248
2022-09-21 12:02:14 +02:00
Linus Dierheimer 183c8d7904 Merge pull request #246 from CarterLi/master
WMTheme: support macOS
2022-09-20 18:14:22 +02:00
李通洲 e5b110375f FFlist: add tests 2022-09-20 23:56:43 +08:00
李通洲 6eed53217d FFstrbuf: fix bugs in ffStrbufAppendS; add more tests 2022-09-20 23:56:43 +08:00
李通洲 254c4e5f50 WMTheme: support macOS 2022-09-20 21:49:11 +08:00
Linus Dierheimer 01a917982c Fix build on macos 2022-09-20 15:21:39 +02:00
Linus Dierheimer a9cb178315 Better error messages for memory & swap 2022-09-20 15:12:24 +02:00
Linus Dierheimer ec4bd5d3a2 Merge pull request #245 from CarterLi/master
[macOS] add player detection
2022-09-20 13:18:26 +02:00
李通洲 7f19cb1d21 Battery: print error info instead of nan% ( macOS ) 2022-09-20 18:26:50 +08:00
李通洲 e60537512e Media: add playing status 2022-09-20 18:07:46 +08:00
李通洲 431f570f05 Media: support player detection ( macOS ) 2022-09-20 18:07:46 +08:00
李通洲 482e5a5eff util/cf_helpers: rename; return error info if failed 2022-09-20 17:50:14 +08:00
Linus Dierheimer c282384dab CPack: Build pkg on free bsd 2022-09-20 11:40:42 +02:00
Linus Dierheimer 81bddbf182 Update README.md 2022-09-20 11:23:49 +02:00
Linus Dierheimer b8fc471678 Better BSD support 2022-09-20 11:16:08 +02:00
Linus Dierheimer fd34811c81 Merge pull request #244 from draumaz/master
Add FreeBSD logo
2022-09-20 09:47:04 +02:00
draumaz 67c5a6b7cc add missing comma, update README 2022-09-20 01:42:51 +00:00
draumaz 6b02e1a0ca add to ffLogoBuiltinGetAll 2022-09-20 01:38:48 +00:00
draumaz 92f1604e6a add preliminary FreeBSD logo 2022-09-20 01:37:48 +00:00
Linus Dierheimer f0cee064bd Basic BSD support 2022-09-19 23:16:43 +02:00
Linus Dierheimer 6bd933eba2 Enable BSD support in CMake 2022-09-19 22:23:31 +02:00
Linus Dierheimer f3e6d04c8e Fix build on macos the second 2022-09-19 21:45:39 +02:00
Linus Dierheimer d5846d94ca Fix build on macos 2022-09-19 21:37:01 +02:00
Linus Dierheimer 2a61d29be9 sysctl utils 2022-09-19 21:31:50 +02:00
Linus Dierheimer 49cdacd5a9 Build cpu on free bsd 2022-09-19 19:31:29 +02:00
Linus Dierheimer ce6d7e386d Build wayland on free bsd 2022-09-19 19:29:13 +02:00
Linus Dierheimer fe1ad0da16 Build local ip on free bsd 2022-09-19 19:26:53 +02:00
Linus Dierheimer 6157de60e6 Processes: fail if neither apple nor sysinfo is present 2022-09-19 19:23:19 +02:00
Linus Dierheimer 61e71ed658 run.sh: only use -j$(nproc) on linux 2022-09-19 19:19:09 +02:00
Linus Dierheimer 381cba2612 Refactor ff_lib_enable 2022-09-19 18:30:00 +02:00
Linus Dierheimer 34b273186a FF_LIBRARY_LOAD: don't implicit create pointer 2022-09-19 18:00:19 +02:00
Linus Dierheimer e3acd8c155 Share more code between media detection on different platforms 2022-09-19 17:53:00 +02:00
Linus Dierheimer 55f28ae8ff Fix build with older libpci versions the second 2022-09-19 16:58:25 +02:00
Linus Dierheimer 6f2748e208 Merge pull request #242 from CarterLi/master
Media: support song detection on macOS
2022-09-19 16:46:20 +02:00
Linus Dierheimer fb3eb9666e Fix build with older libpci versions 2022-09-19 16:43:43 +02:00
Linus Dierheimer 8d663300c7 Detect FQDN only on linux 2022-09-19 15:57:52 +02:00
Linus Dierheimer d29d99bd6d Use pci_fill_info when possible 2022-09-19 15:54:27 +02:00
李通洲 bbdeb668d6 Media: support song detection on macOS 2022-09-19 20:05:23 +08:00
Linus Dierheimer 85578c6807 Don't use url for vlc or spotify player name 2022-09-18 17:32:15 +02:00
Linus Dierheimer 93871c1e98 Fix build on android 2022-09-18 17:16:45 +02:00
AloneER0 bcacaa9401 Add the Crystal Linux Logo (#239) 2022-09-18 17:06:37 +02:00
Linus Dierheimer d079e25a43 Fix some memory leaks 2022-09-18 16:30:26 +02:00
Linus Dierheimer b4306b944e Fix build on MacOS 2022-09-18 16:05:39 +02:00
Linus Dierheimer fd75f0b7e7 GH actions: build with libplist enabled 2022-09-18 16:00:28 +02:00
Linus Dierheimer 87c3459f5d Moved terminal font detection logic to detection folder 2022-09-18 15:53:51 +02:00
Linus Dierheimer 051a043a4b Merge pull request #237 from CarterLi/master
[macOS] Implement `swap` `processes` `Terminalfont`
2022-09-17 17:18:18 +02:00
Linus Dierheimer 913a3e79d4 Fixed a memory leak in config dirs init 2022-09-17 16:44:59 +02:00
Carter Li 59557e06fd CI: disable release job on fork repo 2022-09-17 21:09:37 +08:00
Carter Li 6d0d916861 CMake: enable AddressSanitizer in Debug mode 2022-09-17 21:09:37 +08:00
Carter Li a0a1c04011 Terminalfont: add Apple Terminal support ( macOS ) 2022-09-17 21:09:37 +08:00
Carter Li b59227e49f Terminalfont: add iTerm2 support ( macOS ) 2022-09-17 21:09:36 +08:00
Carter Li c64e2c14c2 Processes: add macOS support 2022-09-17 16:23:04 +08:00
Carter Li 8c6cf2ccda Swap: add macOS support 2022-09-17 11:21:05 +08:00
Linus Dierheimer bd657328d2 Merge pull request #236 from CarterLi/master
Various fixes
2022-09-17 01:29:04 +02:00
Carter Li 45d6f21402 GPU: better support Intel GPUs 2022-09-17 03:02:03 +08:00
Carter Li 4d569db0fd refactor: use MACH_PORT_NULL instead of magic number 0 2022-09-17 03:02:03 +08:00
Carter Li d46f9ab4dc util/cfdict_helpers: code improvements
1. simplify CFString usage
2. support get string from CFDataRef
2022-09-17 03:01:24 +08:00
Carter Li 3d4ce07892 Vulkan: set gpu->coreCount 2022-09-17 01:49:00 +08:00
Carter Li bb3689b348 GPU: fix Intel compatibility 2022-09-17 01:49:00 +08:00
Carter Li d5500ad4f7 Battery: fix Intel compatibility
`MaxCapacity` on Intel MBP is not 100
2022-09-17 01:49:00 +08:00
Carter Li 9e4a55d285 util/cfdict_helpers: fix stupid copy & paste errors 2022-09-17 01:49:00 +08:00
Linus Dierheimer 999b9187a0 Merge pull request #234 from SladeGetz/macports_expansion
Added support for MacPorts package manager
2022-09-16 19:24:34 +02:00
Slade Getz 73095ef9e9 Increased FF_PACKAGE_NUM_FORMAT_ARGS by 1 in src/modules/packages.c. Modified the help output in src/fastfetch.c. Added MacPorts pkg mngr to the README.md. 2022-09-16 11:13:02 -06:00
Slade Getz f4fc9692eb Merge branch 'LinusDierheimer:master' into macports_expansion 2022-09-16 10:57:50 -06:00
Linus Dierheimer 59ebc745c0 Merge pull request #235 from CarterLi/master
macOS: add battery info support; fix GPU detection; various improvements
2022-09-16 18:02:38 +02:00
李通洲 09f3bd5a79 GPU: correct detection of Apple M1 GPU
Don't cheat
2022-09-16 23:43:08 +08:00
李通洲 413d126bcc Battery: add dirty support for macOS 2022-09-16 23:43:08 +08:00
李通洲 9eeb216b70 util: add check macros to avoid possible mistakes 2022-09-16 23:43:08 +08:00
李通洲 f362fdb01d Battery: move detection code into src/detection
Prepare for macOS implementation
2022-09-16 23:43:08 +08:00
李通洲 155d4e90ae FFlist: support static init
Also fix possible memory corruption bug in ffListAdd
2022-09-16 18:39:27 +08:00
Linus Dierheimer df9aec6e86 Small updates 2022-09-16 09:56:21 +02:00
Slade Getz d903ccb6f6 Added support for MacPorts package manager 2022-09-15 14:17:33 -06:00
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
Linus Dierheimer 02cc214dfc Release 1.5.6
Bugfix: Don't segfault when connecting to some wayland compositors
See https://github.com/LinusDierheimer/fastfetch/issues/188
2022-07-03 16:16:39 +02:00
Linus Dierheimer 609fa14f4f Wayland: use a single, common stub listener 2022-07-03 16:10:17 +02:00
Linus Dierheimer 7d6f92a446 Wayland: only use required stub listeners 2022-06-30 12:22:46 +02:00
Linus Dierheimer bc76ebfb3f Wayland: add stub listeners 2022-06-30 12:16:38 +02:00
Linus Dierheimer c2da7b19f9 Song: Don't show album by default 2022-06-29 12:47:57 +02:00
Linus Dierheimer 41b024d3b1 Refactor wayland code the third 2022-06-29 11:08:42 +02:00
Linus Dierheimer 9b62d17d8d Refactor wayland code the second 2022-06-28 21:41:13 +02:00
Linus Dierheimer 1861d55f7d Refactor wayland code 2022-06-28 11:57:08 +02:00
Linus Dierheimer 3b2a6e4a6e Don't load sqlite3 id db path doesn't exist 2022-06-27 15:38:34 +02:00
Linus Dierheimer 8ab7a8ba37 Release 1.5.5
Feature: Detect wayland WM much faster
Bugfix: Wayland backend for resolution working once again
Bugfix: Plasma values are no longer victims to race conditions
2022-06-26 13:41:55 +02:00
Linus Dierheimer 22a3ab4a81 Detect wayland WM _much_ faster 2022-06-26 13:35:16 +02:00
Linus Dierheimer 44d6780545 Merge pull request #185 from artixnous/master
Fix misaligned Artix logo
2022-06-25 17:41:16 +02:00
nous 5820c9bbff Update builtin.c 2022-06-25 13:26:07 +03:00
Linus Dierheimer 3ba486a5b8 Wayland: switch to wl_proxy_marshal_constructor_versioned 2022-06-23 15:59:59 +02:00
Linus Dierheimer 2d2ba4c5b3 Wayland: switch to wl_proxy_marshal_flags 2022-06-23 15:51:29 +02:00
Linus Dierheimer 94ad782caa No unneeded casts 2022-06-23 10:44:53 +02:00
Linus Dierheimer b079e86c5e update bug_report.yml 2022-06-23 10:36:53 +02:00
Linus Dierheimer 91ba03d988 Add warning about public IP to bug_report.yml 2022-06-23 10:35:46 +02:00
Linus Dierheimer c440fdfca8 Uses instance->state.configDirs consistenlty (in particular thread save) troughout the project 2022-06-22 20:14:10 +02:00
Linus Dierheimer af0c72aa61 Methods for caching generic data 2022-06-20 16:35:15 +02:00
Linus Dierheimer 8fa09ca093 Refactored read methods 2022-06-20 16:27:33 +02:00
Linus Dierheimer 6e731c80d0 Refactored write methods 2022-06-19 18:22:00 +02:00
Linus Dierheimer 45eae78980 Better ordering in initCacheDir 2022-06-19 18:21:41 +02:00
Linus Dierheimer fb35a6e889 Release 1.5.4
Feature: Better WSL / WSLg support
Feature: --<module>-error arguments
Bugfix: Show GiB instad of GB
Feature: Export much more information to host format string
Feature: Expose CPU temp to cpu format string
Feature: Expose GPU temp to gpi format string
Bugfix: Print last line of logo, if it is higher than the infos
Logo: Alpine Linux
Refactor: Cleaned up header includes
Refactor: Build libfastfetch as OBJECT lib, as the linked binary is never needed
Feature: Detect termux as terminal
2022-06-18 23:39:48 +02:00
Linus Dierheimer 26d17250b6 Detect WSLg 2022-06-18 14:55:56 +02:00
Linus Dierheimer 9176797327 Detect Windows Terminal better 2022-06-18 14:51:10 +02:00
Linus Dierheimer 9d3f762c20 Better fallback for wayland detection 2022-06-18 15:27:46 +02:00
Linus Dierheimer fe71291769 Clean up includes 2022-06-18 14:25:31 +02:00
Linus Dierheimer f35dc9f46a Detect termux 2022-06-18 00:45:28 +02:00
Linus Dierheimer a6209187ae Fix build on Android part 4 2022-06-18 00:41:43 +02:00
Linus Dierheimer af2f97e0c9 Fix build on Android part 3 2022-06-18 00:22:07 +02:00
Linus Dierheimer 0691112e5e Fix build on Android part 2 2022-06-18 00:20:22 +02:00
Linus Dierheimer e61b31acab Fix build on Android 2022-06-18 00:15:23 +02:00
Linus Dierheimer 5d853f3b17 GPU temp detection 2022-06-17 23:38:33 +02:00
Linus Dierheimer 20e2f1e19d Detect CPU temp only if a custom format string is given 2022-06-17 20:41:11 +02:00
Linus Dierheimer ad28b3aac5 rename date-time to datetime 2022-06-17 20:40:51 +02:00
Linus Dierheimer eb0bbd0796 Detect WSL as host name 2022-06-17 20:01:02 +02:00
Linus Dierheimer da77a7936f Detect WSL as host 2022-06-17 19:59:01 +02:00
Linus Dierheimer eac875b8b1 Update bash completion to include --<module>-error options 2022-06-17 18:28:37 +02:00
Linus Dierheimer 97d2096df8 Delete performance test
I never really used it, and it didn't even build any more
2022-06-17 18:19:53 +02:00
Linus Dierheimer 6e3e717224 --<module>-error options 2022-06-17 18:15:36 +02:00
Linus Dierheimer aae182c889 Merge pull request #180 from draumaz/master
Add Alpine Linux logos
2022-06-17 10:44:54 +02:00
draumaz 5c7b9d223a Merge pull request #1 from draumaz/workbench
Merge Alpine Linux logos
2022-06-17 04:12:50 +00:00
draumaz c80f8cf422 further fixes 2022-06-16 21:11:14 -07:00
draumaz b150e8d106 whoops 2022-06-16 21:10:23 -07:00
draumaz bb897f03f0 add small logo 2022-06-16 21:08:39 -07:00
draumaz 517d80eadc update getAll function 2022-06-16 21:03:39 -07:00
draumaz 36964d6b1d Initial Alpine addition 2022-06-16 21:02:20 -07:00
Linus Dierheimer 5e96ba8384 Fix cpu temp detection the second 2022-06-16 14:55:02 +02:00
Linus Dierheimer 481affa50a Fix cpu temp detection 2022-06-16 14:39:01 +02:00
Linus Dierheimer a33e296656 Merge pull request #178 from Samisafool/patch-1
fix spelling of temperature
2022-06-16 14:17:07 +02:00
Samisafool 85a36ae7ef fix spelling of temperature 2022-06-16 17:10:59 +05:30
Linus Dierheimer 1eff343733 Finish exposing temperatur to cpu format 2022-06-16 13:36:00 +02:00
Linus Dierheimer acdbf6933c Merge pull request #177 from x-zvf/feature-cpu-temp
Add CPU package temperature to CPU module.
2022-06-16 13:21:34 +02:00
xzvf ea53833466 Remove unnecessary checks for content->length 2022-06-16 13:18:38 +02:00
xzvf c491c11988 update DEVELOPMENT.md 2022-06-16 13:15:48 +02:00
xzvf dcaeab7e96 Rewrite to use ffDetectTemps. 2022-06-16 13:14:03 +02:00
xzvf bccd1cf960 Merge pull request #1 from LinusDierheimer/master
build temps file
2022-06-16 13:14:03 +02:00
xzvf 5b030de20a Quality of life improvement: make run.sh not run ff, if the build fails 2022-06-16 13:14:03 +02:00
xzvf fa9b38eb2d Merge pull request #1 from LinusDierheimer/master
build temps file
2022-06-16 12:54:28 +02:00
Linus Dierheimer 716522e29a build temps file 2022-06-15 23:15:49 +02:00
Linus Dierheimer 921e4a6c8d Merge pull request #176 from x-zvf/fix-run-sh-script
Quality of life improvement: make run.sh not run ff, if the build fails
2022-06-15 16:43:59 +02:00
xzvf 7d43118abb Quality of life improvement: make run.sh not run ff, if the build fails 2022-06-15 16:28:07 +02:00
xzvf d8bb36f119 Add CPU package temperature to CPU module.
This is done by looking for a specified thermal zone in
/sys/class/thermal/thermal_zone*/ .
Unfortunately there is no better way to find the
temperature, then to check all registered zones.
This still needs to be extended to support other hardware,
right now only x86 CPUs and Raspberry pi are tested.
Maybe the FF_CPU_THERMAL_ZONES array could be user configurable,
but I could not figure out how to add an array as a config parameter.
2022-06-15 16:21:50 +02:00
Linus Dierheimer ae8b5bde65 Fix printing of remaining logo 2022-06-15 11:07:22 +02:00
Linus Dierheimer 3d8a071781 Update verbose 2022-06-14 20:07:42 +02:00
Linus Dierheimer 4cf912e535 Disk: Change GB to GiB 2022-06-14 17:17:22 +02:00
Linus Dierheimer e1b5445783 Export much more values to host format string 2022-06-14 17:10:46 +02:00
Linus Dierheimer a04daf1fff Clean up git ignore 2022-06-13 21:28:49 +02:00
Linus Dierheimer df0a4c0d46 Remove unneeded property set from CMakeLists.txt 2022-06-11 14:17:10 +02:00
Linus Dierheimer d70e160d72 Merge branch 'master' of github.com:LinusDierheimer/fastfetch 2022-06-10 23:02:11 +02:00
Linus Dierheimer 8c52cd0d91 Change libfastfetch target to be OBJECT library 2022-06-10 23:01:56 +02:00
Linus Dierheimer 4622d7a300 Change libfatsfetch target to be OBJECT library 2022-06-10 22:58:35 +02:00
Linus Dierheimer 09f7180dd5 Merge pull request #169 from ADawesomeguy/patch-1
fix: correct "hout" to "hour"
2022-06-10 22:37:07 +02:00
Abheek Dhawan 6ae8b46f68 fix: correct "hout" to "hour" 2022-06-10 15:12:39 -05:00
Linus Dierheimer 2d0ffb55b7 Release 1.5.3
Enable LTO by default
Fix compile bug when LTO enabled
2022-06-08 17:18:02 +02:00
Linus Dierheimer 22a8cfdcfe Remove obsolete strbuf function 2022-06-08 17:14:11 +02:00
Linus Dierheimer 63041aa24b Enable link time optimization 2022-06-08 16:25:14 +02:00
Linus Dierheimer 242df5f2f0 Explicitly set c standard to 11 2022-06-08 15:52:55 +02:00
Linus Dierheimer ec1bbd118f Update README.md 2022-06-08 12:11:00 +02:00
Linus Dierheimer fe624123dc Merge pull request #168 from Yureien/master
Fix build if ImageMagick is not installed
2022-06-08 12:08:10 +02:00
Linus Dierheimer 8577be3d6d Update packaging section in README 2022-06-08 12:07:06 +02:00
Soham Sen d185dc74b8 Bumped version to 1.5.2 2022-06-08 15:32:52 +05:30
Soham Sen 54c09cab18 Fix build if ImageMagick is not installed 2022-06-08 15:22:34 +05:30
Linus Dierheimer dbe24c7508 Fix --print-logos 2022-06-08 11:28:26 +02:00
Linus Dierheimer d23d4ef5a0 Relase 1.5.0
Module: Vulkan
Module: OpenGL
Module: OpenCL
Feature: Detect Bedrock linux
Feature: Detect packages on Bedrock linux
Feature: --pipe option
Logo: Bedrock linux
Bugfix: Locale detection on Ubuntu and deriviates
Bugfix: bolt keys and title, if main color is not set
2022-06-08 11:17:08 +02:00
Linus Dierheimer daac1b783c Refactored logo choosing logic 2022-06-08 10:59:33 +02:00
Linus Dierheimer 2e98dd7710 Move ffPrintLogoAndKey to printing.c 2022-06-06 14:30:06 +02:00
Linus Dierheimer 9d6d2ca5a4 Add osmesa to help texts 2022-06-06 14:24:14 +02:00
Linus Dierheimer e4a1a836fe Fix keys not being bolt if main color is not set 2022-06-06 14:20:05 +02:00
Linus Dierheimer 1e3cabff2d --pipe option 2022-06-06 14:02:21 +02:00
Linus Dierheimer 008cf3b83d OpenCL module 2022-06-05 00:18:40 +02:00
Linus Dierheimer 3daede53eb Don't cache OS 2022-06-04 22:43:57 +02:00
Linus Dierheimer 36d9b5a9bd Finish OpenGL module 2022-06-04 19:30:26 +02:00
Linus Dierheimer 1826e23c29 OpenGL module 2022-06-04 15:21:34 +02:00
Linus Dierheimer 43b3998b9d Fix bedrock linux detection 2022-06-03 01:48:50 +02:00
Linus Dierheimer c55cc9c732 ffParsePropFileValues: only allocate storage on the heap if numQuerys > 4 2022-06-03 00:24:53 +02:00
Linus Dierheimer 0244e5ebd7 removed unused code 2022-06-02 23:24:50 +02:00
Linus Dierheimer ea6805de82 Escape bedrock option 2022-06-02 23:06:49 +02:00
Linus Dierheimer 9aba57cdea Bedrock package support 2022-06-02 22:58:19 +02:00
Linus Dierheimer 0dffd8debf Vulkan module 2022-06-01 00:04:58 +02:00
Linus Dierheimer 032ba375b6 Enable chafa only if ImageMagick is found 2022-05-29 16:23:56 +02:00
Linus Dierheimer 743bc07bad Correctly detect locale on ubuntu systems 2022-05-29 16:17:36 +02:00
Linus Dierheimer 044e5496fd Fix bedrock logo 2022-05-25 14:28:08 +02:00
Linus Dierheimer 102b2d33c7 Bedrock linux detection 2022-05-25 14:06:59 +02:00
Linus Dierheimer afc144fa01 Merge branch 'master' of github.com:LinusDierheimer/fastfetch 2022-05-25 14:00:36 +02:00
Linus Dierheimer ededa4d6dd Bedrock linux logo 2022-05-25 14:00:18 +02:00
Linus Dierheimer af4596b666 Bedrock linux 2022-05-25 13:59:40 +02:00
Linus Dierheimer 8c910089cc Detect KDE plasma version more reliable 2022-05-24 13:58:38 +02:00
Linus Dierheimer e79af7ba79 Relase 1.4.2
Bugfix: RPM package count on SUSE platforms
Bugfix: Prepend /var with TARGET_DIR_ROOT
2022-05-24 13:41:23 +02:00
Linus Dierheimer 960364bd47 Use librpm as rpm fallback 2022-05-24 13:36:33 +02:00
Linus Dierheimer ea44231c78 Don't prepend proc with TARGET_DIR_ROOT
Should make future packaging for termux simpler
2022-05-23 20:01:18 +02:00
Linus Dierheimer 60af0b9e39 Release 1.4.0
Feature: Display images converted to ascii art as logo, using chafa
Feature: Stretch images by using the --logo-height option
Logo: RedstarOS
Logo: Devuan
Logo: Rocky
Bugfix: Better calculation of image dimensions
Bugfix: Better rpm package detection
Bugfix: Format uptime right, when hours > 0 and minutes = 0
Bugfix: Only detect themes for installed gtk versions
2022-05-23 19:39:49 +02:00
Linus Dierheimer e4ecb9d069 Use sqlite to get rpm package count 2022-05-23 19:30:02 +02:00
Linus Dierheimer 3c648d84db Better GTK detection 2022-05-23 16:19:58 +02:00
Linus Dierheimer 45db4a5c3d Fix possible use after free 2022-05-23 15:50:25 +02:00
Linus Dierheimer caf976bec2 Fix building without chafa enabled 2022-05-23 15:36:19 +02:00
Linus Dierheimer b3d855355e Rewrote image dimension calculation 2022-05-23 15:32:10 +02:00
Linus Dierheimer 0a2eb49891 Merge pull request #164 from draumaz/master
Add Rocky Linux logo
2022-05-23 12:34:06 +02:00
draumaz ab2efa151a update readme 2022-05-23 03:29:04 -07:00
draumaz 1aee3f81c5 added Rocky Linux logo 2022-05-23 03:22:39 -07:00
Linus Dierheimer 4c7031cb12 Merge pull request #161 from Samisafool/patch-1
Typo
2022-05-16 11:51:08 +02:00
Samisafool 81c96d0f11 Typo 2022-05-16 09:54:48 +05:30
Linus Dierheimer 4d8680ec2d Merge pull request #160 from draumaz/master
Add Devuan logo
2022-05-15 23:46:56 +02:00
draumaz 039eb3a38a Fix alphabetical ordering 2022-05-15 13:48:10 -07:00
draumaz d07a653404 Update README.md 2022-05-15 13:45:31 -07:00
draumaz 76c0b7e457 Update README.md 2022-05-15 13:43:36 -07:00
draumaz 1c0e532b79 add Devuan 2022-05-15 06:22:28 -07:00
Linus Dierheimer c79a9f1bff Format uptime better 2022-05-14 14:13:10 +02:00
Linus Dierheimer 759069adfa Merge pull request #157 from Samisafool/patch-1
Fix bug_report.md
2022-05-14 14:03:04 +02:00
Samisafool 66ff6adfb0 Update bug_report.md 2022-05-13 14:06:05 +05:30
Samisafool 1dba19c49f Typo 2022-05-12 08:29:47 +05:30
Samisafool 2afd158d96 Fix bug_report.md 2022-05-12 08:28:24 +05:30
Linus Dierheimer 36c2ce6219 Look for newer versions of librpm 2022-05-05 15:48:01 +02:00
Linus Dierheimer 5f6432c150 RedstarOS logo 2022-05-04 18:11:32 +02:00
Linus Dierheimer e9f0eca3dd Add documentation about logo height option 2022-04-30 11:25:22 +02:00
Linus Dierheimer 998691847e logo-height option 2022-04-30 11:22:51 +02:00
Linus Dierheimer 64e5ef0df7 Fix output with no custom logo 2022-04-29 21:52:42 +02:00
Linus Dierheimer cc1e876faf Better automatic logo type detection 2022-04-29 21:44:32 +02:00
Linus Dierheimer 964a5aa8b4 Add chafa to feature list 2022-04-29 14:11:22 +02:00
Linus Dierheimer ad2601f097 Fix visual bug in README.md 2022-04-29 13:08:39 +02:00
Linus Dierheimer 7cae63ac05 Require chafa>=1.10 2022-04-29 13:07:20 +02:00
Linus Dierheimer 0d26cfb218 Dont try to build with ubuntu's outdated chafa enabled 2022-04-29 13:05:38 +02:00
Linus Dierheimer 3b6855b9da Build github packages with chafa support 2022-04-28 19:17:13 +02:00
Linus Dierheimer 51414c5511 Ascii image output using chafa 2022-04-28 19:15:46 +02:00
Linus Dierheimer 24f8ad7673 Release 1.3.4
* Bugfix: Using custom logos in terminals that don't support \033[14t or \033[18t once again works
* Feature: Ubuntu flavour detection
* Feature: Kubuntu logo
* Feature: Deepin logo
2022-04-27 08:03:15 +02:00
Linus Dierheimer e404dd62c0 Check for ubuntu flavours 2022-04-26 19:21:19 +02:00
Linus Dierheimer 21b315d548 Use a timeout when waiting for terminal responses 2022-04-26 17:17:16 +02:00
Linus Dierheimer 14fa052257 Use reasonable timeout for dbus 2022-04-25 18:42:05 +02:00
Linus Dierheimer 5861012d95 Deepin logo 2022-04-25 18:01:29 +02:00
Linus Dierheimer 4d9fbd93d2 Kubuntu logo 2022-04-25 17:51:51 +02:00
Linus Dierheimer 1d99bd2e08 Fix prebuild deb package for real this time 2022-04-23 11:28:46 +02:00
Linus Dierheimer 52eed51eb6 Fix prebuild deb package 2022-04-23 11:24:24 +02:00
Linus Dierheimer e5237c14cb Fix build without any image magick enabled 2022-04-22 21:29:14 +02:00
Linus Dierheimer 47d8ddad35 Release 1.3.0: Image support 2022-04-22 15:51:54 +02:00
Linus Dierheimer 37ab01d5ee Refactored some variable namings to reflect image support 2022-04-22 15:49:50 +02:00
Linus Dierheimer 80f7a982e0 Even faster image caching 2022-04-22 13:20:40 +02:00
Linus Dierheimer cff3aed49c RHEL logo 2022-04-21 18:07:39 +02:00
Linus Dierheimer 572d4ec8e9 NixOS support 2022-04-21 17:59:26 +02:00
Linus Dierheimer 5bceb29c79 Image caching 2022-04-21 15:50:45 +02:00
Linus Dierheimer 8b153833b1 Fallback to escape sequences if ioctl failed 2022-04-19 11:48:08 +02:00
Linus Dierheimer adc92b5548 Update packages.c 2022-04-19 00:32:28 +02:00
Linus Dierheimer 03e949ed30 Update DEVELOPMENT.md 2022-04-15 00:56:02 +02:00
Linus Dierheimer 6accb587af zlib support 2022-04-14 15:11:14 +02:00
Linus Dierheimer 373e041e5e Always dlclose when possible 2022-04-14 11:43:06 +02:00
Linus Dierheimer 31bdd25a26 Kitty graphics protocol support 2022-04-14 11:36:57 +02:00
Linus Dierheimer 703ec597fa Improved ImageMagick detection 2022-04-13 23:13:25 +02:00
Linus Dierheimer 3b1314102f Kitty graphics initial support 2022-04-13 23:04:42 +02:00
Linus Dierheimer d349b7f7fb Merge pull request #145 from Henryws/patch-1
fix(README): fix typo
2022-04-13 11:27:59 +02:00
The TwilightBlood dabdb104e2 fix(README): fix typo 2022-04-12 18:34:40 -05:00
Linus Dierheimer 8d5ce7bcdb Fix build when ImageMagick 6 enabled 2022-04-11 22:54:07 +02:00
Linus Dierheimer 751568e9f3 Faster fallback in sixel code 2022-04-11 22:51:51 +02:00
Linus Dierheimer 430fe9fe9a Avoid unnecessary cache validation 2022-04-11 18:54:56 +02:00
Linus Dierheimer 8831c07d2b Look for multiple versions of a library 2022-04-11 17:41:21 +02:00
Linus Dierheimer e009bb1516 Try with include math.h for ubuntu build 2022-04-11 16:39:56 +02:00
Linus Dierheimer 82e2790e1b Define isnan for imagemagick 6 2022-04-11 16:32:47 +02:00
Linus Dierheimer 64182539aa Support ImageMagick 6 too (this one is for you, Ubuntu) 2022-04-11 16:19:02 +02:00
Linus Dierheimer c67fd169f8 Refactor sixel code a bit 2022-04-10 22:08:41 +02:00
Linus Dierheimer f58d0df336 Default to termux directories on android 2022-04-10 15:26:18 +02:00
Linus Dierheimer bd0c593871 Simplify packaging for termux 2022-04-10 15:07:52 +02:00
Linus Dierheimer a032d37ad4 Refactored method naming / ordering 2022-04-08 15:50:49 +02:00
Linus Dierheimer a4861606b7 Small Sixel improvements 2022-04-06 14:54:39 +02:00
Linus Dierheimer 88fe34102e Only support ImageMagick 7 for now 2022-04-06 14:21:52 +02:00
Linus Dierheimer 5346104ffa Initial sixel support 2022-04-06 14:02:05 +02:00
Linus Dierheimer 12371cdc84 Merge branch 'master' of github.com:LinusDierheimer/fastfetch 2022-04-02 14:44:44 +02:00
Linus Dierheimer 3248afe91c Prepare flashfetch for images in terminal too 2022-04-02 14:44:26 +02:00
Linus Dierheimer 1731ab2c5f Prepare for images in the terminal #2 2022-04-02 14:42:18 +02:00
Linus Dierheimer fcc8927917 Prepare for images in the terminal 2022-04-02 14:35:43 +02:00
Linus Dierheimer ccf4e2d2b5 OpenSUSE logos 2022-03-28 12:36:08 +02:00
Linus Dierheimer f2998a329d Add license info to rpm package 2022-03-25 12:24:56 +01:00
Linus Dierheimer 30365e8997 Release prebuild binaries as tar.gz and zip 2022-03-25 12:16:06 +01:00
Linus Dierheimer 5b66938bf4 Release with rpm package too 2022-03-25 12:09:48 +01:00
Linus Dierheimer 80c5600a7b Use cmake to build packages 2022-03-25 11:57:58 +01:00
Linus Dierheimer 65ce2eafed Hopefully finally fix github actions 2022-03-24 22:26:44 +01:00
Linus Dierheimer d840c7a12d Use workflow instead of action 2022-03-24 22:15:46 +01:00
Linus Dierheimer 634e27bc42 Try to give github actions the right permissions 2022-03-24 22:02:39 +01:00
Linus Dierheimer cc18315e84 Fix check action 2022-03-24 21:59:15 +01:00
Linus Dierheimer 83e2787b24 Use reusable action for check 2022-03-24 21:57:53 +01:00
Linus Dierheimer ef5a9384da Try to fix github actions again 2022-03-24 21:49:39 +01:00
Linus Dierheimer 2d7e6c37ff Try to fix github actions 2022-03-24 21:43:27 +01:00
Linus Dierheimer 92e8f23261 Refactored github actions again 2022-03-24 21:38:56 +01:00
Linus Dierheimer e09f1d3647 Refactored github actions 2022-03-24 21:32:45 +01:00
Linus Dierheimer 6f01e33955 Clear URL from unsucessfull media detection too 2022-03-24 19:06:20 +01:00
Linus Dierheimer 4b813cdf59 Automatic track commits between versions 2022-03-24 18:56:44 +01:00
Linus Dierheimer 942c583c89 Media: Don't show website urls 2022-03-23 21:41:52 +01:00
Linus Dierheimer 24a48c1fc0 Dont show lyric information in song title 2022-03-23 16:07:47 +01:00
Linus Dierheimer e2e95732e8 Don't remove dirty / clean from song title 2022-03-23 15:58:30 +01:00
Linus Dierheimer d647f9e3f2 Pretty song output, if the media is a browser playing a video 2022-03-23 15:43:30 +01:00
365 changed files with 27658 additions and 8588 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ trim_trailing_whitespace = true
[*.{md,fflogo}]
trim_trailing_whitespace = false
[*.{txt,fflogo}]
[*.{fflogo}]
insert_final_newline = false
[*.yml]
+1 -1
View File
@@ -1 +1 @@
custom: paypal.me/linusdierheimer
github: LinusDierheimer
+13 -5
View File
@@ -7,6 +7,13 @@ assignees: ''
---
# General description of bug:
# Often helpful questions:
* Does the issue occur across multiple terminal emulators? [Y/N]
* Does the issue occur across multiple shells? (bash, zsh, fish, etc) [Y/N]
Output of `fastfetch --version`:
```
//paste here
@@ -18,6 +25,9 @@ Output of `fastfetch --load-config devinfo`:
```
Output of `fastfetch --load-config devinfo-verbose`:
<!--
Note that this output will contain you public IP. If it is not relevant for the issue, feel free to remove it before uploading.
-->
```
//paste here
```
@@ -27,9 +37,7 @@ Output of `fastfetch --list-features`:
//paste here
```
<!--
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 to much work) for you, post the output of `fastfetch --show-errors --recache --multithreading false --disable-linewrap false`.
Often helpful questions:
* Does the issue occur across multiple terminal emulators?
* Does the issue occur across multiple shells? (bash, zsh, fish, etc)
If this isn't possible (or too much work) for you, post the output of `fastfetch --show-errors --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.
```
+281 -66
View File
@@ -1,101 +1,316 @@
name: Manage pushes and pull requests
name: manage pushes
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
BUILD_TYPE: Release
- push
- pull_request
jobs:
check:
name: Build, Run and Analyze fastfetch
runs-on: ubuntu-latest
linux-buildtest:
name: Linux build test
permissions:
actions: read
contents: write
security-events: write
contents: read
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
os: [ubuntu-22.04, ubuntu-20.04]
compiler: [gcc, clang]
enableFeatures: [ON, OFF]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: checkout repository
uses: actions/checkout@v3
- name: Update and install 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 libxfconf-0-dev librpm-dev libzstd-dev
- 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 libcjson-dev libnm-dev libpulse-dev
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: configure project
env:
CC: ${{ matrix.compiler }}
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBCJSON=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} .
- name: Configure
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .
- name: build project
run: cmake --build .
- name: Build
run: cmake --build . -j$(nproc)
- name: run tests
run: ctest
- name: Run fastfetch
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true
- name: run fastfetch
run: ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: Run flashfetch
run: ./flashfetch
- name: run flashfetch
run: ./flashfetch
- name: Run tests
run: ctest
linux:
name: Linux
runs-on: ubuntu-20.04 # 22.04 ships a newer version of glibc than debian stable, allow those people to use the debian package
permissions:
security-events: write
contents: read
outputs:
ffversion: ${{ steps.ffversion.outputs.ffversion }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: Build deb package
run: sh packaging/deb/create.sh .
- 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 libcjson-dev libnm-dev libpulse-dev
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c
- name: Create tarball
if: github.event_name == 'push'
run: tar -cvf fastfetch.tar ./fastfetch -C packaging/deb ./fastfetch.deb
- name: configure project
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
- name: Upload tarball
if: github.event_name == 'push'
uses: actions/upload-artifact@v3
with:
name: fastfetch.tar
path: ./fastfetch.tar
- name: build project
run: cmake --build . --target package
deploy:
name: Create GitHub release
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: list features
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: get fastfetch version
id: ffversion
run: echo "ffversion=$(./fastfetch --version-raw)" >> $GITHUB_OUTPUT
- 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 imagemagick chafa
- 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: list features
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-macos
path: ./fastfetch-*.*
freebsd:
name: FreeBSD
runs-on: macos-12
permissions:
security-events: write
contents: read
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: run VM
uses: vmactions/freebsd-vm@v0
with:
prepare: |
pkg install -y cmake git pkgconf pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd
run: |
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
cmake --build . --target package
./fastfetch --list-features
time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
time ./flashfetch
ctest
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-freebsd
path: ./fastfetch-*.*
win64:
name: Win64
runs-on: windows-latest
permissions:
security-events: write
contents: read
defaults:
run:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: CLANG64
update: true
install: git zip mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
- name: print msys version
run: uname -a
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/clang64/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: copy necessary dlls
run: cp /clang64/bin/{libcjson,OpenCL,vulkan-1}.dll .
- name: list features
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: create zip archive
run: zip fastfetch-$(./fastfetch --version-raw)-Win64.zip *.dll fastfetch.exe flashfetch.exe
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-win64
path: ./fastfetch-*-Win64.zip
win32:
name: Win32
runs-on: windows-latest
permissions:
security-events: write
contents: read
defaults:
run:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: CLANG32
update: true
install: git zip mingw-w64-clang-i686-cmake mingw-w64-clang-i686-clang mingw-w64-clang-i686-cjson mingw-w64-clang-i686-vulkan-loader mingw-w64-clang-i686-opencl-icd
- name: print msys version
run: uname -a
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/clang32/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: copy necessary dlls
run: cp /clang32/bin/{libcjson,OpenCL,vulkan-1}.dll .
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: create zip archive
run: zip fastfetch-$(./fastfetch --version-raw)-Win32.zip *.dll fastfetch.exe flashfetch.exe
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-win32
path: ./fastfetch-*-Win32.zip
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'LinusDierheimer/fastfetch'
name: Release
runs-on: ubuntu-latest
needs: check
if: github.event_name == 'push'
needs:
- linux
- macos
- freebsd
- win64
- win32
permissions:
contents: write
steps:
- name: Download tarball
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: fastfetch.tar
path: ./fastfetch.tar
- name: Extract tarball
run: tar --overwrite -xvf ./fastfetch.tar/fastfetch.tar
- name: Get fastfetch version
id: get_version_fastfetch
run: echo "::set-output name=release::$(./fastfetch --version-raw)"
- name: Get latest release version
- name: get latest release version
id: get_version_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
- name: Push release
if: steps.get_version_fastfetch.outputs.release != steps.get_version_release.outputs.release
- name: create 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,./fastfetch.deb
artifactErrorsFailBuild: true
artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-freebsd/*,fastfetch-win64/*,fastfetch-win32/*
+2 -2
View File
@@ -2,8 +2,8 @@
**/.vscode/
**/.cache/
**/.kdev4/
**/.DS_Store
/.vs
cscope.*
tags
fastfetch.kdev4
**/*.deb
packaging/deb/fastfetch
-3
View File
@@ -1,3 +0,0 @@
[submodule "packaging/aur"]
path = packaging/aur
url = https://aur.archlinux.org/fastfetch-git.git
+337
View File
@@ -0,0 +1,337 @@
# 1.10.3
Bugfixes:
* Fix uninitialized variables (GPU, Windows)
* Fix compiling errors (Windows)
Improvements:
* Improve preformance (WmTheme amd Font, Windows and macOS)
* Enable nonblocking public-ip / weather detection (Android)
# 1.10.2
Bugfixes:
* Handle `kAudioObjectPropertyElementMain` for macOS **SDK** < 12 (#425, @nandahkrishna)
* Add missing `NULL` for `ffProcessAppendStdOut` (#421)
# 1.10.1
New release for debugging #421
# 1.10.0
Notable Changes:
* With the support of Win32 platform, original Windows 64bit artifact file is renamed to Win64 to avoid possible confusion
Features:
* Bluetooth module
* Sound module
* Gamepad module
* Support colored percentage numbers output (#409)
* Support `--localip-compact-type` option (#408)
* Terminator terminal font detection (@Zerogiven, #415)
* Windows 32bit compatibility
* Support global configuration in MSYS2 environment (Windows)
* Support GPU driver version detection on Windows 11
* Support scaled resolution detection for wayland (Linux)
Bugfixes:
* Fix build with older libnm versions
* Fix a rare case that fails to detect terminal
* Fix Muffin detection (@Zerogiven, #411)
* Fix IPv6 detection (Windows)
* Fix scoop package count detection when scoop is installed in non-default path (Windows, #417)
* Fix UB reported by clang
* Honor $SCOOP when detecting scoop packages (#417)
Other:
* Simplified wmtheme output format (Windows)
* Improved GPU detection performance on Windows 11
* Lastest Mac model identifier support (macOS)
# 1.9.1
Bugfixes:
* Fix builds on s390x (@jonathanspw, #402)
* Fix zero refresh rate on some monitors (macOS)
* Fix default formatting of Wifi module
# 1.9.0
Notable Changes:
* fastfetch no longer creates a sample config file silently. Use `--gen-config` to generate one.
* fastfetch now search for user config file in the order of `fastfetch --list-config-paths`
* Unknown disks are hidden by default.
* `Resolution` module is renamed to `Display`. (#393)
Features:
* `--logo-padding-top` option (@CarterLi, #372)
* Raw image file as logo support (@CarterLi)
* Look for config files in `$APPDATA` ([RoamingAppData](https://superuser.com/questions/21458/why-are-there-directories-called-local-locallow-and-roaming-under-users-user#answer-21462)) (Windows)
* Look for config files in `~/Library/Preferences` (macOS)
* Add `--list-config-paths` option which list search paths of config files
* Add `--list-data-paths` option which list search paths for presets and logos
* Add `Brightness` module support
* Add `Battery` module support for FreeBSD
* Add `--disk-show-unknown` option for Disk module
* Add `--disk-show-subvolumes` option for Disk module
* Add `--gpu-hide-integrated` option (#379)
* Add `--gpu-hide-discrete` option (#379)
* Detect terminal version when available
* Support `WezTerm` terminal font detection (requires [`wezterm` executable](https://wezfurlong.org/wezterm/cli/general.html) being available)
* Add `--shell-version` and `--terminal-version` options to disable shell / terminal version detection
* Enhance `--percent-type` to allow hiding other texts (#387)
* Add Wifi module support for Linux
* Detect scaled resolutions (Windows, macOS)
* Optimise font module printing (Windows)
* Detect pacman package count inside MSYS2 environment (Windows)
* Add Wifi / Battery module support for Android
* Disk name support for Linux
Logos:
* Raspbian (@IamNoRobot, #373)
Bugfixes:
* `--logo-type` now does accept `iterm` too (@CarterLi, #374)
* Fix mintty terminal font detection (Windows)
* Fix bug that line buffering doesn't work properly (Windows)
* Fix rpm package count detection (Linux)
* Fix cpu temp detection (Linux)
Other:
* Fixed a Typo in iterm error message (@jessebot, #376)
* Don't try to load config file in `/etc` (Windows)
# 1.8.2
Bugfixes:
* Fix memleaks Users module (Windows)
* Fix shell detection when installed with scoop (Windows)
* Don't use libcJSON as wlanapi's dll name (Windows)
* Align artifact names to other platforms (Windows)
# 1.8.1
Notable Changes:
* `Song` was used as an alias to `Media` module. It's removed to avoid confusion. All song related flags (`--song-key`, etc) should change to media (`--media-key`, etc). (@CarterLi)
Bugfixes:
* Mountpoint paths on linux get decoded correctly (#364)
* Color parsing once again works (@IanManske, #365)
* Using a custom key with a placeholder for the local ip module now does work correctly if multiple interfaces are present (#368)
# 1.8.0
This release introduces Windows support! Fastfetch now fully support all major desktop OSes (Linux, macOS, Windows and FreeBSD)
Notable Changes:
* Bios / Board / Chassis modules are splitted against Host module for performance reasons
* Caching is removed. Option `--nocache` is removed accordingly
Features:
* Windows (7 and newer) is officially and fully supported
* FreeBSD support is improved greatly (Bios, Cpu Temp, Cpu Usage, Disk, Host, Processes, Swap, Terminal / Shell, Uptime)
* Adds a new flag `--stat`, which prints time usage for individual modules
* Adds Wifi module which supports Windows and macOS
* Adds data source option for logo printing
* Detects Homebrew Cellar and Cask seperately
* Detects WSL version
* Detects disk based on mount point
* Exposes more chafa configs
* Improves performance for Cpu Usage, Public IP, Weather modules
* Improves performance for Kitty image protocol when both image width / height specified
* Improves performance for large file loading
* Improves performance for macOS WM and Host detection
* Improves shell and terminal detection on macOS
* Supports Deepin Terminal terminal font
* Supports GPU detection on Android
* Supports Kitty Terminal terminal font
* Supports bar output for percentage values
* Supports Bios module on macOS
* Supports eopkg package manager detection
* Supports iTerm image logo protocol
* Supports image logo printing on macOS
* Supports tcsh version detection
* Vulkan module on macOS no longer requires vulkan-loader to work
Logos:
* Alpine
* CRUX
* EndeavourOS
* Enso
* Garuda small
* Nobara
* OpenMandriva
* Parabola GNU/Linux-libre
* Rocky
* Rosa
* Solus
* Univalent
* Vanilla OS
Bugfixes:
* Fixes disk size detection on 32bit Linux (#337)
* Fixes cpu freq detection in WSL
* Fixes internal bug of FFstrbuf
* Fixes some memory leaks
* Fixes segfault if 0 is given as argument index
* Lots of code refactors
# 1.7.5
Fixes a crash on linux that could happen when getting zsh version (#285)
# 1.7.4
The last element in the default structure (currently the color blocks) is now printed again (#283)
# 1.7.3
A lot of small improvements for MacOS & BSD platforms.
Features:
* BSD is now officially supported (#228)
* MacPorts package manager support (@SladeGetz, #234)
* Battery support for MacOS (@CarterLi, #235)
* Processes, swap & terminal font support for MacOS(@CarterLi, #237)
* Media support for MacOS (@CarterLi, #242)
* Player support for MacOS (@CarterLi, #245)
* WM theme support for MacOS (@CarterLi, #246)
* CPU usage support for MacOS (@CarterLi, #247)
* Power Adapter module (@CarterLi, #249)
* Windows terminal font for WSL (@CarterLi, #254)
* Temps & Font support for MacOS (@CarterLi, #258)
* Terminal font support for Termux (@CarterLi, #263)
* Weather module (@CarterLi, #266)
Logos
* Crystal linux (@AloneER0, #239)
* FreeBSD (@draumaz, #244)
* New Ubuntu (@AloneER0, #259)
Bugfixes:
* Don't segfault in GPU code on Intel Macs (@CarterLi, #236)
* Don't use hardcoded size units in presets (@dr460nf1r3, #255)
* Don't crash with some format strings (#252)
* --logo none keeps key color now (#264)
# 1.7.2
Fixes the bash completions
# 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
+766 -210
View File
File diff suppressed because it is too large Load Diff
-8
View File
@@ -11,13 +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
- [ ] Support for printing images as ascii art logos (using imlib2 and libcaca probably)
- [ ] Support for printing images in terminals that support it
- [ ] Better OS output for all possible combinations of /etc/os-release variables.
- [ ] Expose temperatures to CPU format string
- [ ] Expose temperatures to GPU format string
- [ ] Fallback GPU detection using GL (multi GPU suport somehow possible?)
- [ ] 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
@@ -25,7 +18,6 @@ Here i just add things that are easy to forget.
- [ ] Make CPU usage detection much faster and more accurate
- [ ] Detect CPU usage in a common detection methode and expose it both to the cpuUsage module and the cpu format string
- [ ] Per session caching
- [ ] RPM packaging
### General
- More presets
+110 -48
View File
@@ -1,100 +1,162 @@
# 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 mainly in C, with performance and customizability in mind. Currently, Linux, Android, FreeBSD, MacOS and Windows 7+ are supported.
<img src="screenshots/example1.png" width="49%" align="left" />
<img src="https://upload.wikimedia.org/wikipedia/commons/2/24/Transparent_Square_Tiles_Texture.png" width="49%" height="16px" align="left" />
<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" />
There are [screenshots on different platforms](https://github.com/LinusDierheimer/fastfetch/wiki)
## Customization
With customization and speed being two competing goals, this project actually builds two executables.
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 buildt 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.
With customization and speed being two competing goals, this project actually builds two executables.
* The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `$XDG_CONFIG_HOME/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 premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config <filename>`. They may also serve as a good example for format arguments.
Logos can be heavily customized to. See the [logo documentation](doc/logo.md) for more information.
## Dependencies
Fastfetch dynamically loads needed libraries if they are available. Therefore its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and `libpthread`. They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions, so you probably don't have to worry about it.
Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions.
The following libraries are used if present at runtime:
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
* [`libvulkan`](https://www.vulkan.org/): Fallback for GPU output.
* [`libxcb-randr`](https://xcb.freedesktop.org/),
[`libXrandr`](https://gitlab.freedesktop.org/xorg/lib/libxrandr),
[`libxcb`](https://xcb.freedesktop.org/),
[`libX11`](https://gitlab.freedesktop.org/xorg/lib/libx11): At least one of them sould be present in X11 sessions for better resolution detection and faster WM detection. The `*randr` ones provide multi monitor support. The `libxcb*` ones usually have better performance.
* [`libwayland-client`](https://wayland.freedesktop.org/): Better resolution performance and output in wayland sessions. Supports different refresh rates per monitor.
* [`libGIO`](https://developer.gnome.org/gio/unstable/): Needed for values that are only stored GSettings.
* [`libDConf`](https://developer.gnome.org/dconf/unstable/): Needed for values that are only stored in DConf + Fallback for GSettings.
* [`libDBus`](https://www.freedesktop.org/wiki/Software/dbus): Needed for detecting current media player and song.
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
* [`librpm`](http://rpm.org/): Needed for rpm package count.
### Linux and FreeBSD
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
* [`libvulkan`](https://www.vulkan.org/): Vulkan module & fallback for GPU output.
* [`libxcb-randr`](https://xcb.freedesktop.org/),
[`libXrandr`](https://gitlab.freedesktop.org/xorg/lib/libxrandr),
[`libxcb`](https://xcb.freedesktop.org/),
[`libX11`](https://gitlab.freedesktop.org/xorg/lib/libx11): At least one of them sould be present in X11 sessions for better display detection and faster WM detection. The `*randr` ones provide multi monitor support The `libxcb*` ones usually have better performance.
* [`libwayland-client`](https://wayland.freedesktop.org/): Better display performance and output in wayland sessions. Supports different refresh rates per monitor.
* [`libGIO`](https://developer.gnome.org/gio/unstable/): Needed for values that are only stored GSettings.
* [`libDConf`](https://developer.gnome.org/dconf/unstable/): Needed for values that are only stored in DConf + Fallback for GSettings.
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel or kitty graphics protocol.
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art.
* [`libZ`](https://www.zlib.net/): Faster image output when using kitty graphics protocol.
* [`libDBus`](https://www.freedesktop.org/wiki/Software/dbus): Bluetooth, Player & Media detection.
* [`libEGL`](https://www.khronos.org/registry/EGL/),
[`libGLX`](https://dri.freedesktop.org/wiki/GLX/),
[`libOSMesa`](https://docs.mesa3d.org/osmesa.html): At least one of them is needed by the OpenGL module for gl context creation.
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count.
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Needed for Windows Terminal font ( WSL ).
* [`libnm`](https://networkmanager.dev/docs/libnm/latest/): Used for Wifi detection.
* [`libpulse`](https://freedesktop.org/software/pulseaudio/doxygen/): Used for Sound detection.
### macOS
* [`MediaRemote`](https://iphonedev.wiki/index.php/MediaRemote.framework): Need for Media detection. It's a private framework provided by newer macOS system.
* [`DisplayServices`](https://developer.apple.com/forums/thread/666383#663154022): Need for screen brightness detection. It's a private framework provided by newer macOS system.
* [`MoltenVK`](https://github.com/KhronosGroup/MoltenVK): Vulkan driver for macOS. [`molten-vk`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/molten-vk.rb)
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel graphics protocol. [`imagemagick`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/imagemagick.rb)
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art. [`chafa`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/chafa.rb)
For the image logo, iTerm with iterm image protocol should work. Apple Terminal is not supported.
### Windows
* [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection.
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Used for Windows Terminal font detection. [`cjson`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-cjson)
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers)
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd)
Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, as fastfetch for Windows targets [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library, [it must be installed manually](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) as UCRT is only pre-installed in Windows 10 and later.
For the image logo, only chafa is supported due to [the design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not built by default due to the massive dependencies of imagemagick. You must built it yourself.
### Android
* [`freetype`](https://www.freetype.org/): Used for Termux font detection. [`freetype`](https://github.com/termux/termux-packages/tree/master/packages/freetype)
* [`libvulkan`](https://www.vulkan.org/): Vulkan module, also used for GPU detection. Usually has been provided by Android system. [`vulkan-loader-android`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-loader-android) [`vulkan-headers`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-headers)
* [`termux-api`](https://github.com/termux/termux-api-package): Used for Wifi / Battery detection. Read [the official doc](https://wiki.termux.com/wiki/Termux:API) for detail or if you hang on these modules (IMPORTANT). [`termux-api`](https://github.com/termux/termux-packages/tree/master/packages/termux-api)
## 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, LocalIP, PublicIP, DateTime, Date, Time, Locale, Colors, Break, Custom
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Theme, Time, Title, Uptime, Vulkan, Wifi, WM, WMTheme
```
##### Logos
##### Builtin logos
```
Android, Arch, Arco, Artix, CachyOS, CentOS, Debian, Endeavour, Fedora, Garuda, Gentoo, KDE Neon, Linux, Manjaro, Mint, Pop!_OS, RebornOS, Ubuntu, Void, Zorin
AlmaLinux, Alpine, Android, Arch, Arco, Artix, Bedrock, CachyOS, CentOS, CRUX, Crystal, Debian, Deepin, Devuan, Endeavour, Enso, Fedora, FreeBSD, Garuda, Gentoo, KDE Neon, KISS, Kubuntu, LangitKetujuh, Linux, MacOS, Manjaro, Mint, MSYS2, NixOS, Nobara, OpenSUSE, OpenSUSE LEAP, OpenSUSE Tumbleweed, Parabola, Pop!_OS, Raspbian, RebornOS, RedstarOS, Rocky, Rosa, Slackware, Solus, Ubuntu, Vanilla, Void, Windows, Windows 11, Windows 8, 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.
* Get a list of all available logos with `fastfetch --print-logos`.
##### Package managers
```
Pacman, dpkg, rpm, emerge, xbps, Flatpak, Snap
apk, brew, Chocolatey, dpkg, emerge, eopkg, Flatpak, MacPorts, nix, Pacman, pkg, rpm, scoop, Snap, xbps
```
##### WM themes
```
KWin, Mutter, Muffin, Marco, XFWM, Openbox (LXDE, LXQT & without DE)
DWM (Windows), KWin, Marco, Muffin, Mutter, Openbox (LXDE, LXQT & without DE), Quartz Compositor (macOS), XFWM
```
##### DE versions
```
KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt
Budgie, Cinnamon, Gnome, KDE Plasma, LXQt, Mate, XFCE4
```
##### Terminal fonts
```
konsole, gnome-terminal-server, tilix, xfce4-terminal, lxterminal, TTY
Alacritty, Apple Terminal, ConEmu, Deepin Terminal, Gnome Terminal, iTerm2, Kitty, Konsole, LXTerminal, mintty, Terminator, Termux, Tilix, TTY, Warp, WezTerm, Windows Terminal, XFCE4 Terminal
```
## Building
fastfetch uses [`cmake`](https://cmake.org/) and [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) for building. The simplest steps to build the fastfetch and flashfetch binaries are:
fastfetch uses [`cmake`](https://cmake.org/) for building. [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) is recommended for better library detection. The simplest steps to build the fastfetch and flashfetch binaries are:
```bash
mkdir -p build
cd build
cmake ..
cmake --build . -j$(nproc) --target fastfetch --target flashfetch
cmake --build . --target fastfetch --target flashfetch
```
If pkg-config fails to find the headers for a library listed in [dependencies](#dependencies), fastfetch will simply build without support for that specific feature. This means, it won't look for it at runtime and just act like it isn't available.
If the build process fails to find the headers for a library listed in [dependencies](#dependencies), fastfetch will simply build without support for that specific feature. This means, it won't look for it at runtime and just act like it isn't available.
### Building on Windows
Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 subsystem (or CLANGARM64 if needed) is suggested (and tested) to build fastfetch. If you need Windows 7 / 8.x support, using MINGW64 is suggested.
1. Install [MSYS2](https://www.msys2.org/#installation)
1. Open `MSYS2 / CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime)
1. Install dependencies
```bash
pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
```
Follow the building instructions of Linux next.
## Packaging
* [AUR](https://aur.archlinux.org/packages/fastfetch-git/): Packaged by me. Will install the fastfetch binary, bash completion and the presets. Git version
* [Manjaro Repositories](https://gitlab.manjaro.org/packages/community/fastfetch): Packaged by a manjaro maintainer. Usually a bit outdated.
* [Gentoo (Guru)](https://github.com/gentoo/guru/tree/master/app-misc/fastfetch): Packed by some other guy. May be out of date some times.
* DEB: Run [`packaging/deb/create.sh`](packaging/deb/create.sh) from the root directory. You can give a custom build directory as an argument.
* Manually:
* Build: Follow the [build instructions](#building).
* Install: `sudo cmake --install build --prefix /usr/local`
### Repositories
[![Packaging status](https://repology.org/badge/vertical-allrepos/fastfetch.svg?header=)](https://repology.org/project/fastfetch/versions)
### Manual
* DEB / RPM package: `cmake --build . --target package`
* Install directly: `cmake --install . --prefix /usr/local`
## FAQ
Q: Why do you need a very performant version of neofetch?
> I like putting neofetch in my ~/.bashrc to have a system overwiew whenever i use the terminal, but the slow speed annoyed me, so i created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
> I like putting neofetch in my ~/.bashrc to have a system overwiew whenever I use the terminal, but the slow speed annoyed me, so I created this. Also neofetch didn't output everything correctly (e.g Font is displayed as "[Plasma], Noto Sans, 10 [GTK2/3]") and writing my own tool gave me the possibility to fine tune it to run perfectly on at least my configuration.
Q: It does not display [*] correctly for me, what can i do?
> This is most likely because your system is not implemented (yet). At the moment i am focusing more on making the core app better, than adding more configurations. Feel free to open a pull request if you want to add support for your configuration
Q: It does not display [*] correctly for me, what can I do?
> This is most likely because your system is not implemented (yet). At the moment I am focusing more on making the core app better, than adding more configurations. Feel free to open a pull request if you want to add support for your configuration
+227 -52
View File
@@ -9,28 +9,40 @@ __fastfetch_complete_help()
"os-format"
"host-format"
"kernel-format"
"uptime-format"
"processes-format"
"packages-format"
"shell-format"
"resolution-format"
"display-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"
"bluetooth-format"
)
COMPREPLY=($(compgen -W "${__ff_helps[*]}" -- "$CURRENT_WORD"))
}
@@ -57,6 +69,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 +111,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,8 +158,11 @@ __fastfetch_completion()
"--list-presets"
"--list-features"
"--print-logos"
"--print-config"
"--print-config-system"
"--print-config-user"
"--print-structure"
"--gen-config"
"--gen-config-force"
)
local FF_OPTIONS_HELP=(
@@ -119,112 +172,216 @@ __fastfetch_completion()
local FF_OPTIONS_BOOL=(
"-r"
"--recache"
"--nocache"
"--show-errors"
"--color-logo"
"--print-remaining-logo"
"--logo-print-remaining"
"--multithreading"
"--stat"
"--allow-slow-operations"
"--disable-linewrap"
"--hide-cursor"
"--cpu-temp"
"--gpu-temp"
"--battery-temp"
"--localip-show-ipv4"
"--localip-show-ipv6"
"--localip-show-loop"
"--localip-name-prefix"
"--localip-compact-type"
"--escape-bedrock"
"--pipe"
"--title-fqdn"
"--escape-bedrock"
"--shell-version"
"--terminal-version"
"--disk-folders"
"--disk-show-removable"
"--disk-show-hidden"
"--disk-show-subvolumes"
"--gpu-hide-integrated"
"--gpu-hide-discrete"
"--disk-show-unknown"
"--bluetooth-show-disconnected"
)
local FF_OPTIONS_STRING=(
"--logo-type"
"--logo-padding"
"--logo-padding-left"
"--logo-padding-right"
"--logo-padding-top"
"--logo-color-1"
"--logo-color-2"
"--logo-color-3"
"--logo-color-4"
"--logo-color-5"
"--logo-color-6"
"--logo-color-7"
"--logo-color-8"
"--logo-width"
"--logo-height"
"--logo-color-9"
"-c"
"--color"
"--spacing"
"-s"
"--color-keys"
"--color-title"
"--separator"
"-x"
"--offsetx"
"-s"
"--structure"
"--set"
"--os-format"
"--set-keyless"
"--player-name"
"--percent-type"
"--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"
"--resolution-key"
"--de-format"
"--shell-format"
"--shell-error"
"--display-key"
"--display-format"
"--display-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"
"--wifi-key"
"--wifi-format"
"--wifi-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"
"--opencl-error"
"--users-key"
"--users-format"
"--users-error"
"--bluetooth-key"
"--bluetooth-format"
"--bluetooth-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-RPM"
"--lib-dconf"
"--lib-dbus"
"--lib-xfconf"
"--lib-sqlite3"
"--lib-rpm"
"--lib-imagemagick"
"--lib-z"
"--lib-chafa"
"--lib-egl"
"--lib-glx"
"--lib-osmesa"
"--lib-opencl"
"--lib-pulse"
"--battery-dir"
"--load-config"
)
local FF_OPTIONS_LOGO=(
@@ -232,6 +389,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
@@ -248,6 +417,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
+116
View File
@@ -0,0 +1,116 @@
# Logo options
## General
| Option | Default | Description |
|--------|---------|-------------|
| `--logo`, `-l` | `""` | The logo source, interpreted depending on type |
| `--logo-type` | `auto` | The logo type. See the following categories for possible values |
| `--<type>` | `""` | Short for `--logo-type <type> --logo <value>` |
| `--logo-padding` | `""` | Sets the padding left and right of the logo |
| `--logo-padding-left` | `0` | Sets the padding left of the logo |
| `--logo-padding-right` | `4` | Sets the padding right of the logo |
| `--logo-padding-top` | `0` | Sets the padding top of the logo |
All filesytem paths can be:
* Absolute
* Relative to the current working directory
* Relative to any of the directories listed by `fastfetch --list-data-paths` + `/logos`
For example, the file `~/.local/share/fastfetch/logos/shrek` can simply be referenced as `shrek`.
## Text
| Option | Default | Description |
|--------|---------|-------------|
| `--logo-color-[1-9]` | `""` | Overrides a color for logos that support it |
| `--logo-print-remaining` | `true` | Print the remaining logo, if it is higher than the keys |
* Color placeholders are in the form `$[1-9]`. To print a `$`, use `$$`.
* If a color placeholder value is not set, the placeholder is simply discarded.
## Image
| Option | Default | Description |
|--------|---------|-------------|
| `--logo-width` | `""` | Sets the width of the logo for logos that support it |
| `--logo-height` | `""` | Sets the height of the logo for logos that support it |
* If one of the height / width options is set, but the other not, the aspect ratio is preserved.
* If neither height nor width is set, the original size is used.
# Logo types
## auto
Trys to detect the logo type depending on the value of `--logo`, in the following order:
* If the value is empty / not set, an autodected builtin logo is displayed.
* If the value is the name of a builtin logo, it is displayed.
* If the value is the path to an image file, and the terminal emulator is known to support an image protocol, the image is displayed.
* If the value is the path to a text file, the content is displayed.
* The autodetected builtin logo is displayed.
## builtin
The value of `--logo` is interpreted as the name of a builtin logo.
* If the value is empty / not set, it is autodetected.
* Use `--list-logos` to get a list of all available logos.
* Use `--print-logos` to see all available logos.
* All builtin logos set default values for `--logo-color-[1-9]`.
* Use `none` to disable the logo, but keep key colors from the detected logo.
## file
The value of `--logo` is interpreted as the path to a file. The content of the file is displayed.
* If the file can't be read, the autodetected builtin logo is displayed.
## file-raw
The value of `--logo` is interpreted as the path to a file. The content of the file is displayed.
* No color placeholder replacement is done.
* If the file can't be read, the autodetected builtin logo is displayed.
## data
The value of `--logo` is interpreted as the logo and directly displayed.
* If the value is empty / not set, the autodetected builtin logo is displayed.
## data-raw
The value of `--logo` is interpreted as the logo and directly displayed.
* No color placeholder replacement is done.
* If the value is empty / not set, the autodetected builtin logo is displayed.
## sixel
The value of `--logo` is interpreted as the path to an image file. It is displayed using the sixel graphics protocol.
* `fastfetch` must be compiled with the `imagemagick6` or `imagemagick7` feature.
## kitty
The value of `--logo` is interpreted as the path to an image file. It is displayed using the kitty graphics protocol.
* If the file is a png file, and both `--logo-width` and `--logo-height` are specified, the image is directly send to the terminal emulator.
* Otherwise `fastfetch` must be compiled with the `imagemagick6` or `imagemagick7` feature.
## iterm
The value of `--logo` is interpreted as the path to an image file. It is displayed using the iTerm graphics protocol.
* Both `--logo-width` and `--logo-height` must be specified.
## chafa
The value of `--logo` is interpreted as the path to an image file. It is converted to an ascii logo using `libchafa`.
* `fastfetch` must be compiled with the `chafa` feature.
* `fastfetch` must be compiled with the `imagemagick6` or `imagemagick7` feature.
* Use `--chafa-fg-only` to set weather to render foreground only.
* Use `--chafa-symbols` to set the symbols.
* Use `--chafa-canvas-mode` to set the canvas mode.
* Use `--chafa-color-space` to set the color space.
* Use `--chafa-dither-mode` to set the dither mode.
* See the [chafa documentation](https://hpjansson.org/chafa/man/) for more information.
## raw
The value of `--logo` is interpreted as the path to a binary file. It is printed as-is.
* Both `--logo-width` and `--logo-height` must be specified.
* Use this to display a pre converted image file.
* If the file can't be read, the autodetected builtin logo is displayed.
Submodule packaging/aur deleted from 7ac9c5d132
-13
View File
@@ -1,13 +0,0 @@
Package: fastfetch
Version: <VERSION>
Section: utils
Priority: extra
Architecture: amd64
Maintainer: Linus@Dierheimer.de
Homepage: https://github.com/LinusDierheimer/fastfetch
Installed-Size: 410K
Description: A fast alternative to neofetch
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, in return only Linux and Android are supported. It also uses
mechanisms like multithreading and caching to finish as fast as possible.
-28
View File
@@ -1,28 +0,0 @@
#!/bin/sh
# This script is intended to be run from the root of the repository.
# If you don't want to use build/ as build directoy, or already build the elsewere, you can give the build directoy as argument.
BUILD_DIR="${1:-build}"
ROOT_DIR="${2:-.}"
PACKAGE_DIR="${BUILD_DIR}/packaging/deb/fastfetch"
# Create missing files
mkdir -p "${BUILD_DIR}" || exit 1
if [ ! -f "${BUILD_DIR}/cmake_install.cmake" ]; then
cmake -S "${ROOT_DIR}" -B "${BUILD_DIR}" || exit 2
rm -f "${BUILD_DIR}/fastfetch" || exit 3 # Always rebuild the project if we reconfigured it
fi
if [ ! -f "${BUILD_DIR}/fastfetch" ]; then
cmake --build "${BUILD_DIR}" || exit 4
fi
# Populate the files
cmake --install "${BUILD_DIR}" --prefix "${PACKAGE_DIR}/usr" || exit 5
mkdir -p "${PACKAGE_DIR}/DEBIAN" || exit 6
sed "s/<VERSION>/$("${BUILD_DIR}/fastfetch" --version-raw)/g" "${ROOT_DIR}/packaging/deb/control-template" > "${PACKAGE_DIR}/DEBIAN/control" || exit 7
# Create the package
dpkg-deb --build "${PACKAGE_DIR}" || exit 8
+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:Break:Colors
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors
+1 -2
View File
@@ -1,4 +1,3 @@
--disable-linewrap false
--multithreading false
--show-errors true
--recache
--show-errors
+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
+3 -3
View File
@@ -1,4 +1,4 @@
--structure Host:Resolution:CPU:GPU:Memory:Disk:Battery
--memory-format "{?2}{2}MiB{?}"
--disk-format "{?2}{2}GB{?}"
--structure Host:Display:CPU:GPU:Memory:Disk:Battery
--memory-format "{?2}{2}{?}"
--disk-format "{?2}{2}{?}"
--battery-format "{?1}{1} {?}{?2}{2} {?}{?3}({3}){?}"
+4 -4
View File
@@ -1,10 +1,10 @@
--structure "Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Terminal:TerminalFont:CPU:GPU:Memory:Break:Colors"
--structure "Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Terminal:TerminalFont:CPU:GPU:Memory:Break:Colors"
--host-format "{/2}{-}{/}{2}{?3} {3}{?}"
--os-format "{3} {12}"
--resolution-format "{}x{}"
--display-format "{}x{}"
--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"
--display-key "Display"
+2 -2
View File
@@ -1,5 +1,5 @@
--structure Title:Separator:OS:Host:Kernel:Uptime:Battery:Break:Packages:Shell:Resolution:Terminal:Break:CPU:GPU:Memory:Break:Colors
--structure Title:Separator:OS:Host:Kernel:Uptime:Battery:Break:Packages:Shell:Display:Terminal:Break:CPU:GPU:Memory:Break:Colors
--host-format "{/2}{-}{/}{2}{?3} {3}{?}"
--battery-format "{/4}{-}{/}{4}%{?5} [{5}]{?}"
--resolution-key "Resolution"
--display-key "Display"
--gpu-key "GPU"
+31 -28
View File
@@ -1,28 +1,31 @@
--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: {}; Name: {}; Version: {}"
--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: {}; bios: {}; scaling max: {}; scaling min: {}; info max: {}; info min: {}; cpuinfo: {}; frequency: {}"
--cpu-usage-format "Percentage: {}"
--gpu-format "Vendor: {}; Vendor pretty: {}; Name: {}; Name pretty: {}; Driver: {}"
--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: {}"
--os-format System: {}; Name: {}; Pretty name: {}; ID: {}; ID like: {}; Variant: {}; Variant ID: {}; Version: {}; Version ID: {}; Version codename: {}; Build ID: {}; Architecture: {}
--host-format Family: product_family: {}; product_name: {}; product_version: {}; product_sku: {}; sys_vendor: {}
--kernel-format Sysname: {}; Release: {}; Version: {}
--uptime-format Days: {}; Hours: {}; Minutes: {}; Seconds: {}
--processes-format Count: {}
--packages-format All: {}; pacman: {}; pacman branch: {}; dpkg: {}; rpm: {}; emerge: {}; eopkg: {}; xbps: {}; apk: {}; flatpak: {}; snap: {}; brew: {}; brew-cask: {}; port: {}; scoop: {}; choco: {}
--shell-format Process name: {}; Process path: {}; Process exe: {}; Process version: {}; User path: {}; User exe: {}; User version: {}
--display-format Width: {}; Height: {}; Refresh rate: {}; ScaledWith: {}; ScaledHeight: {}
--de-format Process name: {}; Pretty name: {}; Version: {}
--wm-format Process name: {}; Pretty name: {}; Protocol: {}
--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: {}; Type: {}
--memory-format Used: {}; Total: {}; Percentage: {}
--disk-format SizeUsed: {}; SizeTotal: {}; SizePercentage: {}; FilesUsed: {}; FilesTotal: {}; FilesPercentage: {}; Removable: {}; Hidden: {}; Filesystem: {}; Name: {}
--battery-format Manufactor: {}; Model: {}; Technology: {}; Capacity: {}; Status: {}
--poweradapter-format Watts: {}; Name: {}; Manufactor: {}; Model: {}; Description: {}
--player-format Pretty: {}; Name: {}; Bus: {}; Url: {}
--media-format Pretty: {}; Name: {}; Artist: {}; Album: {}
--datetime-format year: {}; yearShort: {}; month: {}; monthPretty: {}; monthName: {}; monthNameShort: {}; weekNumber: {}; weekday: {}; weekdayShort: {}; dayInYear: {}; dayInMonth: {}; dayInWeek: {}; hour: {}; hourPretty: {}; hour12: {}; hour12Pretty: {}; minute: {}; minutePretty: {}; second: {}; secondPretty: {}
--vulkan-format driver: {}; Api Version: {}; Conformance Version: {}
--opengl-format version: {}; renderer: {}; vendor: {}
--opencl-format version: {}; device: {}; vendor: {}
--bluetooth-format Name: {}; Address: {}; Type: {}; Battery: {}
+19 -3
View File
@@ -1,6 +1,22 @@
#!/bin/env sh
#!/usr/bin/env sh
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

+99
View File
@@ -0,0 +1,99 @@
#include "util/textModifier.h"
#include "bar.h"
// green, yellow, red: print the color on nth (0~9) block
// set its value == 10 means the color will not be printed
void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red)
{
assert(green <= 10 && yellow <= 10 && red <= 10);
// [ 0%, 5%) prints 0 blocks
// [ 5%, 15%) prints 1 block;
// ...
// [85%, 95%) prints 9 blocks;
// [95%,100%] prints 10 blocks
percent = (uint8_t)(percent + 5) / 10;
assert(percent <= 10);
if(!instance->config.pipe)
ffStrbufAppendS(buffer, "\033[97m[ ");
else
ffStrbufAppendS(buffer, "[ ");
for (uint8_t i = 0; i < percent; ++i)
{
if(!instance->config.pipe)
{
if (i == green)
ffStrbufAppendS(buffer, "\033[32m");
else if (i == yellow)
ffStrbufAppendS(buffer, "\033[93m");
else if (i == red)
ffStrbufAppendS(buffer, "\033[91m");
}
ffStrbufAppendS(buffer, "");
}
if (percent < 10)
{
if(!instance->config.pipe)
ffStrbufAppendS(buffer, "\033[97m");
for (uint8_t i = percent; i < 10; ++i)
ffStrbufAppendS(buffer, "-");
}
if(!instance->config.pipe)
ffStrbufAppendS(buffer, "\033[97m ]" FASTFETCH_TEXT_MODIFIER_RESET);
else
ffStrbufAppendS(buffer, " ]");
}
// if (green < yellow)
// [0, green]: print green
// (green, yellow]: print yellow
// (yellow, 100]: print red
//
// if (green > yellow)
// [green, 100]: print green
// [yellow, green): print yellow
// [0, yellow): PRINT RED
void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses)
{
assert(green <= 100 && yellow <= 100);
bool colored = !!(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT);
if (parentheses)
ffStrbufAppendC(buffer, '(');
if (colored && !instance->config.pipe)
{
if(green < yellow)
{
if (percent <= green)
ffStrbufAppendS(buffer, "\033[32m");
else if (percent <= yellow)
ffStrbufAppendS(buffer, "\033[93m");
else
ffStrbufAppendS(buffer, "\033[91m");
}
else
{
if (percent >= green)
ffStrbufAppendS(buffer, "\033[32m");
else if (percent >= yellow)
ffStrbufAppendS(buffer, "\033[93m");
else
ffStrbufAppendS(buffer, "\033[91m");
}
}
ffStrbufAppendF(buffer, "%u%%", (unsigned) percent);
if (colored && !instance->config.pipe)
{
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
if (parentheses)
ffStrbufAppendC(buffer, ')');
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#ifndef FF_INCLUDED_common_bar
#define FF_INCLUDED_common_bar
#include "fastfetch.h"
enum
{
FF_PERCENTAGE_TYPE_NUM_BIT = 1 << 0,
FF_PERCENTAGE_TYPE_BAR_BIT = 1 << 1,
FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT = 1 << 2,
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
};
void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red);
void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses);
#endif
+206
View File
@@ -0,0 +1,206 @@
#include "dbus.h"
#ifdef FF_HAVE_DBUS
#include "common/thread.h"
#include "util/stringUtils.h"
static bool loadLibSymbols(const FFinstance* instance, FFDBusLibrary* lib)
{
FF_LIBRARY_LOAD(dbus, &instance->config.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_bus_get, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_new_method_call, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_init, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_init_append, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_append_basic, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_get_arg_type, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_get_basic, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_recurse, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_has_next, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_iter_next, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_unref, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_connection_send_with_reply_and_block, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_connection_flush, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_pending_call_block, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_pending_call_steal_reply, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_pending_call_unref, false)
dbus = NULL; // don't auto dlclose
return true;
}
static const FFDBusLibrary* loadLib(const FFinstance* instance)
{
static FFDBusLibrary lib;
static bool loaded = false;
static bool loadSuccess = false;
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
ffThreadMutexLock(&mutex);
if(!loaded)
{
loaded = true;
loadSuccess = loadLibSymbols(instance, &lib);
}
ffThreadMutexUnlock(&mutex);
return loadSuccess ? &lib : NULL;
}
const char* ffDBusLoadData(const FFinstance* instance, DBusBusType busType, FFDBusData* data)
{
data->lib = loadLib(instance);
if(data->lib == NULL)
return "Failed to load DBus library";
data->connection = data->lib->ffdbus_bus_get(busType, NULL);
if(data->connection == NULL)
return "Failed to connect to DBus";
return NULL;
}
bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result)
{
int argType = dbus->lib->ffdbus_message_iter_get_arg_type(iter);
if(argType == DBUS_TYPE_STRING)
{
const char* value = NULL;
dbus->lib->ffdbus_message_iter_get_basic(iter, &value);
if(!ffStrSet(value))
return false;
ffStrbufAppendS(result, value);
return true;
}
if(argType != DBUS_TYPE_VARIANT && argType != DBUS_TYPE_ARRAY)
return false;
DBusMessageIter subIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &subIter);
if(argType == DBUS_TYPE_VARIANT)
return ffDBusGetValue(dbus, &subIter, result);
//At this point we have an array
bool foundAValue = false;
while(true)
{
if(ffDBusGetValue(dbus, &subIter, result))
{
foundAValue = true;
ffStrbufAppendS(result, ", ");
}
FF_DBUS_ITER_CONTINUE(dbus, &subIter);
}
if(foundAValue)
ffStrbufSubstrBefore(result, result->length - 2);
return foundAValue;
}
bool ffDBusGetBool(FFDBusData* dbus, DBusMessageIter* iter, bool* result)
{
int argType = dbus->lib->ffdbus_message_iter_get_arg_type(iter);
if(argType == DBUS_TYPE_BOOLEAN)
{
dbus_bool_t value = 0;
dbus->lib->ffdbus_message_iter_get_basic(iter, &value);
*result = value != 0;
return true;
}
if(argType != DBUS_TYPE_VARIANT)
return false;
DBusMessageIter subIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &subIter);
return ffDBusGetBool(dbus, &subIter, result);
}
bool ffDBusGetByte(FFDBusData* dbus, DBusMessageIter* iter, uint8_t* result)
{
int argType = dbus->lib->ffdbus_message_iter_get_arg_type(iter);
if(argType == DBUS_TYPE_BYTE)
{
dbus->lib->ffdbus_message_iter_get_basic(iter, result);
return true;
}
if(argType != DBUS_TYPE_VARIANT)
return false;
DBusMessageIter subIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &subIter);
return ffDBusGetByte(dbus, &subIter, result);
}
DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method)
{
DBusMessage* message = dbus->lib->ffdbus_message_new_method_call(busName, objectPath, interface, method);
if(message == NULL)
return NULL;
DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, FF_DBUS_TIMEOUT_MILLISECONDS, NULL);
dbus->lib->ffdbus_message_unref(message);
return reply;
}
DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property)
{
DBusMessage* message = dbus->lib->ffdbus_message_new_method_call(busName, objectPath, "org.freedesktop.DBus.Properties", "Get");
if(message == NULL)
return NULL;
DBusMessageIter requestIterator;
dbus->lib->ffdbus_message_iter_init_append(message, &requestIterator);
if(!dbus->lib->ffdbus_message_iter_append_basic(&requestIterator, DBUS_TYPE_STRING, &interface))
{
dbus->lib->ffdbus_message_unref(message);
return NULL;
}
if(!dbus->lib->ffdbus_message_iter_append_basic(&requestIterator, DBUS_TYPE_STRING, &property))
{
dbus->lib->ffdbus_message_unref(message);
return NULL;
}
DBusMessage* reply = dbus->lib->ffdbus_connection_send_with_reply_and_block(dbus->connection, message, FF_DBUS_TIMEOUT_MILLISECONDS, NULL);
dbus->lib->ffdbus_message_unref(message);
return reply;
}
void ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, FFstrbuf* result)
{
DBusMessage* reply = ffDBusGetProperty(dbus, busName, objectPath, interface, property);
if(reply == NULL)
return;
DBusMessageIter rootIterator;
if(!dbus->lib->ffdbus_message_iter_init(reply, &rootIterator))
{
dbus->lib->ffdbus_message_unref(reply);
return;
}
ffDBusGetValue(dbus, &rootIterator, result);
dbus->lib->ffdbus_message_unref(reply);
}
#endif //FF_HAVE_DBUS
+57
View File
@@ -0,0 +1,57 @@
#pragma once
#ifndef FF_INCLUDED_common_dbus
#define FF_INCLUDED_common_dbus
#ifdef FF_HAVE_DBUS
#include <dbus/dbus.h>
#include "util/FFstrbuf.h"
#include "common/library.h"
#define FF_DBUS_TIMEOUT_MILLISECONDS 35
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
{ \
if(!(dbus)->lib->ffdbus_message_iter_has_next(iterator)) \
break; \
(dbus)->lib->ffdbus_message_iter_next(iterator); \
continue; \
}
typedef struct FFDBusLibrary
{
FF_LIBRARY_SYMBOL(dbus_bus_get)
FF_LIBRARY_SYMBOL(dbus_message_new_method_call)
FF_LIBRARY_SYMBOL(dbus_message_iter_init)
FF_LIBRARY_SYMBOL(dbus_message_iter_init_append)
FF_LIBRARY_SYMBOL(dbus_message_iter_append_basic)
FF_LIBRARY_SYMBOL(dbus_message_iter_get_arg_type)
FF_LIBRARY_SYMBOL(dbus_message_iter_get_basic)
FF_LIBRARY_SYMBOL(dbus_message_iter_recurse)
FF_LIBRARY_SYMBOL(dbus_message_iter_has_next)
FF_LIBRARY_SYMBOL(dbus_message_iter_next)
FF_LIBRARY_SYMBOL(dbus_message_unref)
FF_LIBRARY_SYMBOL(dbus_connection_send_with_reply_and_block)
FF_LIBRARY_SYMBOL(dbus_connection_flush)
FF_LIBRARY_SYMBOL(dbus_pending_call_block)
FF_LIBRARY_SYMBOL(dbus_pending_call_steal_reply)
FF_LIBRARY_SYMBOL(dbus_pending_call_unref)
} FFDBusLibrary;
typedef struct FFDBusData
{
const FFDBusLibrary* lib;
DBusConnection* connection;
} FFDBusData;
const char* ffDBusLoadData(const FFinstance* instance, DBusBusType busType, FFDBusData* data); //Returns an error message or NULL on success
bool ffDBusGetValue(FFDBusData* dbus, DBusMessageIter* iter, FFstrbuf* result);
bool ffDBusGetBool(FFDBusData* dbus, DBusMessageIter* iter, bool* result);
bool ffDBusGetByte(FFDBusData* dbus, DBusMessageIter* iter, uint8_t* result);
DBusMessage* ffDBusGetMethodReply(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* method);
DBusMessage* ffDBusGetProperty(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property);
void ffDBusGetPropertyString(FFDBusData* dbus, const char* busName, const char* objectPath, const char* interface, const char* property, FFstrbuf* result);
#endif // FF_HAVE_DBUS
#endif // FF_INCLUDED_common_dbus
+233
View File
@@ -0,0 +1,233 @@
#include "fastfetch.h"
#include "common/font.h"
#include <string.h>
static void fontInit(FFfont* font)
{
ffStrbufInit(&font->pretty);
ffStrbufInit(&font->name);
ffStrbufInitA(&font->size, 4);
ffListInitA(&font->styles, sizeof(FFstrbuf), 4);
}
static void fontInitPretty(FFfont* font)
{
ffStrbufAppend(&font->pretty, &font->name);
if(font->size.length == 0 && font->styles.length == 0)
return;
else if(font->pretty.length == 0)
ffStrbufAppendS(&font->pretty, "default");
ffStrbufAppendS(&font->pretty, " (");
if(font->size.length > 0)
{
ffStrbufAppend(&font->pretty, &font->size);
ffStrbufAppendS(&font->pretty, "pt");
if(font->styles.length > 0)
ffStrbufAppendS(&font->pretty, ", ");
}
for(uint32_t i = 0; i < font->styles.length; i++)
{
ffStrbufAppend(&font->pretty, ffListGet(&font->styles, i));
if(i < font->styles.length - 1)
ffStrbufAppendS(&font->pretty, ", ");
}
ffStrbufAppendC(&font->pretty, ')');
}
void ffFontInitQt(FFfont* font, const char* data)
{
fontInit(font);
//See https://doc.qt.io/qt-5/qfont.html#toString
//Family
while(*data != ',' && *data != '\0')
{
ffStrbufAppendC(&font->name, *data);
++data;
}
if(*data != '\0')
++data;
ffStrbufTrim(&font->name, ' ');
//Size
while(*data != ',' && *data != '\0')
{
ffStrbufAppendC(&font->size, *data);
++data;
}
if(*data != '\0')
++data;
ffStrbufTrim(&font->size, ' ');
#define FF_FONT_QT_SKIP_VALUE \
while(*data != ',' && *data != '\0') \
++data; \
if(*data != '\0') \
++data;
FF_FONT_QT_SKIP_VALUE //Pixel size
FF_FONT_QT_SKIP_VALUE //Style hint
FF_FONT_QT_SKIP_VALUE //Font weight
FF_FONT_QT_SKIP_VALUE //Font style
FF_FONT_QT_SKIP_VALUE //Underline
FF_FONT_QT_SKIP_VALUE //Strike out
FF_FONT_QT_SKIP_VALUE //Fixed pitch
FF_FONT_QT_SKIP_VALUE //Always 0
#undef FF_FONT_QT_SKIP_VALUE
while(*data != '\0')
{
while(*data == ' ')
++data;
if(*data == '\0')
break;
FFstrbuf* style = ffListAdd(&font->styles);
ffStrbufInit(style);
while(*data != ' ' && *data != '\0')
{
ffStrbufAppendC(style, *data);
++data;
}
}
fontInitPretty(font);
}
static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* alternativeBuffer)
{
while(**data == ' ' || **data == '\t' || **data == ',')
++(*data);
const char* wordStart = *data;
while(**data != ' ' && **data != '\t' && **data != ',' && **data != '\0' && **data != '`' && **data != '\\')
++(*data);
uint32_t wordLength = (uint32_t) (*data - wordStart);
if(wordLength == 0)
return;
if(**data == '\0' || **data == '`' || **data == '\\')
{
ffStrbufAppendNS(&font->size, wordLength, wordStart);
if(ffStrbufEndsWithS(&font->size, "px"))
ffStrbufSubstrBefore(&font->size, font->size.length - 2);
double dummy;
if(sscanf(font->size.chars, "%lf", &dummy) == 1)
return;
ffStrbufClear(&font->size);
}
if(
strncasecmp(wordStart, "Ultra", 5) == 0 ||
strncasecmp(wordStart, "Extra", 5) == 0 ||
strncasecmp(wordStart, "Semi", 4) == 0 ||
strncasecmp(wordStart, "Demi", 4) == 0 ||
strncasecmp(wordStart, "Normal", wordLength) == 0 ||
strncasecmp(wordStart, "Roman", wordLength) == 0 ||
strncasecmp(wordStart, "Oblique", wordLength) == 0 ||
strncasecmp(wordStart, "Italic", wordLength) == 0 ||
strncasecmp(wordStart, "Thin", wordLength) == 0 ||
strncasecmp(wordStart, "Light", wordLength) == 0 ||
strncasecmp(wordStart, "Bold", wordLength) == 0 ||
strncasecmp(wordStart, "Black", wordLength) == 0 ||
strncasecmp(wordStart, "Condensed", wordLength) == 0 ||
strncasecmp(wordStart, "Expanded", wordLength) == 0
) {
if(alternativeBuffer == NULL)
{
alternativeBuffer = ffListAdd(&font->styles);
ffStrbufInit(alternativeBuffer);
}
ffStrbufAppendNSExludingC(alternativeBuffer, wordLength, wordStart, '-');
if(
strncasecmp(wordStart, "Ultra ", 6) == 0 ||
strncasecmp(wordStart, "Extra ", 6) == 0 ||
strncasecmp(wordStart, "Semi ", 5) == 0 ||
strncasecmp(wordStart, "Demi ", 5) == 0
) {
fontPangoParseWord(data, font, alternativeBuffer);
}
return;
}
if(alternativeBuffer != NULL)
{
ffStrbufAppendNSExludingC(alternativeBuffer, wordLength, wordStart, '-');
return;
}
if(font->name.length > 0)
ffStrbufAppendC(&font->name, ' ');
ffStrbufAppendNS(&font->name, wordLength, wordStart);
}
void ffFontInitPango(FFfont* font, const char* data)
{
fontInit(font);
while(*data != '\0' && *data != '`' && *data != '\\')
fontPangoParseWord(&data, font, NULL);
fontInitPretty(font);
}
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);
}
void ffFontDestroy(FFfont* font)
{
ffStrbufDestroy(&font->pretty);
ffStrbufDestroy(&font->name);
ffStrbufDestroy(&font->size);
for(uint32_t i = 0; i < font->styles.length; i++)
ffStrbufDestroy(ffListGet(&font->styles, i));
ffListDestroy(&font->styles);
}
+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
+33 -45
View File
@@ -1,21 +1,31 @@
#include "fastfetch.h"
#include "common/format.h"
#include "common/parsing.h"
#include "util/textModifier.h"
#include "util/stringUtils.h"
#include <inttypes.h>
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
{
if(formatarg->type == FF_FORMAT_ARG_TYPE_INT)
ffStrbufAppendF(buffer, "%i", *(int*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT)
ffStrbufAppendF(buffer, "%u", *(uint32_t*)formatarg->value);
ffStrbufAppendF(buffer, "%" PRIu32, *(uint32_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT16)
ffStrbufAppendF(buffer, "%hu", *(uint16_t*)formatarg->value);
ffStrbufAppendF(buffer, "%" PRIu16, *(uint16_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_UINT8)
ffStrbufAppendF(buffer, "%hhu", *(uint8_t*)formatarg->value);
ffStrbufAppendF(buffer, "%" PRIu8, *(uint8_t*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_STRING)
ffStrbufAppendS(buffer, (const char*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_STRBUF)
ffStrbufAppend(buffer, (FFstrbuf*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_FLOAT)
ffStrbufAppendF(buffer, "%f", *(float*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_DOUBLE)
ffStrbufAppendF(buffer, "%g", *(double*)formatarg->value);
else if(formatarg->type == FF_FORMAT_ARG_TYPE_BOOL)
ffStrbufAppendS(buffer, formatarg->value != NULL ? "true" : "false");
else if(formatarg->type == FF_FORMAT_ARG_TYPE_LIST)
{
const FFlist* list = formatarg->value;
@@ -32,15 +42,14 @@ void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
}
}
static inline bool placeholderValueIsForError(const FFstrbuf* placeholderValue)
{
return
ffStrbufIgnCaseCompS(placeholderValue, "e") == 0 ||
ffStrbufIgnCaseCompS(placeholderValue, "error") == 0 ||
ffStrbufIgnCaseCompS(placeholderValue, "0") == 0
;
}
/**
* @brief parses a string to a uint32_t
*
* If the string can't be parsed, or is < 1, uint32_t max is returned.
*
* @param placeholderValue the string to parse
* @return uint32_t the parsed value
*/
static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
{
uint32_t result = UINT32_MAX;
@@ -48,7 +57,7 @@ static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
if(placeholderValue->chars[0] != '-')
sscanf(placeholderValue->chars, "%u", &result);
return result;
return result == 0 ? UINT32_MAX : result;
}
static inline void appendInvalidPlaceholder(FFstrbuf* buffer, const char* start, const FFstrbuf* placeholderValue, uint32_t index, uint32_t formatStringLength)
@@ -62,26 +71,29 @@ 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 > 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)
(arg->type == FF_FORMAT_ARG_TYPE_UINT && *(uint32_t*)arg->value > 0) ||
(arg->type == FF_FORMAT_ARG_TYPE_BOOL && arg->value != NULL)
);
}
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments)
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments)
{
uint32_t argCounter = 0;
@@ -128,13 +140,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
while(i < formatstr->length && formatstr->chars[i] != '}')
ffStrbufAppendC(&placeholderValue, formatstr->chars[i++]);
// test for error, if so print it
if(placeholderValueIsForError(&placeholderValue)) {
ffStrbufAppend(buffer, error);
ffStrbufDestroy(&placeholderValue);
continue;
}
// test if for stop, if so break the loop
if(placeholderValue.length == 1 && placeholderValue.chars[0] == '-')
{
@@ -173,7 +178,7 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
appendInvalidPlaceholder(buffer, "{", &placeholderValue, i, formatstr->length);
else
{
ffStrbufAppendS(buffer, "\033[0m");
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
--numOpenColors;
}
@@ -186,14 +191,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
{
ffStrbufSubstrAfter(&placeholderValue, 0);
// continue if an error is set
if(placeholderValueIsForError(&placeholderValue) && error != NULL && error->length > 0)
{
++numOpenIfs;
ffStrbufDestroy(&placeholderValue);
continue;
}
uint32_t index = getArgumentIndex(&placeholderValue);
// testing for an invalid index
@@ -223,14 +220,6 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
{
ffStrbufSubstrAfter(&placeholderValue, 0);
//continue if an error os not set
if(placeholderValueIsForError(&placeholderValue) && (error == NULL || error->length == 0))
{
++numOpenNotIfs;
ffStrbufDestroy(&placeholderValue);
continue;
}
uint32_t index = getArgumentIndex(&placeholderValue);
// testing for an invalid index
@@ -284,6 +273,5 @@ void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, const FFst
ffStrbufTrimRight(buffer, ' ');
if(numOpenColors > 0)
ffStrbufAppendS(buffer, "\033[0m");
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}
+32
View File
@@ -0,0 +1,32 @@
#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_FLOAT,
FF_FORMAT_ARG_TYPE_DOUBLE,
FF_FORMAT_ARG_TYPE_LIST,
FF_FORMAT_ARG_TYPE_BOOL
} 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);
#define FF_FORMAT_ARG_VALUE_BOOL(xpr) ((xpr) ? (const void*) 1 : NULL)
#endif
+391 -181
View File
@@ -1,189 +1,121 @@
#include "fastfetch.h"
#include "common/parsing.h"
#include "common/thread.h"
#include "detection/displayserver/displayserver.h"
#include "util/textModifier.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <signal.h>
static bool strbufEqualsAdapter(const void* first, const void* second)
{
return ffStrbufComp(second, first) == 0;
}
static void initConfigDirs(FFstate* state)
{
ffListInit(&state->configDirs, sizeof(FFstrbuf));
const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if(xdgConfigHome != NULL)
{
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
ffStrbufInitA(buffer, 64);
ffStrbufAppendS(buffer, xdgConfigHome);
ffStrbufTrimRight(buffer, '/');
}
FFstrbuf xdgConfigDirs;
ffStrbufInitA(&xdgConfigDirs, 64);
ffStrbufAppendS(&xdgConfigDirs, getenv("XDG_CONFIG_DIRS"));
#define FF_ENSURE_ONLY_ONCE_IN_LIST(element) \
if(ffListFirstIndexComp(&state->configDirs, element, strbufEqualsAdapter) < state->configDirs.length - 1) \
--state->configDirs.length;
FFstrbuf* userConfigHome = ffListAdd(&state->configDirs);
ffStrbufInitA(userConfigHome, 64);
ffStrbufAppendS(userConfigHome, state->passwd->pw_dir);
ffStrbufAppendS(userConfigHome, "/.config");
FF_ENSURE_ONLY_ONCE_IN_LIST(userConfigHome)
FFstrbuf* userHome = ffListAdd(&state->configDirs);
ffStrbufInitA(userHome, 64);
ffStrbufAppendS(userHome, state->passwd->pw_dir);
FF_ENSURE_ONLY_ONCE_IN_LIST(userHome)
uint32_t startIndex = 0;
while (startIndex < xdgConfigDirs.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&xdgConfigDirs, startIndex, ':');
xdgConfigDirs.chars[colonIndex] = '\0';
FFstrbuf* buffer = (FFstrbuf*) ffListAdd(&state->configDirs);
ffStrbufInitA(buffer, 64);
ffStrbufAppendS(buffer, xdgConfigDirs.chars + startIndex);
ffStrbufTrimRight(buffer, '/');
FF_ENSURE_ONLY_ONCE_IN_LIST(buffer);
startIndex = colonIndex + 1;
}
FFstrbuf* systemConfigHome = ffListAdd(&state->configDirs);
ffStrbufInitA(systemConfigHome, 64);
ffStrbufAppendS(systemConfigHome, "/etc/xdg");
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfigHome)
FFstrbuf* systemConfig = ffListAdd(&state->configDirs);
ffStrbufInitA(systemConfig, 64);
ffStrbufAppendS(systemConfig, "/etc");
FF_ENSURE_ONLY_ONCE_IN_LIST(systemConfig)
#undef FF_ENSURE_ONLY_ONCE_IN_LIST
}
static void initCacheDir(FFstate* state)
{
ffStrbufInitA(&state->cacheDir, 64);
ffStrbufAppendS(&state->cacheDir, getenv("XDG_CACHE_HOME"));
if(state->cacheDir.length == 0)
{
ffStrbufAppendS(&state->cacheDir, state->passwd->pw_dir);
ffStrbufAppendS(&state->cacheDir, "/.cache/");
}
else if(!ffStrbufEndsWithC(&state->cacheDir, '/'))
ffStrbufAppendC(&state->cacheDir, '/');
mkdir(state->cacheDir.chars, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); //I hope everybody has a cache folder, but who knows
ffStrbufAppendS(&state->cacheDir, "fastfetch/");
mkdir(state->cacheDir.chars, S_IRWXU | S_IRGRP | S_IROTH);
}
#ifdef _WIN32
#include <wincon.h>
#include <locale.h>
#include <shlobj.h>
#include "util/windows/unicode.h"
#else
#include <signal.h>
#endif
static void initState(FFstate* state)
{
state->logoWidth = 0;
state->passwd = getpwuid(getuid());
uname(&state->utsname);
sysinfo(&state->sysinfo);
state->logoHeight = 0;
state->keysHeight = 0;
initConfigDirs(state);
initCacheDir(state);
ffPlatformInit(&state->platform);
}
static void initModuleArg(FFModuleArgs* args)
{
ffStrbufInit(&args->key);
ffStrbufInit(&args->outputFormat);
ffStrbufInit(&args->errorFormat);
}
static void defaultConfig(FFinstance* instance)
{
ffStrbufInit(&instance->config.color);
ffStrbufInitA(&instance->config.logo.source, 0);
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufInit(&instance->config.logo.colors[i]);
instance->config.logo.width = 0;
instance->config.logo.height = 0; //preserve aspect ratio
instance->config.logo.paddingTop = 0;
instance->config.logo.paddingLeft = 0;
instance->config.logo.paddingRight = 4;
instance->config.logo.printRemaining = true;
instance->config.logo.preserveAspectRadio = false;
instance->config.logo.chafaFgOnly = false;
ffStrbufInitS(&instance->config.logo.chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
instance->config.logo.chafaCanvasMode = UINT32_MAX;
instance->config.logo.chafaColorSpace = UINT32_MAX;
instance->config.logo.chafaDitherMode = UINT32_MAX;
ffStrbufInit(&instance->config.colorKeys);
ffStrbufInit(&instance->config.colorTitle);
ffStrbufInit(&instance->config.separator);
ffStrbufAppendS(&instance->config.separator, ": ");
instance->config.logoKeySpacing = 4;
instance->config.offsetx = 0;
instance->config.colorLogo = true;
instance->config.showErrors = false;
instance->config.recache = false;
instance->config.cacheSave = true;
instance->config.printRemainingLogo = true;
instance->config.allowSlowOperations = false;
instance->config.disableLinewrap = true;
instance->config.hideCursor = true;
instance->config.userLogoIsRaw = false;
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;
instance->config.stat = false;
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufInit(&instance->config.logoColors[i]);
ffStrbufInitA(&instance->config.osFormat, 0);
ffStrbufInitA(&instance->config.osKey, 0);
ffStrbufInitA(&instance->config.hostFormat, 0);
ffStrbufInitA(&instance->config.hostKey, 0);
ffStrbufInitA(&instance->config.kernelFormat, 0);
ffStrbufInitA(&instance->config.kernelKey, 0);
ffStrbufInitA(&instance->config.uptimeFormat, 0);
ffStrbufInitA(&instance->config.uptimeKey, 0);
ffStrbufInitA(&instance->config.processesFormat, 0);
ffStrbufInitA(&instance->config.processesKey, 0);
ffStrbufInitA(&instance->config.packagesFormat, 0);
ffStrbufInitA(&instance->config.packagesKey, 0);
ffStrbufInitA(&instance->config.shellFormat, 0);
ffStrbufInitA(&instance->config.shellKey, 0);
ffStrbufInitA(&instance->config.resolutionFormat, 0);
ffStrbufInitA(&instance->config.resolutionKey, 0);
ffStrbufInitA(&instance->config.deFormat, 0);
ffStrbufInitA(&instance->config.deKey, 0);
ffStrbufInitA(&instance->config.wmFormat, 0);
ffStrbufInitA(&instance->config.wmKey, 0);
ffStrbufInitA(&instance->config.wmThemeFormat, 0);
ffStrbufInitA(&instance->config.wmThemeKey, 0);
ffStrbufInitA(&instance->config.themeFormat, 0);
ffStrbufInitA(&instance->config.themeKey, 0);
ffStrbufInitA(&instance->config.iconsFormat, 0);
ffStrbufInitA(&instance->config.iconsKey, 0);
ffStrbufInitA(&instance->config.fontFormat, 0);
ffStrbufInitA(&instance->config.fontKey, 0);
ffStrbufInitA(&instance->config.cursorKey, 0);
ffStrbufInitA(&instance->config.cursorFormat, 0);
ffStrbufInitA(&instance->config.terminalFormat, 0);
ffStrbufInitA(&instance->config.terminalKey, 0);
ffStrbufInitA(&instance->config.termFontFormat, 0);
ffStrbufInitA(&instance->config.termFontKey, 0);
ffStrbufInitA(&instance->config.cpuFormat, 0);
ffStrbufInitA(&instance->config.cpuKey, 0);
ffStrbufInitA(&instance->config.cpuUsageFormat, 0);
ffStrbufInitA(&instance->config.cpuUsageKey, 0);
ffStrbufInitA(&instance->config.gpuFormat, 0);
ffStrbufInitA(&instance->config.gpuKey, 0);
ffStrbufInitA(&instance->config.memoryFormat, 0);
ffStrbufInitA(&instance->config.memoryKey, 0);
ffStrbufInitA(&instance->config.diskFormat, 0);
ffStrbufInitA(&instance->config.diskKey, 0);
ffStrbufInitA(&instance->config.batteryFormat, 0);
ffStrbufInitA(&instance->config.batteryKey, 0);
ffStrbufInitA(&instance->config.localeFormat, 0);
ffStrbufInitA(&instance->config.localeKey, 0);
ffStrbufInitA(&instance->config.localIpKey, 0);
ffStrbufInitA(&instance->config.localIpFormat, 0);
ffStrbufInitA(&instance->config.publicIpKey, 0);
ffStrbufInitA(&instance->config.publicIpFormat, 0);
ffStrbufInitA(&instance->config.playerKey, 0);
ffStrbufInitA(&instance->config.playerFormat, 0);
ffStrbufInitA(&instance->config.songKey, 0);
ffStrbufInitA(&instance->config.songFormat, 0);
ffStrbufInitA(&instance->config.dateTimeKey, 0);
ffStrbufInitA(&instance->config.dateTimeFormat, 0);
ffStrbufInitA(&instance->config.dateKey, 0);
ffStrbufInitA(&instance->config.dateFormat, 0);
ffStrbufInitA(&instance->config.timeKey, 0);
ffStrbufInitA(&instance->config.timeFormat, 0);
initModuleArg(&instance->config.os);
initModuleArg(&instance->config.host);
initModuleArg(&instance->config.bios);
initModuleArg(&instance->config.board);
initModuleArg(&instance->config.brightness);
initModuleArg(&instance->config.chassis);
initModuleArg(&instance->config.kernel);
initModuleArg(&instance->config.uptime);
initModuleArg(&instance->config.processes);
initModuleArg(&instance->config.packages);
initModuleArg(&instance->config.shell);
initModuleArg(&instance->config.display);
initModuleArg(&instance->config.de);
initModuleArg(&instance->config.wm);
initModuleArg(&instance->config.wmTheme);
initModuleArg(&instance->config.theme);
initModuleArg(&instance->config.icons);
initModuleArg(&instance->config.font);
initModuleArg(&instance->config.cursor);
initModuleArg(&instance->config.terminal);
initModuleArg(&instance->config.terminalFont);
initModuleArg(&instance->config.cpu);
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.wifi);
initModuleArg(&instance->config.player);
initModuleArg(&instance->config.media);
initModuleArg(&instance->config.dateTime);
initModuleArg(&instance->config.date);
initModuleArg(&instance->config.time);
initModuleArg(&instance->config.vulkan);
initModuleArg(&instance->config.openGL);
initModuleArg(&instance->config.openCL);
initModuleArg(&instance->config.users);
initModuleArg(&instance->config.bluetooth);
initModuleArg(&instance->config.sound);
initModuleArg(&instance->config.gamepad);
ffStrbufInitA(&instance->config.libPCI, 0);
ffStrbufInitA(&instance->config.libVulkan, 0);
@@ -196,9 +128,42 @@ static void defaultConfig(FFinstance* instance)
ffStrbufInitA(&instance->config.libDConf, 0);
ffStrbufInitA(&instance->config.libDBus, 0);
ffStrbufInitA(&instance->config.libXFConf, 0);
ffStrbufInitA(&instance->config.libSQLite3, 0);
ffStrbufInitA(&instance->config.librpm, 0);
ffStrbufInitA(&instance->config.libImageMagick, 0);
ffStrbufInitA(&instance->config.libZ, 0);
ffStrbufInitA(&instance->config.libChafa, 0);
ffStrbufInitA(&instance->config.libEGL, 0);
ffStrbufInitA(&instance->config.libGLX, 0);
ffStrbufInitA(&instance->config.libOSMesa, 0);
ffStrbufInitA(&instance->config.libOpenCL, 0);
ffStrbufInitA(&instance->config.libcJSON, 0);
ffStrbufInitA(&instance->config.libfreetype, 0);
ffStrbufInit(&instance->config.libPulse);
ffStrbufInit(&instance->config.libwlanapi);
ffStrbufInit(&instance->config.libnm);
instance->config.cpuTemp = false;
instance->config.gpuTemp = false;
instance->config.batteryTemp = false;
instance->config.gpuHideIntegrated = false;
instance->config.gpuHideDiscrete = false;
instance->config.shellVersion = true;
instance->config.terminalVersion = true;
instance->config.titleFQDN = false;
ffStrbufInitA(&instance->config.diskFolders, 0);
instance->config.diskShowRemovable = true;
instance->config.diskShowHidden = false;
instance->config.diskShowUnknown = false;
instance->config.diskShowSubvolumes = false;
instance->config.bluetoothShowDisconnected = false;
instance->config.soundType = FF_SOUND_TYPE_MAIN;
ffStrbufInitA(&instance->config.batteryDir, 0);
@@ -207,70 +172,276 @@ static void defaultConfig(FFinstance* instance)
instance->config.localIpShowIpV4 = true;
instance->config.localIpShowIpV6 = false;
instance->config.localIpShowLoop = false;
instance->config.localIpV6First = false;
ffStrbufInit(&instance->config.localIpNamePrefix);
instance->config.localIpCompactType = FF_LOCALIP_COMPACT_TYPE_NONE;
instance->config.publicIpTimeout = 0;
ffStrbufInit(&instance->config.publicIpUrl);
instance->config.weatherTimeout = 0;
ffStrbufInitS(&instance->config.weatherOutputFormat, "%t+-+%C+(%l)");
ffStrbufInitA(&instance->config.osFile, 0);
ffStrbufInitA(&instance->config.playerName, 0);
instance->config.percentType = 1;
ffStrbufInitS(&instance->config.commandShell,
#ifdef _WIN32
"cmd"
#elif defined(__FreeBSD__)
"csh"
#else
"bash"
#endif
);
ffListInit(&instance->config.commandKeys, sizeof(FFstrbuf));
ffListInit(&instance->config.commandTexts, sizeof(FFstrbuf));
}
void ffInitInstance(FFinstance* instance)
{
#ifdef WIN32
//https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendations&view=msvc-170#utf-8-support
setlocale(LC_ALL, ".UTF8");
#endif
initState(&instance->state);
defaultConfig(instance);
ffCacheValidate(instance);
}
static void resetConsole(bool disableLinewrap, bool hideCursor)
#if defined(FF_HAVE_THREADS) && !(defined(__APPLE__) || defined(_WIN32) || defined(__ANDROID__))
#include "detection/gtk_qt/gtk_qt.h"
#define FF_START_DETECTION_THREADS
FF_THREAD_ENTRY_DECL_WRAPPER(ffConnectDisplayServer, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectQt, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK2, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK3, FFinstance*)
FF_THREAD_ENTRY_DECL_WRAPPER(ffDetectGTK4, FFinstance*)
void startDetectionThreads(FFinstance* instance)
{
if(disableLinewrap)
fputs("\033[?7h", stdout);
if(hideCursor)
fputs("\033[?25h", stdout);
ffThreadDetach(ffThreadCreate(ffConnectDisplayServerThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectQtThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK2ThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK3ThreadMain, instance));
ffThreadDetach(ffThreadCreate(ffDetectGTK4ThreadMain, instance));
}
#endif //FF_HAVE_THREADS
static volatile bool ffDisableLinewrap = true;
static volatile bool ffHideCursor = true;
static void resetConsole()
{
if(ffDisableLinewrap)
fputs("\033[?7h", stdout);
if(ffHideCursor)
fputs("\033[?25h", stdout);
#if defined(_WIN32) && defined(FF_ENABLE_BUFFER)
fflush(stdout);
#endif
}
#ifdef _WIN32
BOOL WINAPI consoleHandler(DWORD signal)
{
FF_UNUSED(signal);
resetConsole();
exit(0);
}
#else
static void exitSignalHandler(int signal)
{
FF_UNUSED(signal);
resetConsole(ffDisableLinewrap, ffHideCursor);
resetConsole();
exit(0);
}
#endif
void ffStart(FFinstance* instance)
{
ffDisableLinewrap = instance->config.disableLinewrap;
ffHideCursor = instance->config.hideCursor;
#ifdef FF_START_DETECTION_THREADS
if(instance->config.multithreading)
startDetectionThreads(instance);
#endif
struct sigaction action = {};
action.sa_handler = exitSignalHandler;
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
#ifdef _WIN32
#ifdef FF_ENABLE_BUFFER
setvbuf(stdout, NULL, _IOFBF, 4096);
#endif
SetConsoleCtrlHandler(consoleHandler, TRUE);
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
GetConsoleMode(hStdout, &mode);
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
SetConsoleOutputCP(CP_UTF8);
#else
#ifndef FF_ENABLE_BUFFER
setvbuf(stdout, NULL, _IONBF, 0);
#endif
struct sigaction action = { .sa_handler = exitSignalHandler };
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);
sigaction(SIGQUIT, &action, NULL);
#endif
if(instance->config.hideCursor)
//reset everything to default before we start printing
if(!instance->config.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
if(ffHideCursor)
fputs("\033[?25l", stdout);
if(instance->config.disableLinewrap)
if(ffDisableLinewrap)
fputs("\033[?7l", stdout);
ffLogoPrint(instance);
}
void ffFinish(FFinstance* instance)
{
if(instance->config.printRemainingLogo)
ffPrintRemainingLogo(instance);
if(instance->config.logo.printRemaining)
ffLogoPrintRemaining(instance);
resetConsole(instance->config.disableLinewrap, instance->config.hideCursor);
resetConsole();
}
static void destroyModuleArg(FFModuleArgs* args)
{
ffStrbufDestroy(&args->key);
ffStrbufDestroy(&args->outputFormat);
ffStrbufDestroy(&args->errorFormat);
}
static void destroyConfig(FFinstance* instance)
{
ffStrbufDestroy(&instance->config.logo.source);
ffStrbufDestroy(&instance->config.logo.chafaSymbols);
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufDestroy(&instance->config.logo.colors[i]);
ffStrbufDestroy(&instance->config.colorKeys);
ffStrbufDestroy(&instance->config.colorTitle);
ffStrbufDestroy(&instance->config.separator);
destroyModuleArg(&instance->config.os);
destroyModuleArg(&instance->config.host);
destroyModuleArg(&instance->config.bios);
destroyModuleArg(&instance->config.board);
destroyModuleArg(&instance->config.kernel);
destroyModuleArg(&instance->config.uptime);
destroyModuleArg(&instance->config.processes);
destroyModuleArg(&instance->config.packages);
destroyModuleArg(&instance->config.shell);
destroyModuleArg(&instance->config.display);
destroyModuleArg(&instance->config.de);
destroyModuleArg(&instance->config.wm);
destroyModuleArg(&instance->config.wmTheme);
destroyModuleArg(&instance->config.theme);
destroyModuleArg(&instance->config.icons);
destroyModuleArg(&instance->config.font);
destroyModuleArg(&instance->config.cursor);
destroyModuleArg(&instance->config.terminal);
destroyModuleArg(&instance->config.terminalFont);
destroyModuleArg(&instance->config.cpu);
destroyModuleArg(&instance->config.cpuUsage);
destroyModuleArg(&instance->config.gpu);
destroyModuleArg(&instance->config.memory);
destroyModuleArg(&instance->config.swap);
destroyModuleArg(&instance->config.disk);
destroyModuleArg(&instance->config.battery);
destroyModuleArg(&instance->config.powerAdapter);
destroyModuleArg(&instance->config.locale);
destroyModuleArg(&instance->config.localIP);
destroyModuleArg(&instance->config.publicIP);
destroyModuleArg(&instance->config.weather);
destroyModuleArg(&instance->config.wifi);
destroyModuleArg(&instance->config.player);
destroyModuleArg(&instance->config.media);
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);
destroyModuleArg(&instance->config.bluetooth);
destroyModuleArg(&instance->config.sound);
destroyModuleArg(&instance->config.gamepad);
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.libPulse);
ffStrbufDestroy(&instance->config.libwlanapi);
ffStrbufDestroy(&instance->config.libnm);
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);
ffStrbufDestroy(&instance->config.commandShell);
FF_LIST_FOR_EACH(FFstrbuf, item, instance->config.commandKeys)
ffStrbufDestroy(item);
ffListDestroy(&instance->config.commandKeys);
FF_LIST_FOR_EACH(FFstrbuf, item, instance->config.commandTexts)
ffStrbufDestroy(item);
ffListDestroy(&instance->config.commandTexts);
}
static void destroyState(FFinstance* instance)
{
ffPlatformDestroy(&instance->state.platform);
}
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()
{
fputs(
#ifdef FF_HAVE_THREADS
"threads\n"
#endif
#ifdef FF_HAVE_LIBPCI
"libpci\n"
#endif
@@ -301,11 +472,50 @@ void ffListFeatures()
#ifdef FF_HAVE_DBUS
"dbus\n"
#endif
#ifdef FF_HAVE_IMAGEMAGICK7
"imagemagick7\n"
#endif
#ifdef FF_HAVE_IMAGEMAGICK6
"imagemagick6\n"
#endif
#ifdef FF_HAVE_CHAFA
"chafa\n"
#endif
#ifdef FF_HAVE_ZLIB
"zlib\n"
#endif
#ifdef FF_HAVE_XFCONF
"xfconf\n"
#endif
#ifdef FF_HAVE_SQLITE3
"sqlite3\n"
#endif
#ifdef FF_HAVE_RPM
"librpm\n"
"rpm\n"
#endif
#ifdef FF_HAVE_EGL
"egl\n"
#endif
#ifdef FF_HAVE_GLX
"glx\n"
#endif
#ifdef FF_HAVE_OSMESA
"osmesa\n"
#endif
#ifdef FF_HAVE_OPENCL
"opencl\n"
#endif
#ifdef FF_HAVE_LIBCJSON
"libcjson\n"
#endif
#ifdef FF_HAVE_FREETYPE
"freetype\n"
#endif
#ifdef FF_HAVE_PULSE
"libpulse\n"
#endif
#ifdef FF_HAVE_LIBNM
"libnm\n"
#endif
""
, stdout);
-505
View File
@@ -1,505 +0,0 @@
#include "fastfetch.h"
#include <malloc.h>
#include <unistd.h>
#include <fcntl.h>
#define FF_IO_CACHE_VALUE_EXTENSION "ffcv"
#define FF_IO_CACHE_SPLIT_EXTENSION "ffcs"
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
{
ffPrintLogoLine(instance);
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
ffPrintColor(&instance->config.color);
if(customKeyFormat == NULL || customKeyFormat->length == 0)
{
fputs(moduleName, stdout);
if(moduleIndex > 0)
printf(" %hhu", moduleIndex);
}
else
{
FFstrbuf key;
ffStrbufInit(&key);
ffParseFormatString(&key, customKeyFormat, NULL, 1, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
});
ffStrbufWriteTo(&key, stdout);
ffStrbufDestroy(&key);
}
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
ffStrbufWriteTo(&instance->config.separator, stdout);
}
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numFormatArgs, const char* message, ...)
{
if(!instance->config.showErrors)
return;
va_list arguments;
va_start(arguments, message);
if(formatString == NULL || formatString->length == 0)
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout);
vprintf(message, arguments);
puts(FASTFETCH_TEXT_MODIFIER_RESET);
}
else
{
FF_STRBUF_CREATE(error);
ffStrbufAppendVF(&error, message, arguments);
// calloc sets all to 0 and FF_FORMAT_ARG_TYPE_NULL also has value 0 so we don't need to explictly set it
FFformatarg* nullArgs = calloc(numFormatArgs, sizeof(FFformatarg));
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, &error, numFormatArgs, nullArgs);
free(nullArgs);
ffStrbufDestroy(&error);
}
va_end(arguments);
}
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, const FFstrbuf* error, uint32_t numArgs, const FFformatarg* arguments)
{
FFstrbuf buffer;
ffStrbufInitA(&buffer, 256);
ffParseFormatString(&buffer, formatString, error, numArgs, arguments);
if(buffer.length > 0)
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
ffStrbufPutTo(&buffer, stdout);
}
ffStrbufDestroy(&buffer);
}
void ffGetCacheFilePath(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
{
ffStrbufAppend(buffer, &instance->state.cacheDir);
ffStrbufAppendS(buffer, moduleName);
if(extension != NULL)
{
ffStrbufAppendC(buffer, '.');
ffStrbufAppendS(buffer, extension);
}
}
void ffReadCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* buffer)
{
FFstrbuf path;
ffStrbufInitA(&path, 64);
ffGetCacheFilePath(instance, moduleName, extension, &path);
ffAppendFileContent(path.chars, buffer);
ffStrbufDestroy(&path);
}
void ffWriteCacheFile(FFinstance* instance, const char* moduleName, const char* extension, FFstrbuf* content)
{
FFstrbuf path;
ffStrbufInitA(&path, 64);
ffGetCacheFilePath(instance, moduleName, extension, &path);
ffWriteFileContent(path.chars, content);
ffStrbufDestroy(&path);
}
static bool printCachedValue(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat)
{
FFstrbuf content;
ffStrbufInitA(&content, 512);
ffReadCacheFile(instance, moduleName, FF_IO_CACHE_VALUE_EXTENSION, &content);
ffStrbufTrimRight(&content, '\0'); //Strbuf always appends a '\0' at the end. We want the last null byte to be at the position of the length
if(content.length == 0)
return false;
uint8_t moduleCounter = 1;
uint32_t startIndex = 0;
while(startIndex < content.length)
{
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
puts(content.chars + startIndex);
startIndex = nullByteIndex + 1;
++moduleCounter;
}
ffStrbufDestroy(&content);
return moduleCounter > 1;
}
static bool printCachedFormat(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs)
{
FFstrbuf content;
ffStrbufInitA(&content, 512);
ffReadCacheFile(instance, moduleName, FF_IO_CACHE_SPLIT_EXTENSION, &content);
ffStrbufTrimRight(&content, '\0'); //Strbuf always appends a '\0' at the end. We want the last null byte to be at the position of the length
if(content.length == 0)
return false;
uint8_t moduleCounter = 1;
FFformatarg* arguments = calloc(numArgs, sizeof(FFformatarg));
uint32_t argumentCounter = 0;
uint32_t startIndex = 0;
while(startIndex < content.length)
{
arguments[argumentCounter].type = FF_FORMAT_ARG_TYPE_STRING;
arguments[argumentCounter].value = &content.chars[startIndex];
++argumentCounter;
uint32_t nullByteIndex = ffStrbufNextIndexC(&content, startIndex, '\0');
if(argumentCounter == numArgs)
{
uint8_t moduleIndex = (moduleCounter == 1 && nullByteIndex == content.length) ? 0 : moduleCounter;
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, NULL, numArgs, arguments);
++moduleCounter;
argumentCounter = 0;
}
startIndex = nullByteIndex + 1;
}
free(arguments);
ffStrbufDestroy(&content);
return moduleCounter > 1;
}
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* formatString, uint32_t numArgs)
{
if(instance->config.recache)
return false;
if(formatString == NULL || formatString->length == 0)
return printCachedValue(instance, moduleName, customKeyFormat);
else
return printCachedFormat(instance, moduleName, customKeyFormat, formatString, numArgs);
}
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, FFcache* cache, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments)
{
if(formatString == NULL || formatString->length == 0)
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
ffStrbufPutTo(value, stdout);
}
else
{
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, formatString, NULL, numArgs, arguments);
}
if(cache->value != NULL)
{
ffStrbufWriteTo(value, cache->value);
fputc('\0', cache->value);
}
if(cache->split == NULL)
return;
for(uint32_t i = 0; i < numArgs; i++)
{
FFstrbuf buffer;
ffStrbufInitA(&buffer, 64);
ffFormatAppendFormatArg(&buffer, &arguments[i]);
ffStrbufWriteTo(&buffer, cache->split);
ffStrbufDestroy(&buffer);
fputc('\0', cache->split);
}
}
void ffPrintAndSaveToCache(FFinstance* instance, const char* moduleName, const FFstrbuf* customKeyFormat, const FFstrbuf* value, const FFstrbuf* formatString, uint32_t numArgs, const FFformatarg* arguments)
{
FFcache cache;
ffCacheOpenWrite(instance, moduleName, &cache);
ffPrintAndAppendToCache(instance, moduleName, 0, customKeyFormat, &cache, value, formatString, numArgs, arguments);
ffCacheClose(&cache);
}
void ffCacheValidate(FFinstance* instance)
{
FFstrbuf path;
ffStrbufInitA(&path, 64);
ffGetCacheFilePath(instance, "cacheversion", "ffv", &path);
FFstrbuf content;
ffStrbufInit(&content);
ffAppendFileContent(path.chars, &content);
bool isSameVersion = ffStrbufCompS(&content, FASTFETCH_PROJECT_VERSION) == 0;
ffStrbufDestroy(&content);
if(isSameVersion)
{
ffStrbufDestroy(&path);
return;
}
instance->config.recache = true;
FFstrbuf version;
ffStrbufInit(&version);
ffStrbufAppendS(&version, FASTFETCH_PROJECT_VERSION);
ffWriteFileContent(path.chars, &version);
ffStrbufDestroy(&version);
ffStrbufDestroy(&path);
}
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache)
{
FFstrbuf cacheFileValue;
ffStrbufInitA(&cacheFileValue, 64);
ffGetCacheFilePath(instance, moduleName, FF_IO_CACHE_VALUE_EXTENSION, &cacheFileValue);
cache->value = fopen(cacheFileValue.chars, "w");
ffStrbufDestroy(&cacheFileValue);
FFstrbuf cacheFileSplit;
ffStrbufInitA(&cacheFileSplit, 64);
ffGetCacheFilePath(instance, moduleName, FF_IO_CACHE_SPLIT_EXTENSION, &cacheFileSplit);
cache->split = fopen(cacheFileSplit.chars, "w");
ffStrbufDestroy(&cacheFileSplit);
}
void ffCacheClose(FFcache* cache)
{
if(cache->value != NULL)
fclose(cache->value);
if(cache->split != NULL)
fclose(cache->split);
}
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
{
bool* searchedValues = malloc(sizeof(bool) * numQueries);
bool allSet = true;
for(uint32_t i = 0; i < numQueries; i++)
{
if((searchedValues[i] = queries[i].buffer->length == 0))
allSet = false;
}
if(allSet)
{
free(searchedValues);
return true;
}
FILE* file = fopen(filename, "r");
if(file == NULL)
return false;
char* line = NULL;
size_t len = 0;
while (getline(&line, &len, file) != -1)
{
for(uint32_t i = 0; i < numQueries; i++)
{
if(!searchedValues[i])
continue;
uint32_t currentLength = queries[i].buffer->length;
queries[i].buffer->length = 0;
if(!ffGetPropValue(line, queries[i].start, queries[i].buffer))
queries[i].buffer->length = currentLength;
}
}
free(searchedValues);
if(line != NULL)
free(line);
fclose(file);
return true;
}
bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileValues(filename, 1, (FFpropquery[]){{start, buffer}});
}
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries)
{
FFstrbuf absolutePath;
ffStrbufInitA(&absolutePath, 64);
ffStrbufAppendS(&absolutePath, instance->state.passwd->pw_dir);
ffStrbufAppendC(&absolutePath, '/');
ffStrbufAppendS(&absolutePath, relativeFile);
bool result = ffParsePropFileValues(absolutePath.chars, numQueries, queries);
ffStrbufDestroy(&absolutePath);
return result;
}
bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileHomeValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries)
{
bool foundAFile = false;
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
{
FFstrbuf* baseDir = (FFstrbuf*) ffListGet(&instance->state.configDirs, i);
uint32_t baseDirLength = baseDir->length;
if(*relativeFile != '/')
ffStrbufAppendC(baseDir, '/');
ffStrbufAppendS(baseDir, relativeFile);
if(ffParsePropFileValues(baseDir->chars, numQueries, queries))
foundAFile = true;
ffStrbufSubstrBefore(baseDir, baseDirLength);
bool allSet = true;
for(uint32_t k = 0; k < numQueries; k++)
{
if(queries[k].buffer->length == 0)
{
allSet = false;
break;
}
}
if(allSet)
break;
}
return foundAFile;
}
bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileConfigValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
bool ffWriteFDContent(int fd, const FFstrbuf* content)
{
return write(fd, content->chars, content->length) != -1;
}
void ffWriteFileContent(const char* fileName, const FFstrbuf* content)
{
int fd = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if(fd == -1)
return;
ffWriteFDContent(fd, content);
close(fd);
}
void ffAppendFDContent(int fd, FFstrbuf* buffer)
{
ssize_t readed = 0;
ffStrbufEnsureFree(buffer, 31); // 32 - 1 for the null terminator
uint32_t free = ffStrbufGetFree(buffer);
while(
(readed = read(fd, buffer->chars + buffer->length, free)) > 0 &&
(uint32_t) readed == free
) {
buffer->length += (uint32_t) readed;
ffStrbufEnsureCapacity(buffer, (buffer->allocated * 2) - 1); // -1 for null terminator
free = ffStrbufGetFree(buffer);
}
// In case of failure, read returns -1. We don't want to substract the length of the buffer.
if(readed > 0)
buffer->length += (uint32_t) readed;
buffer->chars[buffer->length] = '\0';
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
}
bool ffAppendFileContent(const char* fileName, FFstrbuf* buffer)
{
int fd = open(fileName, O_RDONLY);
if(fd == -1)
return false;
ffAppendFDContent(fd, buffer);
close(fd);
return true;
}
bool ffGetFileContent(const char* fileName, FFstrbuf* buffer)
{
ffStrbufClear(buffer);
return ffAppendFileContent(fileName, buffer);
}
// Not thread safe!
void ffSuppressIO(bool suppress)
{
static bool init = false;
static int origOut = -1;
static int origErr = -1;
static int nullFile = -1;
if(!init)
{
if(!suppress)
return;
origOut = dup(STDOUT_FILENO);
origErr = dup(STDERR_FILENO);
nullFile = open("/dev/null", O_WRONLY);
init = true;
}
if(nullFile == -1)
return;
fflush(stdout);
fflush(stderr);
dup2(suppress ? nullFile : origOut, STDOUT_FILENO);
dup2(suppress ? nullFile : origErr, STDERR_FILENO);
}
void ffPrintColor(const FFstrbuf* colorValue)
{
fputs("\033[", stdout);
ffStrbufWriteTo(colorValue, stdout);
fputc('m', stdout);
}
bool ffFileExists(const char* fileName, mode_t mode)
{
struct stat fileStat;
return stat(fileName, &fileStat) == 0 && ((fileStat.st_mode & S_IFMT) == mode);
}
+123
View File
@@ -0,0 +1,123 @@
#pragma once
#ifndef FF_INCLUDED_common_io_io
#define FF_INCLUDED_common_io_io
#include "util/FFstrbuf.h"
#ifdef _WIN32
#include <fileapi.h>
#include <io.h>
typedef HANDLE FFNativeFD;
#else
#include <unistd.h>
typedef int FFNativeFD;
#endif
static inline FFNativeFD FFUnixFD2NativeFD(int unixfd)
{
#ifndef _WIN32
return unixfd;
#else
return (FFNativeFD) _get_osfhandle(unixfd);
#endif
}
static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data)
{
#ifndef _WIN32
return write(fd, data, dataSize) != -1;
#else
DWORD written;
return WriteFile(fd, data, (DWORD) dataSize, &written, NULL) && written == dataSize;
#endif
}
static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content)
{
return ffWriteFDData(fd, content->length, content->chars);
}
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer)
{
return ffWriteFileData(fileName, buffer->length, buffer->chars);
}
static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data)
{
#ifndef _WIN32
return read(fd, data, dataSize);
#else
DWORD readed;
if(!ReadFile(fd, data, (DWORD)dataSize, &readed, NULL))
return -1;
return (ssize_t)readed;
#endif
}
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data);
bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer);
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer);
static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer)
{
ffStrbufClear(buffer);
return ffAppendFileBuffer(fileName, buffer);
}
//Bit flags, combine with |
typedef enum FFPathType
{
FF_PATHTYPE_REGULAR = 1,
FF_PATHTYPE_LINK = 2,
FF_PATHTYPE_DIRECTORY = 4
} FFPathType;
#define FF_PATHTYPE_FILE (FF_PATHTYPE_REGULAR | FF_PATHTYPE_LINK)
#define FF_PATHTYPE_ANY (FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY)
bool ffPathExists(const char* path, FFPathType pathType);
#ifndef _WIN32
FF_C_SCANF(2, 3)
void ffGetTerminalResponse(const char* request, const char* format, ...);
#endif
// Not thread safe!
bool ffSuppressIO(bool suppress);
static inline void ffUnsuppressIO(bool* suppressed)
{
if (!*suppressed) return;
ffSuppressIO(false);
*suppressed = false;
}
#define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true)
void ffListFilesRecursively(const char* path);
static inline bool wrapClose(FFNativeFD* pfd)
{
assert(pfd);
#ifndef WIN32
if (*pfd < 0)
return false;
close(*pfd);
#else
// https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
if (*pfd == NULL || *pfd == INVALID_HANDLE_VALUE)
return false;
CloseHandle(*pfd);
#endif
return true;
}
#define FF_AUTO_CLOSE_FD __attribute__((__cleanup__(wrapClose)))
#endif // FF_INCLUDED_common_io_io
+226
View File
@@ -0,0 +1,226 @@
#include "io.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <termios.h>
#include <poll.h>
#include <dirent.h>
static void createSubfolders(const char* fileName)
{
FFstrbuf path;
ffStrbufInit(&path);
while(*fileName != '\0')
{
ffStrbufAppendC(&path, *fileName);
if(*fileName == '/')
mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH);
++fileName;
}
ffStrbufDestroy(&path);
}
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC;
int openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
int FF_AUTO_CLOSE_FD fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
{
createSubfolders(fileName);
fd = open(fileName, openFlagsModes, openFlagsRights);
if(fd == -1)
return false;
}
return write(fd, data, dataSize) > 0;
}
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer)
{
ssize_t readed = 0;
struct stat fileInfo;
if(fstat(fd, &fileInfo) != 0)
return false;
ffStrbufEnsureFree(buffer, fileInfo.st_size > 0 ? (uint32_t)fileInfo.st_size : 31);
uint32_t free = ffStrbufGetFree(buffer);
while(
(readed = read(fd, buffer->chars + buffer->length, free)) > 0 &&
(uint32_t) readed == free
) {
buffer->length += (uint32_t) readed;
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
free = ffStrbufGetFree(buffer);
}
// In case of failure, read returns -1. We don't want to substract the length of the buffer.
if(readed > 0)
buffer->length += (uint32_t) readed;
buffer->chars[buffer->length] = '\0';
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
return readed >= 0;
}
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
{
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY);
if(fd == -1)
return -1;
return ffReadFDData(fd, dataSize, data);
}
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
int FF_AUTO_CLOSE_FD fd = open(fileName, O_RDONLY);
if(fd == -1)
return false;
return ffAppendFDBuffer(fd, buffer);
}
bool ffPathExists(const char* path, FFPathType type)
{
struct stat fileStat;
if(stat(path, &fileStat) != 0)
return false;
int mode = fileStat.st_mode & S_IFMT;
if(type & FF_PATHTYPE_REGULAR && mode == S_IFREG)
return true;
if(type & FF_PATHTYPE_DIRECTORY && mode == S_IFDIR)
return true;
if(type & FF_PATHTYPE_LINK && mode == S_IFLNK)
return true;
return false;
}
void ffGetTerminalResponse(const char* request, const char* format, ...)
{
struct termios oldTerm, newTerm;
if(tcgetattr(STDIN_FILENO, &oldTerm) == -1)
return;
newTerm = oldTerm;
newTerm.c_lflag &= (tcflag_t) ~(ICANON | ECHO);
if(tcsetattr(STDIN_FILENO, TCSANOW, &newTerm) == -1)
return;
fputs(request, stdout);
fflush(stdout);
struct pollfd pfd;
pfd.fd = STDIN_FILENO;
pfd.events = POLLIN;
pfd.revents = 0;
//Give the terminal 35ms to respond
if(poll(&pfd, 1, 35) <= 0)
{
tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm);
return;
}
char buffer[512];
ssize_t readed = read(STDIN_FILENO, buffer, sizeof(buffer) - 1);
tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm);
if(readed <= 0)
return;
buffer[readed] = '\0';
va_list args;
va_start(args, format);
vsscanf(buffer, format, args);
va_end(args);
}
bool ffSuppressIO(bool suppress)
{
static bool init = false;
static int origOut = -1;
static int origErr = -1;
static int nullFile = -1;
if(!init)
{
if(!suppress)
return true;
origOut = dup(STDOUT_FILENO);
origErr = dup(STDERR_FILENO);
nullFile = open("/dev/null", O_WRONLY);
init = true;
}
if(nullFile == -1)
return false;
fflush(stdout);
fflush(stderr);
dup2(suppress ? nullFile : origOut, STDOUT_FILENO);
dup2(suppress ? nullFile : origErr, STDERR_FILENO);
return true;
}
void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* folderName)
{
DIR* dir = opendir(folder->chars);
if(dir == NULL)
return;
uint32_t folderLength = folder->length;
if(folderName != NULL)
printf("%s/\n", folderName);
struct dirent* entry;
while((entry = readdir(dir)) != NULL)
{
if(entry->d_type == DT_DIR)
{
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
ffStrbufAppendS(folder, entry->d_name);
ffStrbufAppendC(folder, '/');
listFilesRecursively(folder, (uint8_t) (indentation + 1), entry->d_name);
ffStrbufSubstrBefore(folder, folderLength);
continue;
}
for(uint8_t i = 0; i < indentation; i++)
fputs(" | ", stdout);
puts(entry->d_name);
}
closedir(dir);
}
void ffListFilesRecursively(const char* path)
{
FFstrbuf folder;
ffStrbufInitS(&folder, path);
ffStrbufEnsureEndsWithC(&folder, '/');
listFilesRecursively(&folder, 0, NULL);
ffStrbufDestroy(&folder);
}
+149
View File
@@ -0,0 +1,149 @@
#include "io.h"
static void createSubfolders(const char* fileName)
{
FF_STRBUF_AUTO_DESTROY path;
ffStrbufInit(&path);
while(*fileName != '\0')
{
ffStrbufAppendC(&path, *fileName);
if(*fileName == '/')
CreateDirectoryA(path.chars, NULL);
++fileName;
}
}
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data)
{
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
{
createSubfolders(fileName);
handle = CreateFileA(fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return false;
}
DWORD written;
return !!WriteFile(handle, data, (DWORD)dataSize, &written, NULL);
}
bool ffAppendFDBuffer(HANDLE handle, FFstrbuf* buffer)
{
DWORD readed = 0;
LARGE_INTEGER fileSize;
if(!GetFileSizeEx(handle, &fileSize))
fileSize.QuadPart = 0;
ffStrbufEnsureFree(buffer, fileSize.QuadPart > 0 ? (uint32_t)fileSize.QuadPart : 31);
uint32_t free = ffStrbufGetFree(buffer);
bool success;
while(
(success = !!ReadFile(handle, buffer->chars + buffer->length, free, &readed, NULL)) &&
(uint32_t) readed == free
) {
buffer->length += (uint32_t) readed;
ffStrbufEnsureFree(buffer, buffer->allocated - 1); // Doubles capacity every round. -1 for the null byte.
free = ffStrbufGetFree(buffer);
}
if(readed > 0)
buffer->length += (uint32_t) readed;
buffer->chars[buffer->length] = '\0';
ffStrbufTrimRight(buffer, '\n');
ffStrbufTrimRight(buffer, ' ');
return success;
}
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data)
{
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return -1;
return ffReadFDData(handle, dataSize, data);
}
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer)
{
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileA(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(handle == INVALID_HANDLE_VALUE)
return false;
return ffAppendFDBuffer(handle, buffer);
}
bool ffPathExists(const char* path, FFPathType type)
{
DWORD attr = GetFileAttributesA(path);
if(attr == INVALID_FILE_ATTRIBUTES)
return false;
if(type & FF_PATHTYPE_REGULAR && !(attr & FILE_ATTRIBUTE_DIRECTORY))
return true;
if(type & FF_PATHTYPE_DIRECTORY && (attr & FILE_ATTRIBUTE_DIRECTORY))
return true;
if(type & FF_PATHTYPE_LINK && (attr & FILE_ATTRIBUTE_REPARSE_POINT))
return true;
return false;
}
bool ffSuppressIO(bool suppress)
{
(void) suppress; //Not implemented.
return false;
}
void listFilesRecursively(FFstrbuf* folder, uint8_t indentation, const char* folderName)
{
uint32_t folderLength = folder->length;
if(folderName != NULL)
printf("%s/\n", folderName);
ffStrbufAppendC(folder, '*');
WIN32_FIND_DATAA entry;
HANDLE hFind = FindFirstFileA(folder->chars, &entry);
if(hFind == INVALID_HANDLE_VALUE)
return;
do
{
if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(strcmp(entry.cFileName, ".") == 0 || strcmp(entry.cFileName, "..") == 0)
continue;
ffStrbufSubstrBefore(folder, folderLength);
ffStrbufAppendS(folder, entry.cFileName);
ffStrbufAppendC(folder, '/');
listFilesRecursively(folder, (uint8_t) (indentation + 1), entry.cFileName);
ffStrbufSubstrBefore(folder, folderLength);
continue;
}
for(uint8_t i = 0; i < indentation; i++)
fputs(" | ", stdout);
puts(entry.cFileName);
} while (FindNextFileA(hFind, &entry));
FindClose(hFind);
}
void ffListFilesRecursively(const char* path)
{
FFstrbuf folder;
ffStrbufInitS(&folder, path);
ffStrbufEnsureEndsWithC(&folder, '/');
listFilesRecursively(&folder, 0, NULL);
ffStrbufDestroy(&folder);
}
+63 -6
View File
@@ -1,22 +1,79 @@
#include "fastfetch.h"
#include "common/library.h"
#include <stdarg.h>
//Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer)
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
#define __SANITIZE_ADDRESS__
#endif
#endif
#ifndef FF_DLOPEN_FLAGS
#ifdef __SANITIZE_ADDRESS__
#define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE
#else
#define FF_DLOPEN_FLAGS RTLD_LAZY
#endif
#endif
static void* libraryLoad(const char* path, int maxVersion)
{
void* result = dlopen(path, FF_DLOPEN_FLAGS);
#ifdef _WIN32
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
FF_UNUSED(maxVersion)
#else
if(result != NULL || maxVersion < 0)
return result;
FFstrbuf pathbuf;
ffStrbufInitA(&pathbuf, 64);
ffStrbufAppendS(&pathbuf, path);
ffStrbufAppendC(&pathbuf, '.');
for(int i = maxVersion; i >= 0; --i)
{
uint32_t originalLength = pathbuf.length;
ffStrbufAppendF(&pathbuf, "%i", i);
result = dlopen(pathbuf.chars, FF_DLOPEN_FLAGS);
if(result != NULL)
break;
ffStrbufSubstrBefore(&pathbuf, originalLength);
}
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);
void* result = NULL;
const char* name = va_arg(defaultNames, const char*);
while(result == NULL && name != NULL)
while(result == NULL)
{
result = dlopen(name, RTLD_LAZY);
name = va_arg(defaultNames, const char*);
const char* path = va_arg(defaultNames, const char*);
if(path == NULL)
break;
int maxVersion = va_arg(defaultNames, int);
result = libraryLoad(path, maxVersion);
}
va_end(defaultNames);
+78
View File
@@ -0,0 +1,78 @@
#pragma once
#ifndef FF_INCLUDED_common_library
#define FF_INCLUDED_common_library
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
#if defined(_WIN32)
#include <libloaderapi.h>
#define FF_DLOPEN_FLAGS 0
FF_C_NODISCARD static inline void* dlopen(const char* path, int mode) { FF_UNUSED(mode); return LoadLibraryA(path); }
FF_C_NODISCARD static inline void* dlsym(void* handle, const char* symbol) { return GetProcAddress((HMODULE)handle, symbol); }
static inline int dlclose(void* handle) { return !FreeLibrary((HMODULE)handle); }
#else
#include <dlfcn.h>
#endif
#ifdef _WIN32
#define FF_LIBRARY_EXTENSION ".dll"
#elif defined(__APPLE__)
#define FF_LIBRARY_EXTENSION ".dylib"
#else
#define FF_LIBRARY_EXTENSION ".so"
#endif
static inline void ffLibraryUnload(void** handle)
{
assert(handle);
if (*handle)
dlclose(*handle);
}
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
void* __attribute__((__cleanup__(ffLibraryUnload))) 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) \
return returnValue;
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, symbolMapping, symbolName, alternateName, returnValue) \
symbolMapping = dlsym(library, #symbolName); \
if(symbolMapping == NULL && !(symbolMapping = dlsym(library, #alternateName))) \
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_LAZY(library, symbolName) \
__typeof__(&symbolName) ff ## symbolName = dlsym(library, #symbolName);
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff ## symbolName, symbolName, "dlsym " #symbolName " failed");
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE2(library, symbolName, alternateName) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, ff ## symbolName, symbolName, alternateName, "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_VAR_MESSAGE2(library, varName, symbolName, alternateName) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS2(library, varName.ff ## symbolName, symbolName, alternateName, "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
-1399
View File
File diff suppressed because it is too large Load Diff
-69
View File
@@ -1,69 +0,0 @@
#include "fastfetch.h"
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer)
{
struct addrinfo hints = {0};
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
struct addrinfo* addr;
if(getaddrinfo(host, "80", &hints, &addr) != 0)
return;
int sock = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(sock == -1)
{
freeaddrinfo(addr);
return;
}
if(timeout > 0)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = timeout * 1000; //milliseconds to microseconds
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
}
if(connect(sock, addr->ai_addr, addr->ai_addrlen) == -1)
{
close(sock);
freeaddrinfo(addr);
return;
}
freeaddrinfo(addr);
FFstrbuf command;
ffStrbufInitA(&command, 64);
ffStrbufAppendS(&command, "GET ");
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&command, host);
ffStrbufAppendS(&command, "\r\n\r\n");
if(send(sock, command.chars, command.length, 0) == -1)
{
ffStrbufDestroy(&command);
close(sock);
return;
}
ssize_t received = recv(sock, buffer->chars + buffer->length, ffStrbufGetFree(buffer), 0);
if(received > 0)
{
buffer->length += (uint32_t) received;
buffer->chars[buffer->length] = '\0';
}
ffStrbufDestroy(&command);
close(sock);
}
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#ifndef FF_INCLUDED_common_networking
#define FF_INCLUDED_common_networking
#include "common/thread.h"
#include "util/FFstrbuf.h"
#ifdef _WIN32
#include <minwindef.h>
#endif
typedef struct FFNetworkingState {
#ifdef _WIN32
uintptr_t sockfd;
OVERLAPPED overlapped;
#else
int sockfd;
FFstrbuf host;
FFstrbuf command;
#ifdef FF_HAVE_THREADS
FFThreadType thread;
#endif
#endif
} FFNetworkingState;
bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers);
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout);
static inline bool ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, const char* headers, FFstrbuf* buffer)
{
FFNetworkingState state;
if(ffNetworkingSendHttpRequest(&state, host, path, headers))
return ffNetworkingRecvHttpResponse(&state, buffer, timeout);
return false;
}
#endif
+103
View File
@@ -0,0 +1,103 @@
#include "fastfetch.h"
#include "common/networking.h"
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netdb.h>
static void connectAndSend(FFNetworkingState* state)
{
struct addrinfo hints = {
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo* addr;
if(getaddrinfo(state->host.chars, "80", &hints, &addr) != 0)
goto error;
state->sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(state->sockfd == -1)
{
freeaddrinfo(addr);
goto error;
}
if(connect(state->sockfd, addr->ai_addr, addr->ai_addrlen) == -1)
{
close(state->sockfd);
freeaddrinfo(addr);
goto error;
}
freeaddrinfo(addr);
if(send(state->sockfd, state->command.chars, state->command.length, 0) < 0)
{
close(state->sockfd);
goto error;
}
goto exit;
error:
state->sockfd = -1;
exit:
ffStrbufDestroy(&state->host);
ffStrbufDestroy(&state->command);
}
FF_THREAD_ENTRY_DECL_WRAPPER(connectAndSend, FFNetworkingState*);
bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers)
{
ffStrbufInitS(&state->host, host);
ffStrbufInitA(&state->command, 64);
ffStrbufAppendS(&state->command, "GET ");
ffStrbufAppendS(&state->command, path);
ffStrbufAppendS(&state->command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&state->command, host);
ffStrbufAppendS(&state->command, "\r\n");
ffStrbufAppendS(&state->command, headers);
ffStrbufAppendS(&state->command, "\r\n");
#ifdef FF_HAVE_THREADS
state->thread = ffThreadCreate(connectAndSendThreadMain, state);
return !!state->thread;
#else
connectAndSend(state);
return state->sockfd != -1;
#endif
}
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout)
{
#ifdef FF_HAVE_THREADS
ffThreadJoin(state->thread);
#endif
if(state->sockfd == -1)
return false;
if(timeout > 0)
{
struct timeval timev;
timev.tv_sec = 0;
timev.tv_usec = (__typeof__(timev.tv_usec)) (timeout * 1000); //milliseconds to microseconds
setsockopt(state->sockfd, SOL_SOCKET, SO_RCVTIMEO, &timev, sizeof(timev));
}
ssize_t received = recv(state->sockfd, buffer->chars + buffer->length, ffStrbufGetFree(buffer), 0);
if(received > 0)
{
buffer->length += (uint32_t) received;
buffer->chars[buffer->length] = '\0';
}
close(state->sockfd);
return ffStrbufStartsWithS(buffer, "HTTP/1.1 200 OK\r\n");
}
+125
View File
@@ -0,0 +1,125 @@
#include <mswsock.h>
#include <ws2tcpip.h>
//Must be included after <mswsock.h>
#include "fastfetch.h"
#include "common/networking.h"
static LPFN_CONNECTEX ConnectEx;
static BOOL WINAPI initWsaData(PINIT_ONCE once, PVOID param, PVOID* context)
{
(void)once;
(void)param;
static WSADATA wsaData;
*context = &wsaData;
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
return FALSE;
if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
return FALSE;
//Dummy socket needed for WSAIoctl
SOCKET sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd == INVALID_SOCKET)
return FALSE;
DWORD dwBytes;
GUID guid = WSAID_CONNECTEX;
if(WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER,
&guid, sizeof(guid),
&ConnectEx, sizeof(ConnectEx),
&dwBytes, NULL, NULL) != 0)
return FALSE;
return closesocket(sockfd) == 0;
}
bool ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
WSADATA* pData;
if(!InitOnceExecuteOnce(&once, initWsaData, NULL, (LPVOID*) &pData))
return false;
memset(state, 0, sizeof(*state));
struct addrinfo hints = {
.ai_family = AF_INET,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo* addr;
if(getaddrinfo(host, "80", &hints, &addr) != 0)
return false;
state->sockfd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
if(state->sockfd == INVALID_SOCKET)
{
freeaddrinfo(addr);
return false;
}
{
//ConnectEx requires the socket to be initially bound
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_addr.s_addr = INADDR_ANY,
.sin_port = 0,
};
if(bind(state->sockfd, (SOCKADDR *)&addr, sizeof(addr)) != 0)
{
printf("bind %d\n", WSAGetLastError());
return false;
}
}
FF_STRBUF_AUTO_DESTROY command;
ffStrbufInitA(&command, 64);
ffStrbufAppendS(&command, "GET ");
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, " HTTP/1.1\nHost: ");
ffStrbufAppendS(&command, host);
ffStrbufAppendS(&command, "\r\n");
ffStrbufAppendS(&command, headers);
ffStrbufAppendS(&command, "\r\n");
BOOL result = ConnectEx(state->sockfd, addr->ai_addr, (int)addr->ai_addrlen, command.chars, command.length, NULL, &state->overlapped);
freeaddrinfo(addr);
if(!result && WSAGetLastError() != WSA_IO_PENDING)
{
closesocket(state->sockfd);
return false;
}
return true;
}
bool ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer, uint32_t timeout)
{
DWORD transfer, flags;
if (!WSAGetOverlappedResult(state->sockfd, &state->overlapped, &transfer, TRUE, &flags))
{
closesocket(state->sockfd);
return false;
}
if(timeout > 0)
{
//https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt
setsockopt(state->sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof(timeout));
}
ssize_t received = recv(state->sockfd, buffer->chars + buffer->length, (int)ffStrbufGetFree(buffer), 0);
if(received > 0)
{
buffer->length += (uint32_t) received;
buffer->chars[buffer->length] = '\0';
}
closesocket(state->sockfd);
return ffStrbufStartsWithS(buffer, "HTTP/1.1 200 OK\r\n");
}
+94 -327
View File
@@ -1,8 +1,97 @@
#include "fastfetch.h"
#include "common/parsing.h"
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
void ffGetGtkPretty(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4)
#ifdef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#endif
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch)
{
if(major->length > 0)
ffStrbufAppend(buffer, major);
else if(minor->length > 0 || patch->length > 0)
ffStrbufAppendC(buffer, '1');
if(minor->length == 0 && patch->length == 0)
return;
ffStrbufAppendC(buffer, '.');
if(minor->length > 0)
ffStrbufAppend(buffer, minor);
else if(patch->length > 0)
ffStrbufAppendC(buffer, '0');
if(patch->length == 0)
return;
ffStrbufAppendC(buffer, '.');
ffStrbufAppend(buffer, patch);
}
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2)
{
if(version1->major != version2->major)
return version1->major > version2->major ? 1 : -1;
if(version1->minor != version2->minor)
return version1->minor > version2->minor ? 1 : -1;
if(version1->patch != version2->patch)
return version1->patch > version2->patch ? 1 : -1;
return 0;
}
void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty)
{
if(version->major > 0 || version->minor > 0 || version->patch > 0)
ffStrbufAppendF(pretty, "%u", version->major);
if(version->minor > 0 || version->patch > 0)
ffStrbufAppendF(pretty, ".%u", version->minor);
if(version->patch > 0)
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)
{
@@ -82,328 +171,6 @@ void ffGetGtkPretty(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3
}
}
static void fontInit(FFfont* font)
{
ffStrbufInit(&font->pretty);
ffStrbufInit(&font->name);
ffStrbufInitA(&font->size, 4);
ffListInitA(&font->styles, sizeof(FFstrbuf), 4);
}
static void fontInitPretty(FFfont* font)
{
ffStrbufAppend(&font->pretty, &font->name);
if(font->size.length == 0 && font->styles.length == 0)
return;
else if(font->pretty.length == 0)
ffStrbufAppendS(&font->pretty, "default");
ffStrbufAppendS(&font->pretty, " (");
if(font->size.length > 0)
{
ffStrbufAppend(&font->pretty, &font->size);
ffStrbufAppendS(&font->pretty, "pt");
if(font->styles.length > 0)
ffStrbufAppendS(&font->pretty, ", ");
}
for(uint32_t i = 0; i < font->styles.length; i++)
{
ffStrbufAppend(&font->pretty, ffListGet(&font->styles, i));
if(i < font->styles.length - 1)
ffStrbufAppendS(&font->pretty, ", ");
}
ffStrbufAppendC(&font->pretty, ')');
}
void ffFontInitQt(FFfont* font, const char* data)
{
fontInit(font);
//See https://doc.qt.io/qt-5/qfont.html#toString
//Family
while(*data != ',' && *data != '\0')
{
ffStrbufAppendC(&font->name, *data);
++data;
}
if(*data != '\0')
++data;
ffStrbufTrim(&font->name, ' ');
//Size
while(*data != ',' && *data != '\0')
{
ffStrbufAppendC(&font->size, *data);
++data;
}
if(*data != '\0')
++data;
ffStrbufTrim(&font->size, ' ');
#define FF_FONT_QT_SKIP_VALUE \
while(*data != ',' && *data != '\0') \
++data; \
if(*data != '\0') \
++data;
FF_FONT_QT_SKIP_VALUE //Pixel size
FF_FONT_QT_SKIP_VALUE //Style hint
FF_FONT_QT_SKIP_VALUE //Font weight
FF_FONT_QT_SKIP_VALUE //Font style
FF_FONT_QT_SKIP_VALUE //Underline
FF_FONT_QT_SKIP_VALUE //Strike out
FF_FONT_QT_SKIP_VALUE //Fixed pitch
FF_FONT_QT_SKIP_VALUE //Always 0
#undef FF_FONT_QT_SKIP_VALUE
while(*data != '\0')
{
while(*data == ' ')
++data;
if(*data == '\0')
break;
FFstrbuf* style = ffListAdd(&font->styles);
ffStrbufInit(style);
while(*data != ' ' && *data != '\0')
{
ffStrbufAppendC(style, *data);
++data;
}
}
fontInitPretty(font);
}
static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* alternativeBuffer)
{
while(**data == ' ' || **data == '\t' || **data == ',')
++(*data);
const char* wordStart = *data;
while(**data != ' ' && **data != '\t' && **data != ',' && **data != '\0' && **data != '`' && **data != '\\')
++(*data);
uint32_t wordLength = (uint32_t) (*data - wordStart);
if(wordLength == 0)
return;
if(**data == '\0' || **data == '`' || **data == '\\')
{
ffStrbufAppendNS(&font->size, wordLength, wordStart);
if(ffStrbufEndsWithS(&font->size, "px"))
ffStrbufSubstrBefore(&font->size, font->size.length - 2);
double dummy;
if(sscanf(font->size.chars, "%lf", &dummy) == 1)
return;
ffStrbufClear(&font->size);
}
if(
strncasecmp(wordStart, "Ultra", 5) == 0 ||
strncasecmp(wordStart, "Extra", 5) == 0 ||
strncasecmp(wordStart, "Semi", 4) == 0 ||
strncasecmp(wordStart, "Demi", 4) == 0 ||
strncasecmp(wordStart, "Normal", wordLength) == 0 ||
strncasecmp(wordStart, "Roman", wordLength) == 0 ||
strncasecmp(wordStart, "Oblique", wordLength) == 0 ||
strncasecmp(wordStart, "Italic", wordLength) == 0 ||
strncasecmp(wordStart, "Thin", wordLength) == 0 ||
strncasecmp(wordStart, "Light", wordLength) == 0 ||
strncasecmp(wordStart, "Bold", wordLength) == 0 ||
strncasecmp(wordStart, "Black", wordLength) == 0 ||
strncasecmp(wordStart, "Condensed", wordLength) == 0 ||
strncasecmp(wordStart, "Expanded", wordLength) == 0
) {
if(alternativeBuffer == NULL)
{
alternativeBuffer = ffListAdd(&font->styles);
ffStrbufInit(alternativeBuffer);
}
ffStrbufAppendNSExludingC(alternativeBuffer, wordLength, wordStart, '-');
if(
strncasecmp(wordStart, "Ultra ", 6) == 0 ||
strncasecmp(wordStart, "Extra ", 6) == 0 ||
strncasecmp(wordStart, "Semi ", 5) == 0 ||
strncasecmp(wordStart, "Demi ", 5) == 0
) {
fontPangoParseWord(data, font, alternativeBuffer);
}
return;
}
if(alternativeBuffer != NULL)
{
ffStrbufAppendNSExludingC(alternativeBuffer, wordLength, wordStart, '-');
return;
}
if(font->name.length > 0)
ffStrbufAppendC(&font->name, ' ');
ffStrbufAppendNS(&font->name, wordLength, wordStart);
}
void ffFontInitPango(FFfont* font, const char* data)
{
fontInit(font);
while(*data != '\0' && *data != '`' && *data != '\\')
fontPangoParseWord(&data, font, NULL);
fontInitPretty(font);
}
void ffFontInitCopy(FFfont* font, const char* name)
{
fontInit(font);
ffStrbufAppendS(&font->name, name);
fontInitPretty(font);
}
void ffFontDestroy(FFfont* font)
{
ffStrbufDestroy(&font->pretty);
ffStrbufDestroy(&font->name);
ffStrbufDestroy(&font->size);
for(uint32_t i = 0; i < font->styles.length; i++)
ffStrbufDestroy(ffListGet(&font->styles, i));
ffListDestroy(&font->styles);
}
static bool getPropValueLine(const char** line, const char* start, FFstrbuf* buffer)
{
if(**line == '\0')
return false;
//Skip any amount of whitespace at the begin of line
while(**line == ' ' || **line == '\t')
++(*line);
while(*start != '\0')
{
// Any amount of whitespace in the format string matches any amount of whitespace in the line, even none
if(*start == ' ' || *start == '\t')
{
while(*start == ' ' || *start == '\t')
++start;
while(**line == ' ' || **line == '\t')
++(*line);
continue;
}
//Line doesn't match start, skip it
if(**line != *start || **line == '\0')
return false;
//Line and start match, continue testing
++(*line);
++start;
}
char valueEnd = '\n';
//Allow faster parsing of XML
if(*(*line - 1) == '>')
valueEnd = '<';
//Skip any amount of whitespace at the begin of the value
while(**line == ' ' || **line == '\t')
++(*line);
//Allow faster parsing of quotet values
if(**line == '"' || **line == '\'')
{
valueEnd = **line;
++(*line);
}
//Copy the value to the buffer
while(**line != valueEnd && **line != '\n' && **line != '\0')
{
ffStrbufAppendC(buffer, **line);
++(*line);
}
ffStrbufTrimRight(buffer, ' ');
return true;
}
bool ffGetPropValue(const char* line, const char* start, FFstrbuf* buffer)
{
return getPropValueLine(&line, start, buffer);
}
bool ffGetPropValueFromLines(const char* lines, const char* start, FFstrbuf* buffer)
{
while(!getPropValueLine(&lines, start, buffer))
{
while(*lines != '\0' && *lines != '\n')
++lines;
if(*lines == '\0')
return false;
//Skip '\n'
++lines;
}
return true;
}
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch)
{
if(major->length > 0)
ffStrbufAppend(buffer, major);
else if(minor->length > 0 || patch->length > 0)
ffStrbufAppendC(buffer, '1');
if(minor->length == 0 && patch->length == 0)
return;
ffStrbufAppendC(buffer, '.');
if(minor->length > 0)
ffStrbufAppend(buffer, minor);
else if(patch->length > 0)
ffStrbufAppendC(buffer, '0');
if(patch->length == 0)
return;
ffStrbufAppendC(buffer, '.');
ffStrbufAppend(buffer, patch);
}
bool ffStrSet(const char* str)
{
if(str == NULL)
return false;
while(*str != '\0')
{
if(*str != ' ' && *str != '\t' && *str != '\n' && *str != '\r')
return true;
}
return false;
}
#ifdef _WIN32
#pragma GCC diagnostic pop
#endif
+25
View File
@@ -0,0 +1,25 @@
#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})
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
+174
View File
@@ -0,0 +1,174 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "util/textModifier.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.colorKeys);
}
//NULL check is required for modules with custom keys, e.g. disk with the folder path
if(customKeyFormat == NULL || customKeyFormat->length == 0)
{
fputs(moduleName, stdout);
if(moduleIndex > 0)
printf(" %hhu", moduleIndex);
}
else
{
FFstrbuf key;
ffStrbufInit(&key);
ffParseFormatString(&key, customKeyFormat, 1, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT8, &moduleIndex}
});
ffPrintUserString(key.chars);
ffStrbufDestroy(&key);
}
if(!instance->config.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
ffStrbufWriteTo(&instance->config.separator, stdout);
if(!instance->config.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
}
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments)
{
FFstrbuf buffer;
ffStrbufInitA(&buffer, 256);
ffParseFormatString(&buffer, format, numArgs, arguments);
if(buffer.length > 0)
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
ffPrintUserString(buffer.chars);
putchar('\n');
}
ffStrbufDestroy(&buffer);
}
void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments)
{
ffPrintFormatString(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->outputFormat, numArgs, arguments);
}
static void printError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, va_list arguments)
{
bool hasCustomErrorFormat = customErrorFormat != NULL && customErrorFormat->length > 0;
if(!hasCustomErrorFormat && !instance->config.showErrors)
return;
if(hasCustomErrorFormat)
{
FFstrbuf error;
ffStrbufInit(&error);
ffStrbufAppendVF(&error, message, arguments);
ffPrintFormatString(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, 1, (FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &error}
});
ffStrbufDestroy(&error);
}
else
{
ffPrintLogoAndKey(instance, moduleName, moduleIndex, customKeyFormat);
if(!instance->config.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_ERROR, stdout);
vprintf(message, arguments);
if(!instance->config.pipe)
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
putchar('\n');
}
}
void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...)
{
va_list arguments;
va_start(arguments, message);
printError(instance, moduleName, moduleIndex, customKeyFormat, customErrorFormat, message, arguments);
va_end(arguments);
}
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...)
{
va_list arguments;
va_start(arguments, message);
printError(instance, moduleName, moduleIndex, &moduleArgs->key, &moduleArgs->errorFormat, message, arguments);
va_end(arguments);
}
void ffPrintColor(const FFstrbuf* colorValue)
{
//If the color is not set, this would reset in \033[m, which resets everything.
//So we only print it, if the main color is at least one char.
if(colorValue->length == 0)
return;
fputs("\033[", stdout);
ffStrbufWriteTo(colorValue, stdout);
fputc('m', stdout);
}
void ffPrintCharTimes(char c, uint32_t times)
{
if(times == 0)
return;
char str[32];
memset(str, c, sizeof(str)); //2 instructions when compiling with AVX2 enabled
for(uint32_t i = sizeof(str); i <= times; i += (uint32_t)sizeof(str))
fwrite(str, 1, sizeof(str), stdout);
uint32_t remaining = times % sizeof(str);
if(remaining > 0)
fwrite(str, 1, remaining, stdout);
}
void ffPrintUserString(const char* value)
{
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
-34
View File
@@ -1,34 +0,0 @@
#include "fastfetch.h"
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
{
int pipes[2];
if(pipe(pipes) == -1)
return;
pid_t childPid = fork();
if(childPid == -1)
return;
//Child
if(childPid == 0)
{
dup2(pipes[1], STDOUT_FILENO);
close(pipes[0]);
close(pipes[1]);
close(STDERR_FILENO);
execvp(argv[0], argv);
exit(901);
}
//Parent
close(pipes[1]);
waitpid(childPid, NULL, 0);
ffAppendFDContent(pipes[0], buffer);
close(pipes[0]);
}
+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
+49
View File
@@ -0,0 +1,49 @@
#include "fastfetch.h"
#include "common/processing.h"
#include "common/io/io.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
{
int pipes[2];
if(pipe(pipes) == -1)
return "pipe() failed";
pid_t childPid = fork();
if(childPid == -1)
return "fork() failed";
//Child
if(childPid == 0)
{
dup2(pipes[1], STDOUT_FILENO);
close(pipes[0]);
close(pipes[1]);
close(STDERR_FILENO);
execvp(argv[0], argv);
exit(901);
}
//Parent
close(pipes[1]);
int FF_AUTO_CLOSE_FD childPipeFd = pipes[0];
int status = -1;
if(waitpid(childPid, &status, 0) < 0)
return "waitpid(childPid, &status, 0) failed";
if (!WIFEXITED(status))
return "WIFEXITED(status) == false";
if(WEXITSTATUS(status) == 901)
return "WEXITSTATUS(status) == 901 ( execvp failed )";
if(!ffAppendFDBuffer(childPipeFd, buffer))
return "ffAppendFDBuffer(childPipeFd, buffer) failed";
return NULL;
}
+68
View File
@@ -0,0 +1,68 @@
#include "fastfetch.h"
#include "common/processing.h"
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
const char* ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[])
{
SECURITY_ATTRIBUTES saAttr = {
.nLength = sizeof(SECURITY_ATTRIBUTES),
.lpSecurityDescriptor = NULL,
.bInheritHandle = TRUE,
};
HANDLE hChildStdoutRead, hChildStdoutWrite;
if (!CreatePipe(&hChildStdoutRead, &hChildStdoutWrite, &saAttr, 0))
return "CreatePipe() failed";
if (!SetHandleInformation(hChildStdoutRead, HANDLE_FLAG_INHERIT, 0))
return "SetHandleInformation(hChildStdoutRead) failed";
PROCESS_INFORMATION piProcInfo = {0};
STARTUPINFOA siStartInfo = {
.cb = sizeof(siStartInfo),
.dwFlags = STARTF_USESTDHANDLES,
.hStdOutput = hChildStdoutWrite,
};
BOOL success;
{
FF_STRBUF_AUTO_DESTROY cmdline;
ffStrbufInitF(&cmdline, "\"%s\"", argv[0]);
for(char* const* parg = &argv[1]; *parg; ++parg)
{
ffStrbufAppendC(&cmdline, ' ');
ffStrbufAppendS(&cmdline, *parg);
}
success = CreateProcessA(
NULL, // application name
cmdline.chars, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo // receives PROCESS_INFORMATION
);
}
CloseHandle(hChildStdoutWrite);
if(!success)
{
CloseHandle(hChildStdoutRead);
return "CreateProcessA() failed";
}
char str[1024];
DWORD nRead;
while(ReadFile(hChildStdoutRead, str, sizeof(str), &nRead, NULL) && nRead > 0)
ffStrbufAppendNS(buffer, nRead, str);
CloseHandle(hChildStdoutRead);
return NULL;
}
+195
View File
@@ -0,0 +1,195 @@
#include "fastfetch.h"
#include "common/properties.h"
#include <stdlib.h>
#ifdef _WIN32
#include "util/windows/getline.h"
#endif
static bool parsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer)
{
if(**line == '\0')
return false;
//Skip any amount of whitespace at the begin of line
while(**line == ' ' || **line == '\t')
++(*line);
while(*start != '\0')
{
// Any amount of whitespace in the format string matches any amount of whitespace in the line, even none
if(*start == ' ' || *start == '\t')
{
while(*start == ' ' || *start == '\t')
++start;
while(**line == ' ' || **line == '\t')
++(*line);
continue;
}
//Line doesn't match start, skip it
if(**line != *start || **line == '\0')
return false;
//Line and start match, continue testing
++(*line);
++start;
}
char valueEnd = '\n';
//Allow faster parsing of XML
if(*(*line - 1) == '>')
valueEnd = '<';
//Skip any amount of whitespace at the begin of the value
while(**line == ' ' || **line == '\t')
++(*line);
//Allow faster parsing of quotet values
if(**line == '"' || **line == '\'')
{
valueEnd = **line;
++(*line);
}
//Copy the value to the buffer
while(**line != valueEnd && **line != '\n' && **line != '\0')
{
ffStrbufAppendC(buffer, **line);
++(*line);
}
ffStrbufTrimRight(buffer, ' ');
return true;
}
bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer)
{
return parsePropLinePointer(&line, start, buffer);
}
bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer)
{
while(!parsePropLinePointer(&lines, start, buffer))
{
while(*lines != '\0' && *lines != '\n')
++lines;
if(*lines == '\0')
return false;
//Skip '\n'
++lines;
}
return true;
}
// 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
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;
if(numQueries > sizeof(valueStorage) / sizeof(valueStorage[0]))
unsetValues = malloc(sizeof(bool) * numQueries);
else
unsetValues = valueStorage;
bool allSet = true;
for(uint32_t i = 0; i < numQueries; i++)
{
if((unsetValues[i] = queries[i].buffer->length == 0))
allSet = false;
}
if(allSet)
goto done;
char* line = NULL;
size_t len = 0;
while (getline(&line, &len, file) != -1)
{
for(uint32_t i = 0; i < numQueries; i++)
{
if(!unsetValues[i])
continue;
uint32_t currentLength = queries[i].buffer->length;
queries[i].buffer->length = 0;
if(!ffParsePropLine(line, queries[i].start, queries[i].buffer))
queries[i].buffer->length = currentLength;
}
}
if(line != NULL)
free(line);
done:
fclose(file);
if(unsetValues != valueStorage)
free(unsetValues);
return true;
}
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries)
{
FFstrbuf absolutePath;
ffStrbufInitA(&absolutePath, 64);
ffStrbufAppend(&absolutePath, &instance->state.platform.homeDir);
ffStrbufAppendC(&absolutePath, '/');
ffStrbufAppendS(&absolutePath, relativeFile);
bool result = ffParsePropFileValues(absolutePath.chars, numQueries, queries);
ffStrbufDestroy(&absolutePath);
return result;
}
bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uint32_t numQueries, FFpropquery* queries)
{
bool foundAFile = false;
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
for(uint32_t i = 0; i < list->length; i++)
{
//We need to copy the dir each time, because it used by multiple threads, so we can't directly write to it.
ffStrbufSet(&baseDir, ffListGet(list, i));
ffStrbufAppendS(&baseDir, relativeFile);
if(ffParsePropFileValues(baseDir.chars, numQueries, queries))
foundAFile = true;
bool allSet = true;
for(uint32_t k = 0; k < numQueries; k++)
{
if(queries[k].buffer->length == 0)
{
allSet = false;
break;
}
}
if(allSet)
break;
}
ffStrbufDestroy(&baseDir);
return foundAFile;
}
+55
View File
@@ -0,0 +1,55 @@
#pragma once
#ifndef FF_INCLUDED_common_properties
#define FF_INCLUDED_common_properties
#include "fastfetch.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 ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileListValues(const FFlist* list, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
static inline bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileValues(filename, 1, (FFpropquery[]){{start, buffer}});
}
static inline bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileHomeValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
static inline bool ffParsePropFileList(const FFlist* list, const char* relativeFile, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileListValues(list, relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
static inline bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries)
{
return ffParsePropFileListValues(&instance->state.platform.configDirs, relativeFile, numQueries, queries);
}
static inline bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileConfigValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
static inline bool ffParsePropFileDataValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries)
{
return ffParsePropFileListValues(&instance->state.platform.dataDirs, relativeFile, numQueries, queries);
}
static inline bool ffParsePropFileData(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer)
{
return ffParsePropFileDataValues(instance, relativeFile, 1, (FFpropquery[]){{start, buffer}});
}
#endif
+106 -25
View File
@@ -1,21 +1,32 @@
#include "fastfetch.h"
#include "common/settings.h"
#include "common/library.h"
#include "common/thread.h"
#include "common/io/io.h"
#include <pthread.h>
#include <string.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; \
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; \
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; \
static FFInitState initState = FF_INITSTATE_UNINITIALIZED; \
pthread_mutex_lock(&mutex); \
ffThreadMutexLock(&mutex); \
if(initState != FF_INITSTATE_UNINITIALIZED) {\
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return initState == FF_INITSTATE_SUCCESSFUL ? &data : NULL; \
} \
initState = FF_INITSTATE_SUCCESSFUL; \
void* libraryHandle = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL); \
if(libraryHandle == NULL) { \
initState = FF_INITSTATE_FAILED; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return NULL; \
} \
@@ -24,20 +35,20 @@
if(data.ff ## symbolName == NULL) { \
dlclose(libraryHandle); \
initState = FF_INITSTATE_FAILED; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return NULL; \
}
#define FF_LIBRARY_DATA_LOAD_RETURN \
initState = FF_INITSTATE_SUCCESSFUL; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return &data;
#define FF_LIBRARY_DATA_LOAD_ERROR \
{ \
dlclose(libraryHandle); \
initState = FF_INITSTATE_FAILED; \
pthread_mutex_unlock(&mutex); \
ffThreadMutexUnlock(&mutex); \
return NULL; \
}
@@ -78,9 +89,9 @@ typedef struct GSettingsData
GVariantGetters variantGetters;
} GSettingsData;
static const GSettingsData* getGSettingsData(FFinstance* instance)
static const GSettingsData* getGSettingsData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance->config.libGIO, "libgio-2.0.so", "libgio-2.0.so.0");
FF_LIBRARY_DATA_LOAD_INIT(GSettingsData, instance->config.libGIO, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_source_lookup)
FF_LIBRARY_DATA_LOAD_SYMBOL(g_settings_schema_has_key)
@@ -103,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)
@@ -132,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;
@@ -150,9 +161,9 @@ typedef struct DConfData
DConfClient* client;
} DConfData;
static const DConfData* getDConfData(FFinstance* instance)
static const DConfData* getDConfData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance->config.libDConf, "libdconf.so", "libdconf.so.1");
FF_LIBRARY_DATA_LOAD_INIT(DConfData, instance->config.libDConf, "libdconf" FF_LIBRARY_EXTENSION, 2);
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_read_full)
FF_LIBRARY_DATA_LOAD_SYMBOL(dconf_client_new)
@@ -170,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)
@@ -188,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);
@@ -220,9 +231,9 @@ typedef struct XFConfData
FF_LIBRARY_SYMBOL(xfconf_init)
} XFConfData;
static const XFConfData* getXFConfData(FFinstance* instance)
static const XFConfData* getXFConfData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance->config.libXFConf, "libxfconf-0.so", "libxfconf-0.so.3");
FF_LIBRARY_DATA_LOAD_INIT(XFConfData, instance->config.libXFConf, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_get)
FF_LIBRARY_DATA_LOAD_SYMBOL(xfconf_channel_has_property)
@@ -237,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)
@@ -260,19 +271,89 @@ 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;
}
#endif //FF_HAVE_XFCONF
#ifdef FF_HAVE_SQLITE3
#include <sqlite3.h>
typedef struct SQLiteData
{
FF_LIBRARY_SYMBOL(sqlite3_open_v2)
FF_LIBRARY_SYMBOL(sqlite3_prepare_v2)
FF_LIBRARY_SYMBOL(sqlite3_step)
FF_LIBRARY_SYMBOL(sqlite3_data_count)
FF_LIBRARY_SYMBOL(sqlite3_column_int)
FF_LIBRARY_SYMBOL(sqlite3_finalize)
FF_LIBRARY_SYMBOL(sqlite3_close)
} SQLiteData;
static const SQLiteData* getSQLiteData(const FFinstance* instance)
{
FF_LIBRARY_DATA_LOAD_INIT(SQLiteData, instance->config.libSQLite3, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_open_v2)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_prepare_v2)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_step)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_data_count)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_column_int)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_finalize)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_close)
FF_LIBRARY_DATA_LOAD_RETURN
}
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query)
{
if(!ffPathExists(dbPath, FF_PATHTYPE_FILE))
return 0;
const SQLiteData* data = getSQLiteData(instance);
if(data == NULL)
return 0;
sqlite3* db;
if(data->ffsqlite3_open_v2(dbPath, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK)
return 0;
sqlite3_stmt* stmt;
if(data->ffsqlite3_prepare_v2(db, query, (int) strlen(query), &stmt, NULL) != SQLITE_OK)
{
data->ffsqlite3_close(db);
return 0;
}
if(data->ffsqlite3_step(stmt) != SQLITE_ROW || data->ffsqlite3_data_count(stmt) < 1)
{
data->ffsqlite3_finalize(stmt);
data->ffsqlite3_close(db);
return 0;
}
int result = data->ffsqlite3_column_int(stmt, 0);
data->ffsqlite3_finalize(stmt);
data->ffsqlite3_close(db);
return result;
}
#else //FF_HAVE_SQLITE3
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query)
{
FF_UNUSED(instance, dbPath, query)
return 0;
}
#endif //FF_HAVE_SQLITE3
#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
+55
View File
@@ -0,0 +1,55 @@
#include "sysctl.h"
#include <stdlib.h>
const char* ffSysctlGetString(const char* propName, FFstrbuf* result)
{
size_t neededLength;
if(sysctlbyname(propName, NULL, &neededLength, NULL, 0) != 0 || neededLength == 1) //neededLength is 1 for empty strings, because of the null terminator
return "sysctlbyname() failed";
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
if(sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) == 0)
result->length += (uint32_t) neededLength - 1;
result->chars[result->length] = '\0';
return NULL;
}
int ffSysctlGetInt(const char* propName, int defaultValue)
{
int result;
size_t neededLength = sizeof(result);
if(sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue)
{
int64_t result;
size_t neededLength = sizeof(result);
if(sysctlbyname(propName, &result, &neededLength, NULL, 0) != 0)
return defaultValue;
return result;
}
void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength)
{
if(sysctl(request, requestLength, NULL, resultLength, NULL, 0) != 0)
return NULL;
void* data = malloc(*resultLength);
if(data == NULL)
return NULL;
if(sysctl(request, requestLength, data, resultLength, NULL, 0) != 0)
{
free(data);
return NULL;
}
return data;
}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#ifndef FF_INCLUDED_common_sysctl
#define FF_INCLUDED_common_sysctl
#include "fastfetch.h"
#include "util/FFcheckmacros.h"
#include <sys/types.h>
#include <sys/sysctl.h>
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
#endif
+48
View File
@@ -0,0 +1,48 @@
#pragma once
#ifndef FF_INCLUDED_common_thread
#define FF_INCLUDED_common_thread
#include "fastfetch.h"
#ifdef FF_HAVE_THREADS
#if defined(_WIN32)
#include <handleapi.h>
#include <synchapi.h>
#include <process.h>
#define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT
typedef SRWLOCK FFThreadMutex;
typedef HANDLE FFThreadType;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) { AcquireSRWLockExclusive(mutex); }
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { ReleaseSRWLockExclusive(mutex); }
static inline FFThreadType ffThreadCreate(unsigned (__stdcall* func)(void*), void* data) {
return (FFThreadType)_beginthreadex(NULL, 0, func, data, 0, NULL);
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; }
static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); }
static inline void ffThreadJoin(FFThreadType thread) { WaitForSingleObject(thread, INFINITE); }
#else
#include <pthread.h>
#define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
typedef pthread_mutex_t FFThreadMutex;
typedef pthread_t FFThreadType;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) { pthread_mutex_lock(mutex); }
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { pthread_mutex_unlock(mutex); }
static inline FFThreadType ffThreadCreate(void* (* func)(void*), void* data) {
FFThreadType newThread = 0;
pthread_create(&newThread, NULL, func, data);
return newThread;
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static void* fn ## ThreadMain (void* data) { fn((paramType)data); return NULL; }
static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); }
static inline void ffThreadJoin(FFThreadType thread) { pthread_join(thread, NULL); }
#endif
#else //FF_HAVE_THREADS
#define FF_THREAD_MUTEX_INITIALIZER 0
typedef char FFThreadMutex;
static inline void ffThreadMutexLock(FFThreadMutex* mutex) { FF_UNUSED(mutex) }
static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { FF_UNUSED(mutex) }
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
#endif //FF_HAVE_THREADS
#endif
-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);
}
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#ifndef FF_INCLUDED_common_time
#define FF_INCLUDED_common_time
#include <stdint.h>
#ifdef _WIN32
#include <synchapi.h>
#include <profileapi.h>
#else
#include <time.h>
#endif
static inline uint64_t ffTimeGetTick() //In msec
{
#ifdef _WIN32
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER start;
QueryPerformanceCounter(&start);
return (uint64_t)(start.QuadPart * 1000 / frequency.QuadPart);
#else
struct timespec timeNow;
clock_gettime(CLOCK_MONOTONIC, &timeNow);
return (uint64_t)((timeNow.tv_sec * 1000) + (timeNow.tv_nsec / 1000000));
#endif
}
static inline void ffTimeSleep(uint32_t msec)
{
#ifdef _WIN32
SleepEx(msec, TRUE);
#else
nanosleep(&(struct timespec){ msec / 1000, (msec % 1000) * 1000000 }, NULL);
#endif
}
#endif
-224
View File
@@ -1,224 +0,0 @@
# Fastfetch configuration
# Write every argument in different lines.
# Direct arguments will overwrite the corresponding ones in this file.
# Argument keys are not case sensitive.
# Whitespaces are trimmed at the beginning and the end.
# Empty lines or lines starting with # are ignored.
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
# Use fastfetch --print-config > ~/.config/fastfetch/config.conf to overwrite this with the current defaults
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
# Of course all of them can be made persistent here too.
# Config option:
# Load additional config files.
# Some are shipped with fastfetch, list them with "fastfetch --list-presets".
# Must be a path to a config file or the name of a shipped preset.
# The config file is completly loaded before continuing in the current file, so the placement of this option matters, as later options overwrite already set ones.
# Can be used multiple times to load multiple config files / presets.
#--load-config /path/to/config.txt
# Structure option:
# Sets the modules to use and their order.
# Must be a list of module names, separated by colons.
# List available modules with "fastfetch --list-modules".
# Get the default structure with "fastfetch --print-structure".
#--structure $"FASTFETCH_DATATEXT_STRUCTURE$"
# Logo option:
# Sets the logo to use.
# List available logos with "fastfetch --list-logos".
# Print available logos with "fastfetch --print-logos".
# Must be the name of an available logo or a path to a text file containing a custom logo.
# Default is the current distribution.
#--logo arch
# Color 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.
# Use "fastfetch --help color" to learn more and see examples.
#--color magenta
# Spacing option:
# Sets the amount of whitespace between the logo and keys.
# Must be an positive integer.
# Default is 4.
#--spacing 4
# Separator option:
# Sets the string placed between a key and its value.
# Can be any string.
# Default is ": ".
#--separator ": "
# Offset option:
# Sets the amount of whitespace before the logo. Can be negative to cut the logo.
# Must be an integer.
# Default is 0.
#--offsetx 0
# Linewrap option:
# Sets if fastfetch should disable linewrap during the run.
# Must be true or false.
# Default is true.
#--disable-linewrap true
# Cursor option:
# Sets if fastfetch should hide the console cursor during the run.
# Must be true or false.
# Default is true.
#--hide-cursor true
# Remaing logo option:
# Sets if the remaining logo should be printed, if it is higher than the information printed.
# Must be true or false.
# Default is true.
#--print-remaining-logo true
# Multithreading option:
# Sets if fastfetch should use multiple threads to detect the values.
# Must be true or false.
# Default is true.
#--multithreading true
# Slow operations option:
# Sets if fastfetch is allowed to use known slow operations to detect more / better values.
# Must be true or false.
# Default is false.
#--allow-slow-operations false
# Color logo option:
# Sets if the logo should be colored.
# Must be true or false.
# Default is true.
#--color-logo true
# Separator string option:
# Sets the string printed by the "separator" module (usually between title and rest of output)
# Must be any string. It is repated / cut to fit perfectly.
# Default is "-"
#--separator-string -
# Logo color options:
# Overwrite a color in the logo. Also works for user provided logos.
# In the user logo, they replace $[1-9]. Use $$ to print a single $ sign.
# Must be linux console color codes or the name of a color.
# Default is the one specified by the logo.
# Use "fastfetch --help color" to learn more and see examples.
# Valid index range is [1-9].
#--color-1 red
#--color-2 32
# [...]
#--color-9 yellow
# User logo raw option:
# Sets if color replacements should be performed on the user provided logo.
# Must be true or false.
# Default is true.
#--color-raw true
# 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
# OS file option
# Sets the path to the file containing the operating system information.
# Should be a valid path to an existing file.
# Note that you might need to run fastfetch with --recache once for it to take affect.
# Default is /etc/os-release.
#--os-file /etc/os-release
# Player name option
# Sets the name of the player. This is also used in song detection
# Must be the exact name of the player or a dbus address (e.g. org.mpris.MediaPlayer2.spotify)
# Default is the first match starting with org.mpris.MediaPlayer2.
#--player-name spotify
# Key options:
# Sets the displayed key of a module
# Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help.
#--os-key OS
#--host-key Host
#--kernel-key Kernel
#--uptime-key Uptime
#--processes-key Processes
#--packages-key Packages
#--shell-key Shell
#--resolution-key Resolution {1}
#--de-key DE
#--wm-key WM
#--wm-theme-key WM Theme
#--theme-key Theme
#--icons-key Icons
#--font-key Font
#--cursor-key Cursor
#--terminal-key Terminal
#--terminal-font-key Terminal Font
#--cpu-key CPU
#--cpu-usage-key CPU Usage
#--gpu-key GPU {1}
#--memory-key Memory
#--disk-key Disk ({1})
#--battery-key Battery {1}
#--locale-key Locale
#--local-ip-key Local IP ({1})
#--public-ip-key Public IP
#--player-key Media Player
#--song-key Song
#--datetime-key Date Time
# Format options:
# Sets the format string for module values.
# For information on format strings, see "fastfetch --help format".
# To see the parameter they take and their default value, see "fastfetch --help *-format", e.g. "fastfetch --help os-format".
# An empty format string (As they are currently below) will behave as if it was not set.
#--os-format
#--host-format
#--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
#--disk-format
#--battery-format
#--locale-format
#--local-ip-format
#--public-ip-format
#--player-format
#--song-format
#--datetime-format
# Library options:
# Sets an user specific path to a library to load.
# Must be a valid path to a library.
#--lib-PCI /usr/lib/libpci.so
#--lib-vulkan /usr/lib/libvulkan.so
#--lib-wayland /usr/lib/libwayland-client.so
#--lib-xcb-randr /usr/lib/libxcb-randr.so
#--lib-xcb /usr/lib/libxcb.so
#--lib-Xrandr /usr/lib/libXrandr.so
#--lib-X11 /usr/lib/libX11.so
#--lib-gio /usr/lib/libgio-2.0.so
#--lib-DConf /usr/lib/libdconf.so
#--lib-DBus /usr/lib/libdbus-1.so
#--lib-XFConf /usr/lib/libxfconf-0.so
#--lib-rpm /usr/lib/librpm.so
+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
+434
View File
@@ -0,0 +1,434 @@
# Fastfetch configuration
# Write every argument in different lines.
# Direct arguments will overwrite the corresponding ones in this file.
# Argument keys are not case sensitive.
# Whitespaces are trimmed at the beginning and the end.
# Empty lines or lines starting with # are ignored.
# This file was shipped with $" FASTFETCH_PROJECT_VERSION $".
# Use fastfetch --gen-config-force to overwrite this file with the current defaults
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
# Of course all of them can be made persistent here too.
# Config option:
# Load additional config files.
# Some are shipped with fastfetch, list them with "fastfetch --list-presets".
# Must be a path to a config file or the name of a shipped preset.
# The config file is completely loaded before continuing in the current file, so the placement of this option matters, as later options overwrite already set ones.
# Can be used multiple times to load multiple config files / presets.
#--load-config /path/to/config.txt
# Structure option:
# Sets the modules to use and their order.
# Must be a list of module names, separated by colons.
# List available modules with "fastfetch --list-modules".
# Get the default structure with "fastfetch --print-structure".
#--structure $" FASTFETCH_DATATEXT_STRUCTURE $"
# Multithreading option:
# Sets if fastfetch should use multiple threads to detect the values.
# Must be true or false.
# Default is true.
#--multithreading true
# Print stat option:
# Sets if fastfetch should print time usage (in ms) for individual modules
# If true, it will also enable --show-errors
# Must be true or false.
# Default is false.
#--stat true
# Slow operations option:
# Sets if fastfetch is allowed to use known slow operations to detect more / better values.
# Must be true or false.
# Default is false.
#--allow-slow-operations false
# Linewrap option:
# Sets if fastfetch should disable linewrap during the run.
# Must be true or false.
# Default is true.
#--disable-linewrap true
# Cursor option:
# Sets if fastfetch should hide the console cursor during the run.
# Must be true or false.
# Default is true.
#--hide-cursor true
# Logo option:
# Sets the logo to use.
# List available logos with "fastfetch --list-logos".
# Print available logos with "fastfetch --print-logos".
# Must be the name of an available logo or a path to a text file containing a custom logo.
# Default is the current distribution.
#--logo arch
# Logo type option:
# Sets the logo type to use.
# Must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty or chafa.
# Default is auto.
#--logo-type auto
# Logo width option:
# Sets the width of the logo (in characters) if the logo is an image.
# Must be a positive integer.
# Default is 65.
#--logo-width 65
# Logo height option:
# Sets the height of the logo (in characters) if the logo is an image.
# Must be a positive integer.
# Default is 0 (keeps aspect ration).
#--logo-height 0
# Logo color options:
# Overwrite a color in the logo. Also works for user provided logos.
# In the user logo, they replace $[1-9]. Use $$ to print a single $ sign.
# Must be linux console color codes or the name of a color.
# Default is the one specified by the logo.
# Use "fastfetch --help color" to learn more and see examples.
# Valid index range is [1-9].
#--logo-color-1 red
#--logo-color-2 32
# [...]
#--logo-color-9 yellow
# Logo padding option:
# Adds a padding to the left and the right side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding 0
# Logo padding left option:
# Adds a padding to the left side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding-left 0
# Logo padding right option:
# Adds a padding to the right side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding-right 0
# Logo padding top option:
# Adds a padding to the top side of the logo.
# Must be a positive integer.
# Default is 0.
#--logo-padding-top 0
# Logo print remaining option:
# Sets if the remaining logo should be printed, it is has more lines than modules to show.
# Must be true or false.
# Default is true.
#--logo-print-remaining true
# Color keys option:
# Sets the color of the keys.
# Must be linux console color codes or the name of a color.
# Default is the key color of the logo.
# Use "fastfetch --help color" to learn more and see examples.
#--color-keys magenta
# Color title option:
# Sets the color of the title.
# Must be linux console color codes or the name of a color.
# Default is the title color of the logo.
# Use "fastfetch --help color" to learn more and see examples.
#--color-title magenta
# Binary prefix option:
# Sets the binary prefix to use.
# Must be a IEC, SI or JEDEC.
# Default is IEC.
#--binary-prefix IEC
# 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.
# Can be any string.
# Default is ": ".
#--separator ": "
# Separator string option:
# Sets the string printed by the "separator" module (usually between title and rest of output)
# Must be any string. It is repated / cut to fit perfectly.
# Default is "-"
#--separator-string -
# Public IP URL option:
# Sets the URL of public IP detection server to be used.
# Only HTTP protocol is supported, and the value should not contain "http://" prefix.
# Default is "ipinfo.io/ip".
#--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.
# Default is /etc/os-release.
#--os-file /etc/os-release
# Player name option
# Sets the name of the player. This is also used in song detection
# Must be the exact name of the player or a dbus address (e.g. org.mpris.MediaPlayer2.spotify)
# Default is the first match starting with org.mpris.MediaPlayer2.
#--player-name spotify
# Escape bedrock option
# Sets if fastfetch should escape the bedrock jail, if it detectes that it is running in one
# Must be true or false.
# Default is true.
#--escape-bedrock true
# GL option
# Sets with opengl context creation library to use
# Must be either auto, egl, glx or osmesa
# Default is auto.
#--gl auto
# GPU hide options
# Sets weather to hide certain gpu types
# Must be either true or false
# Default is false.
#--gpu-hide-integrated
#--gpu-hide-discrete
# Shell option
# Sets if shell version should be detected and printed
# Must be either true or false
# Default is true.
#--shell-version true
# Terminal option
# Sets if terminal version should be detected and printed
# Must be either true or false
# Default is true.
#--terminal-version true
# Disk show options
# Sets if certain types of disk should be printed
# Must be either true or false
# Default is false except for --disk-show-removable.
#--disk-show-removable true
#--disk-show-hidden false
#--disk-show-subvolumes false
#--disk-show-unknown false
# Disk option
# A colon (semicolon on Windows) separated list of folder paths for the disk output
# This option override `--disk-show-*` options above
# Must be a string
# Default is "/:/home" ("C:\\;D:\\ ..." on Windows).
#--disk-folders /:/home
# Bluetooth show disconnected option
# Sets if disconnected bluetooth devices should be printed
# Must be either true or false
# Default is false.
#--bluetooth-show-disconnected false
# Sound show all option
# Sets if all sound devices should be printed
# Must be either main, active or all. Default is main
# Default is main.
#--sound-type main
# Percentage output type option
# Applies to all modules that prints percentage values. Currently memory, swap, disk, battery and CPU usage are supported.
# Only works with default format ( without --module-format option ).
# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar; 6: prints bar and hide other texts; 9: prints colored number
#--percent-type 1
# Key options:
# Sets the displayed key of a module
# Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help.
#--os-key OS
#--host-key Host
#--chassis-key Chassis
#--kernel-key Kernel
#--uptime-key Uptime
#--processes-key Processes
#--packages-key Packages
#--shell-key Shell
#--display-key Display {1}
#--brightness-key Brightness ({1})
#--de-key DE
#--wm-key WM
#--wm-theme-key WM Theme
#--theme-key Theme
#--icons-key Icons
#--font-key Font
#--cursor-key Cursor
#--terminal-key Terminal
#--terminal-font-key Terminal Font
#--cpu-key CPU
#--cpu-usage-key CPU Usage
#--gpu-key GPU {1}
#--memory-key Memory
#--swap-key Swap
#--disk-key Disk ({1})
#--battery-key Battery {1}
#--poweradapter-key Power Adapter {1}
#--locale-key Locale
#--local-ip-key Local IP ({1})
#--public-ip-key Public IP
#--wifi-key Wifi
#--weather-key Weather
#--player-key Media Player
#--media-key Media
#--datetime-key Date Time
#--vulkan-key Vulkan
#--opengl-key OpenGL
#--opencl-key OpenCL
#--users-key Users
#--bluetooth-key Bluetooth
#--sound-key Sound
#--gamepad-key Gamepad
# Format options:
# Sets the format string for module values.
# For information on format strings, see "fastfetch --help format".
# To see the parameter they take and their default value, see "fastfetch --help *-format", e.g. "fastfetch --help os-format".
# An empty format string (As they are currently below) will behave as if it was not set.
#--os-format
#--host-format
#--chassis-format
#--kernel-format
#--uptime-format
#--processes-format
#--packages-format
#--shell-format
#--display-format
#--brightness-format
#--de-format
#--wm-format
#--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
#--weather-format
#--player-format
#--media-format
#--datetime-format
#--vulkan-format
#--opengl-format
#--opencl-format
#--users-format
#--bluetooth-format
#--sound-format
#--gamepad-format
# Error options:
# Sets the format string to use if an error occured
# For information on format strings, see "fastfetch --help format".
# Each of them take the error as first and only argument.
# If one of them is set, the module will appear, even if --show-errors is not given.
#--os-error
#--host-error
#--chassis-error
#--kernel-error
#--uptime-error
#--processes-error
#--packages-error
#--shell-error
#--display-error
#--brightness-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
#--swap-error
#--disk-error
#--battery-error
#--poweradapter-error
#--locale-error
#--local-ip-error
#--public-ip-error
#--weather-error
#--player-error
#--media-error
#--datetime-error
#--vulkan-error
#--opengl-error
#--opencl-error
#--users-error
#--bluetooth-error
#--sound-error
#--gamepad-error
# Library options:
# Sets an user specific path to a library to load.
# Must be a valid path to a library.
#--lib-PCI /usr/lib/libpci.so
#--lib-vulkan /usr/lib/libvulkan.so (libMoltenVK.dylib on macOS)
#--lib-wayland /usr/lib/libwayland-client.so
#--lib-xcb-randr /usr/lib/libxcb-randr.so
#--lib-xcb /usr/lib/libxcb.so
#--lib-Xrandr /usr/lib/libXrandr.so
#--lib-X11 /usr/lib/libX11.so
#--lib-gio /usr/lib/libgio-2.0.so
#--lib-DConf /usr/lib/libdconf.so
#--lib-DBus /usr/lib/libdbus-1.so
#--lib-XFConf /usr/lib/libxfconf-0.so
#--lib-sqlite3 /usr/lib/libsqlite3.so
#--lib-rpm /usr/lib/librpm.so
#--lib-imagemagick /usr/lib/libMagickCore-7.Q16HDRI.so
#--lib-z /usr/lib/libz.so
#--lib-chafa /usr/lib/libchafa.so
#--lib-egl /usr/lib/libEGL.so
#--lib-glx /usr/lib/libGLX.so
#--lib-osmesa /usr/lib/libOSMesa.so
#--lib-opencl /usr/lib/libOpenCL.so
#--lib-cjson /usr/lib/libcjson.so
#--lib-cjson /usr/lib/libasound.so
#--lib-freetype /data/data/com.termux/files/usr/lib
#--lib-pulse /usr/lib/libpulse.so
+114 -103
View File
@@ -1,105 +1,80 @@
Usage: fastfetch <options>
Informative options:
-h, --help: shows this message and exits
-h <command>, --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: Show this message
-h,--help <command>: Show help for a specific command
-v,--version: Show the version of fastfetch
--list-config-paths: List search paths of config files
--list-data-paths: List search paths of presets and logos
--list-logos: List available logos
--list-modules: List available modules
--list-presets: List presets fastfetch knows about; they can be loaded with --load-config (+)
--list-features: List the supported features fastfetch was compiled with (mainly for development)
--print-logos: Print available logos
--print-config-system: Print the default system config
--print-config-user: Print the default user config
--print-structure: Print the default structure
--gen-config: Generate a sample config file in the default path
--gen-config-force: Generate a sample config file in the default path. Overwrite the existing one
General options:
--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.
--set <key=value>: hard set the value of a key
-c <color>, --color <color>: sets the color of the keys. Must be a linux console color code or the name of a color (+)
--color-[1-9] <color>: overwrites a color of the logo. Must be a linux console color code or the name of a color
--spacing <width>: sets the distance between logo and text
-s <str>, --separator <str>: sets the separator between key and value. Default is a colon with a space
-x <offset>, --offsetx <offset>: sets the x offset. Can be negative to cut the logo, but no more than logo width.
--show-errors <?value>: print occuring errors
-r <?value> --recache <?value>: generate new cached values
--nocache <?value>: don't use cached values, but also don't overwrite existing ones
--print-remaining-logo <?value>: print the remaining logo, if it is higher than the number of lines shown
--multithreading <?value>: use multiple threads to detect values
--load-config <file>: load a config file (+)
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
--disable-linewrap <?value>: Disable linewrap during the run
--hide-cursor <?value>: Hide the cursor during the run
--logo-raw <?value>: Print a custom logo as is, without any color replacements
--load-config <file>: Load a config file or preset (+)
--multithreading <?value>: Use multiple threads to detect values
--stat <?value>: Show time usage (in ms) for individual modules
--allow-slow-operations <?value>: Allow operations that are usually very slow for more detailed output
--escape-bedrock <?value>: On Bedrock Linux, whether to escape the bedrock jail
--pipe <?value>: Disable logo and all escape sequences
Logo options:
-l <name>, --logo <name>: sets the shown logo. Also changes the main color accordingly. This will also load file contents as logo if the given argument is a valid path.
--color-logo <?value>: if set to false, the logo will be black / white
-l,--logo <logo>: Set the logo; if default, the name of a builtin logo or a path to a file
--logo-type <type>: Set the type of the logo given; must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty, iterm or chafa
--logo-width <width>: Set the width of the logo (in characters), if it is an image. Required for iTerm image protocol
--logo-height <height>: Set the height of the logo (in characters), if it is an image. Required for iTerm image protocol
--logo-preserve-aspect-radio <?value>: Set if the logo should fill the specified width and height as much as possible without stretching. Supported by iTerm image protocol
--logo-color-[1-9] <color>: Overwrite a color in the logo
--logo-padding <padding>: Set the padding on the left and the right of the logo
--logo-padding-left <padding>: Set the padding on the left of the logo
--logo-padding-right <padding>: Set the padding on the right of the logo
--logo-padding-top <padding>: Set the padding on the top of the logo
--logo-print-remaining <?value>: Whether to print the remaining logo, if it has more lines than modules to display
--file <file>: Short for --logo-type file --logo <file>
--file-raw <file>: Short for --logo-type file-raw --logo <file>
--data <data>: Short for --logo-type data --logo <data>
--data-raw <data>: Short for --logo-type data-raw --logo <data>
--sixel <file>: Short for --logo-type sixel --logo <file>
--kitty <file>: Short for --logo-type kitty --logo <file>
--iterm <file>: Short for --logo-type iterm --logo <file>
--chafa <file>: Short for --logo-type chafa --logo <file>
--chafa-fg-only <?value>: Produce character-cell output using foreground colors only. See chafa document for detail
--chafa-symbols <str>: Specify character symbols to employ in final output. See chafa document for detail
--chafa-canvas-mode <value>: Determine how colors are used in the output. This value maps the int value of enum ChafaCanvasMode. See chafa document for detail
--chafa-color-space <value>: Set color space used for quantization. 0 for RGB; 1 for DIN99d. See chafa document for detail
--chafa-dither-mode <value>: Set output dither mode (No effect with 24-bit color). This value maps the int value of enum ChafaDitherMode. See chafa document for detail
Format options: Provide the format string for custom output. Use fastfetch --help *-format for specific help.
--os-format <format>
--host-format <format>
--kernel-format <format>
--uptime-format <format>
--processes-format <format>
--packages-format <format>
--shell-format <format>
--resolution-format <format>
--de-format <format>
--wm-format <format>
--wm-theme-format <format>
--theme-format <format>
--icons-format <format>
--font-format <format>
--cursor-format <format>
--terminal-format <format>
--terminal-font-format <format>
--cpu-format <format>
--cpu-usage-format <format>
--gpu-format <format>
--memory-format <format>
--disk-format <format>
--battery-format <format>
--locale-format <format>
--local-ip-format <format>
--public-ip-format <format>
--player-format <format>
--song-format <format>
--datetime-format <format>
--time-format <format>
--date-format <format>
Display options:
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
--color-keys <color>: Set the color of the keys
--color-title <color>: Set the color of the title
-c,--color <color>: Set the color of both the keys and title
--separator <str>: Set the separator between key and value. Default is a colon with a space
--set <key=value>: Hard set the value of a key
--set-keyless <key=value>: Hard set the value of a key, but don't print the key or the separator
--show-errors <?value>: Print occurring errors
--disable-linewrap <?value>: Whether to disable line wrap during the run
--hide-cursor <?value>: Whether to hide the cursor during the run
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC.
Key options: Provide a custom key for an output
--os-key <key>
--host-key <key>
--kernel-key <key>
--uptime-key <key>
--processes-key <key>
--packages-key <key>
--shell-key <key>
--resolution-key <key>: takes the resolution index as argument
--de-key <key>
--wm-key <key>
--wm-theme-key <key>
--theme-key <key>
--icons-key <key>
--font-key <key>
--cursor-key <key>
--terminal-key <key>
--terminal-font-key <key>
--cpu-key <key>
--cpu-usage-key <key>
--gpu-key <key>: takes the gpu index as format argument
--memory-key <key>
--disk-key <key>: takes the mount path as format argument
--battery-key <key>: takes the battery index as format argument
--locale-key <key>
--local-ip-key <key>: takes the name of this network interface as format argument
--public-ip-key <key>
--player-key <key>
--song-key <key>
--datetime-key <key>
--time-key <key>
--date-key <key>
General module options:
--<module>-format <format>: Set the format string to use for each specific module.
To see how a format string works, use fastfetch --help format.
To see help about a specific format string, use fastfetch --help <module>-format.
--<module>-key <key>: Set the key to use for each specific module.
For modules which print multiple lines, the string is parsed as a format string with the index as first character.
--<module>-error <format>: Set the error format string to use for each specific module.
The error is given as the first and only argument.
Setting this for a module will cause it to appear, even if --show-errors is not given.
Library options: Set the path of a library to load
--lib-PCI <path>
@@ -113,18 +88,54 @@ Library options: Set the path of a library to load
--lib-DConf <path>
--lib-DBus <path>
--lib-XFConf <path>
--lib-RPM <path>
--lib-sqlite3 <path>
--lib-rpm <path>
--lib-imagemagick <path>
--lib-z <path>
--lib-chafa <path>
--lib-egl <path>
--lib-glx <path>
--lib-osmesa <path>
--lib-opencl <path>
--lib-cjson <path>
--lib-pulse <path>
--lib-freetype <path>
Module specific options:
--separator-string <str>: Set the string printed by the separator module
--os-file <path>: Set the path to the file containing OS informations
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--localip-show-ipv4 <?value>: Show ipv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show ipv6 addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--player-name: The name of the player to use
--title-fqdn <?value>: Set if the title should use fully qualified domain name. Default is false
--separator-string <str>: Set the string printed by the separator module
--os-file <path>: Set the path to the file containing OS information
--shell-version <?value>: Set if shell version should be detected and printed
--terminal-version <?value>: Set if terminal version should be detected and printed
--disk-folders <folders>: A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows)
--disk-show-removable <?value>: Set if removable volume should be printed. Default is true
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
--bluetooth-show-disconnected: <?value>: Set if disconnected bluetooth devices should be printed. Default is false
--sound-type: <value>: Set what type of sound devices should be printed. Should be either main, active or all. Default is main
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--gpu-hide-integrated <?value>: Hide integrated GPU if supported. Default is false
--gpu-hide-discrete <?value>: Hide discrete GPU 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
--localip-compact-type <str>: Show IPs in one line. Should be either none, oneline, multiline. Default is none
--localip-v6first <?value>: Set if ipv6 should be printed first. Default is false
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--public-ip-url: The URL of public IP detection server to be used.
--weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0)
--weather-output-format: The output weather format to be used. It must be URI encoded.
--player-name: The name of the player to use
--gl <value>: Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1
--command-shell <str>: Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others
--command-key <str>: Set the module key to display, can be specified mulitple times
--command-text <str>: Set the command text to be executed, can be specified mulitple times
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
If a value starts with a ?, it is optional. "true" will be used if not set.
+1 -7
View File
@@ -19,24 +19,18 @@ If a "{?}" is found without an opener, it is printed as is.
To only print something if a variable is not set, do the same as with if, just replace every '?' with a '!'.
For example to print a fallback for a second value if it is not set, use "{?2}{2}{?}{/2}Second value fallback{/}"
There is a special variable set if an error occured during detection. You can access it with "{e}", "{error}" o
You can use ifs and not ifs with it like with an index. For example use "{?e}some text{?}", to print a text if an
To stop formatting at any point in the format string, use "{-}".
For example to print an error instead of the normal output if it occured, prefix the format string with "{?e}{e}{-
To print something with color, start a placeholder with a '#' and then the linux terminal color encoding.
"\\033[" at the start, and an 'm' at the end is automatically added, so don't do that.
A "{#}" is equivalent to a "{#0}" and resets everything to normal.
For example to print something pink and underline, use "{#4;35}...{#}".
If not in a format string, fastfetch wraps errors with "{#1;31}error{#}", so you might want to do that to if you
Information about what the numbers mean can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Sele
Which escape codes are supported and how they look is defined by your terminal.
If a format string evaluates to an empty value, the whole line in the output will be discarded.
You can therefore use --host-format " " to disable host output.
Note that --host-format "" would evaluate as not set, and therefore use the built-in host format
This can be used to print nothing if an error occured: prefix the format string with "{?e}{-}{?}...".
Format string is also the way to go to set a fixed value - just use one without placeholders.
For example when running in headless mode, you could use "--resolution-format "Preferred".
For example when running in headless mode, you could use "--display-format Preferred".
+12 -2
View File
@@ -1,5 +1,9 @@
Battery
Bios
Bluetooth
Board
Break
Chassis
Colors
CPU
CPUUsage
@@ -8,6 +12,7 @@ Date
Datetime
DE
Disk
Display
Font
GPU
Host
@@ -15,21 +20,26 @@ Icons
Kernel
Locale
LocalIP
Media
Memory
OpenGL
OS
Packages
Player
PowerAdapter
Processes
PublicIP
Resolution
Separator
Shell
Song
Swap
Terminal
TerminalFont
Theme
Time
Title
Uptime
Vulkan
Weather
Wifi
WM
WMTheme
+1 -1
View File
@@ -1 +1 @@
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:Locale:Break:Colors
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:PowerAdapter:Locale:Break:Colors
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#ifndef FF_INCLUDED_detection_battery_battery
#define FF_INCLUDED_detection_battery_battery
#include "fastfetch.h"
#define FF_BATTERY_TEMP_UNSET (0/0.0)
typedef struct BatteryResult
{
FFstrbuf manufacturer;
FFstrbuf modelName;
FFstrbuf technology;
double capacity;
FFstrbuf status;
double temperature;
} BatteryResult;
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results);
#endif
+56
View File
@@ -0,0 +1,56 @@
#include "fastfetch.h"
#include "battery.h"
#include "common/processing.h"
#include "common/properties.h"
#define FF_TERMUX_API_PATH FASTFETCH_TARGET_DIR_ROOT "/libexec/termux-api"
#define FF_TERMUX_API_PARAM "BatteryStatus"
const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* results)
{
FF_STRBUF_AUTO_DESTROY buffer;
ffStrbufInit(&buffer);
if(ffProcessAppendStdOut(&buffer, (char* const[]){
FF_TERMUX_API_PATH,
FF_TERMUX_API_PARAM,
NULL
}))
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
if(buffer.chars[0] != '{')
return "`" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` prints invalid result (not a JSON object)";
BatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
ffStrbufInit(&battery->technology);
if(ffParsePropLines(buffer.chars, "\"percentage\": ", &battery->status))
{
battery->capacity = ffStrbufToDouble(&battery->status);
ffStrbufClear(&battery->status);
}
if(instance->config.batteryTemp)
{
if(ffParsePropLines(buffer.chars, "\"temperature\": ", &battery->status))
{
ffStrbufTrimRight(&battery->status, ',');
ffStrbufTrim(&battery->status, '"');
battery->temperature = ffStrbufToDouble(&battery->status);
ffStrbufClear(&battery->status);
}
}
if(ffParsePropLines(buffer.chars, "\"status\": ", &battery->status))
{
ffStrbufTrimRight(&battery->status, ',');
ffStrbufTrim(&battery->status, '"');
}
return NULL;
}
+108
View File
@@ -0,0 +1,108 @@
#include "fastfetch.h"
#include "battery.h"
#include "util/apple/cf_helpers.h"
#include "detection/temps/temps_apple.h"
#include <IOKit/IOKitLib.h>
static double detectBatteryTemp()
{
FF_LIST_AUTO_DESTROY temps;
ffListInit(&temps, sizeof(FFTempValue));
ffDetectCoreTemps(FF_TEMP_BATTERY, &temps);
if(temps.length == 0)
return FF_BATTERY_TEMP_UNSET;
double result = 0;
for(uint32_t i = 0; i < temps.length; ++i)
{
FFTempValue* tempValue = (FFTempValue*)ffListGet(&temps, i);
result += tempValue->value;
//TODO: do we really need this?
ffStrbufDestroy(&tempValue->name);
ffStrbufDestroy(&tempValue->deviceClass);
}
result /= temps.length;
return result;
}
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
FF_UNUSED(instance);
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery");
if (matchDict == NULL)
return "IOServiceMatching(\"AppleSmartBattery\") failed";
io_iterator_t iterator;
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
return "IOServiceGetMatchingServices() failed";
io_registry_entry_t registryEntry;
while((registryEntry = IOIteratorNext(iterator)) != 0)
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
{
IOObjectRelease(registryEntry);
continue;
}
bool boolValue;
const char* error;
BatteryResult* battery = ffListAdd(results);
battery->capacity = 0.0/0.0;
int currentCapacity, maxCapacity;
if ((error = ffCfDictGetInt(properties, CFSTR("MaxCapacity"), &maxCapacity)))
return error;
if (maxCapacity <= 0)
return "Querying MaxCapacity failed";
if ((error = ffCfDictGetInt(properties, CFSTR("CurrentCapacity"), &currentCapacity)))
return error;
if(currentCapacity <= 0)
return "Querying CurrentCapacity failed";
battery->capacity = currentCapacity * 100.0 / maxCapacity;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->technology);
if (!ffCfDictGetBool(properties, CFSTR("built-in"), &boolValue) && boolValue)
{
ffStrbufAppendS(&battery->manufacturer, "Apple Inc.");
ffStrbufAppendS(&battery->modelName, "Builtin");
ffStrbufAppendS(&battery->technology, "Lithium");
}
else
{
ffStrbufAppendS(&battery->manufacturer, "Unknown");
ffStrbufAppendS(&battery->modelName, "Unknown");
ffStrbufAppendS(&battery->technology, "Unknown");
}
ffStrbufInit(&battery->status);
if (!ffCfDictGetBool(properties, CFSTR("FullyCharged"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Fully charged");
else if (!ffCfDictGetBool(properties, CFSTR("IsCharging"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Charging");
else
ffStrbufAppendS(&battery->status, "");
if(instance->config.batteryTemp)
battery->temperature = detectBatteryTemp();
else
battery->temperature = FF_BATTERY_TEMP_UNSET;
CFRelease(properties);
IOObjectRelease(registryEntry);
}
IOObjectRelease(iterator);
return NULL;
}
+59
View File
@@ -0,0 +1,59 @@
#include "fastfetch.h"
#include "battery.h"
#include <dev/acpica/acpiio.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
#include <unistd.h>
const char* ffDetectBatteryImpl(FF_MAYBE_UNUSED FFinstance* instance, FFlist* results)
{
//https://www.freebsd.org/cgi/man.cgi?acpi_battery(4)
//https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c
int acpifd = open("/dev/acpi", O_RDONLY);
if(acpifd < 0)
return "open(\"/dev/acpi\", O_RDONLY) failed";
int units = ioctl(acpifd, ACPIIO_BATT_GET_UNITS, 0);
if(units < 0)
{
close(acpifd);
return "No acpiio battery units found";
}
for(int i = 0; i < units; ++i)
{
union acpi_battery_ioctl_arg battio;
battio.unit = i;
if(ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) < 0 || (battio.battinfo.state & ACPI_BATT_STAT_NOT_PRESENT))
continue;
BatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
ffStrbufInit(&battery->technology);
battery->capacity = battio.battinfo.cap;
if(battio.battinfo.state & ACPI_BATT_STAT_INVALID)
{
ffStrbufAppendS(&battery->status, "Invalid");
}
else
{
if(battio.battinfo.state & ACPI_BATT_STAT_DISCHARG)
ffStrbufAppendS(&battery->status, "Discharging, ");
else if(battio.battinfo.state & ACPI_BATT_STAT_CHARGING)
ffStrbufAppendS(&battery->status, "Charging, ");
if(battio.battinfo.state & ACPI_BATT_STAT_CRITICAL)
ffStrbufAppendS(&battery->status, "Ctritical");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
close(acpifd);
return NULL;
}
+119
View File
@@ -0,0 +1,119 @@
#include "fastfetch.h"
#include "common/io/io.h"
#include "battery.h"
#include <dirent.h>
static void parseBattery(FFstrbuf* dir, FFlist* results)
{
uint32_t dirLength = dir->length;
FFstrbuf testBatteryBuffer;
ffStrbufInit(&testBatteryBuffer);
//type must exist and be "Battery"
ffStrbufAppendS(dir, "/type");
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Battery") != 0)
{
ffStrbufDestroy(&testBatteryBuffer);
return;
}
//scope may not exist or must not be "Device"
ffStrbufAppendS(dir, "/scope");
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(ffStrbufIgnCaseCompS(&testBatteryBuffer, "Device") == 0)
{
ffStrbufDestroy(&testBatteryBuffer);
return;
}
BatteryResult* result = ffListAdd(results);
//capacity must exist and be not empty
ffStrbufAppendS(dir, "/capacity");
bool available = ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(available)
result->capacity = ffStrbufToDouble(&testBatteryBuffer);
ffStrbufDestroy(&testBatteryBuffer);
if(!available)
{
result->capacity = 0.0/0.0;
--results->length;
return;
}
//At this point, we have a battery. Try to get as much values as possible.
ffStrbufInit(&result->manufacturer);
ffStrbufAppendS(dir, "/manufacturer");
ffReadFileBuffer(dir->chars, &result->manufacturer);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->modelName);
ffStrbufAppendS(dir, "/model_name");
ffReadFileBuffer(dir->chars, &result->modelName);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->technology);
ffStrbufAppendS(dir, "/technology");
ffReadFileBuffer(dir->chars, &result->technology);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufInit(&result->status);
ffStrbufAppendS(dir, "/status");
ffReadFileBuffer(dir->chars, &result->status);
ffStrbufSubstrBefore(dir, dirLength);
result->temperature = FF_BATTERY_TEMP_UNSET;
}
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) {
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
if(instance->config.batteryDir.length > 0)
{
ffStrbufAppend(&baseDir, &instance->config.batteryDir);
ffStrbufEnsureEndsWithC(&baseDir, '/');
}
else
{
ffStrbufAppendS(&baseDir, "/sys/class/power_supply/");
}
uint32_t baseDirLength = baseDir.length;
DIR* dirp = opendir(baseDir.chars);
if(dirp == NULL)
{
ffStrbufDestroy(&baseDir);
return "opendir(batteryDir) == NULL";
}
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
ffStrbufAppendS(&baseDir, entry->d_name);
parseBattery(&baseDir, results);
ffStrbufSubstrBefore(&baseDir, baseDirLength);
}
closedir(dirp);
if(results->length == 0) {
ffStrbufDestroy(&baseDir);
return "batteryDir doesn't contain any battery folder";
}
ffStrbufDestroy(&baseDir);
return NULL;
}
@@ -0,0 +1,8 @@
#include "fastfetch.h"
#include "battery.h"
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
FF_UNUSED(instance, results)
return "Not supported on this platform";
}
+171
View File
@@ -0,0 +1,171 @@
#include "battery.h"
#include "util/windows/unicode.h"
#include "util/mallocHelper.h"
#include <setupapi.h>
#include <batclass.h>
#include <devguid.h>
#include <winternl.h>
#include <powrprof.h>
#ifdef FF_USE_WIN_NTAPI
NTSYSCALLAPI
NTSTATUS
NTAPI
NtPowerInformation(
IN POWER_INFORMATION_LEVEL InformationLevel,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength);
#define CallNtPowerInformation NtPowerInformation
#endif
static inline void wrapCloseHandle(HANDLE* handle)
{
if(*handle)
CloseHandle(*handle);
}
static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
{
if(*hdev)
SetupDiDestroyDeviceInfoList(*hdev);
}
const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
{
if(instance->config.allowSlowOperations)
{
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(hdev == INVALID_HANDLE_VALUE)
return "SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY) failed";
for(DWORD idev = 0;; idev++)
{
SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) };
if(!SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did))
break;
DWORD cbRequired = 0;
SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer
SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired);
if(!pdidd)
break; //Out of memory
pdidd->cbSize = sizeof(*pdidd);
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
continue;
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
DWORD dwWait = 0;
DWORD dwOut;
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_TAG, &dwWait, sizeof(dwWait), &bqi.BatteryTag, sizeof(bqi.BatteryTag), &dwOut, NULL) && bqi.BatteryTag)
continue;
BATTERY_INFORMATION bi = {0};
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL))
continue;
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
continue;
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
ffStrbufInitS(&battery->technology, "Lead Acid");
else if(memcmp(bi.Chemistry, "LION", 4) == 0 || memcmp(bi.Chemistry, "Li-I", 4) == 0)
ffStrbufInitS(&battery->technology, "Lithium Ion");
else if(memcmp(bi.Chemistry, "NiCd", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Cadmium");
else if(memcmp(bi.Chemistry, "NiMH", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Metal Hydride");
else if(memcmp(bi.Chemistry, "NiZn", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Zinc");
else if(memcmp(bi.Chemistry, "RAM\0", 4) == 0)
ffStrbufInitS(&battery->technology, "Rechargeable Alkaline-Manganese");
else
ffStrbufInitS(&battery->technology, "Unknown");
{
ffStrbufInit(&battery->modelName);
bqi.InformationLevel = BatteryDeviceName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->modelName, name);
}
{
ffStrbufInit(&battery->manufacturer);
bqi.InformationLevel = BatteryManufactureName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->manufacturer, name);
}
battery->temperature = 0.0/0.0;
if(instance->config.batteryTemp)
{
bqi.InformationLevel = BatteryTemperature;
ULONG temp;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &temp, sizeof(temp), &dwOut, NULL))
battery->temperature = temp;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY)
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
else
battery->capacity = 0;
ffStrbufInit(&battery->status);
if(bs.PowerState & BATTERY_POWER_ON_LINE)
ffStrbufAppendS(&battery->status, "AC Connected, ");
if(bs.PowerState & BATTERY_DISCHARGING)
ffStrbufAppendS(&battery->status, "Discharging, ");
if(bs.PowerState & BATTERY_CHARGING)
ffStrbufAppendS(&battery->status, "Charging");
if(bs.PowerState & BATTERY_CRITICAL)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
}
else
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(CallNtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
BatteryResult* battery = (BatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->temperature = 0.0/0.0;
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
{
ffStrbufAppendS(&battery->status, "AC Connected");
if(info.Charging)
ffStrbufAppendS(&battery->status, ", Charging");
}
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
}
}
return NULL;
}
+19
View File
@@ -0,0 +1,19 @@
#pragma once
#ifndef FF_INCLUDED_detection_bios_bios
#define FF_INCLUDED_detection_bios_bios
#include "fastfetch.h"
typedef struct FFBiosResult
{
FFstrbuf biosDate;
FFstrbuf biosRelease;
FFstrbuf biosVendor;
FFstrbuf biosVersion;
FFstrbuf error;
} FFBiosResult;
void ffDetectBios(FFBiosResult* bios);
#endif
+70
View File
@@ -0,0 +1,70 @@
#include "bios.h"
#include "util/apple/cf_helpers.h"
#include <IOKit/IOKitLib.h>
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
io_registry_entry_t registryEntry;
#ifndef __aarch64__
//https://github.com/osquery/osquery/blob/master/osquery/tables/system/darwin/smbios_tables.cpp
//For Intel
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/rom")))
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
{
IOObjectRelease(registryEntry);
ffStrbufAppendS(&bios->error, "IORegistryEntryCreateCFProperties(registryEntry) failed");
return;
}
ffCfDictGetString(properties, CFSTR("vendor"), &bios->biosVendor);
ffCfDictGetString(properties, CFSTR("version"), &bios->biosVersion);
ffCfDictGetString(properties, CFSTR("release-date"), &bios->biosDate);
if(!ffStrbufContainC(&bios->biosDate, '-'))
ffStrbufAppendS(&bios->biosRelease, "Efi-");
ffStrbufAppend(&bios->biosRelease, &bios->biosVersion);
CFRelease(properties);
IOObjectRelease(registryEntry);
return;
}
#else
//For arm64
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/")))
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
{
ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->biosVendor);
CFRelease(properties);
}
IOObjectRelease(registryEntry);
}
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen")))
{
CFMutableDictionaryRef properties;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
{
ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->biosRelease);
ffStrbufAppend(&bios->biosVersion, &bios->biosRelease);
ffStrbufSubstrAfterFirstC(&bios->biosVersion, '-');
CFRelease(properties);
}
IOObjectRelease(registryEntry);
}
#endif
}
+26
View File
@@ -0,0 +1,26 @@
#include "bios.h"
#include <kenv.h>
static void kenvLookup(const char* name, FFstrbuf* result)
{
ffStrbufEnsureFree(result, 255);
int len = kenv(KENV_GET, name, result->chars, 256);
if(len > 0)
result->length = (uint32_t) len;
}
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
//https://wiki.ghostbsd.org/index.php/Kenv
kenvLookup("smbios.bios.reldate", &bios->biosDate);
kenvLookup("smbios.system.product", &bios->biosRelease);
kenvLookup("smbios.bios.vendor", &bios->biosVendor);
kenvLookup("smbios.bios.version", &bios->biosVersion);
}
+58
View File
@@ -0,0 +1,58 @@
#include "bios.h"
#include "common/io/io.h"
#include <stdlib.h>
static bool hostValueSet(FFstrbuf* value)
{
return
value->length > 0 &&
ffStrbufStartsWithIgnCaseS(value, "To be filled") != true &&
ffStrbufStartsWithIgnCaseS(value, "To be set") != true &&
ffStrbufStartsWithIgnCaseS(value, "OEM") != true &&
ffStrbufStartsWithIgnCaseS(value, "O.E.M.") != true &&
ffStrbufIgnCaseCompS(value, "None") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Product Version") != 0 &&
ffStrbufIgnCaseCompS(value, "System Name") != 0 &&
ffStrbufIgnCaseCompS(value, "System Version") != 0 &&
ffStrbufIgnCaseCompS(value, "Default string") != 0 &&
ffStrbufIgnCaseCompS(value, "Undefined") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Specified") != 0 &&
ffStrbufIgnCaseCompS(value, "Not Applicable") != 0 &&
ffStrbufIgnCaseCompS(value, "INVALID") != 0 &&
ffStrbufIgnCaseCompS(value, "Type1ProductConfigId") != 0 &&
ffStrbufIgnCaseCompS(value, "All Series") != 0
;
}
static void getHostValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer)
{
ffReadFileBuffer(devicesPath, buffer);
if(hostValueSet(buffer))
return;
ffReadFileBuffer(classPath, buffer);
if(hostValueSet(buffer))
return;
ffStrbufClear(buffer);
}
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
getHostValue("/sys/devices/virtual/dmi/id/bios_date", "/sys/class/dmi/id/bios_date", &bios->biosDate);
ffStrbufInit(&bios->biosRelease);
getHostValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
getHostValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
getHostValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->biosVersion);
}
+11
View File
@@ -0,0 +1,11 @@
#include "bios.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInitS(&bios->error, "Not supported on this platform");
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
}
+28
View File
@@ -0,0 +1,28 @@
#include "bios.h"
#include "util/windows/registry.h"
void ffDetectBios(FFBiosResult* bios)
{
ffStrbufInit(&bios->error);
ffStrbufInit(&bios->biosDate);
ffStrbufInit(&bios->biosRelease);
ffStrbufInit(&bios->biosVendor);
ffStrbufInit(&bios->biosVersion);
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\BIOS", &hKey, &bios->error))
return;
if(!ffRegReadStrbuf(hKey, L"BIOSVersion", &bios->biosRelease, &bios->error))
return;
ffRegReadStrbuf(hKey, L"BIOSVendor", &bios->biosVendor, NULL);
ffRegReadStrbuf(hKey, L"BIOSReleaseDate", &bios->biosDate, NULL);
uint32_t major, minor;
if(
ffRegReadUint(hKey, L"BiosMajorRelease", &major, NULL) &&
ffRegReadUint(hKey, L"BiosMinorRelease", &minor, NULL)
)
ffStrbufAppendF(&bios->biosVersion, "%u.%u", (unsigned)major, (unsigned)minor);
}
+15
View File
@@ -0,0 +1,15 @@
#include "bluetooth.h"
#include "../internal.h"
void ffDetectBluetoothImpl(const FFinstance* instance, FFBluetoothResult* bluetooth);
const FFBluetoothResult* ffDetectBluetooth(const FFinstance* instance)
{
FF_DETECTION_INTERNAL_GUARD(FFBluetoothResult,
ffStrbufInit(&result.error);
ffListInit(&result.devices, sizeof(FFBluetoothDevice));
ffDetectBluetoothImpl(instance, &result);
)
}
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#ifndef FF_INCLUDED_detection_bluetooth_bluetooth
#define FF_INCLUDED_detection_bluetooth_bluetooth
#include "fastfetch.h"
typedef struct FFBluetoothDevice
{
FFstrbuf name;
FFstrbuf address;
FFstrbuf type;
uint8_t battery; // 0-100%
bool connected;
} FFBluetoothDevice;
typedef struct FFBluetoothResult
{
FFstrbuf error;
FFlist devices; // List of FFBluetoothDevice
} FFBluetoothResult;
const FFBluetoothResult* ffDetectBluetooth(const FFinstance* instance);
#endif
+93
View File
@@ -0,0 +1,93 @@
#include "bluetooth.h"
#import <IOBluetooth/IOBluetooth.h>
void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoothResult* bluetooth)
{
NSArray<IOBluetoothDevice*>* ioDevices = IOBluetoothDevice.pairedDevices;
if(!ioDevices)
{
ffStrbufAppendS(&bluetooth->error, "IOBluetoothDevice.pairedDevices failed");
return;
}
for(IOBluetoothDevice* ioDevice in ioDevices)
{
FFBluetoothDevice* device = ffListAdd(&bluetooth->devices);
ffStrbufInitS(&device->name, ioDevice.name.UTF8String);
ffStrbufInitS(&device->address, ioDevice.addressString.UTF8String);
ffStrbufInit(&device->type);
device->battery = 0;
device->connected = !!ioDevice.isConnected;
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorLimitedDiscoverableMode)
ffStrbufAppendS(&device->type, "Limited Discoverable Mode, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorReserved1)
ffStrbufAppendS(&device->type, "LE audio, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorReserved2)
ffStrbufAppendS(&device->type, "Reserved for future use, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorPositioning)
ffStrbufAppendS(&device->type, "Positioning, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorNetworking)
ffStrbufAppendS(&device->type, "Networking, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorRendering)
ffStrbufAppendS(&device->type, "Rendering, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorCapturing)
ffStrbufAppendS(&device->type, "Capturing, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorObjectTransfer)
ffStrbufAppendS(&device->type, "Object Transfer, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorAudio)
ffStrbufAppendS(&device->type, "Audio, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorTelephony)
ffStrbufAppendS(&device->type, "Telephony, ");
if(ioDevice.serviceClassMajor & kBluetoothServiceClassMajorInformation)
ffStrbufAppendS(&device->type, "Information, ");
if(device->type.length == 0)
{
switch(ioDevice.deviceClassMajor)
{
case kBluetoothDeviceClassMajorMiscellaneous:
ffStrbufAppendS(&device->type, "Miscellaneous");
break;
case kBluetoothDeviceClassMajorComputer:
ffStrbufAppendS(&device->type, "Computer");
break;
case kBluetoothDeviceClassMajorPhone:
ffStrbufAppendS(&device->type, "Phone");
break;
case kBluetoothDeviceClassMajorLANAccessPoint:
ffStrbufAppendS(&device->type, "LAN/Network Access point");
break;
case kBluetoothDeviceClassMajorAudio:
ffStrbufAppendS(&device->type, "Audio/Video");
break;
case kBluetoothDeviceClassMajorPeripheral:
ffStrbufAppendS(&device->type, "Peripheral");
break;
case kBluetoothDeviceClassMajorImaging:
ffStrbufAppendS(&device->type, "Imaging");
break;
case kBluetoothDeviceClassMajorWearable:
ffStrbufAppendS(&device->type, "Wearable");
break;
case kBluetoothDeviceClassMajorToy:
ffStrbufAppendS(&device->type, "Toy");
break;
case kBluetoothDeviceClassMajorHealth:
ffStrbufAppendS(&device->type, "Health");
break;
case kBluetoothDeviceClassMajorUnclassified:
ffStrbufAppendS(&device->type, "Uncategorized");
break;
default:
ffStrbufAppendS(&device->type, "Unknown");
break;
}
}
else
{
ffStrbufTrimRight(&device->type, ' ');
ffStrbufTrimRight(&device->type, ',');
}
}
}
+203
View File
@@ -0,0 +1,203 @@
#include "bluetooth.h"
#ifdef FF_HAVE_DBUS
#include "common/dbus.h"
/* Example dbus reply, striped to only the relevant parts:
array [ //root
dict entry( //object
object path "/org/bluez/hci0/dev_03_21_8B_91_16_4D"
array [
dict entry( //property
string "org.bluez.Device1"
array [
dict entry( //value
string "Address"
variant string "03:21:8B:91:16:4D"
)
dict entry( //value
string "Name"
variant string "JBL TUNE160BT"
)
dict entry( //value
string "Icon"
variant string "audio-headset"
)
dict entry( //value
string "Connected"
variant boolean true
)
]
)
dict entry( //property
string "org.bluez.Battery1"
array [
dict entry( //value
string "Percentage"
variant byte 100
)
]
)
]
)
]
*/
static void detectBluetoothValue(FFDBusData* dbus, DBusMessageIter* iter, FFBluetoothDevice* device)
{
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY)
return;
DBusMessageIter dictIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_STRING)
return;
const char* deviceProperty;
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &deviceProperty);
dbus->lib->ffdbus_message_iter_next(&dictIter);
if(strcmp(deviceProperty, "Address") == 0)
ffDBusGetValue(dbus, &dictIter, &device->address);
else if(strcmp(deviceProperty, "Name") == 0)
ffDBusGetValue(dbus, &dictIter, &device->name);
else if(strcmp(deviceProperty, "Icon") == 0)
ffDBusGetValue(dbus, &dictIter, &device->type);
else if(strcmp(deviceProperty, "Percentage") == 0)
ffDBusGetByte(dbus, &dictIter, &device->battery);
else if(strcmp(deviceProperty, "Connected") == 0)
ffDBusGetBool(dbus, &dictIter, &device->connected);
}
static void detectBluetoothProperty(FFDBusData* dbus, DBusMessageIter* iter, FFBluetoothDevice* device)
{
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY)
return;
DBusMessageIter dictIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_STRING)
return;
const char* propertyType;
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &propertyType);
if(strstr(propertyType, "Device") == NULL && strstr(propertyType, "Battery") == NULL)
return; //We don't care about other properties
dbus->lib->ffdbus_message_iter_next(&dictIter);
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_ARRAY)
return;
DBusMessageIter arrayIter;
dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter);
while(true)
{
detectBluetoothValue(dbus, &arrayIter, device);
FF_DBUS_ITER_CONTINUE(dbus, &arrayIter);
}
}
static void detectBluetoothObject(FFBluetoothResult* bluetooth, FFDBusData* dbus, DBusMessageIter* iter)
{
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_DICT_ENTRY)
return;
DBusMessageIter dictIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &dictIter);
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_OBJECT_PATH)
return;
const char* objectPath;
dbus->lib->ffdbus_message_iter_get_basic(&dictIter, &objectPath);
//We don't want adapter objects
if(strstr(objectPath, "dev_") == NULL)
return;
dbus->lib->ffdbus_message_iter_next(&dictIter);
if(dbus->lib->ffdbus_message_iter_get_arg_type(&dictIter) != DBUS_TYPE_ARRAY)
return;
DBusMessageIter arrayIter;
dbus->lib->ffdbus_message_iter_recurse(&dictIter, &arrayIter);
FFBluetoothDevice* device = ffListAdd(&bluetooth->devices);
ffStrbufInit(&device->name);
ffStrbufInit(&device->address);
ffStrbufInit(&device->type);
device->battery = 0;
device->connected = false;
while(true)
{
detectBluetoothProperty(dbus, &arrayIter, device);
FF_DBUS_ITER_CONTINUE(dbus, &arrayIter);
}
if(device->name.length == 0)
{
ffStrbufDestroy(&device->name);
ffStrbufDestroy(&device->address);
ffStrbufDestroy(&device->type);
--bluetooth->devices.length;
}
}
static void detectBluetoothRoot(FFBluetoothResult* bluetooth, FFDBusData* dbus, DBusMessageIter* iter)
{
if(dbus->lib->ffdbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
return;
DBusMessageIter arrayIter;
dbus->lib->ffdbus_message_iter_recurse(iter, &arrayIter);
while(true)
{
detectBluetoothObject(bluetooth, dbus, &arrayIter);
FF_DBUS_ITER_CONTINUE(dbus, &arrayIter);
}
}
static const char* detectBluetooth(const FFinstance* instance, FFBluetoothResult* bluetooth)
{
FFDBusData dbus;
const char* error = ffDBusLoadData(instance, DBUS_BUS_SYSTEM, &dbus);
if(error)
return error;
DBusMessage* managedObjects = ffDBusGetMethodReply(&dbus, "org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
if(!managedObjects)
return "Failed to call GetManagedObjects";
DBusMessageIter rootIter;
if(!dbus.lib->ffdbus_message_iter_init(managedObjects, &rootIter))
{
dbus.lib->ffdbus_message_unref(managedObjects);
return "Failed to get root iterator of GetManagedObjects";
}
detectBluetoothRoot(bluetooth, &dbus, &rootIter);
dbus.lib->ffdbus_message_unref(managedObjects);
return NULL;
}
#endif
void ffDetectBluetoothImpl(const FFinstance* instance, FFBluetoothResult* bluetooth)
{
#ifdef FF_HAVE_DBUS
ffStrbufAppendS(&bluetooth->error, detectBluetooth(instance, bluetooth));
#else
FF_UNUSED(instance);
ffStrbufAppendS(&bluetooth->error, "Fastfetch was compiled without DBus support");
#endif
}
@@ -0,0 +1,6 @@
#include "bluetooth.h"
void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoothResult* bluetooth)
{
ffStrbufAppendS(&bluetooth->error, "Bluetooth not supported on this platform");
}
+114
View File
@@ -0,0 +1,114 @@
#include "bluetooth.h"
#include "util/windows/unicode.h"
#include <bluetoothapis.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpointer-sign"
void ffDetectBluetoothImpl(FF_MAYBE_UNUSED const FFinstance* instance, FFBluetoothResult* bluetooth)
{
BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = {
.fReturnConnected = TRUE,
.fReturnRemembered = TRUE,
.fReturnAuthenticated = TRUE,
.fReturnUnknown = TRUE,
.dwSize = sizeof(btsp)
};
BLUETOOTH_DEVICE_INFO btdi = {
.dwSize = sizeof(btdi)
};
HBLUETOOTH_DEVICE_FIND hFind = BluetoothFindFirstDevice(&btsp, &btdi);
if(!hFind)
ffStrbufAppendS(&bluetooth->error, "BluetoothFindFirstDevice() failed or no devices found");
do {
FFBluetoothDevice* device = ffListAdd(&bluetooth->devices);
ffStrbufInit(&device->name);
ffStrbufInit(&device->address);
ffStrbufInit(&device->type);
device->battery = 0;
device->connected = !!btdi.fConnected;
ffStrbufSetWS(&device->name, btdi.szName);
for (uint32_t i = 0; i < sizeof(btdi.Address.rgBytes) / sizeof(btdi.Address.rgBytes); ++i)
ffStrbufAppendF(&device->address, "%X:", btdi.Address.rgBytes[i]);
ffStrbufTrimRight(&device->name, ':');
//https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers/Assigned%20Number%20Types/Assigned%20Numbers.pdf
if(BitTest(&btdi.ulClassofDevice, 13))
ffStrbufAppendS(&device->type, "Limited Discoverable Mode, ");
if(BitTest(&btdi.ulClassofDevice, 14))
ffStrbufAppendS(&device->type, "LE audio, ");
if(BitTest(&btdi.ulClassofDevice, 15))
ffStrbufAppendS(&device->type, "Reserved for future use, ");
if(BitTest(&btdi.ulClassofDevice, 16))
ffStrbufAppendS(&device->type, "Positioning, ");
if(BitTest(&btdi.ulClassofDevice, 17))
ffStrbufAppendS(&device->type, "Networking, ");
if(BitTest(&btdi.ulClassofDevice, 18))
ffStrbufAppendS(&device->type, "Rendering, ");
if(BitTest(&btdi.ulClassofDevice, 19))
ffStrbufAppendS(&device->type, "Capturing, ");
if(BitTest(&btdi.ulClassofDevice, 20))
ffStrbufAppendS(&device->type, "Object Transfer, ");
if(BitTest(&btdi.ulClassofDevice, 21))
ffStrbufAppendS(&device->type, "Audio, ");
if(BitTest(&btdi.ulClassofDevice, 22))
ffStrbufAppendS(&device->type, "Telephony, ");
if(BitTest(&btdi.ulClassofDevice, 23))
ffStrbufAppendS(&device->type, "Information, ");
if(device->type.length == 0)
{
uint32_t majorDeviceClasses = (btdi.ulClassofDevice >> 8) & ~(UINT32_MAX << 5);
switch(majorDeviceClasses)
{
case 0b00000:
ffStrbufAppendS(&device->type, "Miscellaneous");
break;
case 0b00001:
ffStrbufAppendS(&device->type, "Computer");
break;
case 0b00010:
ffStrbufAppendS(&device->type, "Phone");
break;
case 0b00011:
ffStrbufAppendS(&device->type, "LAN/Network Access point");
break;
case 0b00100:
ffStrbufAppendS(&device->type, "Audio/Video");
break;
case 0b00101:
ffStrbufAppendS(&device->type, "Peripheral");
break;
case 0b00110:
ffStrbufAppendS(&device->type, "Imaging");
break;
case 0b00111:
ffStrbufAppendS(&device->type, "Wearable");
break;
case 0b01000:
ffStrbufAppendS(&device->type, "Toy");
break;
case 0b01001:
ffStrbufAppendS(&device->type, "Health");
break;
case 0b11111:
ffStrbufAppendS(&device->type, "Uncategorized");
break;
default:
ffStrbufAppendS(&device->type, "Unknown");
break;
}
}
else
{
ffStrbufTrimRight(&device->type, ' ');
ffStrbufTrimRight(&device->type, ',');
}
} while (BluetoothFindNextDevice(hFind, &btdi));
}
#pragma GCC diagnostic pop

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