master ohmu/fastfetch-openbsd / src / detection / icons / icons_windows.c
ohmu  ·  2026-10-15
 1#include "icons.h"
 2#include "common/windows/registry.h"
 3
 4const char* ffDetectIcons(FFIconsResult* result) {
 5    FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
 6    if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", &hKey, nullptr) &&
 7        !ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, nullptr)) {
 8        // If the key doesn't exist, it means that the user never changed the default settings.
 9        ffStrbufSetStatic(&result->icons2, "Recycle Bin");
10        return nullptr;
11    }
12
13    // Whether these icons are hidden
14    uint32_t ThisPC = 1, UsersFiles = 1, RemoteNetwork = 1, RecycleBin = 0 /* Shown by default */, ControlPanel = 1;
15    ffRegReadUint(hKey, L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", &ThisPC, nullptr);
16    ffRegReadUint(hKey, L"{59031a47-3f72-44a7-89c5-5595fe6b30ee}", &UsersFiles, nullptr);
17    ffRegReadUint(hKey, L"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", &RemoteNetwork, nullptr);
18    ffRegReadUint(hKey, L"{645FF040-5081-101B-9F08-00AA002F954E}", &RecycleBin, nullptr);
19    ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, nullptr);
20
21    if (ThisPC && UsersFiles && RemoteNetwork && RecycleBin && ControlPanel) {
22        return "All icons are hidden";
23    }
24
25    if (!ThisPC) {
26        ffStrbufAppendS(&result->icons1, "This PC, ");
27    }
28    if (!UsersFiles) {
29        ffStrbufAppendS(&result->icons1, "User's Files");
30    }
31    ffStrbufTrimRight(&result->icons1, ' ');
32    ffStrbufTrimRight(&result->icons1, ',');
33
34    if (!RemoteNetwork) {
35        ffStrbufAppendS(&result->icons2, "Remote Network, ");
36    }
37    if (!RecycleBin) {
38        ffStrbufAppendS(&result->icons2, "Recycle Bin, ");
39    }
40    if (!ControlPanel) {
41        ffStrbufAppendS(&result->icons2, "Control Panel");
42    }
43    ffStrbufTrimRight(&result->icons2, ' ');
44    ffStrbufTrimRight(&result->icons2, ',');
45
46    return nullptr;
47}