Skip to content

Commit de2cd79

Browse files
authored
Merge pull request #739 from fastfetch-cli/dev
Release: v2.8.6
2 parents d317997 + cc40ef4 commit de2cd79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+580
-197
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# 2.8.6
2+
3+
Changes:
4+
* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temp": { "unit": "C" } }`
5+
6+
Bugfixes:
7+
* Fix incorrect GPU name detection for Intel iGPU on Linux (#736, GPU, Linux)
8+
9+
Features:
10+
* Support additional temperature formatting options (#737)
11+
* `{ "temp": { "ndigits": 1 } }`
12+
* `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
13+
* Support specifying custom `pci.ids` path for Linux (GPU, Linux)
14+
115
# 2.8.5
216

317
Bugfixes:

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
22

33
project(fastfetch
4-
VERSION 2.8.5
4+
VERSION 2.8.6
55
LANGUAGES C
66
DESCRIPTION "Fast neofetch-like system information tool"
77
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
@@ -76,6 +76,10 @@ option(ENABLE_PROPRIETARY_GPU_DRIVER_API "Enable proprietary GPU driver API (NVM
7676
option(BUILD_TESTS "Build tests" OFF) # Also create test executables
7777
option(SET_TWEAK "Add tweak to project version" ON) # This is set to off by github actions for release builds
7878

79+
if (LINUX)
80+
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
81+
endif()
82+
7983
####################
8084
# Compiler options #
8185
####################
@@ -277,6 +281,7 @@ set(LIBFASTFETCH_SRC
277281
src/common/printing.c
278282
src/common/properties.c
279283
src/common/settings.c
284+
src/common/temps.c
280285
src/detection/chassis/chassis.c
281286
src/detection/cpu/cpu.c
282287
src/detection/cpuusage/cpuusage.c
@@ -724,8 +729,8 @@ if(yyjson_FOUND)
724729
else()
725730
# Used for dlopen finding dylibs installed by homebrew
726731
# `/opt/homebrew/lib` is not on in dlopen search path by default
727-
if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX})
728-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ENV{HOMEBREW_PREFIX}/lib")
732+
if(APPLE)
733+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/opt/homebrew/lib -Wl,-rpath,/usr/local/lib")
729734
endif()
730735
endif()
731736

@@ -762,6 +767,11 @@ if(HAVE_WCWIDTH)
762767
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WCWIDTH)
763768
endif()
764769

770+
if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
771+
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
772+
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
773+
endif()
774+
765775
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
766776
if(NOT ENABLE_${VARNAME})
767777
return()

doc/json_schema.json

Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/schema",
2+
"$schema": "https://json-schema.org/draft-07/schema",
33
"$defs": {
44
"colors": {
55
"type": "string",
@@ -44,6 +44,32 @@
4444
"description": "Value greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
4545
}
4646
}
47+
},
48+
"temperature": {
49+
"description": "Detect and display temperature if supported",
50+
"oneOf": [
51+
{
52+
"type": "boolean",
53+
"default": false
54+
},
55+
{
56+
"type": "object",
57+
"properties": {
58+
"green": {
59+
"type": "integer",
60+
"minimum": 0,
61+
"maximum": 100,
62+
"description": "Value (in celsius) less then green will be shown in green"
63+
},
64+
"yellow": {
65+
"type": "integer",
66+
"minimum": 0,
67+
"maximum": 100,
68+
"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"
69+
}
70+
}
71+
}
72+
]
4773
}
4874
},
4975
"type": "object",
@@ -272,7 +298,7 @@
272298
"description": "Force display detection to use DRM. Linux only",
273299
"oneOf": [
274300
{
275-
"type": "bool",
301+
"type": "boolean",
276302
"const": false,
277303
"description": "Try `wayland`, then `x11`, then `drm`"
278304
},
@@ -282,7 +308,7 @@
282308
"const": "sysfs-only"
283309
},
284310
{
285-
"type": "bool",
311+
"type": "boolean",
286312
"const": true,
287313
"description": "Try `libdrm` first, then `sysfs` if libdrm failed"
288314
}
@@ -407,11 +433,42 @@
407433
}
408434
}
409435
},
410-
"temperatureUnit": {
411-
"type": "string",
412-
"description": "Set the unit of the temperature",
413-
"enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"],
414-
"default": "C"
436+
"temp": {
437+
"type": "object",
438+
"description": "Set how temperature values should be displayed",
439+
"properties": {
440+
"unit": {
441+
"type": "string",
442+
"description": "Set the unit of the temperature",
443+
"enum": ["CELSIUS", "C", "FAHRENHEIT", "F", "KELVIN", "K"],
444+
"default": "C"
445+
},
446+
"ndigits": {
447+
"type": "integer",
448+
"description": "Set the number of digits to keep after the decimal point when formatting temperature values",
449+
"minimum": 0,
450+
"maximum": 9,
451+
"default": 1
452+
},
453+
"color": {
454+
"type": "object",
455+
"description": "Set color used in different states of temperature values",
456+
"properties": {
457+
"green": {
458+
"description": "Color used in green state",
459+
"$ref": "#/$defs/colors"
460+
},
461+
"yellow": {
462+
"description": "Color used in yellow state",
463+
"$ref": "#/$defs/colors"
464+
},
465+
"red": {
466+
"description": "Color used in red state",
467+
"$ref": "#/$defs/colors"
468+
}
469+
}
470+
}
471+
}
415472
},
416473
"bar": {
417474
"type": "object",
@@ -839,9 +896,7 @@
839896
"default": false
840897
},
841898
"temp": {
842-
"description": "Detect and display Battery temperature if supported",
843-
"type": "boolean",
844-
"default": false
899+
"$ref": "#/$defs/temperature"
845900
},
846901
"percent": {
847902
"$ref": "#/$defs/percent"
@@ -939,9 +994,7 @@
939994
"const": "cpu"
940995
},
941996
"temp": {
942-
"description": "Detect and display CPU temperature if supported",
943-
"type": "boolean",
944-
"default": false
997+
"$ref": "#/$defs/temperature"
945998
},
946999
"freqNdigits": {
9471000
"description": "Set the number of digits to keep after the decimal point when printing CPU frequency",
@@ -1286,9 +1339,7 @@
12861339
"const": "gpu"
12871340
},
12881341
"temp": {
1289-
"description": "Detect and display GPU temperature if supported",
1290-
"type": "boolean",
1291-
"default": false
1342+
"$ref": "#/$defs/temperature"
12921343
},
12931344
"driverSpecific": {
12941345
"description": "Use driver specific method to detect more detailed GPU information (memory usage, core count, etc)",
@@ -1511,9 +1562,7 @@
15111562
"type": "string"
15121563
},
15131564
"temp": {
1514-
"description": "Detect and display SSD temperature if supported",
1515-
"type": "boolean",
1516-
"default": false
1565+
"$ref": "#/$defs/temperature"
15171566
},
15181567
"key": {
15191568
"$ref": "#/$defs/key"

src/common/parsing.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,6 @@ void ffParseSize(uint64_t bytes, FFstrbuf* result)
9696
}
9797
}
9898

99-
void ffParseTemperature(double celsius, FFstrbuf* buffer)
100-
{
101-
switch (instance.config.display.temperatureUnit)
102-
{
103-
case FF_TEMPERATURE_UNIT_CELSIUS:
104-
ffStrbufAppendF(buffer, "%.1f°C", celsius);
105-
break;
106-
case FF_TEMPERATURE_UNIT_FAHRENHEIT:
107-
ffStrbufAppendF(buffer, "%.1f°F", celsius * 1.8 + 32);
108-
break;
109-
case FF_TEMPERATURE_UNIT_KELVIN:
110-
ffStrbufAppendF(buffer, "%.1f K", celsius + 273.15);
111-
break;
112-
}
113-
}
114-
11599
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4)
116100
{
117101
if(gtk2->length > 0 && gtk3->length > 0 && gtk4->length > 0)

src/common/parsing.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "fastfetch.h"
3+
#include "util/FFstrbuf.h"
44

55
#include <stdint.h>
66

@@ -11,6 +11,12 @@ typedef struct FFVersion
1111
uint32_t patch;
1212
} FFVersion;
1313

14+
typedef struct FFColorRangeConfig
15+
{
16+
uint8_t green;
17+
uint8_t yellow;
18+
} FFColorRangeConfig;
19+
1420
#define FF_VERSION_INIT ((FFVersion) {0})
1521

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

2228
void ffParseSize(uint64_t bytes, FFstrbuf* result);
23-
void ffParseTemperature(double celsius, FFstrbuf* buffer);

src/common/percent.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/textModifier.h"
77
#include "util/stringUtils.h"
88

9-
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config)
9+
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config)
1010
{
1111
uint8_t green = config.green, yellow = config.yellow;
1212
assert(green <= 100 && yellow <= 100);
@@ -75,7 +75,7 @@ void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config
7575
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
7676
}
7777

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

9090
if (colored && !options->pipe)
9191
{
92-
const char* colorGreen = instance.config.display.percentColorGreen.chars;
93-
const char* colorYellow = instance.config.display.percentColorYellow.chars;
94-
const char* colorRed = instance.config.display.percentColorRed.chars;
92+
const char* colorGreen = options->percentColorGreen.chars;
93+
const char* colorYellow = options->percentColorYellow.chars;
94+
const char* colorRed = options->percentColorRed.chars;
9595

9696
if(percent != percent)
9797
ffStrbufAppendS(buffer, "\e[" FF_COLOR_FG_LIGHT_BLACK "m");
@@ -126,7 +126,7 @@ void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config
126126
ffStrbufAppendC(buffer, ')');
127127
}
128128

129-
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config)
129+
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config)
130130
{
131131
if (!ffStrStartsWithIgnCase(subkey, "percent-"))
132132
return false;
@@ -160,7 +160,7 @@ bool ffPercentParseCommandOptions(const char* key, const char* subkey, const cha
160160
return false;
161161
}
162162

163-
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config)
163+
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config)
164164
{
165165
if (!ffStrEqualsIgnCase(key, "percent"))
166166
return false;
@@ -198,7 +198,7 @@ bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfi
198198
return true;
199199
}
200200

201-
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config)
201+
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config)
202202
{
203203
if (config.green == defaultConfig.green && config.yellow == defaultConfig.yellow)
204204
return;

src/common/percent.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "util/FFstrbuf.h"
4+
#include "common/parsing.h"
45

56
enum
67
{
@@ -10,12 +11,6 @@ enum
1011
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
1112
};
1213

13-
typedef struct FFPercentConfig
14-
{
15-
uint8_t green;
16-
uint8_t yellow;
17-
} FFPercentConfig;
18-
1914
// if (green <= yellow)
2015
// [0, green]: print green
2116
// (green, yellow]: print yellow
@@ -26,12 +21,12 @@ typedef struct FFPercentConfig
2621
// [yellow, green): print yellow
2722
// [0, yellow): print red
2823

29-
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFPercentConfig config);
30-
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFPercentConfig config, bool parentheses);
24+
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config);
25+
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses);
3126

3227
typedef struct yyjson_val yyjson_val;
3328
typedef struct yyjson_mut_doc yyjson_mut_doc;
3429
typedef struct yyjson_mut_val yyjson_mut_val;
35-
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFPercentConfig* config);
36-
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFPercentConfig* config);
37-
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFPercentConfig defaultConfig, FFPercentConfig config);
30+
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config);
31+
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config);
32+
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config);

0 commit comments

Comments
 (0)