Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev

This commit is contained in:
Linus Dierheimer
2023-01-14 16:38:52 +01:00
18 changed files with 134 additions and 108 deletions
+1 -76
View File
@@ -197,80 +197,6 @@ jobs:
name: fastfetch-windows
path: ./fastfetch-*-Windows.zip
win7:
name: Win7
runs-on: windows-latest
permissions:
security-events: write
contents: read
defaults:
run:
shell: msys2 {0}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git zip mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc mingw-w64-x86_64-cjson mingw-w64-x86_64-vulkan-loader mingw-w64-x86_64-opencl-icd
- name: print msys version
run: uname -a
# https://github.com/msys2/MINGW-packages/issues/13524#event-7555720785
- name: create OpenCL.pc
run: |
cat > /mingw64/lib/pkgconfig/OpenCL.pc << EOF
prefix=/mingw64
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenCL
Description: Open Computing Language generic Installable Client Driver Loader
Version: 2022.09.30-1
Libs: -L${libdir} -lOpenCL.dll
Cflags: -I${includedir}
EOF
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: c, cpp
- name: configure project
run: env PKG_CONFIG_PATH=/mingw64/lib/pkgconfig/:$PKG_CONFIG_PATH cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DENABLE_BUFFER=Off .
- name: build project
run: cmake --build .
- name: perform CodeQL analysis
uses: github/codeql-action/analyze@v2
- name: copy necessary dlls
run: cp /mingw64/bin/{libcjson,libOpenCL,vulkan-1}.dll .
- name: run fastfetch
run: time ./fastfetch --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run flashfetch
run: time ./flashfetch
- name: run tests
run: ctest
- name: create zip archive
run: zip fastfetch-$(./fastfetch --version-raw)-Win7.zip *.dll fastfetch.exe flashfetch.exe
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: fastfetch-win7
path: ./fastfetch-*-Win7.zip
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'LinusDierheimer/fastfetch'
name: Release
@@ -280,7 +206,6 @@ jobs:
- macos
- freebsd
- windows
- win7
permissions:
contents: write
steps:
@@ -300,4 +225,4 @@ jobs:
tag: ${{ needs.linux.outputs.ffversion }}
commit: ${{ github.sha }}
artifactErrorsFailBuild: true
artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-freebsd/*,fastfetch-windows/*,fastfetch-win7/*
artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-freebsd/*,fastfetch-windows/*
+1
View File
@@ -20,6 +20,7 @@ Features:
* Detect terminal version when available
* Support `WezTerm` terminal font detection (requires [`wezterm` executable](https://wezfurlong.org/wezterm/cli/general.html) being available)
* Add `--shell-version` and `--terminal-version` options to disable shell / terminal version detection
* Enhance `--percent-type` to allow hiding other texts (#387)
Logos:
* Raspbian (@IamNoRobot, #373)
+1 -4
View File
@@ -70,10 +70,7 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers)
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd)
Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, special build `fastfetch-win7` is provided to support these old systems, which
1. Build with the ancient [MSVCRT](https://en.wikipedia.org/wiki/Microsoft_Windows_library_files#MSVCRT.DLL,_MSVCP*.DLL_and_CRTDLL.DLL) C runtime library, instead of the modern [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library
2. Disable stdout application buffer, which seems to problematic for ConEmu.
Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, as fastfetch for Windows targets [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library, [it must be installed manually](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) as UCRT is only pre-installed in Windows 10 and later.
For the image logo, only chafa is supported due to [the design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not built by default due to the massive dependencies of imagemagick. You must built it yourself.
+1
View File
@@ -9,6 +9,7 @@ enum
{
FF_PERCENTAGE_TYPE_NUM_BIT = 1,
FF_PERCENTAGE_TYPE_BAR_BIT = 2,
FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT = 4,
};
void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red);
+4
View File
@@ -402,6 +402,10 @@ static void resetConsole()
if(ffHideCursor)
fputs("\033[?25h", stdout);
#if defined(_WIN32) && defined(FF_ENABLE_BUFFER)
fflush(stdout);
#endif
}
#ifdef _WIN32
+1 -1
View File
@@ -259,7 +259,7 @@
# Percentage output type option
# Applies to all modules that prints percentage values. Currently memory, swap, disk, battery and CPU usage are supported.
# Only works with default format ( without --module-format option ).
# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar
# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar; 6: prints bar and hide other texts
#--percent-type 1
# Key options:
+1 -1
View File
@@ -125,7 +125,7 @@ Module specific options:
--weather-output-format: The output weather format to be used. It must be URI encoded.
--player-name: The name of the player to use
--gl <value>: Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both. 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. Default is 1
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
If a value starts with a ?, it is optional. "true" will be used if not set.
+1
View File
@@ -8,6 +8,7 @@
#define FF_GPU_TEMP_UNSET (0/0.0)
#define FF_GPU_CORE_COUNT_UNSET -1
#define FF_GPU_VENDOR_NAME_APPLE "Apple"
#define FF_GPU_VENDOR_NAME_AMD "AMD"
#define FF_GPU_VENDOR_NAME_INTEL "Intel"
#define FF_GPU_VENDOR_NAME_NVIDIA "NVIDIA"
+26 -1
View File
@@ -5,6 +5,7 @@
#include "util/apple/cf_helpers.h"
#include <IOKit/graphics/IOGraphicsLib.h>
#include <wchar.h>
static double detectGpuTemp(const FFstrbuf* gpuName)
{
@@ -61,7 +62,31 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
gpu->type = FF_GPU_TYPE_UNKNOWN;
ffStrbufInitA(&gpu->vendor, 0);
ffStrbufInit(&gpu->vendor);
int vendorId;
if(!ffCfDictGetInt(properties, CFSTR("vendor-id"), &vendorId))
{
if(vendorId == 0x106b)
{
ffStrbufAppendS(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE);
gpu->type = FF_GPU_TYPE_INTEGRATED;
}
else if(wmemchr((const wchar_t[]) {0x1002, 0x1022}, (wchar_t)vendorId, 2))
{
ffStrbufAppendS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
gpu->type = FF_GPU_TYPE_DISCRETE; // Apple never used AMD CPUs
}
else if(wmemchr((const wchar_t[]) {0x03e7, 0x8086, 0x8087}, (wchar_t)vendorId, 3))
{
ffStrbufAppendS(&gpu->vendor, FF_GPU_VENDOR_NAME_INTEL);
gpu->type = FF_GPU_TYPE_INTEGRATED;
}
else if(wmemchr((const wchar_t[]) {0x0955, 0x10de, 0x12d2}, (wchar_t)vendorId, 3))
{
ffStrbufAppendS(&gpu->vendor, FF_GPU_VENDOR_NAME_NVIDIA);
gpu->type = FF_GPU_TYPE_DISCRETE;
}
}
ffStrbufInit(&gpu->driver);
ffCfDictGetString(properties, CFSTR("CFBundleIdentifier"), &gpu->driver);
+2 -2
View File
@@ -26,8 +26,6 @@ static const char* detectWithDxgi(FFlist* gpus)
FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
gpu->type = FF_GPU_TYPE_UNKNOWN;
if(wmemchr((const wchar_t[]) {0x1002, 0x1022}, (wchar_t)desc.VendorId, 2))
ffStrbufInitS(&gpu->vendor, FF_GPU_VENDOR_NAME_AMD);
else if(wmemchr((const wchar_t[]) {0x03e7, 0x8086, 0x8087}, (wchar_t)desc.VendorId, 3))
@@ -42,6 +40,8 @@ static const char* detectWithDxgi(FFlist* gpus)
ffStrbufInit(&gpu->driver);
gpu->type = desc.DedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
adapter->Release();
gpu->temperature = FF_GPU_TEMP_UNSET;
+2 -1
View File
@@ -13,6 +13,7 @@ static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t in
ffPrintLogoAndKey(instance, FF_BATTERY_MODULE_NAME, index, &instance->config.battery.key);
bool showStatus =
!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT) &&
result->status.length > 0 &&
ffStrbufIgnCaseCompS(&result->status, "Unknown") != 0;
@@ -35,7 +36,7 @@ static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t in
{
if(str.length > 0)
ffStrbufAppendC(&str, ' ');
ffStrbufAppendF(&str, "%.0f%%", result->capacity);
ffStrbufAppendF(&str, str.length > 0 ? "(%u%%)" : "%u%%", (unsigned) result->capacity);
}
}
+10 -5
View File
@@ -47,17 +47,22 @@ static void printDisk(FFinstance* instance, const FFDisk* disk)
ffAppendPercentBar(instance, &str, bytesPercentage, 0, 5, 8);
ffStrbufAppendC(&str, ' ');
}
ffStrbufAppendF(&str, "%s / %s", usedPretty.chars, totalPretty.chars);
if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffStrbufAppendF(&str, " (%u%%)", bytesPercentage);
{
ffStrbufAppendF(&str, str.length > 0 ? "(%u%%) " : "%u%% ", bytesPercentage);
}
}
else
ffStrbufAppendS(&str, "Unknown");
ffStrbufAppendS(&str, "Unknown ");
if(disk->type == FF_DISK_TYPE_EXTERNAL)
ffStrbufAppendS(&str, " [Removable]");
if(disk->type == FF_DISK_TYPE_EXTERNAL && !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
ffStrbufAppendS(&str, "[Removable]");
ffStrbufTrimRight(&str, ' ');
ffStrbufPutTo(&str, stdout);
ffStrbufDestroy(&str);
}
+5 -7
View File
@@ -37,13 +37,13 @@ static void printGPUResult(FFinstance* instance, uint8_t index, const FFGPUResul
}
else
{
FFstrbuf type;
const char* type;
if(gpu->type == FF_GPU_TYPE_INTEGRATED)
ffStrbufInitS(&type, "Integrated");
type = "Integrated";
else if(gpu->type == FF_GPU_TYPE_DISCRETE)
ffStrbufInitS(&type, "Discrete");
type = "Discrete";
else
ffStrbufInitS(&type, "Unknown");
type = "Unknown";
ffPrintFormat(instance, FF_GPU_MODULE_NAME, index, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
@@ -51,10 +51,8 @@ static void printGPUResult(FFinstance* instance, uint8_t index, const FFGPUResul
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature},
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
{FF_FORMAT_ARG_TYPE_STRBUF, &type},
{FF_FORMAT_ARG_TYPE_STRING, type},
});
ffStrbufDestroy(&type);
}
}
+4 -2
View File
@@ -52,11 +52,13 @@ static void printMemory(FFinstance* instance, const char* name, const FFModuleAr
ffStrbufAppendC(&str, ' ');
}
ffStrbufAppendF(&str, "%s / %s", usedPretty.chars, totalPretty.chars);
if(!(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars);
if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT)
ffStrbufAppendF(&str, " (%u%%)", percentage);
ffStrbufAppendF(&str, str.length > 0 ? "(%u%%)" : "%u%%", percentage);
ffStrbufTrimRight(&str, ' ');
ffStrbufPutTo(&str, stdout);
ffStrbufDestroy(&str);
}
+22
View File
@@ -1,6 +1,7 @@
#include "FFlist.h"
#include <stdlib.h>
#include <string.h>
void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity)
{
@@ -34,6 +35,27 @@ uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool(*compF
return list->length;
}
bool ffListShift(FFlist* list, void* result)
{
if(list->length == 0)
return false;
memcpy(result, list->data, list->elementSize);
memmove(list->data, list->data + list->elementSize, list->elementSize * (list->length - 1));
--list->length;
return true;
}
bool ffListPop(FFlist* list, void* result)
{
if(list->length == 0)
return false;
memcpy(result, ffListGet(list, list->length - 1), list->elementSize);
--list->length;
return result;
}
void ffListDestroy(FFlist* list)
{
//Avoid free-after-use. These 3 assignments are cheap so don't remove them
+5
View File
@@ -26,6 +26,11 @@ void* ffListAdd(FFlist* list);
FF_C_NODISCARD uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*));
// Removes the first element, and copy its value to `*result`
bool ffListShift(FFlist* list, void* result);
// Removes the last element, and copy its value to `*result`
bool ffListPop(FFlist* list, void* result);
void ffListDestroy(FFlist* list);
static inline void ffListInit(FFlist* list, uint32_t elementSize)
+22 -7
View File
@@ -44,7 +44,10 @@ const char* ffCfDictGetString(CFDictionaryRef dict, CFStringRef key, FFstrbuf* r
const char* ffCfDictGetBool(CFDictionaryRef dict, CFStringRef key, bool* result)
{
CFBooleanRef cf = (CFBooleanRef)CFDictionaryGetValue(dict, key);
if(cf == NULL || CFGetTypeID(cf) != CFBooleanGetTypeID())
if(cf == NULL)
return "CFDictionaryGetValue() failed";
if(CFGetTypeID(cf) != CFBooleanGetTypeID())
return "TypeID is not 'CFBoolean'";
*result = CFBooleanGetValue(cf);
@@ -53,13 +56,25 @@ const char* ffCfDictGetBool(CFDictionaryRef dict, CFStringRef key, bool* result)
const char* ffCfDictGetInt(CFDictionaryRef dict, CFStringRef key, int* result)
{
CFNumberRef cf = (CFNumberRef)CFDictionaryGetValue(dict, key);
if (cf == NULL || CFGetTypeID(cf) != CFNumberGetTypeID())
return "TypeID is not 'CFNumber'";
CFTypeRef cf = (CFTypeRef)CFDictionaryGetValue(dict, key);
if(cf == NULL)
return "CFDictionaryGetValue() failed";
if(!CFNumberGetValue(cf, kCFNumberSInt32Type, result))
return "Number type is not SInt32";
return NULL;
if(CFGetTypeID(cf) == CFNumberGetTypeID())
{
if(!CFNumberGetValue((CFNumberRef)cf, kCFNumberSInt32Type, result))
return "Number type is not SInt32";
return NULL;
}
else if(CFGetTypeID(cf) == CFDataGetTypeID())
{
if(CFDataGetLength((CFDataRef)cf) != sizeof(int))
return "Data length is not sizeof(int)";
CFDataGetBytes((CFDataRef)cf, CFRangeMake(0, sizeof(int)), (uint8_t*)result);
return NULL;
}
return "TypeID is neither 'CFNumber' nor 'CFData'";
}
const char* ffCfDictGetDict(CFDictionaryRef dict, CFStringRef key, CFDictionaryRef* result)
+25 -1
View File
@@ -31,6 +31,7 @@ static bool numEqualsAdapter(const void* first, const void* second)
int main(void)
{
FFlist list;
uint32_t n = 0;
//initA
@@ -44,6 +45,14 @@ int main(void)
FF_LIST_FOR_EACH(uint32_t, item, list)
VERIFY(false);
//shift
VERIFY(!ffListShift(&list, &n));
VERIFY(list.length == 0);
//pop
VERIFY(!ffListPop(&list, &n));
VERIFY(list.length == 0);
//add
for (uint32_t i = 1; i <= FF_LIST_DEFAULT_ALLOC + 1; ++i)
{
@@ -64,6 +73,7 @@ int main(void)
VERIFY(*(uint32_t*)ffListGet(&list, 0) == 1);
VERIFY(*(uint32_t*)ffListGet(&list, i - 1) == i);
}
VERIFY(list.length == FF_LIST_DEFAULT_ALLOC + 1);
uint32_t sum = 0;
//forEach
@@ -72,11 +82,25 @@ int main(void)
VERIFY(sum == (1 + FF_LIST_DEFAULT_ALLOC + 1) * (FF_LIST_DEFAULT_ALLOC + 1) / 2);
// ffListFirstIndexComp
uint32_t n = 10;
n = 10;
VERIFY(ffListFirstIndexComp(&list, &n, numEqualsAdapter) == 9);
n = 999;
VERIFY(ffListFirstIndexComp(&list, &n, numEqualsAdapter) == list.length);
//shift
VERIFY(ffListShift(&list, &n));
VERIFY(n == 1);
VERIFY(list.length == FF_LIST_DEFAULT_ALLOC);
VERIFY(*(uint32_t*) ffListGet(&list, 0) == 2);
VERIFY(*(uint32_t*) ffListGet(&list, list.length - 1) == FF_LIST_DEFAULT_ALLOC + 1);
//pop
VERIFY(ffListPop(&list, &n));
VERIFY(n == FF_LIST_DEFAULT_ALLOC + 1);
VERIFY(list.length == FF_LIST_DEFAULT_ALLOC - 1);
VERIFY(*(uint32_t*) ffListGet(&list, 0) == 2);
VERIFY(*(uint32_t*) ffListGet(&list, list.length - 1) == FF_LIST_DEFAULT_ALLOC);
//Destroy
ffListDestroy(&list);