2021-02-18 22:25:36 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifndef FASTFETCH_INCLUDED
|
|
|
|
|
#define FASTFETCH_INCLUDED
|
|
|
|
|
|
2022-06-18 14:25:31 +02:00
|
|
|
#include "fastfetch_config.h"
|
|
|
|
|
|
2021-02-18 22:25:36 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdbool.h>
|
2022-06-18 14:25:31 +02:00
|
|
|
|
2022-10-13 18:12:54 +08:00
|
|
|
#ifndef _WIN32
|
|
|
|
|
#include <pwd.h>
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
#else
|
|
|
|
|
#include "util/windows/pwd.h"
|
|
|
|
|
#include "util/windows/utsname.h"
|
|
|
|
|
#endif
|
2022-09-04 14:30:52 +02:00
|
|
|
|
2021-03-19 20:57:07 +01:00
|
|
|
#include "util/FFstrbuf.h"
|
2021-04-24 13:05:43 +02:00
|
|
|
#include "util/FFlist.h"
|
2021-03-19 20:57:07 +01:00
|
|
|
|
2021-10-19 19:34:55 +02:00
|
|
|
static inline void ffUnused(int dummy, ...) { (void) dummy; }
|
|
|
|
|
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
|
2022-12-28 15:55:31 +08:00
|
|
|
#define FF_UNUSED_PARAM __attribute__ ((__unused__))
|
2021-04-09 14:07:05 +02:00
|
|
|
|
2021-12-19 22:39:22 +01:00
|
|
|
#define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9)
|
|
|
|
|
|
2022-04-02 14:35:43 +02:00
|
|
|
typedef enum FFLogoType
|
2021-11-09 15:14:25 +01:00
|
|
|
{
|
2022-12-12 13:43:10 +01:00
|
|
|
FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo
|
|
|
|
|
FF_LOGO_TYPE_BUILTIN, //builtin ascii art
|
|
|
|
|
FF_LOGO_TYPE_FILE, //text file, printed with color code replacement
|
|
|
|
|
FF_LOGO_TYPE_FILE_RAW, //text file, printed as is
|
|
|
|
|
FF_LOGO_TYPE_DATA, //text data, printed with color code replacement
|
|
|
|
|
FF_LOGO_TYPE_DATA_RAW, //text data, printed as is
|
|
|
|
|
FF_LOGO_TYPE_IMAGE_SIXEL, //image file, printed as sixel codes.
|
|
|
|
|
FF_LOGO_TYPE_IMAGE_KITTY, //image file, printed as kitty graphics protocol
|
2022-12-22 21:37:16 +08:00
|
|
|
FF_LOGO_TYPE_IMAGE_ITERM, //image file, printed as iterm graphics protocol
|
2022-12-12 13:43:10 +01:00
|
|
|
FF_LOGO_TYPE_IMAGE_CHAFA, //image file, printed as ascii art using libchafa
|
2023-01-01 12:37:39 +08:00
|
|
|
FF_LOGO_TYPE_IMAGE_RAW, //image file, printed as raw binary string
|
2022-04-02 14:35:43 +02:00
|
|
|
} FFLogoType;
|
2021-11-09 15:14:25 +01:00
|
|
|
|
2022-08-26 16:02:04 +02:00
|
|
|
typedef enum FFBinaryPrefixType
|
|
|
|
|
{
|
|
|
|
|
FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard)
|
|
|
|
|
FF_BINARY_PREFIX_TYPE_SI, // 1000 Bytes = 1 KB, 1000 KB = 1 MB, ...
|
|
|
|
|
FF_BINARY_PREFIX_TYPE_JEDEC, // 1024 Bytes = 1 kB, 1024 K = 1 MB, ...
|
|
|
|
|
} FFBinaryPrefixType;
|
|
|
|
|
|
2022-06-04 15:21:34 +02:00
|
|
|
typedef enum FFGLType
|
|
|
|
|
{
|
|
|
|
|
FF_GL_TYPE_AUTO,
|
|
|
|
|
FF_GL_TYPE_EGL,
|
2022-06-04 19:30:26 +02:00
|
|
|
FF_GL_TYPE_GLX,
|
2022-09-14 14:55:28 +02:00
|
|
|
FF_GL_TYPE_OSMESA
|
2022-06-04 15:21:34 +02:00
|
|
|
} FFGLType;
|
|
|
|
|
|
2022-06-17 18:15:36 +02:00
|
|
|
typedef struct FFModuleArgs
|
|
|
|
|
{
|
|
|
|
|
FFstrbuf key;
|
|
|
|
|
FFstrbuf outputFormat;
|
|
|
|
|
FFstrbuf errorFormat;
|
|
|
|
|
} FFModuleArgs;
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
typedef struct FFconfig
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2022-07-10 18:28:17 +02:00
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
FFstrbuf source;
|
|
|
|
|
FFLogoType type;
|
|
|
|
|
FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
|
|
|
|
|
uint32_t width;
|
|
|
|
|
uint32_t height;
|
2023-01-01 17:24:37 +08:00
|
|
|
uint32_t paddingTop;
|
2022-07-10 18:28:17 +02:00
|
|
|
uint32_t paddingLeft;
|
|
|
|
|
uint32_t paddingRight;
|
|
|
|
|
bool printRemaining;
|
2022-12-22 21:37:16 +08:00
|
|
|
bool preserveAspectRadio;
|
2022-12-22 02:07:35 +08:00
|
|
|
|
|
|
|
|
bool chafaFgOnly;
|
|
|
|
|
FFstrbuf chafaSymbols;
|
2022-12-22 11:36:13 +08:00
|
|
|
uint32_t chafaCanvasMode;
|
|
|
|
|
uint32_t chafaColorSpace;
|
|
|
|
|
uint32_t chafaDitherMode;
|
2022-07-10 18:28:17 +02:00
|
|
|
} logo;
|
2021-06-13 14:23:35 +02:00
|
|
|
|
2022-09-07 19:50:10 +02:00
|
|
|
//If one of those is empty, ffLogoPrint will set them
|
|
|
|
|
FFstrbuf colorKeys;
|
|
|
|
|
FFstrbuf colorTitle;
|
|
|
|
|
|
2021-05-15 12:36:25 +02:00
|
|
|
FFstrbuf separator;
|
2022-04-02 14:35:43 +02:00
|
|
|
|
2021-02-19 16:23:41 +01:00
|
|
|
bool showErrors;
|
2021-02-22 16:52:51 +01:00
|
|
|
bool recache;
|
2021-05-09 21:41:17 +02:00
|
|
|
bool allowSlowOperations;
|
2021-06-17 13:49:25 +02:00
|
|
|
bool disableLinewrap;
|
|
|
|
|
bool hideCursor;
|
2022-06-02 23:06:49 +02:00
|
|
|
bool escapeBedrock;
|
2022-08-26 16:02:04 +02:00
|
|
|
FFBinaryPrefixType binaryPrefixType;
|
2022-06-04 15:21:34 +02:00
|
|
|
FFGLType glType;
|
2022-06-06 14:02:21 +02:00
|
|
|
bool pipe; //disables logo and all escape sequences
|
2022-07-25 15:01:11 +02:00
|
|
|
bool multithreading;
|
2022-12-14 11:30:50 +08:00
|
|
|
bool stat;
|
2021-03-03 21:03:12 +01:00
|
|
|
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs os;
|
|
|
|
|
FFModuleArgs host;
|
2022-10-05 00:41:43 +08:00
|
|
|
FFModuleArgs bios;
|
2022-12-24 22:48:10 +08:00
|
|
|
FFModuleArgs chassis;
|
2022-10-05 17:03:30 +08:00
|
|
|
FFModuleArgs board;
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs kernel;
|
|
|
|
|
FFModuleArgs uptime;
|
|
|
|
|
FFModuleArgs processes;
|
|
|
|
|
FFModuleArgs packages;
|
|
|
|
|
FFModuleArgs shell;
|
|
|
|
|
FFModuleArgs resolution;
|
|
|
|
|
FFModuleArgs de;
|
2022-11-26 18:23:08 +08:00
|
|
|
FFModuleArgs wifi;
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs wm;
|
|
|
|
|
FFModuleArgs wmTheme;
|
|
|
|
|
FFModuleArgs theme;
|
|
|
|
|
FFModuleArgs icons;
|
|
|
|
|
FFModuleArgs font;
|
|
|
|
|
FFModuleArgs cursor;
|
|
|
|
|
FFModuleArgs terminal;
|
|
|
|
|
FFModuleArgs terminalFont;
|
|
|
|
|
FFModuleArgs cpu;
|
|
|
|
|
FFModuleArgs cpuUsage;
|
|
|
|
|
FFModuleArgs gpu;
|
|
|
|
|
FFModuleArgs memory;
|
2022-09-08 14:51:31 +02:00
|
|
|
FFModuleArgs swap;
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs disk;
|
|
|
|
|
FFModuleArgs battery;
|
2022-09-22 19:00:59 +08:00
|
|
|
FFModuleArgs powerAdapter;
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs locale;
|
|
|
|
|
FFModuleArgs localIP;
|
|
|
|
|
FFModuleArgs publicIP;
|
2022-09-29 17:05:01 +08:00
|
|
|
FFModuleArgs weather;
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs player;
|
2022-12-30 10:47:57 +08:00
|
|
|
FFModuleArgs media;
|
2022-06-17 18:15:36 +02:00
|
|
|
FFModuleArgs dateTime;
|
|
|
|
|
FFModuleArgs date;
|
|
|
|
|
FFModuleArgs time;
|
|
|
|
|
FFModuleArgs vulkan;
|
|
|
|
|
FFModuleArgs openGL;
|
|
|
|
|
FFModuleArgs openCL;
|
2022-09-26 23:45:46 +08:00
|
|
|
FFModuleArgs users;
|
2021-03-27 18:14:19 +01:00
|
|
|
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf libPCI;
|
2021-11-13 18:25:35 +01:00
|
|
|
FFstrbuf libVulkan;
|
2021-04-16 16:49:33 +02:00
|
|
|
FFstrbuf libWayland;
|
2022-01-05 14:40:57 +01:00
|
|
|
FFstrbuf libXcbRandr;
|
|
|
|
|
FFstrbuf libXcb;
|
|
|
|
|
FFstrbuf libXrandr;
|
|
|
|
|
FFstrbuf libX11;
|
2021-05-02 18:52:42 +02:00
|
|
|
FFstrbuf libGIO;
|
2021-04-05 23:42:07 +02:00
|
|
|
FFstrbuf libDConf;
|
2022-02-13 23:51:13 +01:00
|
|
|
FFstrbuf libDBus;
|
2021-05-11 20:06:17 +02:00
|
|
|
FFstrbuf libXFConf;
|
2022-05-23 19:30:02 +02:00
|
|
|
FFstrbuf libSQLite3;
|
2022-05-24 13:36:33 +02:00
|
|
|
FFstrbuf librpm;
|
2022-04-06 14:02:05 +02:00
|
|
|
FFstrbuf libImageMagick;
|
2022-04-14 15:11:14 +02:00
|
|
|
FFstrbuf libZ;
|
2022-04-28 19:15:46 +02:00
|
|
|
FFstrbuf libChafa;
|
2022-06-04 15:21:34 +02:00
|
|
|
FFstrbuf libEGL;
|
|
|
|
|
FFstrbuf libGLX;
|
2022-06-04 19:30:26 +02:00
|
|
|
FFstrbuf libOSMesa;
|
2022-06-05 00:18:40 +02:00
|
|
|
FFstrbuf libOpenCL;
|
2022-09-24 00:57:32 +08:00
|
|
|
FFstrbuf libcJSON;
|
2022-09-26 23:07:18 +08:00
|
|
|
FFstrbuf libfreetype;
|
2022-11-27 16:00:56 +08:00
|
|
|
FFstrbuf libwlanapi;
|
2021-03-03 21:03:12 +01:00
|
|
|
|
2022-09-26 11:06:21 +08:00
|
|
|
bool cpuTemp;
|
|
|
|
|
bool gpuTemp;
|
|
|
|
|
bool batteryTemp;
|
|
|
|
|
|
2022-07-22 19:36:00 +02:00
|
|
|
bool titleFQDN;
|
|
|
|
|
|
2021-03-28 15:38:52 +02:00
|
|
|
FFstrbuf diskFolders;
|
2022-10-17 13:19:48 +02:00
|
|
|
bool diskShowRemovable;
|
|
|
|
|
bool diskShowHidden;
|
2021-03-28 15:38:52 +02:00
|
|
|
|
2021-04-24 13:05:43 +02:00
|
|
|
FFstrbuf batteryDir;
|
|
|
|
|
|
2021-11-18 18:25:24 +01:00
|
|
|
FFstrbuf separatorString;
|
|
|
|
|
|
2021-10-17 12:42:15 +08:00
|
|
|
bool localIpShowLoop;
|
|
|
|
|
bool localIpShowIpV4;
|
|
|
|
|
bool localIpShowIpV6;
|
2022-09-26 16:20:51 +08:00
|
|
|
FFstrbuf localIpNamePrefix;
|
2021-10-17 12:42:15 +08:00
|
|
|
|
2022-09-29 14:22:40 +08:00
|
|
|
FFstrbuf publicIpUrl;
|
2022-01-10 20:20:18 +01:00
|
|
|
uint32_t publicIpTimeout;
|
|
|
|
|
|
2022-09-29 17:05:01 +08:00
|
|
|
FFstrbuf weatherOutputFormat;
|
|
|
|
|
uint32_t weatherTimeout;
|
|
|
|
|
|
2022-01-18 18:56:37 +01:00
|
|
|
FFstrbuf osFile;
|
|
|
|
|
|
2022-02-13 23:51:13 +01:00
|
|
|
FFstrbuf playerName;
|
2022-10-18 22:55:28 +08:00
|
|
|
|
|
|
|
|
uint32_t percentType;
|
2021-02-27 18:30:05 +01:00
|
|
|
} FFconfig;
|
2021-02-19 16:23:41 +01:00
|
|
|
|
2021-06-20 21:04:55 +02:00
|
|
|
typedef struct FFstate
|
|
|
|
|
{
|
2022-04-06 14:02:05 +02:00
|
|
|
uint32_t logoWidth;
|
2022-04-02 14:35:43 +02:00
|
|
|
uint32_t logoHeight;
|
|
|
|
|
uint32_t keysHeight;
|
2021-06-20 21:04:55 +02:00
|
|
|
|
|
|
|
|
struct passwd* passwd;
|
|
|
|
|
struct utsname utsname;
|
2022-09-04 14:30:52 +02:00
|
|
|
|
2021-06-20 21:04:55 +02:00
|
|
|
FFlist configDirs;
|
|
|
|
|
} FFstate;
|
|
|
|
|
|
|
|
|
|
typedef struct FFinstance
|
|
|
|
|
{
|
|
|
|
|
FFconfig config;
|
|
|
|
|
FFstate state;
|
|
|
|
|
} FFinstance;
|
|
|
|
|
|
2022-04-02 14:35:43 +02:00
|
|
|
//////////////////////
|
2022-07-25 15:01:11 +02:00
|
|
|
// Init functions //
|
2022-04-02 14:35:43 +02:00
|
|
|
//////////////////////
|
2021-04-09 14:07:05 +02:00
|
|
|
|
|
|
|
|
//common/init.c
|
|
|
|
|
void ffInitInstance(FFinstance* instance);
|
2021-06-17 13:49:25 +02:00
|
|
|
void ffStart(FFinstance* instance);
|
2021-04-09 14:07:05 +02:00
|
|
|
void ffFinish(FFinstance* instance);
|
2022-09-22 22:02:58 +02:00
|
|
|
void ffDestroyInstance(FFinstance* instance);
|
2021-04-09 14:07:05 +02:00
|
|
|
|
2022-02-13 23:51:13 +01:00
|
|
|
void ffListFeatures();
|
|
|
|
|
|
2022-04-02 14:35:43 +02:00
|
|
|
////////////////////
|
|
|
|
|
// Logo functions //
|
|
|
|
|
////////////////////
|
|
|
|
|
|
2022-06-08 10:59:33 +02:00
|
|
|
void ffLogoPrint(FFinstance* instance);
|
|
|
|
|
void ffLogoPrintRemaining(FFinstance* instance);
|
|
|
|
|
void ffLogoPrintLine(FFinstance* instance);
|
2022-04-02 14:35:43 +02:00
|
|
|
|
2022-06-08 10:59:33 +02:00
|
|
|
void ffLogoBuiltinPrint(FFinstance* instance);
|
|
|
|
|
void ffLogoBuiltinList();
|
|
|
|
|
void ffLogoBuiltinListAutocompletion();
|
2022-04-02 14:35:43 +02:00
|
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
// Module functions //
|
|
|
|
|
//////////////////////
|
2021-04-09 14:07:05 +02:00
|
|
|
|
2021-04-28 19:53:30 +02:00
|
|
|
//Common
|
|
|
|
|
|
2022-06-17 18:15:36 +02:00
|
|
|
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs);
|
2022-09-27 22:06:53 +08:00
|
|
|
void ffPrepareCPUUsage();
|
2022-09-28 03:10:33 +08:00
|
|
|
void ffPreparePublicIp(FFinstance* instance);
|
2022-09-29 17:05:01 +08:00
|
|
|
void ffPrepareWeather(FFinstance* instance);
|
2022-02-25 13:30:37 +01:00
|
|
|
|
2021-04-28 19:53:30 +02:00
|
|
|
//Printing
|
2021-03-11 17:21:18 +01:00
|
|
|
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintCustom(FFinstance* instance, const char* key, const char* value);
|
|
|
|
|
void ffPrintBreak(FFinstance* instance);
|
|
|
|
|
void ffPrintTitle(FFinstance* instance);
|
2021-05-15 12:36:25 +02:00
|
|
|
void ffPrintSeparator(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintOS(FFinstance* instance);
|
|
|
|
|
void ffPrintHost(FFinstance* instance);
|
2022-10-05 00:41:43 +08:00
|
|
|
void ffPrintBios(FFinstance* instance);
|
2022-10-05 17:03:30 +08:00
|
|
|
void ffPrintBoard(FFinstance* instance);
|
2022-12-24 22:48:10 +08:00
|
|
|
void ffPrintChassis(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintKernel(FFinstance* instance);
|
|
|
|
|
void ffPrintUptime(FFinstance* instance);
|
2021-10-18 22:38:00 +08:00
|
|
|
void ffPrintProcesses(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintPackages(FFinstance* instance);
|
|
|
|
|
void ffPrintShell(FFinstance* instance);
|
|
|
|
|
void ffPrintResolution(FFinstance* instance);
|
|
|
|
|
void ffPrintDesktopEnvironment(FFinstance* instance);
|
2021-03-05 21:38:35 +01:00
|
|
|
void ffPrintWM(FFinstance* instance);
|
2021-04-03 23:10:14 +02:00
|
|
|
void ffPrintWMTheme(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintTheme(FFinstance* instance);
|
|
|
|
|
void ffPrintIcons(FFinstance* instance);
|
|
|
|
|
void ffPrintFont(FFinstance* instance);
|
2021-06-20 21:04:55 +02:00
|
|
|
void ffPrintCursor(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintTerminal(FFinstance* instance);
|
2021-03-11 17:21:18 +01:00
|
|
|
void ffPrintTerminalFont(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintCPU(FFinstance* instance);
|
2021-11-24 16:16:25 +08:00
|
|
|
void ffPrintCPUUsage(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintGPU(FFinstance* instance);
|
|
|
|
|
void ffPrintMemory(FFinstance* instance);
|
2022-09-08 14:51:31 +02:00
|
|
|
void ffPrintSwap(FFinstance* instance); //Also in modules/memory.c
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintDisk(FFinstance* instance);
|
|
|
|
|
void ffPrintBattery(FFinstance* instance);
|
2022-09-23 14:59:28 +08:00
|
|
|
void ffPrintPowerAdapter(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintLocale(FFinstance* instance);
|
2022-02-13 23:51:13 +01:00
|
|
|
void ffPrintPlayer(FFinstance* instance);
|
2022-12-30 10:47:57 +08:00
|
|
|
void ffPrintMedia(FFinstance* instance);
|
2022-02-25 13:30:37 +01:00
|
|
|
void ffPrintDateTime(FFinstance* instance);
|
|
|
|
|
void ffPrintDate(FFinstance* instance);
|
|
|
|
|
void ffPrintTime(FFinstance* instance);
|
2022-02-14 12:04:54 +01:00
|
|
|
void ffPrintLocalIp(FFinstance* instance);
|
|
|
|
|
void ffPrintPublicIp(FFinstance* instance);
|
2022-09-29 17:05:01 +08:00
|
|
|
void ffPrintWeather(FFinstance* instance);
|
2022-11-26 18:23:08 +08:00
|
|
|
void ffPrintWifi(FFinstance* instance);
|
2021-02-27 19:22:28 +01:00
|
|
|
void ffPrintColors(FFinstance* instance);
|
2022-06-01 00:04:58 +02:00
|
|
|
void ffPrintVulkan(FFinstance* instance);
|
2022-06-04 15:21:34 +02:00
|
|
|
void ffPrintOpenGL(FFinstance* instance);
|
2022-06-05 00:18:40 +02:00
|
|
|
void ffPrintOpenCL(FFinstance* instance);
|
2022-09-26 14:57:27 +08:00
|
|
|
void ffPrintUsers(FFinstance* instance);
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-03-27 18:14:19 +01:00
|
|
|
#endif
|