Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: v2.8.6 #739

Merged
merged 14 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 2.8.6

Changes:
* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temp": { "unit": "C" } }`

Bugfixes:
* Fix incorrect GPU name detection for Intel iGPU on Linux (#736, GPU, Linux)

Features:
* Support additional temperature formatting options (#737)
* `{ "temp": { "ndigits": 1 } }`
* `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
* Support specifying custom `pci.ids` path for Linux (GPU, Linux)

# 2.8.5

Bugfixes:
Expand Down
16 changes: 13 additions & 3 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.8.5
VERSION 2.8.6
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
Expand Down Expand Up @@ -76,6 +76,10 @@ option(ENABLE_PROPRIETARY_GPU_DRIVER_API "Enable proprietary GPU driver API (NVM
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds

if (LINUX)
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
endif()

####################
# Compiler options #
####################
Expand Down Expand Up @@ -277,6 +281,7 @@ set(LIBFASTFETCH_SRC
src/common/printing.c
src/common/properties.c
src/common/settings.c
src/common/temps.c
src/detection/chassis/chassis.c
src/detection/cpu/cpu.c
src/detection/cpuusage/cpuusage.c
Expand Down Expand Up @@ -724,8 +729,8 @@ if(yyjson_FOUND)
else()
# Used for dlopen finding dylibs installed by homebrew
# `/opt/homebrew/lib` is not on in dlopen search path by default
if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ENV{HOMEBREW_PREFIX}/lib")
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/opt/homebrew/lib -Wl,-rpath,/usr/local/lib")
endif()
endif()

Expand Down Expand Up @@ -762,6 +767,11 @@ if(HAVE_WCWIDTH)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WCWIDTH)
endif()

if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
endif()

function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
if(NOT ENABLE_${VARNAME})
return()
Expand Down
89 changes: 69 additions & 20 deletions doc/json_schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/schema",
"$schema": "https://json-schema.org/draft-07/schema",
"$defs": {
"colors": {
"type": "string",
Expand Down Expand Up @@ -44,6 +44,32 @@
"description": "Value greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
}
}
},
"temperature": {
"description": "Detect and display temperature if supported",
"oneOf": [
{
"type": "boolean",
"default": false
},
{
"type": "object",
"properties": {
"green": {
"type": "integer",
"minimum": 0,
"maximum": 100,
"description": "Value (in celsius) less then green will be shown in green"
},
"yellow": {
"type": "integer",
"minimum": 0,
"maximum": 100,
"description": "Value (in celsius) greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
}
}
}
]
}
},
"type": "object",
Expand Down Expand Up @@ -272,7 +298,7 @@
"description": "Force display detection to use DRM. Linux only",
"oneOf": [
{
"type": "bool",
"type": "boolean",
"const": false,
"description": "Try `wayland`, then `x11`, then `drm`"
},
Expand All @@ -282,7 +308,7 @@
"const": "sysfs-only"
},
{
"type": "bool",
"type": "boolean",
"const": true,
"description": "Try `libdrm` first, then `sysfs` if libdrm failed"
}
Expand Down Expand Up @@ -407,11 +433,42 @@
}
}
},
"temperatureUnit": {
"type": "string",
"description": "Set the unit of the temperature",
"enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"],
"default": "C"
"temp": {
"type": "object",
"description": "Set how temperature values should be displayed",
"properties": {
"unit": {
"type": "string",
"description": "Set the unit of the temperature",
"enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"],
"default": "C"
},
"ndigits": {
"type": "integer",
"description": "Set the number of digits to keep after the decimal point when formatting temperature values",
"minimum": 0,
"maximum": 9,
"default": 1
},
"color": {
"type": "object",
"description": "Set color used in different states of temperature values",
"properties": {
"green": {
"description": "Color used in green state",
"$ref": "#/$defs/colors"
},
"yellow": {
"description": "Color used in yellow state",
"$ref": "#/$defs/colors"
},
"red": {
"description": "Color used in red state",
"$ref": "#/$defs/colors"
}
}
}
}
},
"bar": {
"type": "object",
Expand Down Expand Up @@ -839,9 +896,7 @@
"default": false
},
"temp": {
"description": "Detect and display Battery temperature if supported",
"type": "boolean",
"default": false
"$ref": "#/$defs/temperature"
},
"percent": {
"$ref": "#/$defs/percent"
Expand Down Expand Up @@ -939,9 +994,7 @@
"const": "cpu"
},
"temp": {
"description": "Detect and display CPU temperature if supported",
"type": "boolean",
"default": false
"$ref": "#/$defs/temperature"
},
"freqNdigits": {
"description": "Set the number of digits to keep after the decimal point when printing CPU frequency",
Expand Down Expand Up @@ -1286,9 +1339,7 @@
"const": "gpu"
},
"temp": {
"description": "Detect and display GPU temperature if supported",
"type": "boolean",
"default": false
"$ref": "#/$defs/temperature"
},
"driverSpecific": {
"description": "Use driver specific method to detect more detailed GPU information (memory usage, core count, etc)",
Expand Down Expand Up @@ -1511,9 +1562,7 @@
"type": "string"
},
"temp": {
"description": "Detect and display SSD temperature if supported",
"type": "boolean",
"default": false
"$ref": "#/$defs/temperature"
},
"key": {
"$ref": "#/$defs/key"
Expand Down
16 changes: 0 additions & 16 deletions src/common/parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,6 @@ void ffParseSize(uint64_t bytes, FFstrbuf* result)
}
}

void ffParseTemperature(double celsius, FFstrbuf* buffer)
{
switch (instance.config.display.temperatureUnit)
{
case FF_TEMPERATURE_UNIT_CELSIUS:
ffStrbufAppendF(buffer, "%.1f°C", celsius);
break;
case FF_TEMPERATURE_UNIT_FAHRENHEIT:
ffStrbufAppendF(buffer, "%.1f°F", celsius * 1.8 + 32);
break;
case FF_TEMPERATURE_UNIT_KELVIN:
ffStrbufAppendF(buffer, "%.1f K", celsius + 273.15);
break;
}
}

void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4)
{
if(gtk2->length > 0 && gtk3->length > 0 && gtk4->length > 0)
Expand Down
9 changes: 7 additions & 2 deletions src/common/parsing.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "fastfetch.h"
#include "util/FFstrbuf.h"

#include <stdint.h>

Expand All @@ -11,6 +11,12 @@ typedef struct FFVersion
uint32_t patch;
} FFVersion;

typedef struct FFColorRangeConfig
{
uint8_t green;
uint8_t yellow;
} FFColorRangeConfig;

#define FF_VERSION_INIT ((FFVersion) {0})

void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
Expand All @@ -20,4 +26,3 @@ void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty);
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);

void ffParseSize(uint64_t bytes, FFstrbuf* result);
void ffParseTemperature(double celsius, FFstrbuf* buffer);
16 changes: 8 additions & 8 deletions src/common/percent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "util/textModifier.h"
#include "util/stringUtils.h"

void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config)
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config)
{
uint8_t green = config.green, yellow = config.yellow;
assert(green <= 100 && yellow <= 100);
Expand Down Expand Up @@ -75,7 +75,7 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
}

void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses)
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses)
{
uint8_t green = config.green, yellow = config.yellow;
assert(green <= 100 && yellow <= 100);
Expand All @@ -89,9 +89,9 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config

if (colored && !options->pipe)
{
const char* colorGreen = instance.config.display.percentColorGreen.chars;
const char* colorYellow = instance.config.display.percentColorYellow.chars;
const char* colorRed = instance.config.display.percentColorRed.chars;
const char* colorGreen = options->percentColorGreen.chars;
const char* colorYellow = options->percentColorYellow.chars;
const char* colorRed = options->percentColorRed.chars;

if(percent != percent)
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m");
Expand Down Expand Up @@ -126,7 +126,7 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config
ffStrbufAppendC(buffer, ')');
}

bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config)
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config)
{
if (!ffStrStartsWithIgnCase(subkey, "percent-"))
return false;
Expand Down Expand Up @@ -160,7 +160,7 @@ bool ffPercentParseCommandOptions(const char* key, const char* subkey, const cha
return false;
}

bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config)
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config)
{
if (!ffStrEqualsIgnCase(key, "percent"))
return false;
Expand Down Expand Up @@ -198,7 +198,7 @@ bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfi
return true;
}

void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config)
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config)
{
if (config.green == defaultConfig.green && config.yellow == defaultConfig.yellow)
return;
Expand Down
17 changes: 6 additions & 11 deletions src/common/percent.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "util/FFstrbuf.h"
#include "common/parsing.h"

enum
{
Expand All @@ -10,12 +11,6 @@ enum
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
};

typedef struct FFPercentConfig
{
uint8_t green;
uint8_t yellow;
} FFPercentConfig;

// if (green <= yellow)
// [0, green]: print green
// (green, yellow]: print yellow
Expand All @@ -26,12 +21,12 @@ typedef struct FFPercentConfig
// [yellow, green): print yellow
// [0, yellow): print red

void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config);
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses);
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config);
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses);

typedef struct yyjson_val yyjson_val;
typedef struct yyjson_mut_doc yyjson_mut_doc;
typedef struct yyjson_mut_val yyjson_mut_val;
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config);
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config);
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config);
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config);
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config);
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config);
Loading