mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Wallpaper (Windows): add new module
This commit is contained in:
@@ -109,6 +109,7 @@ static void defaultConfig(FFinstance* instance)
|
||||
initModuleArg(&instance->config.date);
|
||||
initModuleArg(&instance->config.time);
|
||||
initModuleArg(&instance->config.vulkan);
|
||||
initModuleArg(&instance->config.wallpaper);
|
||||
initModuleArg(&instance->config.openGL);
|
||||
initModuleArg(&instance->config.openCL);
|
||||
initModuleArg(&instance->config.users);
|
||||
@@ -369,6 +370,7 @@ static void destroyConfig(FFinstance* instance)
|
||||
destroyModuleArg(&instance->config.locale);
|
||||
destroyModuleArg(&instance->config.localIP);
|
||||
destroyModuleArg(&instance->config.publicIP);
|
||||
destroyModuleArg(&instance->config.wallpaper);
|
||||
destroyModuleArg(&instance->config.weather);
|
||||
destroyModuleArg(&instance->config.wifi);
|
||||
destroyModuleArg(&instance->config.player);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_detection_wallpaper
|
||||
#define FF_INCLUDED_detection_wallpaper
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "wallpaper.h"
|
||||
|
||||
const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "wallpaper.h"
|
||||
#include "util/windows/registry.h"
|
||||
|
||||
const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result)
|
||||
{
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hKey, NULL))
|
||||
return "ffRegOpenKeyForRead(Control Panel\\Desktop) failed";
|
||||
|
||||
if(!ffRegReadStrbuf(hKey, L"WallPaper", result, NULL))
|
||||
return "ffRegReadStrbuf(WallPaper) failed";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -223,6 +223,12 @@ static inline void printCommandHelp(const char* command)
|
||||
"Combined icons"
|
||||
);
|
||||
}
|
||||
else if(strcasecmp(command, "wallpaper-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("wallpaper", "{}", 1,
|
||||
"Wallpaper image file"
|
||||
);
|
||||
}
|
||||
else if(strcasecmp(command, "font-format") == 0)
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("font", "{} [QT], {} [GTK2], {} [GTK3], {} [GTK4]", 4,
|
||||
@@ -1145,6 +1151,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
else if(optionParseModuleArgs(key, value, "wm-theme", &instance->config.wmTheme)) {}
|
||||
else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {}
|
||||
else if(optionParseModuleArgs(key, value, "icons", &instance->config.icons)) {}
|
||||
else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {}
|
||||
else if(optionParseModuleArgs(key, value, "font", &instance->config.font)) {}
|
||||
else if(optionParseModuleArgs(key, value, "cursor", &instance->config.cursor)) {}
|
||||
else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {}
|
||||
@@ -1450,6 +1457,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
|
||||
ffPrintWMTheme(instance);
|
||||
else if(strcasecmp(line, "icons") == 0)
|
||||
ffPrintIcons(instance);
|
||||
else if(strcasecmp(line, "wallpaper") == 0)
|
||||
ffPrintWallpaper(instance);
|
||||
else if(strcasecmp(line, "font") == 0)
|
||||
ffPrintFont(instance);
|
||||
else if(strcasecmp(line, "cursor") == 0)
|
||||
|
||||
@@ -130,6 +130,7 @@ typedef struct FFconfig
|
||||
FFModuleArgs shell;
|
||||
FFModuleArgs display;
|
||||
FFModuleArgs de;
|
||||
FFModuleArgs wallpaper;
|
||||
FFModuleArgs wifi;
|
||||
FFModuleArgs wm;
|
||||
FFModuleArgs wmTheme;
|
||||
@@ -318,6 +319,7 @@ void ffPrintWM(FFinstance* instance);
|
||||
void ffPrintWMTheme(FFinstance* instance);
|
||||
void ffPrintTheme(FFinstance* instance);
|
||||
void ffPrintIcons(FFinstance* instance);
|
||||
void ffPrintWallpaper(FFinstance* instance);
|
||||
void ffPrintFont(FFinstance* instance);
|
||||
void ffPrintCursor(FFinstance* instance);
|
||||
void ffPrintTerminal(FFinstance* instance);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/wallpaper/wallpaper.h"
|
||||
|
||||
#define FF_WALLPAPER_MODULE_NAME "Wallpaper"
|
||||
#define FF_WALLPAPER_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintWallpaper(FFinstance* instance)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY wallpaper;
|
||||
ffStrbufInit(&wallpaper);
|
||||
const char* error = ffDetectWallpaper(instance, &wallpaper);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->config.wallpaper.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper.key);
|
||||
ffStrbufPutTo(&wallpaper, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &wallpaper}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user