Repository: fastfetch-cli/fastfetch
File: src/modules/cursor.c (C)

Code before:
    }

    FFstrbuf cursorSize;
    ffStrbufInit(&cursorSize);
    int cursorSizeVal = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue;
    if(cursorSizeVal > 0)
        ffStrbufAppendF(&cursorSize, "%i", cursorSizeVal);

    printCursor(instance, &cursorTheme, &cursorSize);
    ffStrbufDestroy(&cursorTheme);
    ffStrbufDestroy(&cursorSize);
}

static void printCursorLXQt(FFinstance* instance)
{
    FFstrbuf cursorTheme;
    ffStrbufInit(&cursorTheme);

    FFstrbuf cursorSize;
    ffStrbufInit(&cursorSize);

    if(ffParsePropFileConfigValues(instance, "/lxqt/session.conf", 2, (FFpropquery[]) {
        {"cursor_theme =", &cursorTheme},
        {"cursor_size =", &cursorSize}
    })) {
    }

    if(cursorTheme.length == 0)
    {
        ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Couldn't find LXQt cursor in session.conf");
        return;
    }

    printCursor(instance, &cursorTheme, &cursorSize);
    ffStrbufDestroy(&cursorTheme);
    ffStrbufDestroy(&cursorSize);
}

static bool printCursorFromXResources(FFinstance* instance)
{
    FFstrbuf theme;
    ffStrbufInit(&theme);

    FFstrbuf size;
    ffStrbufInit(&size);

    ffParsePropFileHomeValues(instance, ".Xresources", 2, (FFpropquery[]) {
        {"Xcursor.theme :", &theme},
        {"Xcursor.size :", &size}
    });


Review comment (suggestion):
I see you copied this over from plasma. `ffParsePropFileConfigValues` returns true if the file was found. So i use the if to set the default values when the file exists. This needs to be done in plasma, because default values are not saved. If this isn't the case in LXQt, a simple
```c
ffParsePropFileConfigValues(instance, "/lxqt/session.conf", 2, (FFpropquery[]) {
    {"cursor_theme =", &cursorTheme},
    {"cursor_size =", &cursorSize}
});
```
should be enough.

Also leading slash is not needed in path.

Code after:
            ffStrbufAppendS(&cursorSize, sizeDefault);
    }

    if(cursorTheme.length == 0)
    {
        ffPrintError(instance, FF_CURSOR_MODULE_NAME, 0, &instance->config.cursorKey, &instance->config.cursorFormat, FF_CURSOR_NUM_FORMAT_ARGS, "Couldn't find cursor in %s", relativeFilePath);
        ffStrbufDestroy(&cursorTheme);
        ffStrbufDestroy(&cursorSize);
        return;
    }

    printCursor(instance, &cursorTheme, &cursorSize);
    ffStrbufDestroy(&cursorTheme);
    ffStrbufDestroy(&cursorSize);
}

static bool printCursorFromXResources(FFinstance* instance)
{
    FFstrbuf theme;
    ffStrbufInit(&theme);

    FFstrbuf size;
    ffStrbufInit(&size);

    ffParsePropFileHomeValues(instance, ".Xresources", 2, (FFpropquery[]) {
        {"Xcursor.theme :", &theme},
        {"Xcursor.size :", &size}
    });

    if(theme.length == 0)
    {
        ffStrbufDestroy(&size);
        ffStrbufDestroy(&theme);
        return false;
    }

    printCursor(instance, &theme, &size);
    ffStrbufDestroy(&size);
    ffStrbufDestroy(&theme);
    return true;
}

static bool printCursorFromXDG(FFinstance* instance, bool user)
{
    FFstrbuf theme;
    ffStrbufInit(&theme);

    if(user)
        ffParsePropFileHome(instance, ".icons/default/index.theme", "Inherits =", &theme);
    else
        ffParsePropFile("/usr/share/icons/default/index.theme", "Inherits =", &theme);