Skip to content

Commit

Permalink
Merge pull request #1184 from fastfetch-cli/dev
Browse files Browse the repository at this point in the history
Release: v2.21.2
  • Loading branch information
CarterLi authored Aug 14, 2024
2 parents 5df2a75 + 030f34d commit c0774b8
Show file tree
Hide file tree
Showing 357 changed files with 1,164 additions and 626 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ jobs:
run: |
uname -a
sudo pkg update
sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm libelf glib dconf dbus sqlite3-tcl xfce4-conf ImageMagick6 ImageMagick7 chafa egl libosmesa opencl ocl-icd v4l_compat
sudo pkg install -y cmake git pkgconf binutils wayland vulkan-headers vulkan-loader libxcb libXrandr libX11 libdrm libelf glib dconf dbus sqlite3-tcl xfce4-conf egl libosmesa opencl ocl-icd v4l_compat
cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
cmake --build . --target package --verbose -j4
./fastfetch --list-features
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 2.21.2

Features:
* Support `--stat <num_in_ms>` to display long running modules in yellow or red

Bugfixes:
* Fix bad Intel Arc GPU name and type detection (GPU, Linux)
* Fix uninited struct fields (GPU, Linux)
* Skip cpu model smbios detection on ARM platforms (CPU, Linux)
* Always use `CurrentControlSet` instead of `ControlSet001` when querying registry (Windows)
* Fix NVIDIA GPUs are missing in GPU detection sometimes (GPU, Windows)
* Fixing detection of `pthread_timedjoin_np` (Linux)

Logos:
* Add HyprOS
* Add GoldenDog Linux

# 2.21.1

Hotfix for a regression that breaks WM detection when running `startx` from TTY (Regression from 2.21.0, #1172 / #1162)
Expand Down
22 changes: 14 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url

project(fastfetch
VERSION 2.21.1
VERSION 2.21.2
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
Expand Down Expand Up @@ -1210,13 +1210,19 @@ if(NOT WIN32)
if(HAVE_WORDEXP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1)
endif()
CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP)
if(HAVE_PTHREAD_NP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_PTHREAD_NP=1)
endif()
check_function_exists("pthread_timedjoin_np" HAVE_TIMEDJOIN_NP)
if(HAVE_TIMEDJOIN_NP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_TIMEDJOIN_NP=1)
if(ENABLE_THREADS AND CMAKE_USE_PTHREADS_INIT)
CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP)
if(HAVE_PTHREAD_NP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_PTHREAD_NP=1)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} pthread_np.h)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} Threads::Threads)
check_function_exists("pthread_timedjoin_np" HAVE_TIMEDJOIN_NP)
if(HAVE_TIMEDJOIN_NP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_TIMEDJOIN_NP=1)
else()
message(WARNING "pthread_timedjoin_np was not found; networking timeout will not work")
endif()
endif()
endif()

Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
fastfetch (2.21.1) jammy; urgency=medium

* Update to 2.21.1

-- Carter Li <[email protected]> Fri, 09 Aug 2024 14:27:10 +0800

fastfetch (2.21.0) jammy; urgency=medium

* Update to 2.21.0
Expand Down
2 changes: 1 addition & 1 deletion debian/files
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fastfetch_2.20.0_source.buildinfo universe/utils optional
fastfetch_2.21.1_source.buildinfo universe/utils optional
14 changes: 11 additions & 3 deletions doc/json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,17 @@
"additionalProperties": false,
"properties": {
"stat": {
"type": "boolean",
"description": "Show time usage (in ms) for individual modules",
"default": false
"description": "Show time usage (in ms) for individual modules with optional threshold",
"oneOf": [
{
"type": "boolean",
"default": false
},
{
"type": "integer",
"minimum": 1
}
]
},
"pipe": {
"type": "boolean",
Expand Down
18 changes: 11 additions & 7 deletions src/common/commandoption.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "commandoption.h"
#include "common/color.h"
#include "common/printing.h"
#include "common/time.h"
#include "common/jsonconfig.h"
Expand Down Expand Up @@ -105,32 +106,35 @@ static void parseStructureCommand(
void ffPrintCommandOption(FFdata* data, yyjson_mut_doc* jsonDoc)
{
//Parse the structure and call the modules
int32_t thres = instance.config.display.stat;
uint32_t startIndex = 0;
while (startIndex < data->structure.length)
{
uint32_t colonIndex = ffStrbufNextIndexC(&data->structure, startIndex, ':');
data->structure.chars[colonIndex] = '\0';

uint64_t ms = 0;
if(instance.config.display.stat)
double ms = 0;
if(thres >= 0)
ms = ffTimeGetTick();

parseStructureCommand(data->structure.chars + startIndex, genJsonResult, jsonDoc);

if(instance.config.display.stat)
if(thres >= 0)
{
ms = ffTimeGetTick() - ms;

if (jsonDoc)
{
yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root);
yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms);
yyjson_mut_obj_add_real(jsonDoc, moduleJson, "stat", ms);
}
else
{
char str[32];
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms);
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
char str[64];
int len = snprintf(str, sizeof str, "%.3fms", ms);
if (thres > 0)
snprintf(str, sizeof str, "\e[%sm%.3fms\e[m", (ms <= thres ? FF_COLOR_FG_GREEN : ms <= 2 * thres ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_RED), ms);
printf("\e[s\e[1A\e[9999999C\e[%dD%s\e[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
}
}

Expand Down
18 changes: 11 additions & 7 deletions src/common/jsonconfig.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/color.h"
#include "common/jsonconfig.h"
#include "common/printing.h"
#include "common/io/io.h"
Expand Down Expand Up @@ -181,12 +182,13 @@ static const char* printJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc)
if (!modules) return NULL;
if (!yyjson_is_arr(modules)) return "Property 'modules' must be an array of strings or objects";

int32_t thres = instance.config.display.stat;
yyjson_val* item;
size_t idx, max;
yyjson_arr_foreach(modules, idx, max, item)
{
uint64_t ms = 0;
if(!prepare && instance.config.display.stat)
double ms = 0;
if(!prepare && thres >= 0)
ms = ffTimeGetTick();

yyjson_val* module = item;
Expand All @@ -208,19 +210,21 @@ static const char* printJsonConfig(bool prepare, yyjson_mut_doc* jsonDoc)
else if(!parseModuleJsonObject(type, module, jsonDoc))
return "Unknown module type";

if(!prepare && instance.config.display.stat)
if(!prepare && thres >= 0)
{
ms = ffTimeGetTick() - ms;
if (jsonDoc)
{
yyjson_mut_val* moduleJson = yyjson_mut_arr_get_last(jsonDoc->root);
yyjson_mut_obj_add_uint(jsonDoc, moduleJson, "stat", ms);
yyjson_mut_obj_add_real(jsonDoc, moduleJson, "stat", ms);
}
else
{
char str[32];
int len = snprintf(str, sizeof str, "%" PRIu64 "ms", ms);
printf("\033[s\033[1A\033[9999999C\033[%dD%s\033[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
char str[64];
int len = snprintf(str, sizeof str, "%.3fms", ms);
if (thres > 0)
snprintf(str, sizeof str, "\e[%sm%.3fms\e[m", (ms <= thres ? FF_COLOR_FG_GREEN : ms <= 2 * thres ? FF_COLOR_FG_YELLOW : FF_COLOR_FG_RED), ms);
printf("\e[s\e[1A\e[9999999C\e[%dD%s\e[u", len, str); // Save; Up 1; Right 9999999; Left <len>; Print <str>; Load
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/common/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
#include <sysinfoapi.h>
#endif

static inline uint64_t ffTimeGetTick() //In msec
static inline double ffTimeGetTick(void) //In msec
{
#ifdef _WIN32
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER start;
QueryPerformanceCounter(&start);
return (uint64_t)(start.QuadPart * 1000 / frequency.QuadPart);
return (double) start.QuadPart * 1000 / (double) frequency.QuadPart;
#else
struct timespec timeNow;
clock_gettime(CLOCK_MONOTONIC, &timeNow);
return (uint64_t)(((uint64_t) timeNow.tv_sec * 1000u) + ((uint64_t) timeNow.tv_nsec / 1000000u));
return (double) timeNow.tv_sec * 1000. + (double) timeNow.tv_nsec / 1000000.;
#endif
}

static inline uint64_t ffTimeGetNow()
static inline uint64_t ffTimeGetNow(void)
{
#ifdef _WIN32
uint64_t timeNow;
Expand Down
2 changes: 1 addition & 1 deletion src/detection/bootmgr/bootmgr_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result)
ffEfiFillLoadOption((FFEfiLoadOption *)buffer, result);

DWORD uefiSecureBootEnabled = 0, bufSize = 0;
if (RegGetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\ControlSet001\\Control\\SecureBoot\\State", L"UEFISecureBootEnabled", RRF_RT_REG_DWORD, NULL, &uefiSecureBootEnabled, &bufSize) == ERROR_SUCCESS)
if (RegGetValueW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\SecureBoot\\State", L"UEFISecureBootEnabled", RRF_RT_REG_DWORD, NULL, &uefiSecureBootEnabled, &bufSize) == ERROR_SUCCESS)
result->secureBoot = !!uefiSecureBootEnabled;

return NULL;
Expand Down
Loading

0 comments on commit c0774b8

Please sign in to comment.