Compare commits

..

32 Commits

Author SHA1 Message Date
Carter Li 22de71efeb Merge pull request #617 from fastfetch-cli/dev
Release v2.2.3
2023-11-08 12:33:16 +08:00
李通洲 ac654ff346 Host (macOS): update the latest models 2023-11-08 10:43:17 +08:00
李通洲 df2fdf05e6 Release v2.2.3 2023-11-08 10:14:31 +08:00
李通洲 788307e98d Doc: update changelog 2023-11-08 09:11:16 +08:00
李通洲 f93341ac61 TerminalShell: fix terminal name detection on NixOS
oops. No one report that...
2023-11-08 09:02:52 +08:00
李通洲 3e0d97db2e Platform: detect system page size 2023-11-08 00:10:16 +08:00
李通洲 864e707224 LocalIP (Android): don't set --default-route-only to true by default on Android
As we can't detect default route on that platform
2023-11-07 20:17:08 +08:00
李通洲 c42b68404f Logo (Image): try improving performace of base64 encoding 2023-11-07 19:04:16 +08:00
Carter Li 18374467e6 Merge pull request #615 from fastfetch-cli/dev
Release v2.2.2
2023-11-07 10:02:19 +08:00
李通洲 499e6c85a0 Battery (Windows): slilence compiler warnings 2023-11-07 09:59:00 +08:00
李通洲 0610faf1be Release v2.2.2 2023-11-07 09:47:37 +08:00
李通洲 778c6f0513 Doc: update changelog 2023-11-07 09:03:01 +08:00
李通洲 c55ba2685f Battery (macOS): add status Discharging to be consistant with other platforms 2023-11-07 08:56:07 +08:00
李通洲 aae66aa966 Logo (Image): fix spelling of --preserve-aspect-ratio
Fix #614
2023-11-07 08:49:22 +08:00
李通洲 a95b60167c Doc: fix typo in README
Fix #613
2023-11-07 08:37:29 +08:00
李通洲 f5b987dba9 Battery (Windows): detect cycle count 2023-11-06 19:40:40 +08:00
李通洲 f8eabdd8a6 Battry (Linux): try detecting cycle count and temperature 2023-11-06 19:08:17 +08:00
李通洲 5ab2c3456d Battery (Apple): better detection 2023-11-06 16:42:16 +08:00
李通洲 97d9ffd193 Bios: detect firmware type 2023-11-06 15:29:55 +08:00
李通洲 fa86bb1f0b CI (FreeBSD): update action version 2023-11-06 10:24:06 +08:00
李通洲 5b9c5ebb5a CI (Win64): improve speed 2023-11-06 10:11:51 +08:00
李通洲 56b03a93c5 CI (Linux): build with imagemagick7 2023-11-06 10:05:01 +08:00
李通洲 3b319f0a1e Global: add missing changes 2023-11-05 13:25:54 +08:00
李通洲 c3352d6d28 CI: always update dependencies explicitly
Fix macOS build
2023-11-05 13:25:13 +08:00
李通洲 f8426384d8 CI: print verbose logs when building 2023-11-05 13:02:48 +08:00
李通洲 8791281b48 CI: try fixing macOS build 2023-11-05 10:38:43 +08:00
李通洲 76ec8aff2e Doc: update changelog 2023-11-05 10:16:48 +08:00
李通洲 7660b0a091 Global: defaults percentType to 9 ( colored number ) 2023-11-05 10:11:53 +08:00
李通洲 7a8e484634 Global: prints LocalIp by default
Fix #611
2023-11-05 10:11:40 +08:00
李通洲 ed01272b91 LocalIP: detect netmask 2023-11-05 09:42:28 +08:00
Viorel 1c660caa85 Fix unitialized variables (#609)
Compiling with gcc 13 and -O3 -flto -Werror=uninitialized found two
possibly unitialized variables.

See also: https://bugs.gentoo.org/916722
2023-11-03 23:03:14 +08:00
李通洲 c241ead1d5 Logo (Builtin): update nixos_small, add nixos_old_small
Fix #608
2023-11-02 23:22:48 +08:00
52 changed files with 515 additions and 328 deletions
+30 -17
View File
@@ -28,6 +28,9 @@ jobs:
- name: checkout repository
uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y musl-dev musl-tools linux-headers-generic libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev directx-headers-dev
@@ -35,7 +38,7 @@ jobs:
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_JSONC=${{ matrix.enableFeatures }} -DENABLE_DIRECTX_HEADERS=${{ matrix.enableFeatures }} .
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_LIBPCI=${{ matrix.enableFeatures }} -DENABLE_VULKAN=${{ matrix.enableFeatures }} -DENABLE_WAYLAND=${{ matrix.enableFeatures }} -DENABLE_XCB_RANDR=${{ matrix.enableFeatures }} -DENABLE_XCB=${{ matrix.enableFeatures }} -DENABLE_XRANDR=${{ matrix.enableFeatures }} -DENABLE_X11=${{ matrix.enableFeatures }} -DENABLE_GIO=${{ matrix.enableFeatures }} -DENABLE_DCONF=${{ matrix.enableFeatures }} -DENABLE_DBUS=${{ matrix.enableFeatures }} -DENABLE_XFCONF=${{ matrix.enableFeatures }} -DENABLE_SQLITE3=${{ matrix.enableFeatures }} -DENABLE_RPM=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK7=${{ matrix.enableFeatures }} -DENABLE_IMAGEMAGICK6=${{ matrix.enableFeatures }} -DENABLE_CHAFA=${{ matrix.enableFeatures }} -DENABLE_ZLIB=${{ matrix.enableFeatures }} -DENABLE_EGL=${{ matrix.enableFeatures }} -DENABLE_GLX=${{ matrix.enableFeatures }} -DENABLE_OSMESA=${{ matrix.enableFeatures }} -DENABLE_OPENCL=${{ matrix.enableFeatures }} -DENABLE_LIBNM=${{ matrix.enableFeatures }} -DENABLE_PULSE=${{ matrix.enableFeatures }} -DENABLE_DIRECTX_HEADERS=${{ matrix.enableFeatures }} .
- name: build project
run: cmake --build .
@@ -43,6 +46,9 @@ jobs:
- name: run tests
run: ctest
- name: run fastfetch --list-features
run: ./fastfetch --list-features
- name: run fastfetch
run: time ./fastfetch -c presets/ci
@@ -64,19 +70,27 @@ jobs:
- name: checkout repository
uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: install required packages
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev ocl-icd-opencl-dev libnm-dev libpulse-dev directx-headers-dev
- name: install linuxbrew packages
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/home/linuxbrew/.linuxbrew/bin/brew install imagemagick --ignore-dependencies
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c
- name: configure project
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
run: PKG_CONFIG_PATH=/home/linuxbrew/.linuxbrew/lib/pkgconfig:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
- name: build project
run: cmake --build . --target package
run: cmake --build . --target package --verbose
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
@@ -119,8 +133,13 @@ jobs:
- name: checkout repository
uses: actions/checkout@v4
- name: uname -a
run: uname -a
- name: install required packages
run: brew install vulkan-loader molten-vk imagemagick chafa
run: |
brew update
brew install vulkan-loader vulkan-headers molten-vk imagemagick chafa
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
@@ -131,7 +150,7 @@ jobs:
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' .
- name: build project
run: cmake --build . --target package
run: cmake --build . --target package --verbose
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
@@ -171,14 +190,16 @@ jobs:
uses: actions/checkout@v4
- name: run VM
uses: cross-platform-actions/action@v0.21.0
uses: cross-platform-actions/action@v0.21.1
with:
operating_system: freebsd
version: '13.2'
run: |
uname -a
sudo pkg update
sudo pkg install -y cmake git pkgconf binutils pciutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd pulseaudio
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
cmake --build . --target package
cmake --build . --target package --verbose
./fastfetch --list-features
time ./fastfetch -c presets/ci
time ./fastfetch -c presets/ci --format json
@@ -215,19 +236,11 @@ jobs:
- name: print msys version
run: uname -a
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/clang64/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
run: cmake --build . --verbose
- name: copy necessary dlls
run: cp /clang64/bin/{OpenCL,vulkan-1}.dll .
@@ -294,7 +307,7 @@ jobs:
run: env PKG_CONFIG_PATH=/clang32/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
- name: build project
run: cmake --build .
run: cmake --build . --verbose
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
+32
View File
@@ -1,3 +1,35 @@
# 2.2.3
Features:
* Update the latest mac models (Host, macOS)
Bugfixes:
* Fix local ips detection on Android. Regression from `2.0.0` (LocalIP, Android)
* Fix terminal detection on NixOS (Terminal)
# 2.2.2
Changes:
* `--percent-type` now defaults to 9 (colored percentage numbers)
* `fastfetch` now prints LocalIp module by default
Features:
* LocalIP module now prints netmask in CIDR format for IPv4 (LocalIP)
* Bios module now detects system firmware type (Bios)
* Improve detection of `Battery`
* Detect cycle count on supported platforms
* Detect temperature on Linux when supported
* Status detection on macOS has been adjusted to be consistant with other platforms
* Linux binaries are built with imagemagick7 support
Bugfixes:
* Fix unitialized variables (#609)
* Fix spelling of `--preserve-aspect-ratio` (#614)
Logos:
* Update NixOS_small
# 2.2.1
Hotfix release for #606
+6 -9
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 2.2.1
VERSION 2.2.3
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
@@ -234,14 +234,11 @@ endif()
function(fastfetch_load_raw_text FILENAME OUTVAR)
file(READ "${FILENAME}" TEMP)
string(REGEX REPLACE "\n$" "" TEMP "${TEMP}") # Remove trailing newline
string(JSON TEMP SET "{}" "${TEMP}" "0") # Encode raw strings using JSON_SET
string(REGEX REPLACE "^\\{[ \t\r\n]*" "" TEMP "${TEMP}") # Remove JSON braces
string(REGEX REPLACE "[ \t\r\n]*:[ \t\r\n]*0[ \t\r\n]*\\}$" "" TEMP "${TEMP}") # Remove trailing ` : 0 }`
if(NOT "${TEMP}" MATCHES "^\"[^\n]*\"")
message(FATAL_ERROR "Internal error: unexpected output: '${TEMP}'")
endif()
set(${OUTVAR} "${TEMP}" PARENT_SCOPE)
string(REGEX REPLACE "\n$" "" TEMP "${TEMP}") # Remove trailing newline
string(REPLACE "\\" "\\\\" TEMP "${TEMP}") # Escape backslashes
string(REPLACE "\n" "\\n" TEMP "${TEMP}") # Replace newlines with \n
string(REPLACE "\"" "\\\"" TEMP "${TEMP}") # Replace quotes with \"
set(${OUTVAR} "\"${TEMP}\"" PARENT_SCOPE)
endfunction(fastfetch_load_raw_text)
file(GLOB LOGO_FILES "src/logo/ascii/*.txt")
+1 -1
View File
@@ -62,7 +62,7 @@ See Wiki: https://github.com/fastfetch-cli/fastfetch/wiki/Building
* Run it with [all supported modules](https://github.com/fastfetch-cli/fastfetch/wiki/Support+Status#available-modules) and find what you interest: `fastfetch -c all.jsonc`
* Find all data that fastfetch detects: `fastfetch -s <module> --format json`
* Display help messages: `fastfetch --help`
* Generate config file based on command line arguments: `fastfetch --arg1 --arg2 --mirgrate-config`
* Generate config file based on command line arguments: `fastfetch --arg1 --arg2 --migrate-config`
## Customization
+2 -2
View File
@@ -156,7 +156,7 @@
"description": "Whether to print the remaining logo, if it has more lines than modules to display",
"default": false
},
"preserveAspectRadio": {
"preserveAspectRatio": {
"type": "boolean",
"description": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol",
"default": false
@@ -415,7 +415,7 @@
"description": "Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number",
"minimum": 0,
"maximum": 255,
"default": 1
"default": 9
},
"ndigits": {
"type": "number",
-3
View File
@@ -4,9 +4,6 @@
"type": "small"
},
"display": {
"percent": {
"type": 9
},
"separator": "\u001b[31m-> "
},
"modules": [
-3
View File
@@ -11,9 +11,6 @@
"size": {
"ndigits": 0,
"maxPrefix": "MB"
},
"percent": {
"type": 9
}
},
"modules": [
-3
View File
@@ -9,9 +9,6 @@
"charElapsed": "=",
"charTotal": "-",
"width": 13
},
"percent": {
"type": 9
}
},
"modules": [
+1 -5
View File
@@ -8,11 +8,6 @@
"top": 2
}
},
"display": {
"percent": {
"type": 9
} // colored percent number
},
"modules": [
"title",
"separator",
@@ -36,6 +31,7 @@
"gpu",
"memory",
"disk",
"localip",
"battery",
"poweradapter",
"locale",
+4 -4
View File
@@ -35,7 +35,7 @@ Logo options:
--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-preserve-aspect-ratio <?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
@@ -74,7 +74,7 @@ Display options:
--disable-linewrap <?value>: Whether to disable line wrap during the run
--hide-cursor <?value>: Whether to hide the cursor during the run
--binary-prefix <value>: Set the binary prefix to used. Must be IEC, SI or JEDEC. Default is IEC
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1
--percent-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 9
--percent-ndigits <value>: Set the number of digits to keep after the decimal point when formatting percentage numbers. Default is 0
--bar-char-elapsed <str>: Set the character to use in elapsed part. Default is '■'
--bar-char-total <str>: Set the character to use in total part. Default is '-'
@@ -162,10 +162,10 @@ Module specific options:
--localip-show-mac <?value>: Show mac addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--localip-name-prefix <str>: Show interfaces with given interface name prefix only. Default is empty
--localip-default-route-only <?value>: Show the interface that is used for default routing only. Default is true
--localip-default-route-only <?value>: Show the interface that is used for default routing only. Default is true on non-android platforms
--localip-compact <?value>: Show all IPs in one line. Default is false
--netio-name-prefix <str>: Show interfaces with given name prefix only. Default is empty
--netio-default-route-only <?value>: Show the interfac that is used for default routing only. Default is true
--netio-default-route-only <?value>: Show the interfac that is used for default routing only. Default is true on non-android platforms
--publicip-timeout <num>: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--publicip-url <str>: The URL of public IP detection server to be used.
--weather-location <str>: Set the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`).
+1 -1
View File
@@ -1 +1 @@
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Locale:Break:Colors
Title:Separator:OS:Host:Kernel:Uptime:Packages:Shell:Display:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Swap:Disk:LocalIp:Battery:PowerAdapter:Locale:Break:Colors
+1
View File
@@ -15,6 +15,7 @@ typedef struct FFBatteryResult
double capacity;
FFstrbuf status;
double temperature;
uint32_t cycleCount;
} FFBatteryResult;
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results);
+1
View File
@@ -35,6 +35,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results)
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
+30 -29
View File
@@ -5,16 +5,6 @@
#include <IOKit/IOKitLib.h>
static double detectBatteryTemp(void)
{
double result = 0;
if(ffDetectCoreTemps(FF_TEMP_BATTERY, &result))
return FF_BATTERY_TEMP_UNSET;
return result;
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
{
io_iterator_t iterator;
@@ -24,7 +14,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
io_registry_entry_t registryEntry;
while((registryEntry = IOIteratorNext(iterator)) != 0)
{
CFMutableDictionaryRef properties;
FF_CFTYPE_AUTO_RELEASE CFMutableDictionaryRef properties = NULL;
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
{
IOObjectRelease(registryEntry);
@@ -35,7 +25,13 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
const char* error;
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->capacity = 0.0/0.0;
int currentCapacity, maxCapacity;
if ((error = ffCfDictGetInt(properties, CFSTR("MaxCapacity"), &maxCapacity)))
@@ -50,33 +46,38 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
battery->capacity = currentCapacity * 100.0 / maxCapacity;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->technology);
ffCfDictGetString(properties, CFSTR("DeviceName"), &battery->modelName);
if (!ffCfDictGetBool(properties, CFSTR("built-in"), &boolValue) && boolValue)
{
ffStrbufAppendS(&battery->manufacturer, "Apple Inc.");
ffStrbufAppendS(&battery->modelName, "Builtin");
ffStrbufAppendS(&battery->technology, "Lithium");
if (!battery->modelName.length)
ffStrbufAppendS(&battery->modelName, "Built-in");
}
ffCfDictGetInt(properties, CFSTR("CycleCount"), (int32_t*) &battery->cycleCount);
if (!ffCfDictGetBool(properties, CFSTR("ExternalConnected"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "AC connected, ");
else
ffStrbufAppendS(&battery->status, "Discharging, ");
if (!ffCfDictGetBool(properties, CFSTR("IsCharging"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Charging, ");
if (!ffCfDictGetBool(properties, CFSTR("AtCriticalLevel"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
if (options->temp)
{
ffStrbufAppendS(&battery->manufacturer, "Unknown");
ffStrbufAppendS(&battery->modelName, "Unknown");
ffStrbufAppendS(&battery->technology, "Unknown");
int64_t temp;
if (!ffCfDictGetInt64(properties, CFSTR("Temperature"), &temp))
battery->temperature = (double) temp / 10 - 273.15;
else
ffDetectCoreTemps(FF_TEMP_BATTERY, &battery->temperature);
}
ffStrbufInit(&battery->status);
if (!ffCfDictGetBool(properties, CFSTR("FullyCharged"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Fully charged");
else if (!ffCfDictGetBool(properties, CFSTR("IsCharging"), &boolValue) && boolValue)
ffStrbufAppendS(&battery->status, "Charging");
else
ffStrbufAppendS(&battery->status, "");
battery->temperature = options->temp ? detectBatteryTemp() : FF_BATTERY_TEMP_UNSET;
CFRelease(properties);
IOObjectRelease(registryEntry);
}
+1
View File
@@ -34,6 +34,7 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
FFBatteryResult* battery = ffListAdd(results);
battery->temperature = FF_BATTERY_TEMP_UNSET;
battery->cycleCount = 0;
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->status);
+24 -7
View File
@@ -1,11 +1,11 @@
#include "fastfetch.h"
#include "common/io/io.h"
#include "battery.h"
#include "common/io/io.h"
#include "detection/temps/temps_linux.h"
#include "util/stringUtils.h"
#include <dirent.h>
static void parseBattery(FFstrbuf* dir, FFlist* results)
static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* options, FFlist* results)
{
uint32_t dirLength = dir->length;
@@ -65,7 +65,26 @@ static void parseBattery(FFstrbuf* dir, FFlist* results)
ffReadFileBuffer(dir->chars, &result->status);
ffStrbufSubstrBefore(dir, dirLength);
ffStrbufAppendS(dir, "/cycle_count");
ffReadFileBuffer(dir->chars, &testBatteryBuffer);
ffStrbufSubstrBefore(dir, dirLength);
if(dir->length)
result->cycleCount = (uint32_t) ffStrbufToUInt(&testBatteryBuffer, 0);
result->temperature = FF_BATTERY_TEMP_UNSET;
if (options->temp)
{
const FFlist* tempsResult = ffDetectTemps();
FF_LIST_FOR_EACH(FFTempValue, value, *tempsResult)
{
if (ffStrbufEqualS(&value->name, id))
{
result->temperature = value->value;
break;
}
}
}
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
@@ -84,7 +103,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
uint32_t baseDirLength = baseDir.length;
DIR* dirp = opendir(baseDir.chars);
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir.chars);
if(dirp == NULL)
return "opendir(batteryDir) == NULL";
@@ -95,12 +114,10 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
continue;
ffStrbufAppendS(&baseDir, entry->d_name);
parseBattery(&baseDir, results);
parseBattery(&baseDir, entry->d_name, options, results);
ffStrbufSubstrBefore(&baseDir, baseDirLength);
}
closedir(dirp);
if(results->length == 0)
return "batteryDir doesn't contain any battery folder";
+133 -124
View File
@@ -30,137 +30,146 @@ static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
SetupDiDestroyDeviceInfoList(*hdev);
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results)
{
if(options->useSetupApi)
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(hdev == INVALID_HANDLE_VALUE)
return "SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY) failed";
SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) };
for(DWORD idev = 0; SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did); idev++)
{
//https://learn.microsoft.com/en-us/windows/win32/power/enumerating-battery-devices
HDEVINFO hdev __attribute__((__cleanup__(wrapSetupDiDestroyDeviceInfoList))) =
SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if(hdev == INVALID_HANDLE_VALUE)
return "SetupDiGetClassDevsW(&GUID_DEVCLASS_BATTERY) failed";
DWORD cbRequired = 0;
SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer
SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired);
if(!pdidd)
break; //Out of memory
pdidd->cbSize = sizeof(*pdidd);
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
continue;
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
DWORD dwWait = 0;
DWORD dwOut;
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_TAG, &dwWait, sizeof(dwWait), &bqi.BatteryTag, sizeof(bqi.BatteryTag), &dwOut, NULL) && bqi.BatteryTag)
continue;
BATTERY_INFORMATION bi = {0};
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL))
continue;
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
continue;
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
ffStrbufInitS(&battery->technology, "Lead Acid");
else if(memcmp(bi.Chemistry, "LION", 4) == 0 || memcmp(bi.Chemistry, "Li-I", 4) == 0)
ffStrbufInitS(&battery->technology, "Lithium Ion");
else if(memcmp(bi.Chemistry, "NiCd", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Cadmium");
else if(memcmp(bi.Chemistry, "NiMH", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Metal Hydride");
else if(memcmp(bi.Chemistry, "NiZn", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Zinc");
else if(memcmp(bi.Chemistry, "RAM\0", 4) == 0)
ffStrbufInitS(&battery->technology, "Rechargeable Alkaline-Manganese");
else
ffStrbufInitS(&battery->technology, "Unknown");
SP_DEVICE_INTERFACE_DATA did = { .cbSize = sizeof(did) };
for(DWORD idev = 0; SetupDiEnumDeviceInterfaces(hdev, NULL, &GUID_DEVCLASS_BATTERY, idev, &did); idev++)
{
DWORD cbRequired = 0;
SetupDiGetDeviceInterfaceDetailW(hdev, &did, NULL, 0, &cbRequired, NULL); //Fail with not enough buffer
SP_DEVICE_INTERFACE_DETAIL_DATA_W* FF_AUTO_FREE pdidd = (SP_DEVICE_INTERFACE_DETAIL_DATA_W*)malloc(cbRequired);
if(!pdidd)
break; //Out of memory
pdidd->cbSize = sizeof(*pdidd);
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
continue;
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hBattery == INVALID_HANDLE_VALUE)
continue;
BATTERY_QUERY_INFORMATION bqi = { .InformationLevel = BatteryInformation };
DWORD dwWait = 0;
DWORD dwOut;
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_TAG, &dwWait, sizeof(dwWait), &bqi.BatteryTag, sizeof(bqi.BatteryTag), &dwOut, NULL) && bqi.BatteryTag)
continue;
BATTERY_INFORMATION bi = {0};
if(!DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &bi, sizeof(bi), &dwOut, NULL))
continue;
if(!(bi.Capabilities & BATTERY_SYSTEM_BATTERY))
continue;
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
if(memcmp(bi.Chemistry, "PbAc", 4) == 0)
ffStrbufInitS(&battery->technology, "Lead Acid");
else if(memcmp(bi.Chemistry, "LION", 4) == 0 || memcmp(bi.Chemistry, "Li-I", 4) == 0)
ffStrbufInitS(&battery->technology, "Lithium Ion");
else if(memcmp(bi.Chemistry, "NiCd", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Cadmium");
else if(memcmp(bi.Chemistry, "NiMH", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Metal Hydride");
else if(memcmp(bi.Chemistry, "NiZn", 4) == 0)
ffStrbufInitS(&battery->technology, "Nickel Zinc");
else if(memcmp(bi.Chemistry, "RAM\0", 4) == 0)
ffStrbufInitS(&battery->technology, "Rechargeable Alkaline-Manganese");
else
ffStrbufInitS(&battery->technology, "Unknown");
{
ffStrbufInit(&battery->modelName);
bqi.InformationLevel = BatteryDeviceName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->modelName, name);
}
{
ffStrbufInit(&battery->manufacturer);
bqi.InformationLevel = BatteryManufactureName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->manufacturer, name);
}
battery->temperature = 0.0/0.0;
if(options->temp)
{
bqi.InformationLevel = BatteryTemperature;
ULONG temp;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &temp, sizeof(temp), &dwOut, NULL))
battery->temperature = temp;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY)
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
else
battery->capacity = 0;
ffStrbufInit(&battery->status);
if(bs.PowerState & BATTERY_POWER_ON_LINE)
ffStrbufAppendS(&battery->status, "AC Connected, ");
if(bs.PowerState & BATTERY_DISCHARGING)
ffStrbufAppendS(&battery->status, "Discharging, ");
if(bs.PowerState & BATTERY_CHARGING)
ffStrbufAppendS(&battery->status, "Charging");
if(bs.PowerState & BATTERY_CRITICAL)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
}
else
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->temperature = 0.0/0.0;
bqi.InformationLevel = BatteryDeviceName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->modelName, name);
}
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
{
ffStrbufAppendS(&battery->status, "AC Connected");
if(info.Charging)
ffStrbufAppendS(&battery->status, ", Charging");
}
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
{
ffStrbufInit(&battery->manufacturer);
bqi.InformationLevel = BatteryManufactureName;
wchar_t name[64];
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), name, sizeof(name), &dwOut, NULL))
ffStrbufSetWS(&battery->manufacturer, name);
}
battery->cycleCount = bi.CycleCount;
battery->temperature = 0.0/0.0;
if(options->temp)
{
bqi.InformationLevel = BatteryTemperature;
ULONG temp;
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_INFORMATION, &bqi, sizeof(bqi), &temp, sizeof(temp), &dwOut, NULL))
battery->temperature = temp;
}
{
BATTERY_STATUS bs;
BATTERY_WAIT_STATUS bws = { .BatteryTag = bqi.BatteryTag };
if(DeviceIoControl(hBattery, IOCTL_BATTERY_QUERY_STATUS, &bws, sizeof(bws), &bs, sizeof(bs), &dwOut, NULL) && bs.Capacity != BATTERY_UNKNOWN_CAPACITY)
battery->capacity = bs.Capacity * 100.0 / bi.FullChargedCapacity;
else
battery->capacity = 0;
ffStrbufInit(&battery->status);
if(bs.PowerState & BATTERY_POWER_ON_LINE)
ffStrbufAppendS(&battery->status, "AC Connected, ");
if(bs.PowerState & BATTERY_DISCHARGING)
ffStrbufAppendS(&battery->status, "Discharging, ");
if(bs.PowerState & BATTERY_CHARGING)
ffStrbufAppendS(&battery->status, "Charging, ");
if(bs.PowerState & BATTERY_CRITICAL)
ffStrbufAppendS(&battery->status, "Critical, ");
ffStrbufTrimRight(&battery->status, ' ');
ffStrbufTrimRight(&battery->status, ',');
}
}
return NULL;
}
static const char* detectWithNtApi(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results)
{
SYSTEM_BATTERY_STATE info;
if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent)
{
FFBatteryResult* battery = (FFBatteryResult*)ffListAdd(results);
ffStrbufInit(&battery->modelName);
ffStrbufInit(&battery->manufacturer);
ffStrbufInit(&battery->technology);
ffStrbufInit(&battery->status);
battery->temperature = 0.0/0.0;
battery->cycleCount = 0;
battery->capacity = info.RemainingCapacity * 100.0 / info.MaxCapacity;
if(info.AcOnLine)
{
ffStrbufAppendS(&battery->status, "AC Connected");
if(info.Charging)
ffStrbufAppendS(&battery->status, ", Charging");
}
else if(info.Discharging)
ffStrbufAppendS(&battery->status, "Discharging");
return NULL;
}
return "NtPowerInformation(SystemBatteryState) failed";
}
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
{
return true
? detectWithSetupApi(options, results)
: detectWithNtApi(options, results);
}
+1
View File
@@ -11,6 +11,7 @@ typedef struct FFBiosResult
FFstrbuf release;
FFstrbuf vendor;
FFstrbuf version;
FFstrbuf type;
} FFBiosResult;
const char* ffDetectBios(FFBiosResult* bios);
+2
View File
@@ -9,5 +9,7 @@ const char* ffDetectBios(FFBiosResult* bios)
if (ffStrbufIgnCaseEqualS(&bios->version, "unknown"))
ffStrbufClear(&bios->version);
ffStrbufSetStatic(&bios->type, "Bootloader");
return NULL;
}
+3 -3
View File
@@ -23,7 +23,7 @@ const char* ffDetectBios(FFBiosResult* bios)
ffCfDictGetString(properties, CFSTR("vendor"), &bios->vendor);
ffCfDictGetString(properties, CFSTR("version"), &bios->version);
ffCfDictGetString(properties, CFSTR("release-date"), &bios->date);
ffStrbufAppendS(&bios->release, "Efi");
ffStrbufSetStatic(&bios->type, "UEFI");
CFRelease(properties);
IOObjectRelease(registryEntry);
@@ -54,12 +54,12 @@ const char* ffDetectBios(FFBiosResult* bios)
uint32_t index = ffStrbufFirstIndexC(&bios->version, '-');
if (index != bios->version.length)
{
ffStrbufAppendNS(&bios->release, index, bios->version.chars);
ffStrbufAppendNS(&bios->type, index, bios->version.chars);
ffStrbufRemoveSubstr(&bios->version, 0, index + 1);
}
else
{
ffStrbufAppendS(&bios->release, "iBoot");
ffStrbufSetStatic(&bios->type, "iBoot");
}
CFRelease(properties);
}
+2
View File
@@ -1,6 +1,7 @@
#include "bios.h"
#include "common/settings.h"
#include "common/sysctl.h"
#include "util/smbiosHelper.h"
const char* ffDetectBios(FFBiosResult* result)
@@ -13,5 +14,6 @@ const char* ffDetectBios(FFBiosResult* result)
ffCleanUpSmbiosValue(&result->vendor);
ffSettingsGetFreeBSDKenv("smbios.bios.version", &result->version);
ffCleanUpSmbiosValue(&result->version);
ffSysctlGetString("machdep.bootmethod", &result->type);
return NULL;
}
+4
View File
@@ -23,5 +23,9 @@ const char* ffDetectBios(FFBiosResult* bios)
getSmbiosValue("/sys/devices/virtual/dmi/id/bios_release", "/sys/class/dmi/id/bios_release", &bios->release);
getSmbiosValue("/sys/devices/virtual/dmi/id/bios_vendor", "/sys/class/dmi/id/bios_vendor", &bios->vendor);
getSmbiosValue("/sys/devices/virtual/dmi/id/bios_version", "/sys/class/dmi/id/bios_version", &bios->version);
if (ffPathExists("/sys/firmware/efi", FF_PATHTYPE_DIRECTORY) || ffPathExists("/sys/firmware/acpi/tables/UEFI", FF_PATHTYPE_FILE))
ffStrbufSetStatic(&bios->type, "UEFI");
else
ffStrbufSetStatic(&bios->type, "BIOS");
return NULL;
}
+37
View File
@@ -2,6 +2,30 @@
#include "util/windows/registry.h"
#include "util/smbiosHelper.h"
#include <ntstatus.h>
#include <winternl.h>
typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION
{
GUID BootIdentifier;
FIRMWARE_TYPE FirmwareType;
union
{
ULONGLONG BootFlags;
struct
{
ULONGLONG DbgMenuOsSelection : 1; // REDSTONE4
ULONGLONG DbgHiberBoot : 1;
ULONGLONG DbgSoftBoot : 1;
ULONGLONG DbgMeasuredLaunch : 1;
ULONGLONG DbgMeasuredLaunchCapable : 1; // 19H1
ULONGLONG DbgSystemHiveReplace : 1;
ULONGLONG DbgMeasuredLaunchSmmProtections : 1;
ULONGLONG DbgMeasuredLaunchSmmLevel : 7; // 20H1
};
};
} SYSTEM_BOOT_ENVIRONMENT_INFORMATION;
const char* ffDetectBios(FFBiosResult* bios)
{
FF_HKEY_AUTO_DESTROY hKey = NULL;
@@ -24,5 +48,18 @@ const char* ffDetectBios(FFBiosResult* bios)
)
ffStrbufAppendF(&bios->release, "%u.%u", (unsigned)major, (unsigned)minor);
// Same as GetFirmwareType, but support (?) Windows 7
// https://ntdoc.m417z.com/system_information_class
SYSTEM_BOOT_ENVIRONMENT_INFORMATION sbei;
if (NT_SUCCESS(NtQuerySystemInformation(90 /*SystemBootEnvironmentInformation*/, &sbei, sizeof(sbei), NULL)))
{
switch (sbei.FirmwareType)
{
case FirmwareTypeBios: ffStrbufSetStatic(&bios->type, "BIOS"); break;
case FirmwareTypeUefi: ffStrbufSetStatic(&bios->type, "UEFI"); break;
default: break;
}
}
return NULL;
}
+2 -4
View File
@@ -83,12 +83,10 @@ static double getFrequency(const char* info, const char* scaling)
static double detectCPUTemp(void)
{
const FFTempsResult* temps = ffDetectTemps();
const FFlist* tempsResult = ffDetectTemps();
for(uint32_t i = 0; i < temps->values.length; i++)
FF_LIST_FOR_EACH(FFTempValue, value, *tempsResult)
{
FFTempValue* value = ffListGet(&temps->values, i);
if(
ffStrbufFirstIndexS(&value->name, "cpu") < value->name.length ||
ffStrbufCompS(&value->name, "k10temp") == 0 ||
+2 -4
View File
@@ -138,12 +138,10 @@ static void pciDetectDriverName(FFGPUResult* gpu, PCIData* pci, struct pci_dev*
FF_MAYBE_UNUSED static void pciDetectTemp(FFGPUResult* gpu, struct pci_dev* device)
{
const FFTempsResult* tempsResult = ffDetectTemps();
const FFlist* tempsResult = ffDetectTemps();
for(uint32_t i = 0; i < tempsResult->values.length; i++)
FF_LIST_FOR_EACH(FFTempValue, tempValue, *tempsResult)
{
FFTempValue* tempValue = ffListGet(&tempsResult->values, i);
//The kernel exposes the device class multiplied by 256 for some reason
if(tempValue->deviceClass == device->device_class * 256)
{
+9
View File
@@ -108,6 +108,15 @@ static const char* getProductName(const FFstrbuf* hwModel)
else if(ffStrbufStartsWithS(hwModel, "Mac"))
{
const char* version = hwModel->chars + strlen("Mac");
if(ffStrEquals(version, "15,3")) return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)";
if(ffStrEquals(version, "15,4")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)";
if(ffStrEquals(version, "15,5")) return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)";
if(ffStrEquals(version, "15,6") ||
ffStrEquals(version, "15,8") ||
ffStrEquals(version, "15,10")) return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)";
if(ffStrEquals(version, "15,7") ||
ffStrEquals(version, "15,9") ||
ffStrEquals(version, "15,11")) return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)";
if(ffStrEquals(version, "14,15")) return "MacBook Air (15-inch, M2, 2023)";
if(ffStrEquals(version, "14,14")) return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)";
if(ffStrEquals(version, "14,13")) return "Mac Studio (M2 Max, 2023, Two USB-C front ports)";
+10 -1
View File
@@ -80,8 +80,17 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
continue;
struct sockaddr_in* ipv4 = (struct sockaddr_in*) ifa->ifa_addr;
char addressBuffer[INET_ADDRSTRLEN];
char addressBuffer[INET_ADDRSTRLEN + 4];
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask;
int cidr = __builtin_popcount(inet_netof(netmask->sin_addr));
if (cidr != 0)
{
size_t len = strlen(addressBuffer);
snprintf(addressBuffer + len, 4, "/%d", cidr);
}
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET, isDefaultRoute);
}
else if (ifa->ifa_addr->sa_family == AF_INET6)
+8 -1
View File
@@ -105,8 +105,15 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
if (ifa->Address.lpSockaddr->sa_family == AF_INET)
{
SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr;
char addressBuffer[INET_ADDRSTRLEN];
char addressBuffer[INET_ADDRSTRLEN + 4];
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
if (ifa->OnLinkPrefixLength)
{
size_t len = strlen(addressBuffer);
snprintf(addressBuffer + len, 4, "/%u", (unsigned) ifa->OnLinkPrefixLength);
}
addNewIp(results, name, addressBuffer, AF_INET, newIp, isDefaultRoute);
newIp = false;
}
+1 -6
View File
@@ -11,17 +11,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.memsize";
uint32_t pagesize;
length = sizeof(pagesize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pagesize, &length, NULL, 0))
return "Failed to read hw.pagesize";
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
vm_statistics64_data_t vmstat;
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
return "Failed to read host_statistics64";
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * pagesize;
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * instance.state.platform.pageSize;
return NULL;
}
+1 -6
View File
@@ -7,17 +7,12 @@ const char* ffDetectMemory(FFMemoryResult* ram)
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
return "Failed to read hw.physmem";
uint32_t pageSize;
length = sizeof(pageSize);
if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pageSize, &length, NULL, 0))
return "Failed to read hw.pagesize";
// vm.stats.vm.* are int values
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * pageSize;
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.pageSize;
return NULL;
}
+4 -5
View File
@@ -7,9 +7,6 @@
const char* ffDetectSwap(FFSwapResult* swap)
{
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
ULONG size = sizeof(SYSTEM_PAGEFILE_INFORMATION);
SYSTEM_PAGEFILE_INFORMATION* FF_AUTO_FREE pstart = (SYSTEM_PAGEFILE_INFORMATION*)malloc(size);
while(true)
@@ -24,8 +21,10 @@ const char* ffDetectSwap(FFSwapResult* swap)
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
break;
}
swap->bytesUsed = (uint64_t)pstart->TotalUsed * sysInfo.dwPageSize;
swap->bytesTotal = (uint64_t)pstart->CurrentSize * sysInfo.dwPageSize;
uint32_t pageSize = instance.state.platform.pageSize;
swap->bytesUsed = (uint64_t)pstart->TotalUsed * pageSize;
swap->bytesTotal = (uint64_t)pstart->CurrentSize * pageSize;
return NULL;
}
+7 -11
View File
@@ -41,23 +41,21 @@ static bool parseHwmonDir(FFstrbuf* dir, FFTempValue* value)
return value->name.length > 0 || value->deviceClass > 0;
}
const FFTempsResult* ffDetectTemps(void)
const FFlist* ffDetectTemps(void)
{
static FFTempsResult result;
static bool init = false;
static FFlist result;
if(init)
if(result.elementSize > 0)
return &result;
init = true;
ffListInitA(&result.values, sizeof(FFTempValue), 16);
ffListInitA(&result, sizeof(FFTempValue), 16);
FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64);
ffStrbufAppendS(&baseDir, "/sys/class/hwmon/");
uint32_t baseDirLength = baseDir.length;
DIR* dirp = opendir(baseDir.chars);
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir.chars);
if(dirp == NULL)
return &result;
@@ -70,19 +68,17 @@ const FFTempsResult* ffDetectTemps(void)
ffStrbufAppendS(&baseDir, entry->d_name);
ffStrbufAppendC(&baseDir, '/');
FFTempValue* temp = ffListAdd(&result.values);
FFTempValue* temp = ffListAdd(&result);
ffStrbufInit(&temp->name);
temp->deviceClass = 0;
if(!parseHwmonDir(&baseDir, temp))
{
ffStrbufDestroy(&temp->name);
--result.values.length;
--result.length;
}
ffStrbufSubstrBefore(&baseDir, baseDirLength);
}
closedir(dirp);
return &result;
}
+1 -6
View File
@@ -12,11 +12,6 @@ typedef struct FFTempValue
double value;
} FFTempValue;
typedef struct FFTempsResult
{
FFlist values; //List of FFTempValue
} FFTempsResult;
const FFTempsResult* ffDetectTemps();
const FFlist* /* List of FFTempValue */ ffDetectTemps();
#endif
@@ -361,13 +361,13 @@ const FFTerminalShellResult* ffDetectTerminalShell()
ffStrbufInitS(&result.shellPrettyName, result.shellExeName);
}
if(result.terminalExeName[0] == '.' && ffStrEndsWith(result.terminalExeName, "-wrapper"))
if(result.terminalExeName[0] == '.' && ffStrEndsWith(result.terminalExeName, "-wrapped"))
{
// For NixOS. Ref: #510 and https://github.com/NixOS/nixpkgs/pull/249428
// We use terminalProcessName when detecting version and font, overriding it for simplication
ffStrbufSetNS(
&result.terminalProcessName,
(uint32_t) (strlen(result.terminalExeName) - strlen(".-wrapper")),
(uint32_t) (strlen(result.terminalExeName) - strlen(".-wrapped")),
result.terminalExeName + 1);
}
+3 -3
View File
@@ -45,13 +45,13 @@ int main(void)
ffPrintMemory(&options->memory);
ffPrintSwap(&options->swap);
ffPrintDisk(&options->disk);
ffPrintLocalIp(&options->localIP);
// ffPrintPublicIp(&options->publicIP);
//ffPrintWifi(&options->wifi);
ffPrintBattery(&options->battery);
ffPrintPowerAdapter(&options->powerAdapter);
//ffPrintPlayer(&options->player);
//ffPrintMedia(&options->media);
//ffPrintLocalIp(&options->localIp);
//ffPrintPublicIp(&options->publicIp);
//ffPrintWifi(&options->wifi);
//ffPrintCPUUsage(&options->cpuUsage);
ffPrintLocale(&options->locale);
//ffPrintDateTime(&options->dateTime);
+7
View File
@@ -0,0 +1,7 @@
$1 \\ $2\\ //
$1 ==\\__$2\\/ $1//
$2 // $2\\$1//
$2==// $1//==
$2 //$1\\$2___$1//
$2// $1/\\ $2\\==
$1// \\ $2\\
+7 -7
View File
@@ -1,7 +1,7 @@
\\ \\ //
==\\__\\/ //
// \\//
==// //==
//\\___//
// /\\ \\==
// \\ \\
$1 ▗▄ $2▗▄ ▄▖
$1 ▄▄🬸█▄▄▄$2🬸█▛ $1▃
$2 ▟▛ ▜$1▃▟🬕
$2🬋🬋🬫█ $1█🬛🬋🬋
$2 🬷▛🮃$1▙ ▟▛
$2 🮃 $1▟█🬴$2▀▀▀█🬴▀▀
$1 ▝▀ ▀▘ $2▀▘
+10 -17
View File
@@ -2596,48 +2596,41 @@ static const FFlogo N[] = {
},
// NixOS
{
.names = {"NixOS", "nix", "nixos-linux", "nix-linux", "nix-os", "nix_os", "nix_os_linux"},
.names = {"NixOS", "nix", "nixos-linux", "nix-linux"},
.lines = FASTFETCH_DATATEXT_LOGO_NIXOS,
.colors = {
FF_COLOR_FG_BLUE,
FF_COLOR_FG_CYAN,
},
.colorKeys = FF_COLOR_FG_CYAN,
.colorTitle = FF_COLOR_FG_BLUE,
},
// NixOS_small
// NixOSSmall
{
.names = {"NixOS_small", "nix_small"},
.names = {"NixOS_small", "nix_small", "nixos-linux-small", "nix-linux-small"},
.lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL,
.colors = {
FF_COLOR_FG_BLUE,
FF_COLOR_FG_CYAN,
},
.colorKeys = FF_COLOR_FG_CYAN,
.colorTitle = FF_COLOR_FG_BLUE,
},
// NixOsOld
// NixOSOld
{
.names = {"nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old"},
.names = {"nixos_old", "nix-old", "nixos-old", "nix_old"},
.type = FF_LOGO_LINE_TYPE_ALTER_BIT,
.lines = FASTFETCH_DATATEXT_LOGO_NIXOS_OLD,
.colors = {
FF_COLOR_FG_BLUE,
FF_COLOR_FG_CYAN,
},
.colorKeys = FF_COLOR_FG_CYAN,
.colorTitle = FF_COLOR_FG_BLUE,
},
// NixOsSmall
// NixOsOldSmall
{
.names = {"nixos_small", "nix-small", "nixos-small", "nix_small", "nix-os-small", "nix_os_small"},
.type = FF_LOGO_LINE_TYPE_SMALL_BIT,
.lines = FASTFETCH_DATATEXT_LOGO_NIXOS_SMALL,
.names = {"nixos_old_small", "nix-old-small", "nixos-old-small", "nix_old_small"},
.type = FF_LOGO_LINE_TYPE_SMALL_BIT | FF_LOGO_LINE_TYPE_ALTER_BIT,
.lines = FASTFETCH_DATATEXT_LOGO_NIXOS_OLD_SMALL,
.colors = {
FF_COLOR_FG_BLUE,
FF_COLOR_FG_CYAN,
},
.colorKeys = FF_COLOR_FG_BLUE,
.colorTitle = FF_COLOR_FG_BLUE,
},
// NetBSD
{
+37 -19
View File
@@ -11,27 +11,45 @@
#include <windows.h>
#endif
// https://github.com/kostya/benchmarks/blob/master/base64/test-nolib.c#L145
static void base64EncodeRaw(uint32_t size, const char *str, uint32_t *out_size, char *output)
{
static const char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *out = output;
const char *ends = str + (size - size % 3);
while (str != ends) {
uint32_t n = __builtin_bswap32(*(uint32_t*) str);
*out++ = chars[(n >> 26) & 63];
*out++ = chars[(n >> 20) & 63];
*out++ = chars[(n >> 14) & 63];
*out++ = chars[(n >> 8) & 63];
str += 3;
}
if (size % 3 == 1) {
uint64_t n = (uint64_t)*str << 16;
*out++ = chars[(n >> 18) & 63];
*out++ = chars[(n >> 12) & 63];
*out++ = '=';
*out++ = '=';
} else if (size % 3 == 2) {
uint64_t n = (uint64_t)*str++ << 16;
n |= (uint64_t)*str << 8;
*out++ = chars[(n >> 18) & 63];
*out++ = chars[(n >> 12) & 63];
*out++ = chars[(n >> 6) & 63];
*out++ = '=';
}
*out = '\0';
*out_size = (uint32_t) (out - output);
}
static FFstrbuf base64Encode(const FFstrbuf* in)
{
const char* base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
FFstrbuf out = ffStrbufCreateA(10 + in->length * 4 / 3);
base64EncodeRaw(in->length, in->chars, &out.length, out.chars);
assert(out.length < out.allocated);
FFstrbuf out = ffStrbufCreateA(8 * (1 + in->length / 6));
unsigned val = 0;
int valb = -6;
for (uint32_t i = 0; i < in->length; ++i)
{
unsigned char c = (unsigned char) in->chars[i];
val = (val << 8) + c;
valb += 8;
while (valb >= 0)
{
ffStrbufAppendC(&out, base64Chars[(val>>valb)&0x3F]);
valb -= 6;
}
}
if (valb > -6) ffStrbufAppendC(&out, base64Chars[((val<<8)>>(valb+8))&0x3F]);
while (out.length % 4) ffStrbufAppendC(&out, '=');
return out;
}
@@ -95,7 +113,7 @@ static bool printImageIterm(void)
ffStrbufAppendF(&buf, "\e]1337;File=inline=1;width=%u;height=%u;preserveAspectRatio=%u:%s\a\n",
(unsigned) options->width,
(unsigned) options->height,
(unsigned) options->preserveAspectRadio,
(unsigned) options->preserveAspectRatio,
base64.chars
);
+6 -2
View File
@@ -6,7 +6,7 @@
#include "modules/battery/battery.h"
#include "util/stringUtils.h"
#define FF_BATTERY_NUM_FORMAT_ARGS 5
#define FF_BATTERY_NUM_FORMAT_ARGS 7
static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index)
{
@@ -70,6 +70,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status},
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature},
{FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount},
});
}
}
@@ -215,6 +216,7 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
yyjson_mut_obj_add_strbuf(doc, obj, "status", &battery->status);
yyjson_mut_obj_add_strbuf(doc, obj, "technology", &battery->technology);
yyjson_mut_obj_add_real(doc, obj, "temperature", battery->temperature);
yyjson_mut_obj_add_uint(doc, obj, "cycleCount", battery->cycleCount);
}
FF_LIST_FOR_EACH(FFBatteryResult, battery, results)
@@ -233,7 +235,9 @@ void ffPrintBatteryHelpFormat(void)
"Battery model",
"Battery technology",
"Battery capacity (percentage)",
"Battery status"
"Battery status",
"Battery temperature",
"Battery cycle count",
});
}
+36 -9
View File
@@ -4,7 +4,7 @@
#include "modules/bios/bios.h"
#include "util/stringUtils.h"
#define FF_BIOS_NUM_FORMAT_ARGS 4
#define FF_BIOS_NUM_FORMAT_ARGS 5
void ffPrintBios(FFBiosOptions* options)
{
@@ -13,9 +13,12 @@ void ffPrintBios(FFBiosOptions* options)
ffStrbufInit(&bios.release);
ffStrbufInit(&bios.vendor);
ffStrbufInit(&bios.version);
ffStrbufInit(&bios.type);
const char* error = ffDetectBios(&bios);
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
if(error)
{
ffPrintError(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
@@ -28,21 +31,40 @@ void ffPrintBios(FFBiosOptions* options)
goto exit;
}
if(options->moduleArgs.outputFormat.length == 0)
if(options->moduleArgs.key.length == 0)
{
ffPrintLogoAndKey(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufWriteTo(&bios.version, stdout);
if (bios.release.length)
printf(" (%s)", bios.release.chars);
putchar('\n');
if(bios.type.length == 0)
ffStrbufSetStatic(&bios.type, "Unknown");
else if (ffStrbufIgnCaseEqualS(&bios.type, "BIOS"))
ffStrbufSetStatic(&bios.type, "Legacy");
ffStrbufSetF(&key, FF_BIOS_MODULE_NAME " (%s)", bios.type.chars);
}
else
{
ffPrintFormat(FF_BIOS_MODULE_NAME, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) {
ffStrbufClear(&key);
ffParseFormatString(&key, &options->moduleArgs.key, 3, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type},
});
}
if(options->moduleArgs.outputFormat.length == 0)
{
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufWriteTo(&bios.version, stdout);
if (bios.release.length)
printf(" (%s)\n", bios.release.chars);
else
putchar('\n');
}
else
{
ffPrintFormat(key.chars, 0, &options->moduleArgs, FF_BIOS_NUM_FORMAT_ARGS, (FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.date},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.release},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.version},
{FF_FORMAT_ARG_TYPE_STRBUF, &bios.type},
});
}
@@ -51,6 +73,7 @@ exit:
ffStrbufDestroy(&bios.release);
ffStrbufDestroy(&bios.vendor);
ffStrbufDestroy(&bios.version);
ffStrbufDestroy(&bios.type);
}
bool ffParseBiosCommandOptions(FFBiosOptions* options, const char* key, const char* value)
@@ -95,6 +118,7 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
ffStrbufInit(&bios.release);
ffStrbufInit(&bios.vendor);
ffStrbufInit(&bios.version);
ffStrbufInit(&bios.type);
const char* error = ffDetectBios(&bios);
@@ -115,12 +139,14 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
yyjson_mut_obj_add_strbuf(doc, obj, "release", &bios.release);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &bios.vendor);
yyjson_mut_obj_add_strbuf(doc, obj, "version", &bios.version);
yyjson_mut_obj_add_strbuf(doc, obj, "type", &bios.type);
exit:
ffStrbufDestroy(&bios.date);
ffStrbufDestroy(&bios.release);
ffStrbufDestroy(&bios.vendor);
ffStrbufDestroy(&bios.version);
ffStrbufDestroy(&bios.type);
}
void ffPrintBiosHelpFormat(void)
@@ -129,7 +155,8 @@ void ffPrintBiosHelpFormat(void)
"bios date",
"bios release",
"bios vendor",
"bios version"
"bios version",
"firmware type",
});
}
+1
View File
@@ -180,6 +180,7 @@ void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
ffGenerateCPUUsageJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->separate = false;
}
void ffDestroyCPUUsageOptions(FFCPUUsageOptions* options)
+7 -1
View File
@@ -370,7 +370,13 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options)
options->showType = FF_LOCALIP_TYPE_IPV4_BIT;
ffStrbufInit(&options->namePrefix);
options->defaultRouteOnly = true;
options->defaultRouteOnly =
#ifdef __ANDROID__
false
#else
true
#endif
;
}
void ffDestroyLocalIpOptions(FFLocalIpOptions* options)
+7 -1
View File
@@ -230,7 +230,13 @@ void ffInitNetIOOptions(FFNetIOOptions* options)
ffOptionInitModuleArg(&options->moduleArgs);
ffStrbufInit(&options->namePrefix);
options->defaultRouteOnly = true;
options->defaultRouteOnly =
#ifdef __ANDROID__
false
#else
true
#endif
;
}
void ffDestroyNetIOOptions(FFNetIOOptions* options)
+1
View File
@@ -176,6 +176,7 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m
yyjson_mut_obj_add_strbuf(doc, obj, "homeDir", &instance.state.platform.homeDir);
yyjson_mut_obj_add_strbuf(doc, obj, "exePath", &instance.state.platform.exePath);
yyjson_mut_obj_add_strbuf(doc, obj, "userShell", &instance.state.platform.userShell);
yyjson_mut_obj_add_uint(doc, obj, "pageSize", instance.state.platform.pageSize);
}
void ffPrintTitleHelpFormat(void)
+1
View File
@@ -148,6 +148,7 @@ void ffInitWMOptions(FFWMOptions* options)
ffGenerateWMJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
options->detectPlugin = false;
}
void ffDestroyWMOptions(FFWMOptions* options)
+1 -1
View File
@@ -303,7 +303,7 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
ffStrbufInitStatic(&options->barCharTotal, "-");
options->barWidth = 10;
options->barBorder = true;
options->percentType = 1;
options->percentType = 9;
options->percentNdigits = 0;
}
+7 -7
View File
@@ -15,7 +15,7 @@ void ffOptionsInitLogo(FFOptionsLogo* options)
options->paddingLeft = 0;
options->paddingRight = 4;
options->printRemaining = true;
options->preserveAspectRadio = false;
options->preserveAspectRatio = false;
options->recache = false;
options->separate = false;
@@ -113,8 +113,8 @@ logoType:
options->paddingRight = ffOptionParseUInt32(key, value);
else if(strcasecmp(subKey, "print-remaining") == 0)
options->printRemaining = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "preserve-aspect-radio") == 0)
options->preserveAspectRadio = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "preserve-aspect-ratio") == 0)
options->preserveAspectRatio = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "recache") == 0)
options->recache = ffOptionParseBoolean(value);
else if(strcasecmp(subKey, "separate") == 0)
@@ -327,9 +327,9 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
options->printRemaining = yyjson_get_bool(val);
continue;
}
else if (strcasecmp(key, "preserveAspectRadio") == 0)
else if (strcasecmp(key, "preserveAspectRatio") == 0)
{
options->preserveAspectRadio = yyjson_get_bool(val);
options->preserveAspectRatio = yyjson_get_bool(val);
continue;
}
else if (strcasecmp(key, "recache") == 0)
@@ -504,8 +504,8 @@ void ffOptionsGenerateLogoJsonConfig(FFOptionsLogo* options, yyjson_mut_doc* doc
if (options->printRemaining != defaultOptions.printRemaining)
yyjson_mut_obj_add_bool(doc, obj, "printRemaining", options->printRemaining);
if (options->preserveAspectRadio != defaultOptions.preserveAspectRadio)
yyjson_mut_obj_add_bool(doc, obj, "preserveAspectRadio", options->preserveAspectRadio);
if (options->preserveAspectRatio != defaultOptions.preserveAspectRatio)
yyjson_mut_obj_add_bool(doc, obj, "preserveAspectRatio", options->preserveAspectRatio);
if (options->recache != defaultOptions.recache)
yyjson_mut_obj_add_bool(doc, obj, "recache", options->recache);
+1 -1
View File
@@ -34,7 +34,7 @@ typedef struct FFOptionsLogo
uint32_t paddingLeft;
uint32_t paddingRight;
bool printRemaining;
bool preserveAspectRadio;
bool preserveAspectRatio;
bool recache;
bool separate;
+2
View File
@@ -22,6 +22,8 @@ typedef struct FFPlatform {
FFstrbuf systemVersion;
FFstrbuf systemArchitecture;
FFstrbuf systemDisplayVersion;
uint32_t pageSize;
} FFPlatform;
void ffPlatformInit(FFPlatform* platform);
+13
View File
@@ -10,6 +10,7 @@
#ifdef __APPLE__
#include <libproc.h>
#include <sys/sysctl.h>
#elif defined(__FreeBSD__)
#include <sys/sysctl.h>
#endif
@@ -153,6 +154,16 @@ static void getUserShell(FFPlatform* platform, const struct passwd* pwd)
ffStrbufAppendS(&platform->userShell, shell);
}
static void getPageSize(FFPlatform* platform)
{
#if defined(__FreeBSD__) || defined(__APPLE__)
size_t length = sizeof(platform->pageSize);
sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &platform->pageSize, &length, NULL, 0);
#else
platform->pageSize = (uint32_t) sysconf(_SC_PAGESIZE);
#endif
}
void ffPlatformInitImpl(FFPlatform* platform)
{
struct passwd* pwd = getpwuid(getuid());
@@ -176,4 +187,6 @@ void ffPlatformInitImpl(FFPlatform* platform)
ffStrbufAppendS(&platform->systemVersion, uts.version);
ffStrbufAppendS(&platform->systemArchitecture, uts.machine);
ffStrbufInit(&platform->systemDisplayVersion);
getPageSize(platform);
}
+5 -3
View File
@@ -183,9 +183,9 @@ static void getSystemReleaseAndVersion(FFPlatform* platform)
}
}
static void getSystemArchitecture(FFPlatform* platform)
static void getSystemArchitectureAndPageSize(FFPlatform* platform)
{
SYSTEM_INFO sysInfo = {0};
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
switch(sysInfo.wProcessorArchitecture)
@@ -215,6 +215,8 @@ static void getSystemArchitecture(FFPlatform* platform)
default:
break;
}
platform->pageSize = sysInfo.dwPageSize;
}
void ffPlatformInitImpl(FFPlatform* platform)
@@ -230,5 +232,5 @@ void ffPlatformInitImpl(FFPlatform* platform)
getUserShell(platform);
getSystemReleaseAndVersion(platform);
getSystemArchitecture(platform);
getSystemArchitectureAndPageSize(platform);
}