From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/icons/icons.h | 11 ++++++++ src/detection/icons/icons_linux.c | 30 ++++++++++++++++++++++ src/detection/icons/icons_nosupport.c | 5 ++++ src/detection/icons/icons_windows.c | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/detection/icons/icons.h create mode 100644 src/detection/icons/icons_linux.c create mode 100644 src/detection/icons/icons_nosupport.c create mode 100644 src/detection/icons/icons_windows.c (limited to 'src/detection/icons') diff --git a/src/detection/icons/icons.h b/src/detection/icons/icons.h new file mode 100644 index 0000000..7f3f20e --- /dev/null +++ b/src/detection/icons/icons.h @@ -0,0 +1,11 @@ +#pragma once + +#include "fastfetch.h" +#include "modules/icons/option.h" + +typedef struct FFIconsResult { + FFstrbuf icons1; + FFstrbuf icons2; +} FFIconsResult; + +const char* ffDetectIcons(FFIconsResult* result); diff --git a/src/detection/icons/icons_linux.c b/src/detection/icons/icons_linux.c new file mode 100644 index 0000000..0ecaa07 --- /dev/null +++ b/src/detection/icons/icons_linux.c @@ -0,0 +1,30 @@ +#include "icons.h" +#include "common/parsing.h" +#include "detection/gtk_qt/gtk_qt.h" +#include "detection/displayserver/displayserver.h" + +const char* ffDetectIcons(FFIconsResult* result) { + const FFDisplayServerResult* wmde = ffConnectDisplayServer(); + + if (ffStrbufIgnCaseEqualS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY)) { + return "Icons aren't supported in TTY"; + } + + const FFstrbuf* plasma = &ffDetectQt()->icons; + const FFstrbuf* gtk2 = &ffDetectGTK2()->icons; + const FFstrbuf* gtk3 = &ffDetectGTK3()->icons; + const FFstrbuf* gtk4 = &ffDetectGTK4()->icons; + + if (plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0) { + return "No icons could be found"; + } + + ffParseGTK(&result->icons2, gtk2, gtk3, gtk4); + + if (plasma->length > 0) { + ffStrbufAppend(&result->icons1, plasma); + ffStrbufAppendS(&result->icons1, " [Qt]"); + } + + return NULL; +} diff --git a/src/detection/icons/icons_nosupport.c b/src/detection/icons/icons_nosupport.c new file mode 100644 index 0000000..ab8cebb --- /dev/null +++ b/src/detection/icons/icons_nosupport.c @@ -0,0 +1,5 @@ +#include "icons.h" + +const char* ffDetectIcons(FF_A_UNUSED FFIconsResult* result) { + return "Not supported on this platform"; +} diff --git a/src/detection/icons/icons_windows.c b/src/detection/icons/icons_windows.c new file mode 100644 index 0000000..e199432 --- /dev/null +++ b/src/detection/icons/icons_windows.c @@ -0,0 +1,47 @@ +#include "icons.h" +#include "common/windows/registry.h" + +const char* ffDetectIcons(FFIconsResult* result) { + FF_AUTO_CLOSE_FD HANDLE hKey = NULL; + if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", &hKey, NULL) && + !ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, NULL)) { + // If the key doesn't exist, it means that the user never changed the default settings. + ffStrbufSetStatic(&result->icons2, "Recycle Bin"); + return NULL; + } + + // Whether these icons are hidden + uint32_t ThisPC = 1, UsersFiles = 1, RemoteNetwork = 1, RecycleBin = 0 /* Shown by default */, ControlPanel = 1; + ffRegReadUint(hKey, L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", &ThisPC, NULL); + ffRegReadUint(hKey, L"{59031a47-3f72-44a7-89c5-5595fe6b30ee}", &UsersFiles, NULL); + ffRegReadUint(hKey, L"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", &RemoteNetwork, NULL); + ffRegReadUint(hKey, L"{645FF040-5081-101B-9F08-00AA002F954E}", &RecycleBin, NULL); + ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, NULL); + + if (ThisPC && UsersFiles && RemoteNetwork && RecycleBin && ControlPanel) { + return "All icons are hidden"; + } + + if (!ThisPC) { + ffStrbufAppendS(&result->icons1, "This PC, "); + } + if (!UsersFiles) { + ffStrbufAppendS(&result->icons1, "User's Files"); + } + ffStrbufTrimRight(&result->icons1, ' '); + ffStrbufTrimRight(&result->icons1, ','); + + if (!RemoteNetwork) { + ffStrbufAppendS(&result->icons2, "Remote Network, "); + } + if (!RecycleBin) { + ffStrbufAppendS(&result->icons2, "Recycle Bin, "); + } + if (!ControlPanel) { + ffStrbufAppendS(&result->icons2, "Control Panel"); + } + ffStrbufTrimRight(&result->icons2, ' '); + ffStrbufTrimRight(&result->icons2, ','); + + return NULL; +} -- cgit v1.2.3