diff --git a/.github/ISSUE_TEMPLATE/logo_request.yml b/.github/ISSUE_TEMPLATE/logo_request.yml index 9790eef5d..fa0570dab 100644 --- a/.github/ISSUE_TEMPLATE/logo_request.yml +++ b/.github/ISSUE_TEMPLATE/logo_request.yml @@ -6,35 +6,42 @@ body: - type: markdown attributes: value: | - Tip: A logo can be displayed by fastfetch without getting into fastfetch's official repo. - For highly customized logo for personal use, it's recommended to keep it locally. + Tip: You can display a logo in fastfetch without adding it to fastfetch's official repo. + For highly customized, personal logos, we recommend keeping them locally. Please refer to https://github.com/fastfetch-cli/fastfetch/wiki/Migrate-Neofetch-Logo-To-Fastfetch - type: textarea attributes: label: OS - description: Paste content of `/etc/os-release` and `/etc/lsb-release` here. If none of these files exist, describe a way to identify the distro + description: Paste the contents of `/etc/os-release` and `/etc/lsb-release` here. If neither file exists, describe how to identify the distro. placeholder: cat /etc/os-release validations: required: true + - type: input + attributes: + label: Distro Website + description: To help prevent spam and verify the request, a distro website is required, and a downloadable ISO must be available on that site. + placeholder: https://example.com + validations: + required: true - type: textarea attributes: label: ASCII Art - description: An ASCII logo should not take up too much space (smaller than 50x20 characters). Please also include the color codes if not available in `os-release` + description: The ASCII logo should not take up too much space (smaller than 50x20 characters, W x H). Please also include the color codes if they are not available in `os-release`. placeholder: Paste ASCII art here validations: required: true - type: input attributes: - label: Original Image - description: If the ASCII art is based on an image, please provide a link to the original image - placeholder: Image URL or distro website URL + label: Original Image URL + description: If the ASCII art is based on an image, please provide a link to the original image file. + placeholder: Image URL from the distro website mentioned above - type: checkboxes attributes: label: Checklist options: - - label: The ASCII art is smaller than 50x20 characters (width x height) + - label: The ASCII art is smaller than 50x20 characters (W x H). required: true - - label: The ASCII art contains color codes, or the color codes are available in `os-release` + - label: The ASCII art includes color codes, or the color codes are available in `os-release`. required: true - - label: The ASCII art contains no internal paddings (spaces at the start and the end of lines) + - label: The ASCII art has no internal padding (spaces at the start and/or end of lines). required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..d99cb91ff --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ +## Summary + + + +## Related issue (required for new logos for new distros) + + + +Closes # + +## Changes + +- + +## Checklist + +- [ ] I have tested my changes locally. diff --git a/CHANGELOG.md b/CHANGELOG.md index bd796459f..e4db07808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# 2.57.1 + +Features: +* Tiny performance improvements (Windows) +* Improves the reliability of hostname retrieval (Title, Windows) + +Bugfixes: +* Fixes potential compilation issues on Linux (#2142, Linux) +* Fixes compilation errors on macOS when building with older SDKs (#2140, macOS) +* Fixes compilation issues when building with `-DENABLE_SYSTEM_YYJSON=ON` (#2143) + +Logos: +* Updates PrismLinux and adds a small variant + # 2.57.0 Deprecation notice: @@ -15,8 +29,8 @@ Features: * Supports Secure Boot detection (Bootmgr, macOS) * Supports DPI scale factor detection on Windows 7 (Display, Windows) * Supports xterm 256-color codes in color configuration - * In `display.color`: "@" (e.g., "@34" for color index 34) - * In `*.format` strings: "#@" (e.g., "#@34" for color index 34) + * In `display.color`: "`@`" (e.g., "`@34`" for color index `34`) + * In `*.format` strings: "`#@`" (e.g., "`#@34`" for color index `34`) * Improves uptime accuracy on Windows 10+ (Uptime, Windows) * Adds a new module `Logo` to query built-in logo raw data in JSON output (Logo) * Usage: `fastfetch -s logo -l -j # Supported in JSON format only` diff --git a/CMakeLists.txt b/CMakeLists.txt index e42ec5080..05718e970 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 2.57.0 + VERSION 2.57.1 LANGUAGES C DESCRIPTION "Fast neofetch-like system information tool" HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch" diff --git a/debian/changelog.tpl b/debian/changelog.tpl index 7a95ddefa..c6a75212b 100644 --- a/debian/changelog.tpl +++ b/debian/changelog.tpl @@ -1,3 +1,9 @@ +fastfetch (2.57.0~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium + + * Update to 2.57.0 + + -- Carter Li Mon, 12 Jan 2026 10:11:21 +0800 + fastfetch (2.56.1~#UBUNTU_CODENAME#) #UBUNTU_CODENAME#; urgency=medium * Update to 2.56.1 diff --git a/src/common/impl/FFPlatform_windows.c b/src/common/impl/FFPlatform_windows.c index d5b7433e6..cd138dc22 100644 --- a/src/common/impl/FFPlatform_windows.c +++ b/src/common/impl/FFPlatform_windows.c @@ -155,10 +155,16 @@ static void getUserName(FFPlatform* platform) static void getHostName(FFPlatform* platform) { - wchar_t buffer[128]; + wchar_t buffer[256]; DWORD len = ARRAY_SIZE(buffer); - if(GetComputerNameExW(ComputerNameDnsHostname, buffer, &len)) - ffStrbufSetWS(&platform->hostName, buffer); + if (GetComputerNameExW(ComputerNameDnsHostname, buffer, &len) && len > 0) + ffStrbufSetNWS(&platform->hostName, len, buffer); + else + { + len = ARRAY_SIZE(buffer); + if (GetComputerNameExW(ComputerNameNetBIOS, buffer, &len) && len > 0) + ffStrbufSetNWS(&platform->hostName, len, buffer); + } } static void getUserShell(FFPlatform* platform) diff --git a/src/common/impl/time.c b/src/common/impl/time.c index b49dd0aee..2927f9784 100644 --- a/src/common/impl/time.c +++ b/src/common/impl/time.c @@ -81,3 +81,15 @@ FFTimeGetAgeResult ffTimeGetAge(uint64_t birthMs, uint64_t nowMs) return result; } + +#ifdef _WIN32 + double ffQpcMultiplier; + + __attribute__((constructor)) + static void ffTimeInitQpcMultiplier(void) + { + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + ffQpcMultiplier = 1000. / (double) frequency.QuadPart; + } +#endif diff --git a/src/common/time.h b/src/common/time.h index cdb345d3c..d8506d3b8 100644 --- a/src/common/time.h +++ b/src/common/time.h @@ -1,11 +1,20 @@ #pragma once +#include #include #include #ifdef _WIN32 - #include + #include + #include #include #include + + NTSYSCALLAPI + NTSTATUS + NTAPI + NtDelayExecution( + _In_ BOOLEAN Alertable, + _In_ PLARGE_INTEGER DelayInterval); #elif defined(__HAIKU__) #include #endif @@ -15,11 +24,10 @@ static inline double ffTimeGetTick(void) //In msec { #ifdef _WIN32 - LARGE_INTEGER frequency; - QueryPerformanceFrequency(&frequency); + extern double ffQpcMultiplier; LARGE_INTEGER start; QueryPerformanceCounter(&start); - return (double) start.QuadPart * 1000 / (double) frequency.QuadPart; + return (double) start.QuadPart * ffQpcMultiplier; #elif defined(__HAIKU__) return (double) system_time() / 1000.; #else @@ -44,12 +52,15 @@ static inline uint64_t ffTimeGetNow(void) #endif } -static inline void ffTimeSleep(uint32_t msec) +// Returns true if not interrupted +static inline bool ffTimeSleep(uint32_t msec) { #ifdef _WIN32 - SleepEx(msec, TRUE); + LARGE_INTEGER interval; + interval.QuadPart = -(int64_t) msec * 10000; // Relative time in 100-nanosecond intervals + return NtDelayExecution(TRUE, &interval) == STATUS_SUCCESS; #else - nanosleep(&(struct timespec){ msec / 1000, (long) (msec % 1000) * 1000000 }, NULL); + return nanosleep(&(struct timespec){ msec / 1000, (long) (msec % 1000) * 1000000 }, NULL) == 0; #endif } diff --git a/src/common/windows/nt.h b/src/common/windows/nt.h index 8d6af4b7e..2110836ab 100644 --- a/src/common/windows/nt.h +++ b/src/common/windows/nt.h @@ -237,14 +237,14 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryDirectoryFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass, - IN BOOLEAN ReturnSingleEntry, - IN PUNICODE_STRING FileName OPTIONAL, - IN BOOLEAN RestartScan); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOLEAN ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOLEAN RestartScan); diff --git a/src/common/windows/util.hpp b/src/common/windows/util.hpp new file mode 100644 index 000000000..9891d638c --- /dev/null +++ b/src/common/windows/util.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +template +struct on_scope_exit { + static_assert(std::is_nothrow_move_constructible::value, + "Fn must be nothrow move constructible"); + + explicit on_scope_exit(Fn &&fn) noexcept + : _fn(std::move(fn)) {}; + on_scope_exit(const on_scope_exit&) = delete; + on_scope_exit& operator=(const on_scope_exit&) = delete; + ~on_scope_exit() noexcept { this->_fn(); } + +private: + Fn _fn; +}; diff --git a/src/detection/bluetooth/bluetooth_windows.cpp b/src/detection/bluetooth/bluetooth_windows.cpp index 069084b24..f4ac9c9c7 100644 --- a/src/detection/bluetooth/bluetooth_windows.cpp +++ b/src/detection/bluetooth/bluetooth_windows.cpp @@ -4,18 +4,10 @@ extern "C" } #include "common/windows/wmi.hpp" #include "common/windows/unicode.hpp" +#include "common/windows/util.hpp" STDAPI InitVariantFromStringArray(_In_reads_(cElems) PCWSTR *prgsz, _In_ ULONG cElems, _Out_ VARIANT *pvar); -template -struct on_scope_exit { - on_scope_exit(Fn &&fn): _fn(std::move(fn)) {} - ~on_scope_exit() { this->_fn(); } - -private: - Fn _fn; -}; - extern "C" const char* ffBluetoothDetectBattery(FFlist* devices) { diff --git a/src/detection/bootmgr/bootmgr_apple.c b/src/detection/bootmgr/bootmgr_apple.c index c7e1bde73..2e00f7f23 100644 --- a/src/detection/bootmgr/bootmgr_apple.c +++ b/src/detection/bootmgr/bootmgr_apple.c @@ -7,7 +7,7 @@ static const char* detectSecureBoot(bool* result) { #if __aarch64__ - FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/chosen"); + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen"); if (!entryDevice) return "IORegistryEntryFromPath() failed"; @@ -20,7 +20,7 @@ static const char* detectSecureBoot(bool* result) *result = (bool) *CFDataGetBytePtr((CFDataRef) prop); #else - FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/options"); + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/options"); if (!entryDevice) return "IORegistryEntryFromPath() failed"; diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index a1b9f9763..91221374f 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -4,20 +4,12 @@ extern "C" { } #include "common/windows/com.hpp" #include "common/windows/unicode.hpp" +#include "common/windows/util.hpp" #include #include #include -template -struct on_scope_exit { - on_scope_exit(Fn &&fn): _fn(std::move(fn)) {} - ~on_scope_exit() { this->_fn(); } - -private: - Fn _fn; -}; - extern "C" const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result) { diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 3cc8a9953..7d24448b5 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -13,103 +13,6 @@ #include #include -typedef struct XcbPropertyData -{ - FF_LIBRARY_SYMBOL(xcb_intern_atom) - FF_LIBRARY_SYMBOL(xcb_intern_atom_reply) - FF_LIBRARY_SYMBOL(xcb_get_property) - FF_LIBRARY_SYMBOL(xcb_get_property_reply) - FF_LIBRARY_SYMBOL(xcb_get_property_value) - FF_LIBRARY_SYMBOL(xcb_get_property_value_length) - FF_LIBRARY_SYMBOL(xcb_get_atom_name) - FF_LIBRARY_SYMBOL(xcb_get_atom_name_name) - FF_LIBRARY_SYMBOL(xcb_get_atom_name_name_length) - FF_LIBRARY_SYMBOL(xcb_get_atom_name_reply) - FF_LIBRARY_SYMBOL(xcb_get_setup) - FF_LIBRARY_SYMBOL(xcb_setup_vendor) - FF_LIBRARY_SYMBOL(xcb_setup_vendor_length) -} XcbPropertyData; - -static bool xcbInitPropertyData(FF_MAYBE_UNUSED void* libraryHandle, XcbPropertyData* propertyData) -{ - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_intern_atom, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_intern_atom_reply, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_reply, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_value, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_property_value_length, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_name, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_name_length, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_atom_name_reply, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_get_setup, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_setup_vendor, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, xcb_setup_vendor_length, false) - - return true; -} - -static void* xcbGetProperty(XcbPropertyData* data, xcb_connection_t* connection, xcb_window_t window, const char* request) -{ - xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(connection, true, (uint16_t) strlen(request), request); - FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(connection, requestAtomCookie, NULL); - if(requestAtomReply == NULL) - return NULL; - - xcb_get_property_cookie_t propertyCookie = data->ffxcb_get_property(connection, false, window, requestAtomReply->atom, XCB_ATOM_ANY, 0, 8 * 1024); - - FF_AUTO_FREE xcb_get_property_reply_t* propertyReply = data->ffxcb_get_property_reply(connection, propertyCookie, NULL); - if(propertyReply == NULL) - return NULL; - - int length = data->ffxcb_get_property_value_length(propertyReply); - if(length <= 0) - return NULL; - - //Why are xcb property strings not null terminated??? - void* replyValue = malloc((size_t)length + 1); - memcpy(replyValue, data->ffxcb_get_property_value(propertyReply), (size_t) length); - ((char*) replyValue)[length] = '\0'; - - return replyValue; -} - -static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connection, xcb_window_t rootWindow, FFDisplayServerResult* result) -{ - if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND) == 0) - return; - - FF_AUTO_FREE xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, connection, rootWindow, "_NET_SUPPORTING_WM_CHECK"); - if(wmWindow == NULL) - return; - - FF_AUTO_FREE char* wmName = (char*) xcbGetProperty(data, connection, *wmWindow, "WM_NAME"); - if(!ffStrSet(wmName)) - wmName = (char*) xcbGetProperty(data, connection, *wmWindow, "_NET_WM_NAME"); - - if(!ffStrSet(wmName)) - return; - - ffStrbufSetS(&result->wmProcessName, wmName); -} - -static void xcbFetchServerVendor(XcbPropertyData* data, xcb_connection_t* connection, FFDisplayServerResult* result) -{ - const xcb_setup_t* setup = data->ffxcb_get_setup(connection); - - int length = data->ffxcb_setup_vendor_length(setup); - if(length <= 0) - return; - - FF_STRBUF_AUTO_DESTROY serverVendor = ffStrbufCreateNS((uint32_t) length, data->ffxcb_setup_vendor(setup)); - - if (!ffStrbufEqualS(&serverVendor, "The X.Org Foundation")) // Original - { - ffStrbufDestroy(&result->wmProtocolName); - ffStrbufInitMove(&result->wmProtocolName, &serverVendor); - } -} - typedef struct XcbRandrData { FF_LIBRARY_SYMBOL(xcb_randr_get_screen_resources_current) @@ -131,15 +34,86 @@ typedef struct XcbRandrData FF_LIBRARY_SYMBOL(xcb_randr_get_output_property_reply) FF_LIBRARY_SYMBOL(xcb_randr_get_output_property_data) FF_LIBRARY_SYMBOL(xcb_randr_get_output_property_data_length) + FF_LIBRARY_SYMBOL(xcb_intern_atom) FF_LIBRARY_SYMBOL(xcb_intern_atom_reply) + FF_LIBRARY_SYMBOL(xcb_get_property) + FF_LIBRARY_SYMBOL(xcb_get_property_reply) + FF_LIBRARY_SYMBOL(xcb_get_property_value) + FF_LIBRARY_SYMBOL(xcb_get_property_value_length) + FF_LIBRARY_SYMBOL(xcb_get_atom_name) + FF_LIBRARY_SYMBOL(xcb_get_atom_name_name) + FF_LIBRARY_SYMBOL(xcb_get_atom_name_name_length) + FF_LIBRARY_SYMBOL(xcb_get_atom_name_reply) + FF_LIBRARY_SYMBOL(xcb_get_setup) + FF_LIBRARY_SYMBOL(xcb_setup_vendor) + FF_LIBRARY_SYMBOL(xcb_setup_vendor_length) //init once xcb_connection_t* connection; FFDisplayServerResult* result; - XcbPropertyData propData; } XcbRandrData; +static void* xcbGetProperty(XcbRandrData* data, xcb_window_t window, const char* request) +{ + xcb_intern_atom_cookie_t requestAtomCookie = data->ffxcb_intern_atom(data->connection, true, (uint16_t) strlen(request), request); + FF_AUTO_FREE xcb_intern_atom_reply_t* requestAtomReply = data->ffxcb_intern_atom_reply(data->connection, requestAtomCookie, NULL); + if(requestAtomReply == NULL) + return NULL; + + xcb_get_property_cookie_t propertyCookie = data->ffxcb_get_property(data->connection, false, window, requestAtomReply->atom, XCB_ATOM_ANY, 0, 8 * 1024); + FF_AUTO_FREE xcb_get_property_reply_t* propertyReply = data->ffxcb_get_property_reply(data->connection, propertyCookie, NULL); + if(propertyReply == NULL) + return NULL; + + int length = data->ffxcb_get_property_value_length(propertyReply); + if(length <= 0) + return NULL; + + //Why are xcb property strings not null terminated??? + void* replyValue = malloc((size_t)length + 1); + memcpy(replyValue, data->ffxcb_get_property_value(propertyReply), (size_t) length); + ((char*) replyValue)[length] = '\0'; + + return replyValue; +} + +static void xcbDetectWMfromEWMH(XcbRandrData* data, xcb_window_t rootWindow, FFDisplayServerResult* result) +{ + if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND) == 0) + return; + + FF_AUTO_FREE xcb_window_t* wmWindow = (xcb_window_t*) xcbGetProperty(data, rootWindow, "_NET_SUPPORTING_WM_CHECK"); + if(wmWindow == NULL) + return; + + FF_AUTO_FREE char* wmName = (char*) xcbGetProperty(data, *wmWindow, "WM_NAME"); + if(!ffStrSet(wmName)) + wmName = (char*) xcbGetProperty(data, *wmWindow, "_NET_WM_NAME"); + + if(!ffStrSet(wmName)) + return; + + ffStrbufSetS(&result->wmProcessName, wmName); +} + +static void xcbFetchServerVendor(XcbRandrData* data, FFDisplayServerResult* result) +{ + const xcb_setup_t* setup = data->ffxcb_get_setup(data->connection); + + int length = data->ffxcb_setup_vendor_length(setup); + if(length <= 0) + return; + + FF_STRBUF_AUTO_DESTROY serverVendor = ffStrbufCreateNS((uint32_t) length, data->ffxcb_setup_vendor(setup)); + + if (!ffStrbufEqualS(&serverVendor, "The X.Org Foundation")) // Original + { + ffStrbufDestroy(&result->wmProtocolName); + ffStrbufInitMove(&result->wmProtocolName, &serverVendor); + } +} + static bool xcbRandrHandleOutput(XcbRandrData* data, xcb_randr_output_t output, FFstrbuf* name, bool primary, FFDisplayType displayType, struct xcb_randr_get_screen_resources_current_reply_t* screenResources, uint8_t bitDepth, double scaleFactor) { xcb_randr_get_output_info_cookie_t outputInfoCookie = data->ffxcb_randr_get_output_info(data->connection, output, XCB_CURRENT_TIME); @@ -251,14 +225,14 @@ static bool xcbRandrHandleMonitor(XcbRandrData* data, xcb_randr_monitor_info_t* .rem = data->ffxcb_randr_monitor_info_outputs_length(monitor) }; - FF_AUTO_FREE xcb_get_atom_name_reply_t* nameReply = data->propData.ffxcb_get_atom_name_reply( + FF_AUTO_FREE xcb_get_atom_name_reply_t* nameReply = data->ffxcb_get_atom_name_reply( data->connection, - data->propData.ffxcb_get_atom_name(data->connection, monitor->name), + data->ffxcb_get_atom_name(data->connection, monitor->name), NULL ); FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateNS( - (uint32_t) data->propData.ffxcb_get_atom_name_name_length(nameReply), - data->propData.ffxcb_get_atom_name_name(nameReply) + (uint32_t) data->ffxcb_get_atom_name_name_length(nameReply), + data->ffxcb_get_atom_name_name(nameReply) ); const FFDisplayType displayType = ffdsGetDisplayType(name.chars); @@ -306,7 +280,7 @@ static bool xcbRandrHandleMonitors(XcbRandrData* data, xcb_screen_t* screen) FF_AUTO_FREE struct xcb_randr_get_screen_resources_current_reply_t* screenResources = data->ffxcb_randr_get_screen_resources_current_reply(data->connection, screenResourcesCookie, NULL); double scaleFactor = 1; - FF_AUTO_FREE const char* resourceManager = xcbGetProperty(&data->propData, data->connection, screen->root, "RESOURCE_MANAGER"); + FF_AUTO_FREE const char* resourceManager = xcbGetProperty(data, screen->root, "RESOURCE_MANAGER"); if (resourceManager) { FF_STRBUF_AUTO_DESTROY dpi = ffStrbufCreate(); @@ -369,6 +343,18 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_intern_atom) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_intern_atom_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_property) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_property_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_property_value) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_property_value_length) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_atom_name) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_atom_name_name) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_atom_name_name_length) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_atom_name_reply) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_get_setup) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_setup_vendor) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_setup_vendor_length) + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current_reply) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current_modes_iterator) @@ -389,8 +375,6 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info_reply) - bool propertyDataInitialized = xcbInitPropertyData(xcbRandr, &data.propData); - data.connection = ffxcb_connect(NULL, NULL); if(ffxcb_connection_has_error(data.connection) > 0) @@ -405,9 +389,9 @@ const char* ffdsConnectXcbRandr(FFDisplayServerResult* result) xcb_screen_iterator_t iterator = ffxcb_setup_roots_iterator(ffxcb_get_setup(data.connection)); - if(iterator.rem > 0 && propertyDataInitialized) { - xcbDetectWMfromEWMH(&data.propData, data.connection, iterator.data->root, result); - xcbFetchServerVendor(&data.propData, data.connection, result); + if(iterator.rem > 0) { + xcbDetectWMfromEWMH(&data, iterator.data->root, result); + xcbFetchServerVendor(&data, result); } diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index 6dd06bf17..8820ad935 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -10,25 +10,29 @@ #include #include -typedef struct X11PropertyData +typedef struct XrandrData { FF_LIBRARY_SYMBOL(XInternAtom) + FF_LIBRARY_SYMBOL(XGetAtomName) FF_LIBRARY_SYMBOL(XGetWindowProperty) FF_LIBRARY_SYMBOL(XServerVendor) FF_LIBRARY_SYMBOL(XFree) -} X11PropertyData; + FF_LIBRARY_SYMBOL(XRRGetMonitors) + FF_LIBRARY_SYMBOL(XRRGetScreenResourcesCurrent) + FF_LIBRARY_SYMBOL(XRRGetOutputInfo) + FF_LIBRARY_SYMBOL(XRRGetOutputProperty) + FF_LIBRARY_SYMBOL(XRRGetCrtcInfo) + FF_LIBRARY_SYMBOL(XRRFreeCrtcInfo) + FF_LIBRARY_SYMBOL(XRRFreeOutputInfo) + FF_LIBRARY_SYMBOL(XRRFreeScreenResources) + FF_LIBRARY_SYMBOL(XRRFreeMonitors) -static bool x11InitPropertyData(FF_MAYBE_UNUSED void* libraryHandle, X11PropertyData* propertyData) -{ - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XInternAtom, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XGetWindowProperty, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XServerVendor, false) - FF_LIBRARY_LOAD_SYMBOL_PTR(libraryHandle, propertyData, XFree, false) + //Init once + Display* display; + FFDisplayServerResult* result; +} XrandrData; - return true; -} - -static unsigned char* x11GetProperty(X11PropertyData* data, Display* display, Window window, const char* request) +static unsigned char* x11GetProperty(XrandrData* data, Display* display, Window window, const char* request) { Atom requestAtom = data->ffXInternAtom(display, request, False); if(requestAtom == None) @@ -44,18 +48,18 @@ static unsigned char* x11GetProperty(X11PropertyData* data, Display* display, Wi return result; } -static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDisplayServerResult* result) +static void x11DetectWMFromEWMH(XrandrData* data, FFDisplayServerResult* result) { if(result->wmProcessName.length > 0 || ffStrbufCompS(&result->wmProtocolName, FF_WM_PROTOCOL_WAYLAND) == 0) return; - Window* wmWindow = (Window*) x11GetProperty(data, display, DefaultRootWindow(display), "_NET_SUPPORTING_WM_CHECK"); + Window* wmWindow = (Window*) x11GetProperty(data, data->display, DefaultRootWindow(data->display), "_NET_SUPPORTING_WM_CHECK"); if(wmWindow == NULL) return; - char* wmName = (char*) x11GetProperty(data, display, *wmWindow, "WM_NAME"); + char* wmName = (char*) x11GetProperty(data, data->display, *wmWindow, "WM_NAME"); if(!ffStrSet(wmName)) - wmName = (char*) x11GetProperty(data, display, *wmWindow, "_NET_WM_NAME"); + wmName = (char*) x11GetProperty(data, data->display, *wmWindow, "_NET_WM_NAME"); if(ffStrSet(wmName)) ffStrbufSetS(&result->wmProcessName, wmName); @@ -64,35 +68,13 @@ static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDispl data->ffXFree(wmWindow); } -static void x11FetchServerVendor(X11PropertyData* data, Display* display, FFDisplayServerResult* result) +static void x11FetchServerVendor(XrandrData* data, FFDisplayServerResult* result) { - const char* serverVendor = data->ffXServerVendor(display); - if (serverVendor && !ffStrEquals(serverVendor, "The X.Org Foundation")) { + const char* serverVendor = data->ffXServerVendor(data->display); + if (serverVendor && !ffStrEquals(serverVendor, "The X.Org Foundation")) ffStrbufSetS(&result->wmProtocolName, serverVendor); - } } -typedef struct XrandrData -{ - FF_LIBRARY_SYMBOL(XInternAtom) - FF_LIBRARY_SYMBOL(XGetAtomName); - FF_LIBRARY_SYMBOL(XFree); - FF_LIBRARY_SYMBOL(XRRGetMonitors) - FF_LIBRARY_SYMBOL(XRRGetScreenResourcesCurrent) - FF_LIBRARY_SYMBOL(XRRGetOutputInfo) - FF_LIBRARY_SYMBOL(XRRGetOutputProperty) - FF_LIBRARY_SYMBOL(XRRGetCrtcInfo) - FF_LIBRARY_SYMBOL(XRRFreeCrtcInfo) - FF_LIBRARY_SYMBOL(XRRFreeOutputInfo) - FF_LIBRARY_SYMBOL(XRRFreeScreenResources) - FF_LIBRARY_SYMBOL(XRRFreeMonitors) - - //Init once - Display* display; - FFDisplayServerResult* result; - X11PropertyData* propData; -} XrandrData; - static bool xrandrHandleCrtc(XrandrData* data, XRROutputInfo* output, FFstrbuf* name, bool primary, FFDisplayType displayType, uint8_t* edidData, uint32_t edidLength, XRRScreenResources* screenResources, uint8_t bitDepth, double scaleFactor) { //We do the check here, because we want the best fallback display if this call failed @@ -247,7 +229,7 @@ static bool xrandrHandleMonitors(XrandrData* data, Screen* screen) XRRScreenResources* screenResources = data->ffXRRGetScreenResourcesCurrent(data->display, RootWindowOfScreen(screen)); double scaleFactor = 1; - char* resourceManager = (char*) x11GetProperty(data->propData, data->display, screen->root, "RESOURCE_MANAGER"); + char* resourceManager = (char*) x11GetProperty(data, data->display, screen->root, "RESOURCE_MANAGER"); if (resourceManager) { FF_STRBUF_AUTO_DESTROY dpi = ffStrbufCreate(); @@ -307,6 +289,8 @@ const char* ffdsConnectXrandr(FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XInternAtom); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XGetAtomName); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XGetWindowProperty); + FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XServerVendor); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XFree); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetMonitors); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetScreenResourcesCurrent); @@ -318,17 +302,13 @@ const char* ffdsConnectXrandr(FFDisplayServerResult* result) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeScreenResources); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeMonitors); - X11PropertyData propertyData; - bool propertyDataInitialized = x11InitPropertyData(xrandr, &propertyData); - data.propData = &propertyData; - data.display = ffXOpenDisplay(NULL); if(data.display == NULL) return "XOpenDisplay() failed"; - if(propertyDataInitialized && ScreenCount(data.display) > 0) { - x11DetectWMFromEWMH(&propertyData, data.display, result); - x11FetchServerVendor(&propertyData, data.display, result); + if(ScreenCount(data.display) > 0) { + x11DetectWMFromEWMH(&data, result); + x11FetchServerVendor(&data, result); } data.result = result; diff --git a/src/detection/gpu/gpu_wsl.cpp b/src/detection/gpu/gpu_wsl.cpp index f2351a9e0..f000194e1 100644 --- a/src/detection/gpu/gpu_wsl.cpp +++ b/src/detection/gpu/gpu_wsl.cpp @@ -6,6 +6,7 @@ extern "C" { #include "detection/gpu/gpu.h" #include "detection/gpu/gpu_driver_specific.h" } +#include "common/windows/util.hpp" #include #include @@ -16,15 +17,6 @@ extern "C" { #pragma GCC diagnostic ignored "-Wmissing-field-initializers" -template -struct on_scope_exit { - on_scope_exit(Fn &&fn): _fn(std::move(fn)) {} - ~on_scope_exit() { this->_fn(); } - -private: - Fn _fn; -}; - extern "C" const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { diff --git a/src/detection/physicalmemory/physicalmemory_apple.m b/src/detection/physicalmemory/physicalmemory_apple.m index 2812f7707..64b73d9b3 100644 --- a/src/detection/physicalmemory/physicalmemory_apple.m +++ b/src/detection/physicalmemory/physicalmemory_apple.m @@ -123,7 +123,7 @@ static const char* detectFromSystemProfiler(FFlist* result) FF_MAYBE_UNUSED static const char* detectFromIokit(FFlist* result) { - FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(kIOMainPortDefault, "IODeviceTree:/chosen"); + FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen"); if (!entryDevice) return "IORegistryEntryFromPath() failed"; diff --git a/src/detection/wm/wm_windows.cpp b/src/detection/wm/wm_windows.cpp index 793d57d51..84ee1bde2 100644 --- a/src/detection/wm/wm_windows.cpp +++ b/src/detection/wm/wm_windows.cpp @@ -7,22 +7,13 @@ extern "C" } #include "common/windows/com.hpp" +#include "common/windows/util.hpp" -#include #include #include #include #include -template -struct on_scope_exit { - on_scope_exit(Fn &&fn): _fn(std::move(fn)) {} - ~on_scope_exit() { this->_fn(); } - -private: - Fn _fn; -}; - extern "C" const char* ffDetectWMPlugin(FFstrbuf* pluginName) { diff --git a/src/logo/ascii/prismlinux.txt b/src/logo/ascii/prismlinux.txt index ac2787719..237ac3993 100644 --- a/src/logo/ascii/prismlinux.txt +++ b/src/logo/ascii/prismlinux.txt @@ -1,17 +1,21 @@ - .;oo;. - .;ldddol;. - .:cldddddolc:. - ':lloddddoooolcc:' - ':lllodddddooooolccc:, - ,:lllloddddooooollllccccc,. - .,clllllddddooooollllllccc::::,. - .,clllllloodoooooooollllccc:::::::,. -'cllllllllllllloooooollcccc::::::::::, - ,lllllllllllllooooolllccc::::::::::, - ,cllllllllllllloollllcc::::::::::; - 'clllllllllllllllcccc::::::::;:, - .clllllllccccc::cc:::::::::;:' - .cllllccccc:;;;:cc::::::;;:. - .cccccccc;;;:::::cc:::;;:. - .:cccc;;;:::::::::c::;:. - .;::::;;;;;;;;;;;;;::. + ⣤⣤ ⢀⡄ + ⢀⣾⣦ ⠙⠛ ⢀⣴⣿⣷ ⢠⣤ + ⣤⡄ ⣸⣿⣿⣷⣄ ⣠⣶⣿⣿⣿⣿ ⠈⠉ ⢀⣤⡀ + ⠉⠁ ⢠⣿⣿⣿⣿⣿⣦⡈⢿⣿⣿⣿⣿⣿⡇⢀⣀⣤⣤⣤⣤⣴⣶⠆⠘⠿⠃ ⠉ ⡀ + ⢤⣄⡀ ⣾⣿⣿⣿⣿⣿⣿⣷⡄⠻⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⣿⣿⡏ ⡇ + ⠘⣿⣿⣿⣿⣶⣤⣈⣉⠛⠿⢿⣿⣿⣿⣿⣦⠘⢿⣿⣿⣷⠈⣿⣿⣿⣿⣿⠏ ⠐⠁ + ⢿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣤⣉⡛⠻⢿⣷⣄⠻⣿⣿ ⣿⣿⣿⣿⠟⢠⣀ ⡐⠁ + ⢰⣶ ⠘⣿⣿⣿⣿⣿⣿⣿⠿⠿⠛⠛⠉⠉ ⠈⠉ ⠘⣿ ⣿⣿⣿⡏⢠⣿⣿⣿⣶⣦⣄⡀ ⠂ + ⠈⠁ ⠙⠋⣉⣉⣤⣤⣶⣶⠾⠉ ⠈ ⢹⣿⠏⢠⣿⣿⣿⣿⣿⣿⣿⣿⠟ + ⢀⣠⣤⣴⣶⣿⣿⣿⣿⣿⣿⣿⠟⠁ ⢸⠟⣰⣿⣿⣿⣿⣿⡿⠟⠉ + ⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⠟⢁⣴⡏ ⠈⣰⣿⣿⣿⠿⠛⣁⡀ ⢀⡒ + ⢤⡀ ⠙⢿⣿⣿⣿⠟⢁⣴⣿⣿ ⣰⡿⠟⢉⣠⣴⣾⣿⣿⣆ + ⠛⠁ ⠔ ⠈⠛⢁⣴⣿⣿⣿⡇⢰⡆ ⠊⣁⣤⣾⣿⣿⣿⣿⣿⣿⣿⣷⡀ + ⡠⠂ ⢀⣴⣿⣿⣿⣿⣿⠃⣾⣿⡄⢢⡀ ⠤⠶⠿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄ + ⢀⠈ ⢀⣴⣿⣿⣿⣿⣿⣿⡿⢠⣿⣿⣷ ⢿⣷⣄⠑⢶⣶⣶⣶⣶⣶⣤⣤⣤⣤⣤⣤ +⠠⠁ ⠚⠛⠿⠿⢿⣿⣿⣿⡇⢸⣿⣿⣿⣧⠈⢿⣿⣿⣦⣌⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⡄ ⢰⣶ +⡆ ⣼⣿⣿⣿⣿⣇⠘⣿⣿⣿⣿⣿⣦⣈⠛⢿⣿⣿⣿⣿⣿⡇ +⢁ ⣀ ⠄⠂⠁⢀⣿⣿⣿⣿⣿⣿⡆⠹⣿⣿⣿⣿⣿⣿⠗ ⠈⠛⢿⣿⣿⡇ + ⠁⠂ ⠒⠒⠈⠁ ⢸⣿⣿⣿⠿⠛⠉ ⢻⣿⣿⣿⣿⠟ ⠈⠙⠃ + ⠼⠛⠉⠁ ⢻⣿⣿⠏ ⢀⣄ + ⠿⠇ ⠈⠿⠁ ⠘⠋ diff --git a/src/logo/ascii/prismlinux_small.txt b/src/logo/ascii/prismlinux_small.txt new file mode 100644 index 000000000..35e43d45d --- /dev/null +++ b/src/logo/ascii/prismlinux_small.txt @@ -0,0 +1,13 @@ + ⢠⣦⡀⠘⠁⢀⣴⣾ ⢀⡄ + ⠛ ⣸⣿⣿⣄⢰⣿⣿⣿⡄⢀⣀⣀⣀⡀⢾⠆⠐⠂⢄ + ⠰⣤⣄⡀ ⢿⣿⣿⣿⣧⡹⣿⣿⡇⣿⣿⣿⡿⠁ + ⢻⣿⣿⣿⣶⣶⣭⣝⡻⠷⣌⢿⡇⢸⣿⡿⢁⣀ + ⠘⠛ ⠸⠿⠟⣛⣋⡭⠅ ⠻⢸⡿⢡⣿⣿⣿⣶⣤⠁ + ⠠⣤⣶⣶⣿⣿⡿⢋ ⠸⣡⣿⣿⡿⠟⠉ + ⢠ ⠈⠻⣿⡿⢋⣴⡟ ⢰⠟⣋⣥⣾⣦⡀ ⠁ + ⠈⠠⠊ ⢈⣴⣿⣿⣇⣧⢀ ⢀⣠⣴⣿⣿⣿⣿⣿⣷⡄ + ⣰⣿⣿⣿⣿⢹⣿⣆⢳⣦⣐⠶⣶⣦⣤⣬⣭⣭⠉⢉⠉⠉ +⡀ ⠈⠉⠉⢉⢸⣿⣿⣆⢻⣿⣷⣮⡙⢿⣿⣿⣿ ⠉ + ⣀⣀ ⠄⠐⠈ ⣾⣿⣿⠿ ⣿⣿⣿⡿ ⠉⠻⢿ + ⠛⠉ ⢀⡀⠘⣿⠟ ⢠⡀ + ⠈⠁ ⠁ diff --git a/src/logo/builtin.c b/src/logo/builtin.c index 9138d1909..996fb79e9 100644 --- a/src/logo/builtin.c +++ b/src/logo/builtin.c @@ -4060,6 +4060,16 @@ static const FFlogo P[] = { FF_COLOR_FG_BLUE, }, }, + // PrismLinuxSmall + { + .names = {"PrismLinux_small"}, + .type = FF_LOGO_LINE_TYPE_SMALL_BIT, + .lines = FASTFETCH_DATATEXT_LOGO_PRISMLINUX_SMALL, + .colors = { + FF_COLOR_FG_BLUE, + FF_COLOR_FG_BLUE, + }, + }, // LAST {}, }; diff --git a/src/modules/logo/logo.c b/src/modules/logo/logo.c index 1d47a52ca..a6fbc7d50 100644 --- a/src/modules/logo/logo.c +++ b/src/modules/logo/logo.c @@ -1,7 +1,5 @@ -#include "3rdparty/yyjson/yyjson.h" #include "common/printing.h" #include "logo/logo.h" -#include "fastfetch.h" #include "modules/logo/logo.h" #include "options/logo.h"