2021-02-18 22:25:36 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifndef FASTFETCH_INCLUDED
|
|
|
|
|
#define FASTFETCH_INCLUDED
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
2021-03-27 15:39:56 +01:00
|
|
|
#include <stdarg.h>
|
2021-02-27 19:22:28 +01:00
|
|
|
#include <string.h>
|
2021-02-18 22:25:36 +01:00
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <pwd.h>
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
|
|
2021-03-19 20:57:07 +01:00
|
|
|
#include "util/FFstrbuf.h"
|
|
|
|
|
|
2021-02-18 22:25:36 +01:00
|
|
|
#define FASTFETCH_TEXT_MODIFIER_BOLT "\033[1m"
|
2021-02-19 16:23:41 +01:00
|
|
|
#define FASTFETCH_TEXT_MODIFIER_ERROR "\033[1;31m"
|
2021-02-18 22:25:36 +01:00
|
|
|
#define FASTFETCH_TEXT_MODIFIER_RESET "\033[0m"
|
|
|
|
|
|
2021-02-19 18:02:36 +01:00
|
|
|
typedef struct FFlogo
|
|
|
|
|
{
|
|
|
|
|
uint8_t width;
|
|
|
|
|
uint8_t height;
|
|
|
|
|
char chars[256][256];
|
|
|
|
|
char name[128];
|
2021-02-22 19:34:34 +01:00
|
|
|
char color[32];
|
2021-02-19 18:02:36 +01:00
|
|
|
} FFlogo;
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
typedef struct FFconfig
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2021-02-19 18:02:36 +01:00
|
|
|
FFlogo logo;
|
2021-03-21 17:02:31 +01:00
|
|
|
uint16_t logo_spacing;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf seperator;
|
2021-02-25 18:38:00 +01:00
|
|
|
int16_t offsetx;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf color;
|
2021-02-22 16:52:51 +01:00
|
|
|
uint8_t titleLength;
|
2021-02-25 18:38:00 +01:00
|
|
|
bool colorLogo;
|
2021-02-19 16:23:41 +01:00
|
|
|
bool showErrors;
|
2021-02-22 16:52:51 +01:00
|
|
|
bool recache;
|
2021-03-06 11:28:38 +01:00
|
|
|
bool cacheSave; //This is only set to true when using arguments, because we dont want so save this values
|
2021-03-19 21:23:15 +01:00
|
|
|
bool printRemainingLogo;
|
2021-03-03 21:03:12 +01:00
|
|
|
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf osFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf osKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf hostFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf hostKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf kernelFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf kernelKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf uptimeFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf uptimeKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf packagesFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf packagesKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf shellFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf shellKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf resolutionFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf resolutionKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf deFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf deKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf wmFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf wmKey;
|
2021-04-03 23:10:14 +02:00
|
|
|
FFstrbuf wmThemeFormat;
|
|
|
|
|
FFstrbuf wmThemeKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf themeFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf themeKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf iconsFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf iconsKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf fontFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf fontKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf terminalFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf terminalKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf termFontFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf termFontKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf cpuFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf cpuKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf gpuFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf gpuKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf memoryFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf memoryKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf diskFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf diskKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf batteryFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf batteryKey;
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf localeFormat;
|
2021-04-03 11:39:59 +02:00
|
|
|
FFstrbuf localeKey;
|
2021-03-27 18:14:19 +01:00
|
|
|
|
2021-03-19 20:57:07 +01:00
|
|
|
FFstrbuf libPCI;
|
|
|
|
|
FFstrbuf libX11;
|
|
|
|
|
FFstrbuf libXrandr;
|
2021-04-05 23:42:07 +02:00
|
|
|
FFstrbuf libDConf;
|
2021-03-03 21:03:12 +01:00
|
|
|
|
2021-03-28 15:38:52 +02:00
|
|
|
FFstrbuf diskFolders;
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
} FFconfig;
|
2021-02-19 16:23:41 +01:00
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
typedef struct FFstate
|
|
|
|
|
{
|
|
|
|
|
uint8_t current_row;
|
2021-02-18 22:25:36 +01:00
|
|
|
struct passwd* passwd;
|
|
|
|
|
struct utsname utsname;
|
2021-02-22 16:52:51 +01:00
|
|
|
struct sysinfo sysinfo;
|
2021-02-18 22:25:36 +01:00
|
|
|
} FFstate;
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
typedef struct FFinstance
|
|
|
|
|
{
|
|
|
|
|
FFconfig config;
|
|
|
|
|
FFstate state;
|
|
|
|
|
} FFinstance;
|
|
|
|
|
|
2021-03-19 20:57:07 +01:00
|
|
|
typedef enum FFformatargtype
|
|
|
|
|
{
|
|
|
|
|
FF_FORMAT_ARG_TYPE_UINT,
|
|
|
|
|
FF_FORMAT_ARG_TYPE_UINT8,
|
|
|
|
|
FF_FORMAT_ARG_TYPE_INT,
|
|
|
|
|
FF_FORMAT_ARG_TYPE_STRING,
|
|
|
|
|
FF_FORMAT_ARG_TYPE_STRBUF,
|
|
|
|
|
FF_FORMAT_ARG_TYPE_DOUBLE
|
|
|
|
|
} FFformatargtype;
|
|
|
|
|
|
|
|
|
|
typedef struct FFformatarg
|
|
|
|
|
{
|
|
|
|
|
FFformatargtype type;
|
2021-04-03 11:39:59 +02:00
|
|
|
const void* value;
|
2021-03-19 20:57:07 +01:00
|
|
|
} FFformatarg;
|
|
|
|
|
|
2021-04-03 11:39:59 +02:00
|
|
|
//Common functions
|
2021-02-27 16:40:05 +01:00
|
|
|
void ffInitState(FFstate* state);
|
2021-03-03 21:03:12 +01:00
|
|
|
void ffDefaultConfig(FFconfig* config);
|
2021-04-03 11:39:59 +02:00
|
|
|
void ffPrintKey(FFinstance* instance, FFstrbuf* customKey, const char* defKey);
|
|
|
|
|
void ffPrintLogoAndKey(FFinstance* instance, FFstrbuf* customKey, const char* defKey);
|
|
|
|
|
void ffPrintError(FFinstance* instance, FFstrbuf* customKey, const char* defKey, const char* message, ...);
|
|
|
|
|
bool ffPrintCachedValue(FFinstance* instance, FFstrbuf* customKey, const char* defKey);
|
|
|
|
|
void ffPrintAndSaveCachedValue(FFinstance* instance, FFstrbuf* customKey, const char* defKey, FFstrbuf* value);
|
2021-03-28 20:36:49 +02:00
|
|
|
void ffAppendFileContent(const char* fileName, FFstrbuf* buffer);
|
2021-03-21 16:52:17 +01:00
|
|
|
void ffGetFileContent(const char* fileName, FFstrbuf* buffer);
|
2021-02-18 22:25:36 +01:00
|
|
|
void ffParsePropFile(const char* file, const char* regex, char* buffer);
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffParsePropFileHome(FFinstance* instance, const char* relativeFile, const char* regex, char* buffer);
|
2021-03-27 15:39:56 +01:00
|
|
|
void ffParseFormatStringV(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, va_list argp);
|
2021-03-19 20:57:07 +01:00
|
|
|
void ffParseFormatString(FFstrbuf* buffer, FFstrbuf* formatstr, uint32_t numArgs, ...);
|
2021-04-03 11:39:59 +02:00
|
|
|
void ffPrintFormatString(FFinstance* instance, FFstrbuf* customKey, const char* defKey, FFstrbuf* formatstr, uint32_t numArgs, ...);
|
2021-04-05 19:25:34 +02:00
|
|
|
void ffParseFont(const char* font, FFstrbuf* name, double* size);
|
|
|
|
|
void ffFontPretty(FFstrbuf* buffer, const FFstrbuf* name, double size);
|
2021-03-19 21:23:15 +01:00
|
|
|
void ffFinish(FFinstance* instance);
|
2021-02-27 18:30:05 +01:00
|
|
|
|
|
|
|
|
//Logo functions
|
|
|
|
|
void ffLoadLogoSet(FFconfig* config, const char* logo);
|
|
|
|
|
void ffLoadLogo(FFconfig* config);
|
|
|
|
|
void ffPrintLogoLine(FFinstance* instance);
|
2021-03-19 21:23:15 +01:00
|
|
|
void ffPrintRemainingLogo(FFinstance* instance);
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
#ifndef FLASHFETCH_BUILD_FLASHFATCH
|
2021-02-19 16:23:41 +01:00
|
|
|
void ffListLogos();
|
2021-02-25 18:38:00 +01:00
|
|
|
void ffPrintLogos(bool color);
|
2021-02-27 18:30:05 +01:00
|
|
|
#endif
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-04-05 19:25:34 +02:00
|
|
|
//Helper functions
|
|
|
|
|
|
|
|
|
|
void ffCalculateGTK2(FFinstance* instance, FFstrbuf** themeNamePtr, FFstrbuf** iconsNamePtr, FFstrbuf** fontNamePtr);
|
|
|
|
|
void ffCalculateGTK4(FFinstance* instance, FFstrbuf** themeNamePtr, FFstrbuf** iconsNamePtr, FFstrbuf** fontNamePtr);
|
|
|
|
|
void ffCalculateGTK3(FFinstance* instance, FFstrbuf** themeNamePtr, FFstrbuf** iconsNamePtr, FFstrbuf** fontNamePtr);
|
|
|
|
|
|
|
|
|
|
void ffFormatGtkPretty(FFstrbuf* buffer, FFstrbuf* gtk2, FFstrbuf* gtk3, FFstrbuf* gtk4);
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
//Module functions
|
2021-03-11 17:21:18 +01:00
|
|
|
|
2021-04-03 23:10:14 +02:00
|
|
|
void ffCalculateTerminal(FFinstance* instance, FFstrbuf** exeNamePtr, FFstrbuf** processNamePtr, FFstrbuf** errorPtr);
|
|
|
|
|
void ffCalculateWM(FFinstance* instance, FFstrbuf** prettyNamePtr, FFstrbuf** processNamePtr, FFstrbuf** errorPtr);
|
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);
|
|
|
|
|
void ffPrintSeperator(FFinstance* instance);
|
|
|
|
|
void ffPrintOS(FFinstance* instance);
|
|
|
|
|
void ffPrintHost(FFinstance* instance);
|
|
|
|
|
void ffPrintKernel(FFinstance* instance);
|
|
|
|
|
void ffPrintUptime(FFinstance* instance);
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
void ffPrintGPU(FFinstance* instance);
|
|
|
|
|
void ffPrintMemory(FFinstance* instance);
|
|
|
|
|
void ffPrintDisk(FFinstance* instance);
|
|
|
|
|
void ffPrintBattery(FFinstance* instance);
|
|
|
|
|
void ffPrintLocale(FFinstance* instance);
|
|
|
|
|
void ffPrintColors(FFinstance* instance);
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-03-27 18:14:19 +01:00
|
|
|
#endif
|