Compare commits

..

72 Commits

Author SHA1 Message Date
Linus Dierheimer d4b32eaaec Merge pull request #205 from licy183/fix-android-header
Fix build error on Android
2022-07-27 19:31:29 +02:00
Linus Dierheimer 910f63f0ad Update changelog 2022-07-27 19:31:14 +02:00
Linus Dierheimer 9a0aa2ac72 Fix compilation issues
1) when building for android
2) when building without wayland
2022-07-27 19:28:55 +02:00
Chongyun Lee dce81055fe Release 1.6.1 2022-07-28 01:28:17 +08:00
Chongyun Lee 66a4fc1600 Fix build error on Android
host.c has an #elif, but actually #else is needed.
2022-07-27 22:50:11 +08:00
Linus Dierheimer 159a114bb7 Release 1.6.0
tag correctly
2022-07-26 22:38:40 +02:00
Linus Dierheimer ac08b46e71 Release 1.6.0
this time with correct packaging the second
2022-07-26 22:27:13 +02:00
Linus Dierheimer ceb92dafd7 Release 1.6.0
this time with correct packaging
2022-07-26 22:13:09 +02:00
Linus Dierheimer 31eeb6dd08 Release 1.6.0 2022-07-26 20:35:15 +02:00
Linus Dierheimer c021689a2b Better nix package sorting
#195
2022-07-26 19:15:00 +02:00
Linus Dierheimer 2ac2762c9f Print nix-default packages
#195
2022-07-26 19:03:15 +02:00
Linus Dierheimer 27dd097671 Improved Nix package detection
#195
2022-07-26 18:36:10 +02:00
Linus Dierheimer c7bf471e29 Refactor: move vulkan detection to own header 2022-07-26 18:18:14 +02:00
Linus Dierheimer 298bc10e5f Refactor: move media detection to own header 2022-07-26 18:15:45 +02:00
Linus Dierheimer 676485ef74 Refactor: move temps detection to own header 2022-07-26 18:13:12 +02:00
Linus Dierheimer fb6da20b0c Refactor: move date/time detection to own header 2022-07-26 18:09:25 +02:00
Linus Dierheimer 0c81d3e894 Refactor: move terminal/shell detection to own header 2022-07-26 18:06:30 +02:00
Linus Dierheimer 5c1aa20042 Refactor: move wm/de detection to own header 2022-07-26 17:56:42 +02:00
Linus Dierheimer 46a27c4e39 Refactor: move gtk detection to own header 2022-07-26 17:47:08 +02:00
Linus Dierheimer 128302596e Refactor: move qt detection to own header 2022-07-26 17:42:28 +02:00
Linus Dierheimer 7a15dee2be Refactor: move os detection to own header 2022-07-26 17:33:51 +02:00
Linus Dierheimer 000bd37f1d Refactor: move title detection to own header 2022-07-26 17:29:09 +02:00
Linus Dierheimer 707e0f930d Refactor: don't include FFvaluestore global 2022-07-25 19:54:33 +02:00
Linus Dierheimer 7676a313c5 Refactor: move threading functions to init 2022-07-25 15:01:11 +02:00
Linus Dierheimer 6e0d76a2fb Refactor: move networking functions to own header 2022-07-25 14:48:59 +02:00
Linus Dierheimer 4c7b7e4a4d Refactor: move processing functions to own header 2022-07-25 14:45:41 +02:00
Linus Dierheimer 4d34091573 Refactor: move format functions to own header 2022-07-25 14:26:08 +02:00
Linus Dierheimer c971e28aca Refactor: move setting functions to own header 2022-07-25 14:20:07 +02:00
Linus Dierheimer c41a29a5c1 Refactor: move parsing functions to own header 2022-07-25 13:59:19 +02:00
Linus Dierheimer 5c73125693 Refactor: move font functions to own header 2022-07-25 13:44:55 +02:00
Linus Dierheimer cea48474a1 Refactor: move caching functions to own header 2022-07-25 13:36:58 +02:00
Linus Dierheimer 536f914f3e Refactor: move printing functions to own header 2022-07-25 13:15:01 +02:00
Linus Dierheimer 778856dd57 Refactor: move property functions to own header 2022-07-25 12:24:23 +02:00
Linus Dierheimer 4a43144991 Refactor: move io functions to own header 2022-07-25 11:48:48 +02:00
Linus Dierheimer ac96cfc748 Refactor: move FFInitState to settings.c 2022-07-25 11:24:50 +02:00
Linus Dierheimer f18ffe3239 Refactor: move library functions and macros to own header 2022-07-25 11:20:38 +02:00
Linus Dierheimer 986bbeebb3 Don't segfault if invalid structure is given
#204
2022-07-25 11:00:41 +02:00
Linus Dierheimer b9d360af97 --title-fqdn option
#203
2022-07-22 19:36:00 +02:00
Linus Dierheimer ec1981c545 Use [QT] instead of [Plasma]
#198 #199
2022-07-22 17:18:36 +02:00
Linus Dierheimer f7e7d8e9f2 Update README.md 2022-07-22 13:42:26 +02:00
Linus Dierheimer ad9fc5845a GTK: Fix detection on XFCE DE
#198 #199
2022-07-22 12:23:35 +02:00
Linus Dierheimer a6b169f3e2 Disk: Print one decimal point if < 100GiB
#202
2022-07-22 11:47:20 +02:00
Linus Dierheimer 8aff9939bc GTK: prefer dconf over config files on certain DEs
#198 #199
2022-07-22 11:24:29 +02:00
Linus Dierheimer 0b8f51188b gh actions: configure correct path for packaging
the follow up
2022-07-21 22:58:38 +02:00
Linus Dierheimer 3c99a82619 gh actions: configure correct path for packaging 2022-07-21 22:55:47 +02:00
Linus Dierheimer d5f3ff1cfe Update README.md 2022-07-21 20:20:40 +02:00
Linus Dierheimer 011c033091 Update README.md 2022-07-21 20:18:34 +02:00
Linus Dierheimer 63bf22fb00 Load system config
#196
2022-07-21 14:37:13 +02:00
Linus Dierheimer f74973db65 Special NixOS OS output
#194
2022-07-21 11:33:19 +02:00
Linus Dierheimer 85656fd515 Fix Mutter detection
#200
2022-07-20 21:32:17 +02:00
Linus Dierheimer 23bf7a407b Fix alacritty term font size
#197
2022-07-20 20:56:02 +02:00
Linus Dierheimer e570cacbc9 Fix typos
#201
2022-07-20 20:44:16 +02:00
Linus Dierheimer a96f79795b Merge pull request #193 from Izorkin/update-nixos-logo
Update old nixos logo
2022-07-19 12:09:25 +02:00
Izorkin 2d51d935c8 update old nixos logo 2022-07-19 12:57:15 +03:00
Linus Dierheimer 9d395f7235 don't print GPU in WSL 2022-07-17 16:11:08 +02:00
Linus Dierheimer 5f16394916 Add alacritty to readme 2022-07-12 16:49:39 +02:00
Linus Dierheimer 6581c9d378 Merge pull request #191 from x-zvf/alacritty-term-support
[enhancement] Add best effort terminal font detection for alacritty.
2022-07-12 16:46:22 +02:00
Péter Bohner (xzvf) 67ac7eef59 buxfix: missing fontSize/fontName would overwrite the other 2022-07-12 16:43:21 +02:00
Péter Bohner (xzvf) b95e83e9e5 Use ffStrbufAppend instead of ffStrbugInitCopy 2022-07-12 16:41:20 +02:00
Péter Bohner (xzvf) e9d9b942fa Cleanup diff 2022-07-12 16:34:35 +02:00
Péter Bohner (xzvf) c95ad74ea2 Refactor to use ffFontInitCopy and detect font size
printAlacritty now usese ffFontInitCopy instead of ffFontInitPango
and also detects font size.
2022-07-12 16:31:19 +02:00
Péter Bohner (xzvf) 85b0be5213 Add best effort terminal font detection for alacritty.
Alacritty's config files are technically YML files, so
simply looking for a prop value "family:" may break some of the time,
but is in fact better than what neofetch does and much easier
to implement then writing a YML parser :)
2022-07-12 14:38:06 +02:00
Linus Dierheimer da671d6cfe Start cleaning up of config struct 2022-07-10 18:28:17 +02:00
Linus Dierheimer 18af9ab902 Wayland: don't destroy proxies our self 2022-07-08 11:48:43 +02:00
Linus Dierheimer 558fbc20e2 Don't detect guake-wrapped as terminal 2022-07-08 11:24:11 +02:00
Linus Dierheimer d9bbbd4fa8 Merge pull request #189 from x-zvf/alacritty-term-support
Fix memory leak in ffParsePropFileValues
2022-07-08 10:46:11 +02:00
Péter Bohner (xzvf) 292a809703 ffParsePropValues: Hoisted fopen call to simplify error handling 2022-07-08 09:09:59 +02:00
Péter Bohner (xzvf) fa13826043 Revert "Coalesce cleanup in ffParsePropFileValues"
This reverts commit 7bc85b2397.
2022-07-08 09:05:00 +02:00
Péter Bohner (xzvf) 7bc85b2397 Coalesce cleanup in ffParsePropFileValues 2022-07-07 15:19:56 +02:00
Péter Bohner (xzvf) 1863d8377a Fix memory leak in ffParseProfFileValues, if more than 4 queries are passed (unsetValues is on the heap) and the file
is not found.
2022-07-07 14:35:59 +02:00
xzvf f9e17f44b1 Merge branch 'LinusDierheimer:master' into master 2022-07-04 20:10:01 +02:00
xzvf fa9b38eb2d Merge pull request #1 from LinusDierheimer/master
build temps file
2022-06-16 12:54:28 +02:00
105 changed files with 1356 additions and 797 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ jobs:
- name: configure project
# We reuse the build binary only for the releases.
# We set tweak version to off, because it is wrong, as git tag will happen after this step. Releases don't have a tweak, so this is ok.
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On .
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr .
- name: build project
run: cmake --build . -j$(nproc) --target package
+23
View File
@@ -0,0 +1,23 @@
# 1.6.1
Fixes build on android (#205)
# 1.6.0
Features:
* Detect QT on more DEs than just KDE Plasma. The [Plasma] category was therefore renamed to [QT]
* Alacritty font detection
* Load `/etc/fastfetch/config.conf` before user config
* Disk: print one decimal point if size < 100GB
* `--title-fqdn` option, to print fully qualified domain name instead of host name in title
Logos:
* updated old NixOS logo
Bugfixes:
* Correctly detect GTK on DEs that store their settings in dconf
* Correctly detect NixOS packages
* Mutter WM detected once again
* Show full NixOS version in OS output
* Don't segfault if an invalid structure is given
* WSL doesn't output GPU anymore, as the name is always meaningless
+15 -7
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs
project(fastfetch
VERSION 1.5.6
VERSION 1.6.1
LANGUAGES C
)
@@ -115,7 +115,8 @@ function(fastfetch_load_text FILENAME OUTVAR)
endfunction(fastfetch_load_text)
fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE)
fastfetch_load_text(src/data/config.txt DATATEXT_CONFIG)
fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM)
fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER)
fastfetch_load_text(src/data/modules.txt DATATEXT_MODULES)
fastfetch_load_text(src/data/help.txt DATATEXT_HELP)
fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR)
@@ -137,7 +138,6 @@ add_library(libfastfetch OBJECT
src/util/FFlist.c
src/util/FFvaluestore.c
src/common/init.c
src/common/threading.c
src/common/io.c
src/common/printing.c
src/common/caching.c
@@ -155,13 +155,14 @@ add_library(libfastfetch OBJECT
src/logo/image/im7.c
src/logo/image/im6.c
src/detection/os.c
src/detection/plasma.c
src/detection/qt.c
src/detection/gtk.c
src/detection/terminalShell.c
src/detection/vulkan.c
src/detection/media.c
src/detection/datetime.c
src/detection/temps.c
src/detection/title.c
src/detection/displayserver/displayServer.c
src/detection/displayserver/wayland.c
src/detection/displayserver/xcb.c
@@ -492,16 +493,21 @@ endif()
# install target #
##################
if(NOT CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "/etc")
endif()
include(GNUInstallDirs)
install(
TARGETS fastfetch
TARGETS fastfetch flashfetch
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
TARGETS flashfetch
DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES src/data/config_system.txt
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}
RENAME "config.conf"
)
install(
@@ -525,6 +531,8 @@ install(
##################
set(CPACK_GENERATOR "DEB;RPM;TGZ;ZIP")
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
set(CPACK_SET_DESTDIR ON)
set(CPACK_PACKAGE_CONTACT "Linus Dierheimer <Linus@Dierheimer.de>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Neofetch clone written in C")
+3 -5
View File
@@ -75,7 +75,7 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt
##### Terminal fonts
```
konsole, gnome-terminal-server, tilix, xfce4-terminal, lxterminal, TTY
konsole, gnome-terminal-server, tilix, xfce4-terminal, alacritty, lxterminal, TTY
```
## Building
@@ -98,10 +98,8 @@ If pkg-config fails to find the headers for a library listed in [dependencies](#
### Manual
Build: Follow the [build instructions](#building).
* Create DEB / RPM: Run `cmake --build . --target package`.
* Install directly: Run `sudo cmake --install . --prefix /usr/local`
* DEB / RPM package: `cmake --build . --target package`
* Install directly: `cmake --install . --prefix /usr/local`
## FAQ
+3 -1
View File
@@ -108,7 +108,8 @@ __fastfetch_completion()
"--list-presets"
"--list-features"
"--print-logos"
"--print-config"
"--print-config-system"
"--print-config-user"
"--print-structure"
)
@@ -132,6 +133,7 @@ __fastfetch_completion()
"--localip-show-loop"
"--escape-bedrock"
"--pipe"
"--title-fqdn"
)
local FF_OPTIONS_STRING=(
+3
View File
@@ -1,4 +1,7 @@
#include "fastfetch.h"
#include "common/caching.h"
#include "common/io.h"
#include "common/printing.h"
#include <stdlib.h>
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#ifndef FF_INCLUDED_common_caching
#define FF_INCLUDED_common_caching
#include "fastfetch.h"
#include "common/format.h"
typedef struct FFcache
{
FILE* value;
FILE* split;
} FFcache;
void ffCacheValidate(FFinstance* instance);
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache);
void ffCacheClose(FFcache* cache);
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs);
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data);
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data);
#endif
+10 -1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/font.h"
#include <string.h>
@@ -188,13 +189,21 @@ void ffFontInitPango(FFfont* font, const char* data)
fontInitPretty(font);
}
void ffFontInitCopy(FFfont* font, const char* name)
void ffFontInitValues(FFfont* font, const char* name, const char* size)
{
fontInit(font);
ffStrbufAppendS(&font->name, name);
ffStrbufAppendS(&font->size, size);
fontInitPretty(font);
}
void ffFontInitCopy(FFfont* font, const char* name)
{
ffFontInitValues(font, name, NULL);
}
void ffFontDestroy(FFfont* font)
{
ffStrbufDestroy(&font->pretty);
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#ifndef FF_INCLUDED_common_font
#define FF_INCLUDED_common_font
#include "util/FFstrbuf.h"
#include "util/FFlist.h"
typedef struct FFfont
{
FFstrbuf pretty;
FFstrbuf name;
FFstrbuf size;
FFlist styles;
} FFfont;
void ffFontInitQt(FFfont* font, const char* data);
void ffFontInitPango(FFfont* font, const char* data);
void ffFontInitCopy(FFfont* font, const char* name);
void ffFontInitValues(FFfont* font, const char* name, const char* size);
void ffFontDestroy(FFfont* font);
#endif
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/format.h"
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg)
{
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#ifndef FF_INCLUDED_common_format
#define FF_INCLUDED_common_format
typedef enum FFformatargtype
{
FF_FORMAT_ARG_TYPE_NULL = 0,
FF_FORMAT_ARG_TYPE_UINT,
FF_FORMAT_ARG_TYPE_UINT16,
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,
FF_FORMAT_ARG_TYPE_LIST
} FFformatargtype;
typedef struct FFformatarg
{
FFformatargtype type;
const void* value;
} FFformatarg;
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
#endif
+89 -9
View File
@@ -1,9 +1,14 @@
#include "fastfetch.h"
#include "common/caching.h"
#include "detection/qt.h"
#include "detection/gtk.h"
#include "detection/displayserver.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <signal.h>
#include <pthread.h>
static bool strbufEqualsAdapter(const void* first, const void* second)
{
@@ -113,15 +118,15 @@ static void initModuleArg(FFModuleArgs* args)
static void defaultConfig(FFinstance* instance)
{
ffStrbufInit(&instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_AUTO;
ffStrbufInit(&instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufInit(&instance->config.logoColors[i]);
instance->config.logoWidth = 0;
instance->config.logoHeight = 0; //preserve aspect ratio
instance->config.logoPaddingLeft = 0;
instance->config.logoPaddingRight = 4;
instance->config.logoPrintRemaining = true;
ffStrbufInit(&instance->config.logo.colors[i]);
instance->config.logo.width = 0;
instance->config.logo.height = 0; //preserve aspect ratio
instance->config.logo.paddingLeft = 0;
instance->config.logo.paddingRight = 4;
instance->config.logo.printRemaining = true;
ffStrbufInit(&instance->config.mainColor);
ffStrbufInit(&instance->config.separator);
@@ -136,6 +141,7 @@ static void defaultConfig(FFinstance* instance)
instance->config.escapeBedrock = true;
instance->config.glType = FF_GL_TYPE_AUTO;
instance->config.pipe = false;
instance->config.multithreading = true;
initModuleArg(&instance->config.os);
initModuleArg(&instance->config.host);
@@ -193,6 +199,8 @@ static void defaultConfig(FFinstance* instance)
ffStrbufInitA(&instance->config.libOSMesa, 0);
ffStrbufInitA(&instance->config.libOpenCL, 0);
instance->config.titleFQDN = false;
ffStrbufInitA(&instance->config.diskFolders, 0);
ffStrbufInitA(&instance->config.batteryDir, 0);
@@ -216,6 +224,75 @@ void ffInitInstance(FFinstance* instance)
defaultConfig(instance);
}
static inline void* detectPlasmaThreadMain(void* instance)
{
ffDetectQt((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK2ThreadMain(void* instance)
{
ffDetectGTK2((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK3ThreadMain(void* instance)
{
ffDetectGTK3((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK4ThreadMain(void* instance)
{
ffDetectGTK4((FFinstance*)instance);
return NULL;
}
static inline void* connectDisplayServerThreadMain(void* instance)
{
ffConnectDisplayServer((FFinstance*)instance);
return NULL;
}
static inline void* startThreadsThreadMain(void* instance)
{
pthread_t dsThread;
pthread_create(&dsThread, NULL, connectDisplayServerThreadMain, instance);
pthread_detach(dsThread);
pthread_t gtk2Thread;
pthread_create(&gtk2Thread, NULL, detectGTK2ThreadMain, instance);
pthread_detach(gtk2Thread);
pthread_t gtk3Thread;
pthread_create(&gtk3Thread, NULL, detectGTK3ThreadMain, instance);
pthread_detach(gtk3Thread);
pthread_t gtk4Thread;
pthread_create(&gtk4Thread, NULL, detectGTK4ThreadMain, instance);
pthread_detach(gtk4Thread);
pthread_t plasmaThread;
pthread_create(&plasmaThread, NULL, detectPlasmaThreadMain, instance);
pthread_detach(plasmaThread);
return NULL;
}
void startDetectionThreads(FFinstance* instance)
{
//Android needs none of the things that are detected here
//And using gsettings sometimes hangs the program in android for some unknown reason,
//and since we don't need it we just never call it.
#ifdef __ANDROID__
return;
#endif
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
pthread_detach(startThreadsThread);
}
static volatile bool ffDisableLinewrap = true;
static volatile bool ffHideCursor = true;
@@ -237,6 +314,9 @@ static void exitSignalHandler(int signal)
void ffStart(FFinstance* instance)
{
if(instance->config.multithreading)
startDetectionThreads(instance);
ffDisableLinewrap = instance->config.disableLinewrap && !instance->config.pipe;
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
@@ -266,7 +346,7 @@ void ffStart(FFinstance* instance)
void ffFinish(FFinstance* instance)
{
if(instance->config.logoPrintRemaining)
if(instance->config.logo.printRemaining)
ffLogoPrintRemaining(instance);
resetConsole();
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/io.h"
#include <sys/stat.h>
#include <unistd.h>
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#ifndef FF_INCLUDED_common_io
#define FF_INCLUDED_common_io
#include <sys/types.h> //mode_t
bool ffWriteFDBuffer(int fd, const FFstrbuf* content);
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer);
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer);
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data);
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer);
bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer);
bool ffFileExists(const char* fileName, mode_t mode);
// Not thread safe!
void ffSuppressIO(bool suppress);
void ffGetTerminalResponse(const char* request, const char* format, ...);
#endif
+1 -1
View File
@@ -1,7 +1,7 @@
#include "fastfetch.h"
#include "common/library.h"
#include <stdarg.h>
#include <dlfcn.h>
static void* libraryLoad(const char* path, int maxVersion)
{
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#ifndef FF_INCLUDED_common_library
#define FF_INCLUDED_common_library
#include <dlfcn.h>
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
void* libraryObjectName = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL);\
if(libraryObjectName == NULL) \
return returnValue;
#define FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, symbolMapping, symbolName, returnValue) \
symbolMapping = dlsym(library, #symbolName); \
if(symbolMapping == NULL) \
{ \
dlclose(library); \
return returnValue; \
}
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, ff ## symbolName, symbolName, returnValue);
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
#endif
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/networking.h"
#include <unistd.h>
#include <sys/socket.h>
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_common_networking
#define FF_INCLUDED_common_networking
#include "util/FFstrbuf.h"
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer);
#endif
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/parsing.h"
bool ffStrSet(const char* str)
{
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#ifndef FF_INCLUDED_parsing_h
#define FF_INCLUDED_parsing_h
#include <stdint.h>
typedef struct FFVersion
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} FFVersion;
#define FF_VERSION_INIT ((FFVersion) {0})
bool ffStrSet(const char* str);
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty);
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
#endif
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat)
{
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#ifndef FF_INCLUDED_common_printing
#define FF_INCLUDED_common_printing
#include "fastfetch.h"
#include "common/format.h"
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...);
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times);
#endif
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/processing.h"
#include "common/io.h"
#include <stdlib.h>
#include <unistd.h>
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_common_processing
#define FF_INCLUDED_common_processing
#include "util/FFstrbuf.h"
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
#endif
+7 -13
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/properties.h"
#include <stdlib.h>
@@ -88,10 +89,13 @@ bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer)
// The following functions return true if the file was found, independently if start was found
// Buffers which already contain content are not overwritten
// The last occurence of start in the first file will be the one used
// The *Values methods always return true, if all properties were already found before, without testing if the file exists
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries)
{
FILE* file = fopen(filename, "r");
if(file == NULL)
return false;
bool valueStorage[4];
bool* unsetValues;
@@ -107,17 +111,8 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
allSet = false;
}
FILE* file = fopen(filename, "r");
if(file == NULL)
return false;
if(allSet)
{
fclose(file);
if(unsetValues != valueStorage)
free(unsetValues);
return true;
}
goto done;
char* line = NULL;
size_t len = 0;
@@ -139,11 +134,10 @@ bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquer
if(line != NULL)
free(line);
done:
fclose(file);
if(unsetValues != valueStorage)
free(unsetValues);
return true;
}
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#ifndef FF_INCLUDED_common_properties
#define FF_INCLUDED_common_properties
#include "util/FFstrbuf.h"
typedef struct FFpropquery
{
const char* start;
FFstrbuf* buffer;
} FFpropquery;
bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer);
bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer);
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer);
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
#endif
+10 -1
View File
@@ -1,8 +1,17 @@
#include "fastfetch.h"
#include "common/settings.h"
#include "common/library.h"
#include "common/io.h"
#include <pthread.h>
#include <string.h>
#include <dlfcn.h>
typedef enum FFInitState
{
FF_INITSTATE_UNINITIALIZED = 0,
FF_INITSTATE_SUCCESSFUL = 1,
FF_INITSTATE_FAILED = 2
} FFInitState;
#define FF_LIBRARY_DATA_LOAD_INIT(dataObject, userLibraryName, ...) \
static dataObject data; \
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#ifndef FF_INCLUDED_common_settings
#define FF_INCLUDED_common_settings
#include "fastfetch.h"
typedef enum FFvarianttype
{
FF_VARIANT_TYPE_STRING,
FF_VARIANT_TYPE_BOOL,
FF_VARIANT_TYPE_INT
} FFvarianttype;
typedef union FFvariant
{
const char* strValue;
int32_t intValue;
struct
{
bool boolValueSet;
bool boolValue;
};
} FFvariant;
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type);
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query);
#ifdef __ANDROID__
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
#endif
#endif
-72
View File
@@ -1,72 +0,0 @@
#include "fastfetch.h"
#include <pthread.h>
static inline void* detectPlasmaThreadMain(void* instance)
{
ffDetectPlasma((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK2ThreadMain(void* instance)
{
ffDetectGTK2((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK3ThreadMain(void* instance)
{
ffDetectGTK3((FFinstance*)instance);
return NULL;
}
static inline void* detectGTK4ThreadMain(void* instance)
{
ffDetectGTK4((FFinstance*)instance);
return NULL;
}
static inline void* connectDisplayServerThreadMain(void* instance)
{
ffConnectDisplayServer((FFinstance*)instance);
return NULL;
}
static inline void* startThreadsThreadMain(void* instance)
{
pthread_t dsThread;
pthread_create(&dsThread, NULL, connectDisplayServerThreadMain, instance);
pthread_detach(dsThread);
pthread_t gtk2Thread;
pthread_create(&gtk2Thread, NULL, detectGTK2ThreadMain, instance);
pthread_detach(gtk2Thread);
pthread_t gtk3Thread;
pthread_create(&gtk3Thread, NULL, detectGTK3ThreadMain, instance);
pthread_detach(gtk3Thread);
pthread_t gtk4Thread;
pthread_create(&gtk4Thread, NULL, detectGTK4ThreadMain, instance);
pthread_detach(gtk4Thread);
pthread_t plasmaThread;
pthread_create(&plasmaThread, NULL, detectPlasmaThreadMain, instance);
pthread_detach(plasmaThread);
return NULL;
}
void ffStartDetectionThreads(FFinstance* instance)
{
//Android needs none of the things that are detected here
//And using gsettings sometimes hangs the program in android for some unknown reason,
//and since we don't need it we just never call it.
#ifdef __ANDROID__
return;
#endif
pthread_t startThreadsThread;
pthread_create(&startThreadsThread, NULL, startThreadsThreadMain, instance);
pthread_detach(startThreadsThread);
}
+16
View File
@@ -0,0 +1,16 @@
# Fastfetch system configuration
# This file sets the defaults for all users of the system.
# For more information about configuration files work,
# see the file ~/.config/fastfetch/config.conf, generated during first
# All options that can be put there (or passed as argument) can be put here too.
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
# Use fastfetch --print-config-system > /etc/fastfetch/config.conf to overwrite this file with the current defaults
# User config option
# Sets if fastfetch should load user provided configuration.
# If this is off, fastfetch ignores the user config file and any passed arguments
# Must be true or false
# Default is true.
#--load-user-config true
@@ -6,7 +6,7 @@
# Empty lines or lines starting with # are ignored.
# This file was shipped with $"FASTFETCH_PROJECT_VERSION$".
# Use fastfetch --print-config > ~/.config/fastfetch/config.conf to overwrite this with the current defaults
# Use fastfetch --print-config-user > ~/.config/fastfetch/config.conf to overwrite this file with the current defaults
# Below some often usefull options are listed. Uncomment and modify them so they take affect.
# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help".
@@ -120,6 +120,12 @@
# Use "fastfetch --help color" to learn more and see examples.
#--color magenta
# Title FQDN option:
# Sets if the title should use the fully qualified domain name.
# Must be true or false.
# Default is false.
#--title-fqdn false
# Separator option:
# Sets the string placed between a key and its value.
# Can be any string.
+12 -10
View File
@@ -1,16 +1,17 @@
Usage: fastfetch <options>
Informative options:
-h,--help: shows this message and exits
-h,--help <command>: shows help for a specific command and exits
-v,--version: prints the version of fastfetch and exits
--list-logos: list available logos and exits
--list-modules: lists available modules and exits
--list-presets: list presets fastfetch knows about and exits. They can be loaded with --load-config. (+)
--list-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
--print-logos: show available logos and exits
--print-config: prints the default config and exits
--print-structure: prints the default stucture and exits
-h,--help: shows this message and exits
-h,--help <command>: shows help for a specific command and exits
-v,--version: prints the version of fastfetch and exits
--list-logos: list available logos and exits
--list-modules: lists available modules and exits
--list-presets: list presets fastfetch knows about and exits. They can be loaded with --load-config. (+)
--list-features: list the supported features fastfetch was compiled with and exits. Mainly for development.
--print-logos: show available logos and exits
--print-config-system: prints the default system config and exits
--print-config-user: prints the default user config and exits
--print-structure: prints the default stucture and exits
General options:
-r,--recache <?value>: generate new cached values
@@ -81,6 +82,7 @@ Library options: Set the path of a library to load
--lib-opencl <path>
Module specific options:
--title-fqdn <?value>: sets if the title should use fully qualified domain name. Default is false.
--separator-string <str>: Set the string printed by the separator module
--os-file <path>: Set the path to the file containing OS informations
--disk-folders <folders>: A colon separated list of folder paths for the disk output. Default is "/:/home"
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "detection/datetime.h"
#include <time.h>
#include <pthread.h>
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#ifndef FF_INCLUDED_detection_datetime
#define FF_INCLUDED_detection_datetime
#include "fastfetch.h"
typedef struct FFDateTimeResult
{
//Examples for 21.02.2022 - 15:18:37
uint16_t year; //2022
uint8_t yearShort; //22
uint8_t month; //2
FFstrbuf monthPretty; //02
FFstrbuf monthName; //February
FFstrbuf monthNameShort; //Feb
uint8_t week; //8
FFstrbuf weekday; //Monday
FFstrbuf weekdayShort; //Mon
uint16_t dayInYear; //52
uint8_t dayInMonth; //21
uint8_t dayInWeek; //1
uint8_t hour; //15
FFstrbuf hourPretty; //15
uint8_t hour12; //3
FFstrbuf hour12Pretty; //03
uint8_t minute; //18
FFstrbuf minutePretty; //18
uint8_t second; //37
FFstrbuf secondPretty; //37
} FFDateTimeResult;
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance);
#endif
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#ifndef FF_INCLUDED_detection_displayserver
#define FF_INCLUDED_detection_displayserver
#include "fastfetch.h"
typedef struct FFResolutionResult
{
uint32_t width;
uint32_t height;
uint32_t refreshRate;
} FFResolutionResult;
typedef struct FFDisplayServerResult
{
FFstrbuf wmProcessName;
FFstrbuf wmPrettyName;
FFstrbuf wmProtocolName;
FFstrbuf deProcessName;
FFstrbuf dePrettyName;
FFstrbuf deVersion;
FFlist resolutions; //List of FFResolutionResult
} FFDisplayServerResult;
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
#endif
@@ -4,6 +4,7 @@
#define FASTFETCH_INCLUDED_DISPLAYSERVER
#include "fastfetch.h"
#include "detection/displayserver.h"
#define FF_DISPLAYSERVER_PROTOCOL_WAYLAND "Wayland"
#define FF_DISPLAYSERVER_PROTOCOL_X11 "X11"
+7 -7
View File
@@ -6,8 +6,9 @@
#include <string.h>
#ifdef FF_HAVE_WAYLAND
#include "common/library.h"
#include "common/io.h"
#include <pthread.h>
#include <dlfcn.h>
#include <wayland-client.h>
#include <sys/socket.h>
@@ -16,7 +17,6 @@ typedef struct WaylandData
FFlist* results;
FF_LIBRARY_SYMBOL(wl_proxy_marshal_constructor_versioned)
FF_LIBRARY_SYMBOL(wl_proxy_add_listener)
FF_LIBRARY_SYMBOL(wl_proxy_destroy)
const struct wl_interface* ffwl_output_interface;
} WaylandData;
@@ -43,9 +43,9 @@ static void stubListener(void* data, ...)
static void waylandOutputModeListener(void* data, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate)
{
WaylandData* wldata = data;
FF_UNUSED(output);
wldata->ffwl_proxy_destroy((struct wl_proxy*) output);
WaylandData* wldata = data;
if(!(flags & WL_OUTPUT_MODE_CURRENT) || width <= 0 || height <= 0)
return;
@@ -111,7 +111,6 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_marshal_constructor_versioned, wl_proxy_marshal_constructor_versioned, false)
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_add_listener, wl_proxy_add_listener, false)
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_output_interface, wl_output_interface, false)
FF_LIBRARY_LOAD_SYMBOL_ADRESS(wayland, data.ffwl_proxy_destroy, wl_proxy_destroy, false)
struct wl_display* display = ffwl_display_connect(NULL);
if(display == NULL)
@@ -141,8 +140,7 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
ffwl_display_dispatch(display);
ffwl_display_roundtrip(display);
data.ffwl_proxy_destroy(registry);
ffwl_display_disconnect(display);
ffwl_display_disconnect(display); //This will also destroy our wl_registry and wl_output proxies
dlclose(wayland);
//We successfully connected to wayland and detected the resolution.
@@ -162,6 +160,8 @@ void ffdsConnectWayland(const FFinstance* instance, FFDisplayServerResult* resul
#ifdef FF_HAVE_WAYLAND
if(detectWayland(instance, result))
return;
#else
FF_UNUSED(instance);
#endif
const char* xdgSessionType = getenv("XDG_SESSION_TYPE");
+6
View File
@@ -1,4 +1,8 @@
#include "displayServer.h"
#include "common/io.h"
#include "common/properties.h"
#include "common/parsing.h"
#include "common/processing.h"
#include <stdlib.h>
#include <ctype.h>
@@ -64,6 +68,8 @@ static void applyPrettyNameIfWM(FFDisplayServerResult* result, const char* proce
strcasecmp(processName, "kwin") == 0
) ffStrbufSetS(&result->wmPrettyName, "KWin");
else if(
strcasecmp(processName, "gnome-shell") == 0 ||
strcasecmp(processName, "gnome shell") == 0 ||
strcasecmp(processName, "gnome-session-binary") == 0 ||
strcasecmp(processName, "Mutter") == 0
) ffStrbufSetS(&result->wmPrettyName, "Mutter");
+1 -1
View File
@@ -1,9 +1,9 @@
#include "displayServer.h"
#ifdef FF_HAVE_XCB
#include "common/library.h"
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <xcb/xcb.h>
typedef struct XcbPropertyData
+2 -1
View File
@@ -1,7 +1,8 @@
#include "displayServer.h"
#ifdef FF_HAVE_X11
#include <dlfcn.h>
#include "common/library.h"
#include "common/parsing.h"
#include <X11/Xlib.h>
typedef struct X11PropertyData
+24 -13
View File
@@ -1,4 +1,8 @@
#include "fastfetch.h"
#include "detection/gtk.h"
#include "common/properties.h"
#include "common/settings.h"
#include "detection/displayserver.h"
#include <pthread.h>
@@ -10,7 +14,7 @@ static inline bool allPropertiesSet(FFGTKResult* result)
result->font.length > 0;
}
static inline void applyGTKDConfSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize)
static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize)
{
if(result->theme.length == 0)
ffStrbufAppendS(&result->theme, themeName);
@@ -28,7 +32,7 @@ static inline void applyGTKDConfSettings(FFGTKResult* result, const char* themeN
ffStrbufAppendF(&result->cursorSize, "%i", cursorSize);
}
static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
static void detectGTKFromSettings(FFinstance* instance, FFGTKResult* result)
{
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -45,7 +49,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
if(init)
{
pthread_mutex_unlock(&mutex);
applyGTKDConfSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
return;
}
@@ -53,7 +57,15 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0)
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Xfce") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Xfce4") == 0)
{
themeName = ffSettingsGetXFConf(instance, "xsettings", "/Net/ThemeName", FF_VARIANT_TYPE_STRING).strValue;
iconsName = ffSettingsGetXFConf(instance, "xsettings", "/Net/IconThemeName", FF_VARIANT_TYPE_STRING).strValue;
fontName = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/FontName", FF_VARIANT_TYPE_STRING).strValue;
cursorTheme = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue;
cursorSize = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue;
}
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Cinnamon") == 0)
{
themeName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/gtk-theme", "org.cinnamon.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
iconsName = ffSettingsGet(instance, "/org/cinnamon/desktop/interface/icon-theme", "org.cinnamon.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
@@ -69,7 +81,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
cursorTheme = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-theme", "org.mate.peripherals-mouse", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
cursorSize = ffSettingsGet(instance, "/org/mate/peripherals-mouse/cursor-size", "org.mate.peripherals-mouse", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
}
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0)
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Gnome") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Unity") == 0 || ffStrbufIgnCaseCompS(&wmde->dePrettyName, "Budgie") == 0)
{
themeName = ffSettingsGet(instance, "/org/gnome/desktop/interface/gtk-theme", "org.gnome.desktop.interface", NULL, "gtk-theme", FF_VARIANT_TYPE_STRING).strValue;
iconsName = ffSettingsGet(instance, "/org/gnome/desktop/interface/icon-theme", "org.gnome.desktop.interface", NULL, "icon-theme", FF_VARIANT_TYPE_STRING).strValue;
@@ -79,7 +91,7 @@ static void detectGTKFromDConf(FFinstance* instance, FFGTKResult* result)
}
pthread_mutex_unlock(&mutex);
applyGTKDConfSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
}
static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
@@ -139,6 +151,12 @@ static void detectGTKFromConfigDir(FFstrbuf* configDir, const char* version, FFG
static void detectGTK(FFinstance* instance, const char* version, FFGTKResult* result)
{
//Mate, Cinnamon and Gnome use dconf to save theme config
//On other DEs, this will do nothing
detectGTKFromSettings(instance, result);
if(allPropertiesSet(result))
return;
//We need to do this because we use multiple threads on configDirs
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
@@ -152,13 +170,6 @@ static void detectGTK(FFinstance* instance, const char* version, FFGTKResult* re
}
ffStrbufDestroy(&baseDir);
if(allPropertiesSet(result))
return;
//Mate, Cinnamon and Gnome use dconf to save theme config
//On other DEs, this will do nothing
detectGTKFromDConf(instance, result);
}
#define FF_DETECT_GTK_IMPL(version) \
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#ifndef FF_INCLUDED_detection_gtk
#define FF_INCLUDED_detection_gtk
#include "fastfetch.h"
typedef struct FFGTKResult
{
FFstrbuf theme;
FFstrbuf icons;
FFstrbuf font;
FFstrbuf cursor;
FFstrbuf cursorSize;
} FFGTKResult;
const FFGTKResult* ffDetectGTK2(FFinstance* instance);
const FFGTKResult* ffDetectGTK4(FFinstance* instance);
const FFGTKResult* ffDetectGTK3(FFinstance* instance);
#endif
+3 -1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "detection/media.h"
#include <string.h>
#include <pthread.h>
@@ -7,7 +8,8 @@
#define FF_DBUS_TIMEOUT_MILLISECONDS 35
#ifdef FF_HAVE_DBUS
#include <dlfcn.h>
#include "common/library.h"
#include "common/parsing.h"
#include <dbus/dbus.h>
#define FF_DBUS_ITER_CONTINUE(iterator) \
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#ifndef FF_INCLUDED_detection_media
#define FF_INCLUDED_detection_media
#include "fastfetch.h"
typedef struct FFMediaResult
{
FFstrbuf busNameShort; //e.g. plasma-browser-integration
FFstrbuf player; // e.g. Google Chrome
FFstrbuf song;
FFstrbuf artist;
FFstrbuf album;
FFstrbuf url;
} FFMediaResult;
const FFMediaResult* ffDetectMedia(FFinstance* instance);
#endif
+6 -1
View File
@@ -1,10 +1,15 @@
#include "fastfetch.h"
#include "detection/os.h"
#include "common/properties.h"
#include "common/parsing.h"
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#if !defined(__ANDROID__)
#if __ANDROID__
#include "common/settings.h"
#else
static bool parseFile(const char* fileName, FFOSResult* result)
{
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#ifndef FF_INCLUDED_detection_os
#define FF_INCLUDED_detection_os
#include "fastfetch.h"
typedef struct FFOSResult
{
FFstrbuf systemName;
FFstrbuf name;
FFstrbuf prettyName;
FFstrbuf id;
FFstrbuf idLike;
FFstrbuf variant;
FFstrbuf variantID;
FFstrbuf version;
FFstrbuf versionID;
FFstrbuf codename;
FFstrbuf buildID;
FFstrbuf architecture;
} FFOSResult;
const FFOSResult* ffDetectOS(const FFinstance* instance);
#endif
+71 -51
View File
@@ -1,9 +1,21 @@
#include "fastfetch.h"
#include "detection/qt.h"
#include "common/properties.h"
#include "detection/displayserver.h"
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
static inline bool allValuesSet(const FFQtResult* result)
{
return
result->widgetStyle.length > 0 &&
result->colorScheme.length > 0 &&
result->icons.length > 0 &&
result->font.length > 0;
}
typedef enum PlasmaCategory
{
PLASMA_CATEGORY_GENERAL,
@@ -12,7 +24,7 @@ typedef enum PlasmaCategory
PLASMA_CATEGORY_OTHER
} PlasmaCategory;
static bool detectFromConfigFile(const char* filename, FFPlasmaResult* result)
static bool detectPlasmaFromFile(const char* filename, FFQtResult* result)
{
FILE* kdeglobals = fopen(filename, "r");
if(kdeglobals == NULL)
@@ -68,10 +80,62 @@ static bool detectFromConfigFile(const char* filename, FFPlasmaResult* result)
return true;
}
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
static void detectPlasma(const FFinstance* instance, FFQtResult* result)
{
bool foundAFile = false;
//We need to do this because we use multiple threads on configDirs
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
{
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
ffStrbufAppendS(&baseDir, "kdeglobals");
if(detectPlasmaFromFile(baseDir.chars, result))
foundAFile = true;
if(allValuesSet(result))
{
ffStrbufDestroy(&baseDir);
return;
}
}
ffStrbufDestroy(&baseDir);
if(!foundAFile)
return;
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
///We must set these values by our self if the file exists (it always does here)
if(result->widgetStyle.length == 0)
ffStrbufAppendS(&result->widgetStyle, "Breeze");
if(result->colorScheme.length == 0)
ffStrbufAppendS(&result->colorScheme, "BreezeLight");
if(result->icons.length == 0)
ffStrbufAppendS(&result->icons, "Breeze");
if(result->font.length == 0)
ffStrbufAppendS(&result->font, "Noto Sans, 10");
}
static void detectLXQt(const FFinstance* instance, FFQtResult* result)
{
ffParsePropFileConfigValues(instance, "lxqt/lxqt.conf", 3, (FFpropquery[]) {
{"style = ", &result->widgetStyle},
{"icon_theme = ", &result->icons},
{"font = ", &result->font}
});
}
const FFQtResult* ffDetectQt(FFinstance* instance)
{
static FFQtResult result;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static FFPlasmaResult result;
static bool init = false;
pthread_mutex_lock(&mutex);
if(init)
@@ -87,55 +151,11 @@ const FFPlasmaResult* ffDetectPlasma(FFinstance* instance)
ffStrbufInit(&result.font);
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->deProcessName, "plasmashell") != 0)
{
pthread_mutex_unlock(&mutex);
return &result;
}
bool foundAFile = false;
//We need to do this because we use multiple threads on configDirs
FFstrbuf baseDir;
ffStrbufInitA(&baseDir, 64);
for(uint32_t i = 0; i < instance->state.configDirs.length; i++)
{
ffStrbufSet(&baseDir, ffListGet(&instance->state.configDirs, i));
ffStrbufAppendS(&baseDir, "kdeglobals");
if(detectFromConfigFile(baseDir.chars, &result))
foundAFile = true;
if(
result.widgetStyle.length > 0 &&
result.colorScheme.length > 0 &&
result.icons.length > 0 &&
result.font.length > 0
) break;
}
ffStrbufDestroy(&baseDir);
if(!foundAFile)
{
pthread_mutex_unlock(&mutex);
return &result;
}
//In Plasma the default value is never set in the config file, but the whole key-value is discarded.
///We must set these values by our self if the file exists (it always does here)
if(result.widgetStyle.length == 0)
ffStrbufAppendS(&result.widgetStyle, "Breeze");
if(result.colorScheme.length == 0)
ffStrbufAppendS(&result.colorScheme, "BreezeLight");
if(result.icons.length == 0)
ffStrbufAppendS(&result.icons, "Breeze");
if(result.font.length == 0)
ffStrbufAppendS(&result.font, "Noto Sans, 10");
if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "KDE Plasma") == 0)
detectPlasma(instance, &result);
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, "LXQt") == 0)
detectLXQt(instance, &result);
pthread_mutex_unlock(&mutex);
return &result;
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#ifndef FF_INCLUDED_detection_qt
#define FF_INCLUDED_detection_qt
#include "fastfetch.h"
typedef struct FFQtResult
{
FFstrbuf widgetStyle;
FFstrbuf colorScheme;
FFstrbuf icons;
FFstrbuf font;
} FFQtResult;
const FFQtResult* ffDetectQt(FFinstance* instance);
#endif
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "detection/temps.h"
#include "common/io.h"
#include <string.h>
#include <pthread.h>
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#ifndef FF_INCLUDED_detection_temps
#define FF_INCLUDED_detection_temps
#include "fastfetch.h"
typedef struct FFTempValue
{
FFstrbuf name;
FFstrbuf deviceClass;
double value;
} FFTempValue;
typedef struct FFTempsResult
{
FFlist values; //List of FFTempValue
} FFTempsResult;
const FFTempsResult* ffDetectTemps(const FFinstance* instance);
#endif
+11 -6
View File
@@ -1,4 +1,8 @@
#include "fastfetch.h"
#include "detection/terminalshell.h"
#include "common/io.h"
#include "common/parsing.h"
#include "common/processing.h"
#include <ctype.h>
#include <string.h>
@@ -69,12 +73,13 @@ static void getTerminalShell(FFTerminalShellResult* result, const char* pid)
//Common programs that are between terminal and own process, but are not the shell
if(
strcasecmp(name, "sudo") == 0 ||
strcasecmp(name, "su") == 0 ||
strcasecmp(name, "doas") == 0 ||
strcasecmp(name, "strace") == 0 ||
strcasecmp(name, "sshd") == 0 ||
strcasecmp(name, "gdb") == 0
strcasecmp(name, "sudo") == 0 ||
strcasecmp(name, "su") == 0 ||
strcasecmp(name, "doas") == 0 ||
strcasecmp(name, "strace") == 0 ||
strcasecmp(name, "sshd") == 0 ||
strcasecmp(name, "gdb") == 0 ||
strcasecmp(name, "guake-wrapped") == 0
) {
getTerminalShell(result, ppid);
return;
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#ifndef FF_INCLUDED_detection_terminalshell
#define FF_INCLUDED_detection_terminalshell
#include "fastfetch.h"
typedef struct FFTerminalShellResult
{
FFstrbuf shellProcessName;
FFstrbuf shellExe;
const char* shellExeName; //pointer to a char in shellExe
FFstrbuf shellVersion;
FFstrbuf terminalProcessName;
FFstrbuf terminalExe;
const char* terminalExeName; //pointer to a char in terminalExe
FFstrbuf userShellExe;
const char* userShellExeName; //pointer to a char in userShellExe
FFstrbuf userShellVersion;
} FFTerminalShellResult;
const FFTerminalShellResult* ffDetectTerminalShell(FFinstance* instance);
#endif
+38
View File
@@ -0,0 +1,38 @@
#include "fastfetch.h"
#include "detection/title.h"
#include <limits.h>
#include <unistd.h>
#include <pthread.h>
#include <netdb.h>
const FFTitleResult* ffDetectTitle(const FFinstance* instance)
{
static FFTitleResult result;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static bool init = false;
pthread_mutex_lock(&mutex);
if(init)
{
pthread_mutex_unlock(&mutex);
return &result;
}
init = true;
ffStrbufInit(&result.userName);
ffStrbufAppendS(&result.userName, instance->state.passwd->pw_name);
ffStrbufInitA(&result.hostname, HOST_NAME_MAX);
ffStrbufAppendS(&result.hostname, instance->state.utsname.nodename);
ffStrbufInitA(&result.fqdn, HOST_NAME_MAX);
struct hostent* host = gethostbyname(result.hostname.chars);
if(host != NULL)
ffStrbufAppendS(&result.fqdn, host->h_name);
if(result.fqdn.length == 0)
ffStrbufAppend(&result.fqdn, &result.hostname);
pthread_mutex_unlock(&mutex);
return &result;
}
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#ifndef FF_INCLUDED_detection_title
#define FF_INCLUDED_detection_title
#include "fastfetch.h"
typedef struct FFTitleResult
{
FFstrbuf userName;
FFstrbuf hostname;
FFstrbuf fqdn; //Fully qualified domain name
} FFTitleResult;
const FFTitleResult* ffDetectTitle(const FFinstance* instance);
#endif
+4 -1
View File
@@ -1,10 +1,13 @@
#include "fastfetch.h"
#include "detection/vulkan.h"
#include <pthread.h>
#ifdef FF_HAVE_VULKAN
#include "common/library.h"
#include "common/io.h"
#include "common/parsing.h"
#include <stdlib.h>
#include <dlfcn.h>
#include <vulkan/vulkan.h>
static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersion)
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#ifndef FF_INCLUDED_detection_vulkan
#define FF_INCLUDED_detection_vulkan
#include "fastfetch.h"
typedef struct FFGPUResult
{
FFstrbuf vendor;
FFstrbuf name;
FFstrbuf driver;
double temperature;
} FFGPUResult;
typedef struct FFVulkanResult
{
FFstrbuf driver;
FFstrbuf apiVersion;
FFstrbuf conformanceVersion;
FFlist devices; //List of FFGPUResult
} FFVulkanResult;
const FFVulkanResult* ffDetectVulkan(const FFinstance* instance);
#endif
+67 -41
View File
@@ -1,4 +1,7 @@
#include "fastfetch.h"
#include "util/FFvaluestore.h"
#include "common/printing.h"
#include "common/parsing.h"
#include <stdlib.h>
#include <string.h>
@@ -10,7 +13,7 @@ typedef struct FFdata
{
FFvaluestore valuestore;
FFstrbuf structure;
bool multithreading;
bool loadUserConfig;
} FFdata;
static void constructAndPrintCommandHelpFormat(const char* name, const char* def, uint32_t numArgs, ...)
@@ -111,6 +114,7 @@ static inline void printCommandHelp(const char* command)
"Number of rpm packages",
"Number of emerge packages",
"Number of xbps packages",
"Number of nix-system packages",
"Number of nix-user packages",
"Number of nix-default packages",
"Number of flatpak packages",
@@ -685,9 +689,14 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
puts(FASTFETCH_PROJECT_VERSION);
exit(0);
}
else if(strcasecmp(key, "--print-config") == 0)
else if(strcasecmp(key, "--print-config-system") == 0)
{
fputs(FASTFETCH_DATATEXT_CONFIG, stdout);
fputs(FASTFETCH_DATATEXT_CONFIG_SYSTEM, stdout);
exit(0);
}
else if(strcasecmp(key, "--print-config-user") == 0)
{
fputs(FASTFETCH_DATATEXT_CONFIG_USER, stdout);
exit(0);
}
else if(strcasecmp(key, "--print-structure") == 0)
@@ -744,13 +753,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
else if(strcasecmp(key, "--load-config") == 0)
optionParseConfigFile(instance, data, key, value);
else if(strcasecmp(key, "--multithreading") == 0)
data->multithreading = optionParseBoolean(value);
instance->config.multithreading = optionParseBoolean(value);
else if(strcasecmp(key, "--allow-slow-operations") == 0)
instance->config.allowSlowOperations = optionParseBoolean(value);
else if(strcasecmp(key, "--escape-bedrock") == 0)
instance->config.escapeBedrock = optionParseBoolean(value);
else if(strcasecmp(key, "--pipe") == 0)
instance->config.pipe = optionParseBoolean(value);
else if(strcasecmp(key, "--load-user-config") == 0)
data->loadUserConfig = optionParseBoolean(value);
////////////////
//Logo options//
@@ -758,13 +769,13 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
else if(strcasecmp(key, "-l") == 0 || strcasecmp(key, "--logo") == 0)
{
optionParseString(key, value, &instance->config.logoSource);
optionParseString(key, value, &instance->config.logo.source);
//this is usally wanted when using the none logo
if(strcasecmp(value, "none") == 0)
{
instance->config.logoPaddingRight = 0;
instance->config.logoPaddingLeft = 0;
instance->config.logo.paddingRight = 0;
instance->config.logo.paddingLeft = 0;
}
}
else if(strcasecmp(key, "--logo-type") == 0)
@@ -776,19 +787,19 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
}
if(strcasecmp(value, "auto") == 0)
instance->config.logoType = FF_LOGO_TYPE_AUTO;
instance->config.logo.type = FF_LOGO_TYPE_AUTO;
else if(strcasecmp(value, "builtin") == 0)
instance->config.logoType = FF_LOGO_TYPE_BUILTIN;
instance->config.logo.type = FF_LOGO_TYPE_BUILTIN;
else if(strcasecmp(value, "file") == 0)
instance->config.logoType = FF_LOGO_TYPE_FILE;
instance->config.logo.type = FF_LOGO_TYPE_FILE;
else if(strcasecmp(value, "raw") == 0)
instance->config.logoType = FF_LOGO_TYPE_RAW;
instance->config.logo.type = FF_LOGO_TYPE_RAW;
else if(strcasecmp(value, "sixel") == 0)
instance->config.logoType = FF_LOGO_TYPE_SIXEL;
instance->config.logo.type = FF_LOGO_TYPE_SIXEL;
else if(strcasecmp(value, "kitty") == 0)
instance->config.logoType = FF_LOGO_TYPE_KITTY;
instance->config.logo.type = FF_LOGO_TYPE_KITTY;
else if(strcasecmp(value, "chafa") == 0)
instance->config.logoType = FF_LOGO_TYPE_CHAFA;
instance->config.logo.type = FF_LOGO_TYPE_CHAFA;
else
{
fprintf(stderr, "Error: unknown logo type: %s\n", value);
@@ -807,48 +818,48 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
exit(472);
}
optionParseColor(key, value, &instance->config.logoColors[index]);
optionParseColor(key, value, &instance->config.logo.colors[index]);
}
else if(strcasecmp(key, "--logo-width") == 0)
instance->config.logoWidth = optionParseUInt32(key, value);
instance->config.logo.width = optionParseUInt32(key, value);
else if(strcasecmp(key, "--logo-height") == 0)
instance->config.logoHeight = optionParseUInt32(key, value);
instance->config.logo.height = optionParseUInt32(key, value);
else if(strcasecmp(key, "--logo-padding") == 0)
{
uint32_t padding = optionParseUInt32(key, value);
instance->config.logoPaddingLeft = padding;
instance->config.logoPaddingRight = padding;
instance->config.logo.paddingLeft = padding;
instance->config.logo.paddingRight = padding;
}
else if(strcasecmp(key, "--logo-padding-left") == 0)
instance->config.logoPaddingLeft = optionParseUInt32(key, value);
instance->config.logo.paddingLeft = optionParseUInt32(key, value);
else if(strcasecmp(key, "--logo-padding-right") == 0)
instance->config.logoPaddingRight = optionParseUInt32(key, value);
instance->config.logo.paddingRight = optionParseUInt32(key, value);
else if(strcasecmp(key, "--logo-print-remaining") == 0)
instance->config.logoPrintRemaining = optionParseBoolean(value);
instance->config.logo.printRemaining = optionParseBoolean(value);
else if(strcasecmp(key, "--sixel") == 0)
{
optionParseString(key, value, &instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_SIXEL;
optionParseString(key, value, &instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_SIXEL;
}
else if(strcasecmp(key, "--kitty") == 0)
{
optionParseString(key, value, &instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_KITTY;
optionParseString(key, value, &instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_KITTY;
}
else if(strcasecmp(key, "--file") == 0)
{
optionCheckString(key, value, &instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_FILE;
optionCheckString(key, value, &instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_FILE;
}
else if(strcasecmp(key, "--raw") == 0)
{
optionParseString(key, value, &instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_RAW;
optionParseString(key, value, &instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_RAW;
}
else if(strcasecmp(key, "--chafa") == 0)
{
optionParseString(key, value, &instance->config.logoSource);
instance->config.logoType = FF_LOGO_TYPE_CHAFA;
optionParseString(key, value, &instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_CHAFA;
}
///////////////////
@@ -1146,6 +1157,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
//Module options//
//////////////////
else if(strcasecmp(key, "--title-fqdn") == 0)
instance->config.titleFQDN = optionParseBoolean(value);
else if(strcasecmp(key, "--disk-folders") == 0)
optionParseString(key, value, &instance->config.diskFolders);
else if(strcasecmp(key, "--battery-dir") == 0)
@@ -1198,8 +1211,21 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
}
}
static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
static void parseConfigFileSystem(FFinstance* instance, FFdata* data)
{
FILE* file = fopen(FASTFETCH_TARGET_DIR_ROOT"/etc/fastfetch/config.conf", "r");
if(file == NULL)
return;
parseConfigFile(instance, data, file);
fclose(file);
}
static void parseConfigFileUser(FFinstance* instance, FFdata* data)
{
if(!data->loadUserConfig)
return;
FFstrbuf* filename = ffListGet(&instance->state.configDirs, 0);
uint32_t filenameLength = filename->length;
@@ -1222,7 +1248,7 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
file = fopen(filename->chars, "w");
if(file != NULL)
{
fputs(FASTFETCH_DATATEXT_CONFIG, file);
fputs(FASTFETCH_DATATEXT_CONFIG_USER, file);
fclose(file);
}
@@ -1231,6 +1257,9 @@ static void parseDefaultConfigFile(FFinstance* instance, FFdata* data)
static void parseArguments(FFinstance* instance, FFdata* data, int argc, const char** argv)
{
if(!data->loadUserConfig)
return;
for(int i = 1; i < argc; i++)
{
if(i == argc - 1 || (
@@ -1334,7 +1363,7 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
else if(strcasecmp(line, "opencl") == 0)
ffPrintOpenCL(instance);
else
ffPrintError(instance, line, 0, NULL, NULL, 0, "<no implementation provided>");
ffPrintErrorString(instance, line, 0, NULL, NULL, "<no implementation provided>");
}
int main(int argc, const char** argv)
@@ -1346,15 +1375,12 @@ int main(int argc, const char** argv)
FFdata data;
ffValuestoreInit(&data.valuestore);
ffStrbufInitA(&data.structure, 256);
data.multithreading = true;
data.loadUserConfig = true;
parseDefaultConfigFile(&instance, &data);
parseConfigFileSystem(&instance, &data);
parseConfigFileUser(&instance, &data);
parseArguments(&instance, &data, argc, argv);
//Start detection threads
if(data.multithreading)
ffStartDetectionThreads(&instance);
//If we don't have a custom structure, use the default one
if(data.structure.length == 0)
ffStrbufSetS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
+15 -363
View File
@@ -9,13 +9,11 @@
#include <stdbool.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/sysinfo.h>
#include "util/FFstrbuf.h"
#include "util/FFlist.h"
#include "util/FFvaluestore.h"
static inline void ffUnused(int dummy, ...) { (void) dummy; }
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
@@ -54,14 +52,17 @@ typedef struct FFModuleArgs
typedef struct FFconfig
{
FFstrbuf logoSource;
FFLogoType logoType;
FFstrbuf logoColors[FASTFETCH_LOGO_MAX_COLORS];
uint32_t logoWidth;
uint32_t logoHeight;
uint32_t logoPaddingLeft;
uint32_t logoPaddingRight;
bool logoPrintRemaining;
struct
{
FFstrbuf source;
FFLogoType type;
FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
uint32_t width;
uint32_t height;
uint32_t paddingLeft;
uint32_t paddingRight;
bool printRemaining;
} logo;
FFstrbuf mainColor; //If this is empty, ffLogoPrint will set it to the main color of the logo
FFstrbuf separator;
@@ -75,6 +76,7 @@ typedef struct FFconfig
bool escapeBedrock;
FFGLType glType;
bool pipe; //disables logo and all escape sequences
bool multithreading;
FFModuleArgs os;
FFModuleArgs host;
@@ -132,6 +134,8 @@ typedef struct FFconfig
FFstrbuf libOSMesa;
FFstrbuf libOpenCL;
bool titleFQDN;
FFstrbuf diskFolders;
FFstrbuf batteryDir;
@@ -169,237 +173,8 @@ typedef struct FFinstance
FFstate state;
} FFinstance;
typedef struct FFVersion
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} FFVersion;
#define FF_VERSION_INIT ((FFVersion) {0})
typedef struct FFTitleResult
{
FFstrbuf userName;
FFstrbuf hostname;
} FFTitleResult;
typedef struct FFOSResult
{
FFstrbuf systemName;
FFstrbuf name;
FFstrbuf prettyName;
FFstrbuf id;
FFstrbuf idLike;
FFstrbuf variant;
FFstrbuf variantID;
FFstrbuf version;
FFstrbuf versionID;
FFstrbuf codename;
FFstrbuf buildID;
FFstrbuf architecture;
} FFOSResult;
typedef struct FFPlasmaResult
{
FFstrbuf widgetStyle;
FFstrbuf colorScheme;
FFstrbuf icons;
FFstrbuf font;
} FFPlasmaResult;
typedef struct FFGTKResult
{
FFstrbuf theme;
FFstrbuf icons;
FFstrbuf font;
FFstrbuf cursor;
FFstrbuf cursorSize;
} FFGTKResult;
typedef struct FFTerminalShellResult
{
FFstrbuf shellProcessName;
FFstrbuf shellExe;
const char* shellExeName; //pointer to a char in shellExe
FFstrbuf shellVersion;
FFstrbuf terminalProcessName;
FFstrbuf terminalExe;
const char* terminalExeName; //pointer to a char in terminalExe
FFstrbuf userShellExe;
const char* userShellExeName; //pointer to a char in userShellExe
FFstrbuf userShellVersion;
} FFTerminalShellResult;
typedef struct FFGPUResult
{
FFstrbuf vendor;
FFstrbuf name;
FFstrbuf driver;
double temperature;
} FFGPUResult;
typedef struct FFVulkanResult
{
FFstrbuf driver;
FFstrbuf apiVersion;
FFstrbuf conformanceVersion;
FFlist devices; //List of FFGPUResult
} FFVulkanResult;
typedef struct FFResolutionResult
{
uint32_t width;
uint32_t height;
uint32_t refreshRate;
} FFResolutionResult;
typedef struct FFDisplayServerResult
{
FFstrbuf wmProcessName;
FFstrbuf wmPrettyName;
FFstrbuf wmProtocolName;
FFstrbuf deProcessName;
FFstrbuf dePrettyName;
FFstrbuf deVersion;
FFlist resolutions; //List of FFResolutionResult
} FFDisplayServerResult;
typedef struct FFTempValue
{
FFstrbuf name;
FFstrbuf deviceClass;
double value;
} FFTempValue;
typedef struct FFTempsResult
{
FFlist values; //List of FFTempValue
} FFTempsResult;
typedef struct FFMediaResult
{
FFstrbuf busNameShort; //e.g. plasma-browser-integration
FFstrbuf player; // e.g. Google Chrome
FFstrbuf song;
FFstrbuf artist;
FFstrbuf album;
FFstrbuf url;
} FFMediaResult;
typedef struct FFDateTimeResult
{
//Examples for 21.02.2022 - 15:18:37
uint16_t year; //2022
uint8_t yearShort; //22
uint8_t month; //2
FFstrbuf monthPretty; //02
FFstrbuf monthName; //February
FFstrbuf monthNameShort; //Feb
uint8_t week; //8
FFstrbuf weekday; //Monday
FFstrbuf weekdayShort; //Mon
uint16_t dayInYear; //52
uint8_t dayInMonth; //21
uint8_t dayInWeek; //1
uint8_t hour; //15
FFstrbuf hourPretty; //15
uint8_t hour12; //3
FFstrbuf hour12Pretty; //03
uint8_t minute; //18
FFstrbuf minutePretty; //18
uint8_t second; //37
FFstrbuf secondPretty; //37
} FFDateTimeResult;
typedef enum FFformatargtype
{
FF_FORMAT_ARG_TYPE_NULL = 0,
FF_FORMAT_ARG_TYPE_UINT,
FF_FORMAT_ARG_TYPE_UINT16,
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,
FF_FORMAT_ARG_TYPE_LIST
} FFformatargtype;
typedef struct FFformatarg
{
FFformatargtype type;
const void* value;
} FFformatarg;
typedef struct FFcache
{
FILE* value;
FILE* split;
} FFcache;
typedef enum FFvarianttype
{
FF_VARIANT_TYPE_STRING,
FF_VARIANT_TYPE_BOOL,
FF_VARIANT_TYPE_INT
} FFvarianttype;
typedef union FFvariant
{
const char* strValue;
int32_t intValue;
struct
{
bool boolValueSet;
bool boolValue;
};
} FFvariant;
#define FF_VARIANT_NULL ((FFvariant){.strValue = NULL})
typedef struct FFfont
{
FFstrbuf pretty;
FFstrbuf name;
FFstrbuf size;
FFlist styles;
} FFfont;
typedef struct FFpropquery
{
const char* start;
FFstrbuf* buffer;
} FFpropquery;
typedef enum FFInitState
{
FF_INITSTATE_UNINITIALIZED = 0,
FF_INITSTATE_SUCCESSFUL = 1,
FF_INITSTATE_FAILED = 2
} FFInitState;
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
void* libraryObjectName = ffLibraryLoad(&userLibraryName, __VA_ARGS__, NULL);\
if(libraryObjectName == NULL) \
return returnValue;
#define FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, symbolMapping, symbolName, returnValue) \
symbolMapping = dlsym(library, #symbolName); \
if(symbolMapping == NULL) \
{ \
dlclose(library); \
return returnValue; \
}
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
__typeof__(&symbolName) FF_LIBRARY_LOAD_SYMBOL_ADRESS(library, ff ## symbolName, symbolName, returnValue);
//////////////////////
// Common functions //
// Init functions //
//////////////////////
//common/init.c
@@ -409,95 +184,6 @@ void ffFinish(FFinstance* instance);
void ffListFeatures();
//common/threading.c
void ffStartDetectionThreads(FFinstance* instance);
//common/io.c
bool ffWriteFDBuffer(int fd, const FFstrbuf* content);
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer);
bool ffAppendFDBuffer(int fd, FFstrbuf* buffer);
ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data);
bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer);
bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer);
bool ffFileExists(const char* fileName, mode_t mode);
void ffSuppressIO(bool suppress); // Not thread safe!
void ffGetTerminalResponse(const char* request, const char* format, ...);
//common/printing.c
void ffPrintLogoAndKey(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat);
void ffPrintFormatString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* format, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintFormat(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintErrorString(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFstrbuf* customKeyFormat, const FFstrbuf* customErrorFormat, const char* message, ...);
void ffPrintError(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, const char* message, ...);
void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times);
//common/caching.c
void ffCacheValidate(FFinstance* instance);
void ffCacheOpenWrite(FFinstance* instance, const char* moduleName, FFcache* cache);
void ffCacheClose(FFcache* cache);
bool ffPrintFromCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, uint32_t numArgs);
void ffPrintAndAppendToCache(FFinstance* instance, const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFcache* cache, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
void ffPrintAndWriteToCache(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs, const FFstrbuf* value, uint32_t numArgs, const FFformatarg* arguments);
void ffCachingWriteData(const FFinstance* instance, const char* moduleName, size_t dataSize, const void* data);
bool ffCachingReadData(const FFinstance* instance, const char* moduleName, size_t dataSize, void* data);
//common/properties.c
bool ffParsePropLine(const char* line, const char* start, FFstrbuf* buffer);
bool ffParsePropLines(const char* lines, const char* start, FFstrbuf* buffer);
bool ffParsePropFileValues(const char* filename, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFile(const char* filename, const char* start, FFstrbuf* buffer);
bool ffParsePropFileHomeValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileHome(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
bool ffParsePropFileConfigValues(const FFinstance* instance, const char* relativeFile, uint32_t numQueries, FFpropquery* queries);
bool ffParsePropFileConfig(const FFinstance* instance, const char* relativeFile, const char* start, FFstrbuf* buffer);
//common/font.c
void ffFontInitQt(FFfont* font, const char* data);
void ffFontInitPango(FFfont* font, const char* data);
void ffFontInitCopy(FFfont* font, const char* name);
void ffFontDestroy(FFfont* font);
//common/format.c
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
//common/parsing.c
bool ffStrSet(const char* str);
void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch);
void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, const FFstrbuf* gtk4);
void ffVersionToPretty(const FFVersion* version, FFstrbuf* pretty);
int8_t ffVersionCompare(const FFVersion* version1, const FFVersion* version2);
//common/processing.c
void ffProcessAppendStdOut(FFstrbuf* buffer, char* const argv[]);
//common/libraries.c
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
//common/networking.c
void ffNetworkingGetHttp(const char* host, const char* path, uint32_t timeout, FFstrbuf* buffer);
//common/settings.c
FFvariant ffSettingsGetDConf(FFinstance* instance, const char* key, FFvarianttype type);
FFvariant ffSettingsGetGSettings(FFinstance* instance, const char* schemaName, const char* path, const char* key, FFvarianttype type);
FFvariant ffSettingsGet(FFinstance* instance, const char* dconfKey, const char* gsettingsSchemaName, const char* gsettingsPath, const char* gsettingsKey, FFvarianttype type);
FFvariant ffSettingsGetXFConf(FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query);
#ifdef __ANDROID__
bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
#endif
////////////////////
// Logo functions //
////////////////////
@@ -510,45 +196,11 @@ void ffLogoBuiltinPrint(FFinstance* instance);
void ffLogoBuiltinList();
void ffLogoBuiltinListAutocompletion();
/////////////////////////
// Detection functions //
/////////////////////////
//detection/os.c
const FFOSResult* ffDetectOS(const FFinstance* instance);
//detection/plasma.c
const FFPlasmaResult* ffDetectPlasma(FFinstance* instance);
//detection/gtk.c
const FFGTKResult* ffDetectGTK2(FFinstance* instance);
const FFGTKResult* ffDetectGTK4(FFinstance* instance);
const FFGTKResult* ffDetectGTK3(FFinstance* instance);
//detection/displayServer.c
const FFDisplayServerResult* ffConnectDisplayServer(const FFinstance* instance);
//detection/terminalShell.c
const FFTerminalShellResult* ffDetectTerminalShell(FFinstance* instance);
//detection/temps.c (currently unused)
const FFTempsResult* ffDetectTemps(const FFinstance* instance);
//detection/media.c
const FFMediaResult* ffDetectMedia(FFinstance* instance);
//detection/dateTime.c
const FFDateTimeResult* ffDetectDateTime(const FFinstance* instance);
//detection/vulkan.c
const FFVulkanResult* ffDetectVulkan(const FFinstance* instance);
//////////////////////
// Module functions //
//////////////////////
//Common
const FFTitleResult* ffDetectTitle(FFinstance* instance);
void ffPrintDateTimeFormat(FFinstance* instance, const char* moduleName, const FFModuleArgs* moduleArgs);
+2 -1
View File
@@ -13,7 +13,8 @@
#define FASTFETCH_TARGET_DIR_HOME "@TARGET_DIR_HOME@"
#define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@"
#define FASTFETCH_DATATEXT_CONFIG "@DATATEXT_CONFIG@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set
#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@" //Requires FASTFETCH_PROJECT_VERSION to be set
#define FASTFETCH_DATATEXT_CONFIG_USER "@DATATEXT_CONFIG_USER@" //Requires FASTFETCH_PROJECT_VERSION and FASTFETCH_DATATEXT_STRUCTURE to be set
#define FASTFETCH_DATATEXT_MODULES "@DATATEXT_MODULES@"
#define FASTFETCH_DATATEXT_HELP "@DATATEXT_HELP@"
#define FASTFETCH_DATATEXT_HELP_COLOR "@DATATEXT_HELP_COLOR@"
+1 -4
View File
@@ -10,10 +10,7 @@ int main(int argc, char** argv)
//Modify instance.config here
//Multithreading --> better performance
ffStartDetectionThreads(&instance);
//Does things like disabling line wrap
//Does things like starting detection threads, disabling line wrap, etc
ffStart(&instance);
//Printing
+28 -19
View File
@@ -998,25 +998,34 @@ static const FFlogo* getLogoNixOsOld()
FF_LOGO_INIT
FF_LOGO_NAMES("nixos_old", "nix-old", "nixos-old", "nix_old", "nix-os-old", "nix_os_old")
FF_LOGO_LINES(
"$1 ::::. $2'::::: ::::'\n"
"$1 '::::: $2':::::. ::::'\n"
"$1 ::::: $2'::::.:::::\n"
"$1 .......:::::..... $2::::::::\n"
"$1 ::::::::::::::::::. $2:::::: $1::::.\n"
" ::::::::::::::::::::: $2:::::. $1.::::'\n"
"$2 ..... ::::' $1:::::'\n"
"$2 ::::: '::' $1:::::'\n"
"$2 ........::::: ' $1:::::::::::.\n"
"$2::::::::::::: $1:::::::::::::\n"
"$2 ::::::::::: $1.. $1:::::\n"
"$2 .::::: $1.::: $1:::::\n"
"$2 .::::: $1::::: $1''''' $2.....\n"
" ::::: $1':::::. $2......:::::::::::::'\n"
" ::: $1::::::. $2':::::::::::::::::'\n"
"$1 .:::::::: $2'::::::::::\n"
"$1 .::::''::::. $2'::::.\n"
"$1 .::::' ::::. $2'::::.\n"
"$1 .:::: :::: $2'::::."
"$1 ____ $2_______ ____\n"
"$1 /####\\ $2\\######\\ /####\\\n"
"$1 ######\\ $2\\######\\ /#####/\n"
"$1 \\######\\ $2\\######\\ /#####/\n"
"$1 \\######\\ $2\\######\\/#####/ $1/\\\n"
"$1 \\######\\ $2\\###########/ $1/##\\\n"
"$1 ________\\######\\______$2\\#########/ $1/####\\\n"
"$1 /#######################$2\\#######/ $1/######\n"
"$1 /#########################$2\\######\\ $1/######/\n"
"$1 /###########################$2\\######\\ $1/######/\n"
"$1 ¯¯¯¯¯¯¯¯¯¯¯¯$2/######/$1¯¯¯¯¯¯¯¯¯$2\\######$1/######/\n"
"$2 /######/ $2\\####$1/######/________\n"
"$2 _____________/######/ $2\\##$1/################\\\n"
"$2 /###################/ $2\\$1/##################\\\n"
"$2 \\##################/$1\\ /###################/\n"
"$2 \\################/$1##\\ /######/¯¯¯¯¯¯¯¯¯¯¯¯¯\n"
"$2 ¯¯¯¯¯¯¯¯/######/$1####\\ /######/\n"
"$2 /######/$1######\\$2_________$1/######/$2____________\n"
"$2 /######/ $1\\######\\$2###########################/\n"
"$2 /######/ $1\\######\\$2#########################/\n"
"$2 ######/ $1/#######\\$2#######################/\n"
"$2 \\####/ $1/#########\\$2¯¯¯¯¯¯\\######\\¯¯¯¯¯¯¯¯\n"
"$2 \\##/ $1/###########\\$2 \\######\\\n"
"$2 \\/ $1/#####/\\######\\$2 \\######\\\n"
"$1 $1/#####/ \\######\\$2 \\######\\\n"
"$1 $1/#####/ \\######\\$2 \\######\n"
"$1 $1\\####/ \\######\\$2 \\####/\n"
"$1 $1¯¯¯¯ ¯¯¯¯¯¯¯$2 ¯¯¯¯"
)
FF_LOGO_COLORS(
"34", //blue
+1 -1
View File
@@ -1,8 +1,8 @@
#ifdef FF_HAVE_IMAGEMAGICK6
#include "image.h"
#include "common/library.h"
#include <dlfcn.h>
#include <magick/MagickCore.h>
static FF_LIBRARY_SYMBOL(ResizeImage);
+1 -1
View File
@@ -1,8 +1,8 @@
#ifdef FF_HAVE_IMAGEMAGICK7
#include "image.h"
#include "common/library.h"
#include <dlfcn.h>
#include <MagickCore/MagickCore.h>
static FF_LIBRARY_SYMBOL(ResizeImage);
+16 -14
View File
@@ -1,4 +1,6 @@
#include "image.h"
#include "common/io.h"
#include "common/printing.h"
#if defined(FF_HAVE_IMAGEMAGICK7) || defined(FF_HAVE_IMAGEMAGICK6)
@@ -17,8 +19,8 @@
#include <sys/ioctl.h>
#ifdef FF_HAVE_ZLIB
#include "common/library.h"
#include <stdlib.h>
#include <dlfcn.h>
#include <zlib.h>
static bool compressBlob(const FFinstance* instance, void** blob, size_t* length)
@@ -109,7 +111,7 @@ static void writeCacheUint32(FFLogoRequestData* requestData, uint32_t value, con
static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestData, const FFstrbuf* result, const char* cacheFileName)
{
//Calculate character dimensions
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logoPaddingLeft + instance->config.logoPaddingRight;
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight;
instance->state.logoHeight = requestData->logoCharacterHeight;
if(requestData->type == FF_LOGO_TYPE_KITTY)
@@ -118,14 +120,14 @@ static void printImagePixels(FFinstance* instance, FFLogoRequestData* requestDat
//Write cache files
writeCacheStrbuf(requestData, result, cacheFileName);
if(instance->config.logoWidth == 0)
if(instance->config.logo.width == 0)
writeCacheUint32(requestData, instance->state.logoWidth, FF_CACHE_FILE_WIDTH);
if(instance->config.logoHeight == 0)
if(instance->config.logo.height == 0)
writeCacheUint32(requestData, instance->state.logoHeight, FF_CACHE_FILE_HEIGHT);
//Write result to stdout
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
fflush(stdout);
ffWriteFDBuffer(STDOUT_FILENO, result);
@@ -296,7 +298,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFinstance* instance, FFLogoRequestData*
}
//+1, because we need to copy the null byte too
imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logoSource.chars, instance->config.logoSource.length + 1);
imageData.ffCopyMagickString(imageInfoIn->filename, instance->config.logo.source.chars, instance->config.logo.source.length + 1);
imageData.image = ffReadImage(imageInfoIn, imageData.exceptionInfo);
ffDestroyImageInfo(imageInfoIn);
@@ -421,7 +423,7 @@ static bool printCachedChars(FFinstance* instance, FFLogoRequestData* requestDat
static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestData)
{
requestData->logoCharacterWidth = instance->config.logoWidth;
requestData->logoCharacterWidth = instance->config.logo.width;
if(requestData->logoCharacterWidth == 0)
{
requestData->logoCharacterWidth = readCachedUint32(requestData, FF_CACHE_FILE_WIDTH);
@@ -429,7 +431,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
return false;
}
requestData->logoCharacterHeight = instance->config.logoHeight;
requestData->logoCharacterHeight = instance->config.logo.height;
if(requestData->logoCharacterHeight == 0)
{
requestData->logoCharacterHeight = readCachedUint32(requestData, FF_CACHE_FILE_HEIGHT);
@@ -450,7 +452,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
if(fd == -1)
return false;
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
fflush(stdout);
char buffer[32768];
@@ -460,7 +462,7 @@ static bool printCachedPixel(FFinstance* instance, FFLogoRequestData* requestDat
close(fd);
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logoPaddingLeft + instance->config.logoPaddingRight;
instance->state.logoWidth = requestData->logoCharacterWidth + instance->config.logo.paddingLeft + instance->config.logo.paddingRight;
instance->state.logoHeight = requestData->logoCharacterHeight;
//Go to upper left corner
@@ -515,20 +517,20 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type)
requestData.characterPixelHeight = 1;
if(
(type != FF_LOGO_TYPE_CHAFA || instance->config.logoWidth == 0 || instance->config.logoHeight == 0) &&
(type != FF_LOGO_TYPE_CHAFA || instance->config.logo.width == 0 || instance->config.logo.height == 0) &&
!getCharacterPixelDimensions(&requestData)
)
return false;
requestData.logoPixelWidth = simpleCeil((double) instance->config.logoWidth * requestData.characterPixelWidth);
requestData.logoPixelHeight = simpleCeil((double) instance->config.logoHeight * requestData.characterPixelHeight);
requestData.logoPixelWidth = simpleCeil((double) instance->config.logo.width * requestData.characterPixelWidth);
requestData.logoPixelHeight = simpleCeil((double) instance->config.logo.height * requestData.characterPixelHeight);
ffStrbufInitA(&requestData.cacheDir, PATH_MAX * 2);
ffStrbufAppend(&requestData.cacheDir, &instance->state.cacheDir);
ffStrbufAppendS(&requestData.cacheDir, "images");
ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX);
if(realpath(instance->config.logoSource.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL)
if(realpath(instance->config.logo.source.chars, requestData.cacheDir.chars + requestData.cacheDir.length) == NULL)
{
//We can safely return here, because if realpath failed, we surely won't be able to read the file
ffStrbufDestroy(&requestData.cacheDir);
+25 -21
View File
@@ -1,4 +1,8 @@
#include "logo.h"
#include "common/io.h"
#include "common/printing.h"
#include "detection/os.h"
#include "detection/terminalshell.h"
#include <ctype.h>
#include <string.h>
@@ -8,18 +12,18 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
uint32_t currentlineLength = 0;
fputs(FASTFETCH_TEXT_MODIFIER_BOLT, stdout);
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
//Use logoColor[0] as the default color
if(doColorReplacement)
ffPrintColor(&instance->config.logoColors[0]);
ffPrintColor(&instance->config.logo.colors[0]);
while(*data != '\0')
{
//We are at the end of a line. Print paddings and update max line length
if(*data == '\n' || (*data == '\r' && *(data + 1) == '\n'))
{
ffPrintCharTimes(' ', instance->config.logoPaddingRight);
ffPrintCharTimes(' ', instance->config.logo.paddingRight);
//We have \r\n, skip the \r
if(*data == '\r')
@@ -28,7 +32,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
putchar('\n');
++data;
ffPrintCharTimes(' ', instance->config.logoPaddingLeft);
ffPrintCharTimes(' ', instance->config.logo.paddingLeft);
if(currentlineLength > instance->state.logoWidth)
instance->state.logoWidth = currentlineLength;
@@ -96,7 +100,7 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
}
else
{
ffPrintColor(&instance->config.logoColors[index]);
ffPrintColor(&instance->config.logo.colors[index]);
++data;
continue;
}
@@ -129,14 +133,14 @@ void ffLogoPrintChars(FFinstance* instance, const char* data, bool doColorReplac
}
}
ffPrintCharTimes(' ', instance->config.logoPaddingRight);
ffPrintCharTimes(' ', instance->config.logo.paddingRight);
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
//Happens if the last line is the longest
if(currentlineLength > instance->state.logoWidth)
instance->state.logoWidth = currentlineLength;
instance->state.logoWidth += instance->config.logoPaddingLeft + instance->config.logoPaddingRight;
instance->state.logoWidth += instance->config.logo.paddingLeft + instance->config.logo.paddingRight;
//Go to the leftmost position
fputs("\033[9999999D", stdout);
@@ -222,8 +226,8 @@ static void logoPrintStruct(FFinstance* instance, const FFlogo* logo)
const char** colors = logo->builtinColors;
for(int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++)
{
if(instance->config.logoColors[i].length == 0)
ffStrbufAppendS(&instance->config.logoColors[i], *colors);
if(instance->config.logo.colors[i].length == 0)
ffStrbufAppendS(&instance->config.logo.colors[i], *colors);
}
ffLogoPrintChars(instance, logo->data, true);
@@ -249,7 +253,7 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement)
FFstrbuf content;
ffStrbufInitA(&content, 2047);
if(!ffAppendFileBuffer(instance->config.logoSource.chars, &content))
if(!ffAppendFileBuffer(instance->config.logo.source.chars, &content))
{
ffStrbufDestroy(&content);
return false;
@@ -261,9 +265,9 @@ static bool logoPrintFileIfExists(FFinstance* instance, bool doColorReplacement)
return true;
}
static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logoType)
static bool logoPrintImageIfExists(FFinstance* instance, FFLogoType logo)
{
if(!ffLogoPrintImageIfExists(instance, logoType))
if(!ffLogoPrintImageIfExists(instance, logo))
return false;
logoApplyMainColorDetected(instance);
@@ -274,14 +278,14 @@ static void logoPrintKnownType(FFinstance* instance)
{
bool successfull;
if(instance->config.logoType == FF_LOGO_TYPE_BUILTIN)
successfull = logoPrintBuiltinIfExists(instance, instance->config.logoSource.chars);
else if(instance->config.logoType == FF_LOGO_TYPE_FILE)
if(instance->config.logo.type == FF_LOGO_TYPE_BUILTIN)
successfull = logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars);
else if(instance->config.logo.type == FF_LOGO_TYPE_FILE)
successfull = logoPrintFileIfExists(instance, true);
else if(instance->config.logoType == FF_LOGO_TYPE_RAW)
else if(instance->config.logo.type == FF_LOGO_TYPE_RAW)
successfull = logoPrintFileIfExists(instance, false);
else //image
successfull = logoPrintImageIfExists(instance, instance->config.logoType);
successfull = logoPrintImageIfExists(instance, instance->config.logo.type);
if(!successfull)
logoPrintDetected(instance);
@@ -300,21 +304,21 @@ void ffLogoPrint(FFinstance* instance)
}
//If the source is not set, we can directly print the detected logo.
if(instance->config.logoSource.length == 0)
if(instance->config.logo.source.length == 0)
{
logoPrintDetected(instance);
return;
}
//If the source and source type is set to something else than auto, always print with the set type.
if(instance->config.logoSource.length > 0 && instance->config.logoType != FF_LOGO_TYPE_AUTO)
if(instance->config.logo.source.length > 0 && instance->config.logo.type != FF_LOGO_TYPE_AUTO)
{
logoPrintKnownType(instance);
return;
}
//If source matches the name of a builtin logo, print it and return.
if(logoPrintBuiltinIfExists(instance, instance->config.logoSource.chars))
if(logoPrintBuiltinIfExists(instance, instance->config.logo.source.chars))
return;
const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance);
@@ -369,7 +373,7 @@ void ffLogoBuiltinPrint(FFinstance* instance)
instance->state.logoHeight = 0;
instance->state.keysHeight = 0;
for(uint8_t i = 0; i < FASTFETCH_LOGO_MAX_COLORS; i++)
ffStrbufClear(&instance->config.logoColors[i]);
ffStrbufClear(&instance->config.logo.colors[i]);
puts("\n");
++methods;
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/io.h"
#include "common/printing.h"
#include <dirent.h>
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
void ffPrintBreak(FFinstance* instance)
{
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
void ffPrintColors(FFinstance* instance)
{
+5
View File
@@ -1,4 +1,9 @@
#include "fastfetch.h"
#include "common/io.h"
#include "common/properties.h"
#include "common/printing.h"
#include "common/caching.h"
#include "detection/temps.h"
#include <stdlib.h>
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
#include <unistd.h>
+6
View File
@@ -1,4 +1,10 @@
#include "fastfetch.h"
#include "common/properties.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "common/settings.h"
#include "detection/gtk.h"
#include "detection/displayserver.h"
#include <stdlib.h>
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
void ffPrintCustom(FFinstance* instance, const char* key, const char* value)
{
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/datetime.h"
#define FF_DATE_MODULE_NAME "Date"
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/datetime.h"
#define FF_DATETIME_MODULE_NAME "Date & Time"
#define FF_DATETIME_NUM_FORMAT_ARGS 20
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/displayserver.h"
#define FF_DE_MODULE_NAME "DE"
#define FF_DE_NUM_FORMAT_ARGS 3
+23 -9
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
#include <sys/statvfs.h>
@@ -24,26 +25,39 @@ static void getKey(FFinstance* instance, FFstrbuf* key, const char* folderPath,
static void printStatvfs(FFinstance* instance, FFstrbuf* key, struct statvfs* fs)
{
const uint32_t GB = 1024 * 1024 * 1024;
const double GB = 1024 * 1024 * 1024;
uint32_t total = (uint32_t) ((fs->f_blocks * fs->f_frsize) / GB);
uint32_t available = (uint32_t) ((fs->f_bfree * fs->f_frsize) / GB);
uint32_t used = total - available;
uint8_t percentage = (uint8_t) ((used / (double) total) * 100.0);
double total = ((double) (fs->f_blocks * fs->f_frsize)) / GB;
double available = ((double) (fs->f_bfree * fs->f_frsize)) / GB;
double used = total - available;
uint8_t percentage = (uint8_t) ((used / total) * 100.0);
uint32_t files = (uint32_t) (fs->f_files - fs->f_ffree);
if(instance->config.disk.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, key->chars, 0, NULL);
printf("%uGiB / %uGiB (%u%%)\n", used, total, percentage);
if(used >= 100.0)
printf("%.0f", used);
else
printf("%.1f", used);
fputs(" GB / ", stdout);
if(total >= 100.0)
printf("%.0f", total);
else
printf("%.1f", total);
printf("GiB (%u%%)\n", percentage);
}
else
{
ffPrintFormatString(instance, key->chars, 0, NULL, &instance->config.disk.outputFormat, FF_DISK_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &used},
{FF_FORMAT_ARG_TYPE_UINT, &total},
{FF_FORMAT_ARG_TYPE_UINT, &files},
{FF_FORMAT_ARG_TYPE_DOUBLE, &used},
{FF_FORMAT_ARG_TYPE_DOUBLE, &total},
{FF_FORMAT_ARG_TYPE_DOUBLE, &files},
{FF_FORMAT_ARG_TYPE_UINT8, &percentage}
});
}
+8 -2
View File
@@ -1,4 +1,10 @@
#include "fastfetch.h"
#include "common/font.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "detection/qt.h"
#include "detection/gtk.h"
#include "detection/displayserver.h"
#define FF_FONT_MODULE_NAME "Font"
#define FF_FONT_NUM_FORMAT_ARGS 21
@@ -18,7 +24,7 @@ void ffPrintFont(FFinstance* instance)
return;
}
const FFstrbuf* plasmaRaw = &ffDetectPlasma(instance)->font;
const FFstrbuf* plasmaRaw = &ffDetectQt(instance)->font;
const FFstrbuf* gtk2Raw = &ffDetectGTK2(instance)->font;
const FFstrbuf* gtk3Raw = &ffDetectGTK3(instance)->font;
const FFstrbuf* gtk4Raw = &ffDetectGTK4(instance)->font;
@@ -51,7 +57,7 @@ void ffPrintFont(FFinstance* instance)
if(plasma.pretty.length > 0)
{
ffStrbufWriteTo(&plasma.pretty, stdout);
fputs(" [Plasma]", stdout);
fputs(" [QT]", stdout);
if(gtk.length > 0)
fputs(", ", stdout);
+17 -1
View File
@@ -1,4 +1,11 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/caching.h"
#include "common/parsing.h"
#include "detection/temps.h"
#include "detection/vulkan.h"
#include <stdlib.h>
#define FF_GPU_MODULE_NAME "GPU"
#define FF_GPU_NUM_FORMAT_ARGS 6
@@ -59,9 +66,9 @@ static void printGPUList(FFinstance* instance, const FFlist* list)
}
#ifdef FF_HAVE_LIBPCI
#include "common/library.h"
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
#include <pci/pci.h>
//see https://github.com/pciutils/pciutils/blob/5bdf63b6b1bc35b59c4b3f47f7ca83ca1868155b/ls-kernel.c#L220
@@ -193,6 +200,15 @@ void ffPrintGPU(FFinstance* instance)
if(ffPrintFromCache(instance, FF_GPU_MODULE_NAME, &instance->config.gpu, FF_GPU_NUM_FORMAT_ARGS))
return;
if(
getenv("WSLENV") != NULL ||
getenv("WSL_DISTRO") != NULL ||
getenv("WSL_INTEROP") != NULL
) {
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpu, "WSL doesn't expose senseful GPU names");
return;
}
#ifdef FF_HAVE_LIBPCI
if(pciPrintGPUs(instance))
return;
+5 -1
View File
@@ -1,11 +1,15 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/caching.h"
#include <stdlib.h>
#define FF_HOST_MODULE_NAME "Host"
#define FF_HOST_NUM_FORMAT_ARGS 15
#ifdef __ANDROID__
#ifndef __ANDROID__
#include "common/io.h"
#else
#include <ctype.h>
#endif
+7 -2
View File
@@ -1,4 +1,9 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "detection/qt.h"
#include "detection/gtk.h"
#include "detection/displayserver.h"
#define FF_ICONS_MODULE_NAME "Icons"
#define FF_ICONS_NUM_FORMAT_ARGS 5
@@ -18,7 +23,7 @@ void ffPrintIcons(FFinstance* instance)
return;
}
const FFstrbuf* plasma = &ffDetectPlasma(instance)->icons;
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
@@ -39,7 +44,7 @@ void ffPrintIcons(FFinstance* instance)
if(plasma->length > 0)
{
ffStrbufWriteTo(plasma, stdout);
fputs(" [Plasma]", stdout);
fputs(" [QT]", stdout);
if(gtkPretty.length > 0)
fputs(", ", stdout);
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
#define FF_KERNEL_MODULE_NAME "Kernel"
#define FF_KERNEL_NUM_FORMAT_ARGS 3
+3
View File
@@ -1,4 +1,7 @@
#include "fastfetch.h"
#include "common/properties.h"
#include "common/printing.h"
#include "common/caching.h"
#include <stdlib.h>
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
#define FF_LOCALIP_MODULE_NAME "Local IP"
#define FF_LOCALIP_NUM_FORMAT_ARGS 1
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
#include <stdlib.h>
+3 -1
View File
@@ -1,10 +1,12 @@
#include "fastfetch.h"
#include "common/printing.h"
#define FF_OPENCL_MODULE_NAME "OpenCL"
#define FF_OPENCL_NUM_FORMAT_ARGS 3
#ifdef FF_HAVE_OPENCL
#include <dlfcn.h>
#include "common/library.h"
#include "common/parsing.h"
#define CL_TARGET_OPENCL_VERSION 100
#include <CL/cl.h>
+3 -1
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/parsing.h"
#include <string.h>
@@ -7,7 +9,7 @@
#if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX) || defined(FF_HAVE_OSMESA)
#define FF_HAVE_GL 1
#include <dlfcn.h>
#include "common/library.h"
#include <GL/gl.h>
#define FF_OPENGL_BUFFER_WIDTH 1
+101 -70
View File
@@ -1,93 +1,124 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/os.h"
#include <ctype.h>
#define FF_OS_MODULE_NAME "OS"
#define FF_OS_NUM_FORMAT_ARGS 12
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
{
//Create the basic output
if(os->name.length > 0)
ffStrbufAppend(result, &os->name);
else if(os->prettyName.length > 0)
ffStrbufAppend(result, &os->name);
else if(os->id.length > 0)
ffStrbufAppend(result, &os->id);
else if(os->systemName.length > 0)
ffStrbufAppend(result, &os->systemName);
else
ffStrbufAppendS(result, "Linux");
//Append version if it is missing
if(os->versionID.length > 0 && ffStrbufFirstIndex(result, &os->versionID) == result->length)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->versionID);
}
else if(os->versionID.length == 0 && os->version.length > 0 && ffStrbufFirstIndex(result, &os->version) == result->length)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->version);
}
//Append variant if it is missing
if(os->variant.length > 0 && ffStrbufFirstIndex(result, &os->variant) == result->length)
{
ffStrbufAppendS(result, " (");
ffStrbufAppend(result, &os->variant);
ffStrbufAppendC(result, ')');
}
else if(os->variant.length == 0 && os->variantID.length > 0 && ffStrbufFirstIndex(result, &os->variantID) == result->length)
{
ffStrbufAppendS(result, " (");
ffStrbufAppend(result, &os->variantID);
ffStrbufAppendC(result, ')');
}
//Append architecture if it is missing
if(ffStrbufFirstIndex(result, &os->architecture) == result->length)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->architecture);
}
}
static void buildOutputNixOS(const FFOSResult* os, FFstrbuf* result)
{
ffStrbufAppendS(result, "NixOS");
if(os->buildID.length > 0)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->buildID);
}
if(os->codename.length > 0)
{
ffStrbufAppendS(result, " (");
ffStrbufAppendC(result, (char) toupper(os->codename.chars[0]));
ffStrbufAppendS(result, os->codename.chars + 1);
ffStrbufAppendC(result, ')');
}
if(os->architecture.length > 0)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->architecture);
}
}
void ffPrintOS(FFinstance* instance)
{
const FFOSResult* result = ffDetectOS(instance);
const FFOSResult* os = ffDetectOS(instance);
if(result->name.length == 0 && result->prettyName.length == 0)
if(os->name.length == 0 && os->prettyName.length == 0)
{
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, "Could not detect OS");
return;
}
FFstrbuf os;
ffStrbufInit(&os);
//Create the basic output
if(result->name.length > 0)
ffStrbufAppend(&os, &result->name);
else if(result->prettyName.length > 0)
ffStrbufAppend(&os, &result->name);
else if(result->id.length > 0)
ffStrbufAppend(&os, &result->id);
else if(result->systemName.length > 0)
ffStrbufAppend(&os, &result->systemName);
else
ffStrbufAppendS(&os, "Linux");
//Append version if it is missing
if(result->versionID.length > 0 && ffStrbufFirstIndex(&os, &result->versionID) == os.length)
{
ffStrbufAppendC(&os, ' ');
ffStrbufAppend(&os, &result->versionID);
}
else if(result->versionID.length == 0 && result->version.length > 0 && ffStrbufFirstIndex(&os, &result->version) == os.length)
{
ffStrbufAppendC(&os, ' ');
ffStrbufAppend(&os, &result->version);
}
//Append variant if it is missing
if(result->variant.length > 0 && ffStrbufFirstIndex(&os, &result->variant) == os.length)
{
ffStrbufAppendS(&os, " (");
ffStrbufAppend(&os, &result->variant);
ffStrbufAppendC(&os, ')');
}
else if(result->variant.length == 0 && result->variantID.length > 0 && ffStrbufFirstIndex(&os, &result->variantID) == os.length)
{
ffStrbufAppendS(&os, " (");
ffStrbufAppend(&os, &result->variantID);
ffStrbufAppendC(&os, ')');
}
//Append architecture if it is missing
if(ffStrbufFirstIndex(&os, &result->architecture) == os.length)
{
ffStrbufAppendS(&os, " [");
ffStrbufAppend(&os, &result->architecture);
ffStrbufAppendC(&os, ']');
}
if(instance->config.os.outputFormat.length == 0)
{
FFstrbuf result;
ffStrbufInit(&result);
if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0)
buildOutputNixOS(os, &result);
else
buildOutputDefault(os, &result);
ffPrintLogoAndKey(instance, FF_OS_MODULE_NAME, 0, &instance->config.os.key);
ffStrbufPutTo(&os, stdout);
ffStrbufPutTo(&result, stdout);
ffStrbufDestroy(&result);
}
else
{
ffPrintFormat(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, FF_OS_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &result->systemName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->prettyName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->id},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->idLike},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variant},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->variantID},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->version},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->versionID},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->codename},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->buildID},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->architecture}
{FF_FORMAT_ARG_TYPE_STRBUF, &os->systemName},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->prettyName},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->id},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->idLike},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->variant},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->variantID},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->version},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->versionID},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->codename},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->buildID},
{FF_FORMAT_ARG_TYPE_STRBUF, &os->architecture}
});
}
ffStrbufDestroy(&os);
}
+41 -9
View File
@@ -1,4 +1,10 @@
#include "fastfetch.h"
#include "common/io.h"
#include "common/properties.h"
#include "common/printing.h"
#include "common/settings.h"
#include "common/processing.h"
#include "detection/os.h"
#include <stdlib.h>
#include <string.h>
@@ -6,7 +12,7 @@
#include <sys/stat.h>
#define FF_PACKAGES_MODULE_NAME "Packages"
#define FF_PACKAGES_NUM_FORMAT_ARGS 11
#define FF_PACKAGES_NUM_FORMAT_ARGS 12
typedef struct PackageCounts
{
@@ -15,6 +21,7 @@ typedef struct PackageCounts
uint32_t rpm;
uint32_t emerge;
uint32_t xbps;
uint32_t nixSystem;
uint32_t nixDefault;
uint32_t flatpak;
uint32_t snap;
@@ -113,10 +120,17 @@ static uint32_t getNixPackages(char* path)
FFstrbuf output;
ffStrbufInitA(&output, 128);
//https://github.com/LinusDierheimer/fastfetch/issues/195#issuecomment-1191748222
FFstrbuf command;
ffStrbufInitA(&command, 255);
ffStrbufAppendS(&command, "for x in $(nix-store --query --requisites ");
ffStrbufAppendS(&command, path);
ffStrbufAppendS(&command, "); do if [ -d $x ]; then echo $x ; fi ; done | cut -d- -f2- | egrep '([0-9]{1,}\\.)+[0-9]{1,}' | egrep -v '\\-doc$|\\-man$|\\-info$|\\-dev$|\\-bin$|^nixos-system-nixos-' | uniq");
ffProcessAppendStdOut(&output, (char* const[]) {
"nix-store",
"-qR",
path,
"sh",
"-c",
command.chars,
NULL
});
@@ -130,7 +144,7 @@ static uint32_t getNixPackages(char* path)
}
#ifdef FF_HAVE_RPM
#include <dlfcn.h>
#include "common/library.h"
#include <rpm/rpmlib.h>
#include <rpm/rpmts.h>
#include <rpm/rpmdb.h>
@@ -215,8 +229,13 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
packageCounts->flatpak += getNumElements(baseDir->chars, DT_DIR);
ffStrbufSubstrBefore(baseDir, baseDirLength);
//nix system
ffStrbufAppendS(baseDir, "/run/current-system");
packageCounts->nixSystem += getNixPackages(baseDir->chars);
ffStrbufSubstrBefore(baseDir, baseDirLength);
//nix default
ffStrbufAppendS(baseDir, "/var/nix/profiles/default");
ffStrbufAppendS(baseDir, "/nix/var/nix/profiles/default");
packageCounts->nixDefault += getNixPackages(baseDir->chars);
ffStrbufSubstrBefore(baseDir, baseDirLength);
@@ -236,15 +255,20 @@ static void getPackageCounts(const FFinstance* instance, FFstrbuf* baseDir, Pack
static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDir, PackageCounts* packageCounts)
{
uint32_t baseDirLength = baseDir->length;
ffStrbufAppendS(baseDir, "/bedrock/strata");
DIR* dir = opendir(baseDir->chars);
if(dir == NULL)
{
ffStrbufSubstrBefore(baseDir, baseDirLength);
getPackageCounts(instance, baseDir, packageCounts);
return;
}
ffStrbufAppendC(baseDir, '/');
uint32_t baseDirLength = baseDir->length;
baseDirLength = baseDir->length;
struct dirent* entry;
while((entry = readdir(dir)) != NULL)
@@ -289,7 +313,7 @@ void ffPrintPackages(FFinstance* instance)
ffStrbufDestroy(&baseDir);
uint32_t all = counts.dpkg + counts.emerge + counts.flatpak + counts.nixDefault + nixUser + counts.pacman + counts.rpm + counts.snap + counts.xbps;
uint32_t all = counts.dpkg + counts.emerge + counts.flatpak + counts.nixSystem + counts.nixDefault + nixUser + counts.pacman + counts.rpm + counts.snap + counts.xbps;
if(all == 0)
{
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packages, "No packages from known package managers found");
@@ -321,6 +345,13 @@ void ffPrintPackages(FFinstance* instance)
FF_PRINT_PACKAGE(rpm)
FF_PRINT_PACKAGE(emerge)
if(counts.nixSystem > 0)
{
printf("%u (nix-system)", counts.nixSystem);
if((all = all - counts.nixSystem) > 0)
printf(", ");
}
if(nixUser > 0)
{
printf("%u (nix-user)", nixUser);
@@ -355,6 +386,7 @@ void ffPrintPackages(FFinstance* instance)
{FF_FORMAT_ARG_TYPE_UINT, &counts.rpm},
{FF_FORMAT_ARG_TYPE_UINT, &counts.emerge},
{FF_FORMAT_ARG_TYPE_UINT, &counts.xbps},
{FF_FORMAT_ARG_TYPE_UINT, &counts.nixSystem},
{FF_FORMAT_ARG_TYPE_UINT, &nixUser},
{FF_FORMAT_ARG_TYPE_UINT, &counts.nixDefault},
{FF_FORMAT_ARG_TYPE_UINT, &counts.flatpak},
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/media.h"
#include <ctype.h>
+1
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/printing.h"
#define FF_PROCESSES_MODULE_NAME "Processes"
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/networking.h"
#define FF_PUBLICIP_MODULE_NAME "Public IP"
#define FF_PUBLICIP_NUM_FORMAT_ARGS 1
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/displayserver.h"
#define FF_RESOLUTION_MODULE_NAME "Resolution"
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
+4 -1
View File
@@ -1,9 +1,12 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/title.h"
void ffPrintSeparator(FFinstance* instance)
{
const FFTitleResult* result = ffDetectTitle(instance);
uint32_t titleLength = result->userName.length + 1 + result->hostname.length;
uint32_t titleLength = result->userName.length + 1 +
(instance->config.titleFQDN ? result->fqdn.length : result->hostname.length);
ffLogoPrintLine(instance);
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/terminalshell.h"
#define FF_SHELL_MODULE_NAME "Shell"
#define FF_SHELL_NUM_FORMAT_ARGS 7
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/media.h"
#include <ctype.h>
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/terminalshell.h"
#include <string.h>
+44
View File
@@ -1,4 +1,11 @@
#include "fastfetch.h"
#include "common/properties.h"
#include "common/printing.h"
#include "common/font.h"
#include "common/settings.h"
#include "common/processing.h"
#include "detection/displayserver.h"
#include "detection/terminalshell.h"
#define FF_TERMFONT_MODULE_NAME "Terminal Font"
#define FF_TERMFONT_NUM_FORMAT_ARGS 5
@@ -179,6 +186,41 @@ static void printXCFETerminal(FFinstance* instance)
}
}
static void printAlacritty(FFinstance* instance) {
FFstrbuf fontName;
FFstrbuf fontSize;
ffStrbufInit(&fontName);
ffStrbufInit(&fontSize);
FFpropquery fontQuery[] = {
{"family:", &fontName},
{"size:", &fontSize},
};
// alacritty parses config files in this order
ffParsePropFileConfigValues(instance, "alacritty/alacritty.yml", 2, fontQuery);
if(fontName.length == 0 || fontSize.length == 0)
ffParsePropFileConfigValues(instance, "alacritty.yml", 2, fontQuery);
if(fontName.length == 0 || fontSize.length == 0)
ffParsePropFileConfigValues(instance, ".alacritty.yml", 2, fontQuery);
//by default alacritty uses its own font called alacritty
if(fontName.length == 0)
ffStrbufAppendS(&fontName, "alacritty");
// the default font size is 11
if(fontSize.length == 0)
ffStrbufAppendS(&fontSize, "11");
FFfont font;
ffFontInitValues(&font, fontName.chars, fontSize.chars);
printTerminalFont(instance, fontName.chars, &font);
ffFontDestroy(&font);
ffStrbufDestroy(&fontName);
ffStrbufDestroy(&fontSize);
}
static void printTTY(FFinstance* instance)
{
FFstrbuf fontName;
@@ -227,6 +269,8 @@ void ffPrintTerminalFont(FFinstance* instance)
printTerminalFontFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile");
else if(ffStrbufStartsWithIgnCaseS(&result->terminalExe, "/dev/tty"))
printTTY(instance);
else if(ffStrbufIgnCaseCompS(&result->terminalProcessName, "alacritty") == 0)
printAlacritty(instance);
else
ffPrintError(instance, FF_TERMFONT_MODULE_NAME, 0, &instance->config.terminalFont, "Unknown terminal: %s", result->terminalProcessName.chars);
}
+7 -2
View File
@@ -1,4 +1,9 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "detection/qt.h"
#include "detection/gtk.h"
#include "detection/displayserver.h"
#define FF_THEME_MODULE_NAME "Theme"
#define FF_THEME_NUM_FORMAT_ARGS 7
@@ -18,7 +23,7 @@ void ffPrintTheme(FFinstance* instance)
return;
}
const FFPlasmaResult* plasma = ffDetectPlasma(instance);
const FFQtResult* plasma = ffDetectQt(instance);
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->theme;
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->theme;
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->theme;
@@ -70,7 +75,7 @@ void ffPrintTheme(FFinstance* instance)
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
{
fputs(" [Plasma]", stdout);
fputs(" [QT]", stdout);
if(gtkPretty.length > 0)
fputs(", ", stdout);
+2
View File
@@ -1,4 +1,6 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/datetime.h"
#define FF_TIME_MODULE_NAME "Time"
+3 -29
View File
@@ -1,32 +1,6 @@
#include "fastfetch.h"
#include <unistd.h>
#include <pthread.h>
const FFTitleResult* ffDetectTitle(FFinstance* instance)
{
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static bool init = false;
static FFTitleResult result;
pthread_mutex_lock(&mutex);
if(init)
{
pthread_mutex_unlock(&mutex);
return &result;
}
init = true;
ffStrbufInit(&result.userName);
ffStrbufAppendS(&result.userName, instance->state.passwd->pw_name);
ffStrbufInitA(&result.hostname, 256);
gethostname(result.hostname.chars, result.hostname.allocated);
ffStrbufRecalculateLength(&result.hostname);
pthread_mutex_unlock(&mutex);
return &result;
}
#include "common/printing.h"
#include "detection/title.h"
static inline void printTitlePart(FFinstance* instance, const FFstrbuf* content)
{
@@ -50,6 +24,6 @@ void ffPrintTitle(FFinstance* instance)
printTitlePart(instance, &result->userName);
putchar('@');
printTitlePart(instance, &result->hostname);
printTitlePart(instance, instance->config.titleFQDN ? &result->fqdn : &result->hostname);
putchar('\n');
}

Some files were not shown because too many files have changed in this diff Show More