Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "ENABLE_IMA
cmake_dependent_option(ENABLE_SIXEL "Enable sixel logo output via the embedded libsixel encoder (Windows, macOS and Android; replaces ImageMagick's SIXEL coder)" ON "ENABLE_IMAGE_LOGO;WIN32 OR APPLE OR ANDROID" OFF)
cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGE_LOGO;ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7 OR WIN32 OR APPLE OR ANDROID" OFF)

option(COMPATIBILITY_FORCE_DRM_DISABLE "Force disable GPU DRM detection (for embedded)" OFF)
option(ENABLE_ZLIB "Enable zlib" ON)
option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF)
option(ENABLE_ASAN "Build fastfetch with ASAN (address sanitizer)" OFF)
Expand Down Expand Up @@ -578,6 +579,7 @@ if(LINUX)
src/common/impl/FFPlatform_unix.c
src/common/impl/binary_linux.c
src/common/impl/kmod_linux.c
src/common/keenetic/version.c
src/detection/battery/battery_linux.c
src/detection/bios/bios_linux.c
src/detection/board/board_linux.c
Expand Down Expand Up @@ -754,6 +756,7 @@ elseif(FreeBSD)
src/common/impl/FFPlatform_unix.c
src/common/impl/binary_linux.c
src/common/impl/kmod_bsd.c
src/common/keenetic/version.c
src/detection/battery/battery_bsd.c
src/detection/bios/bios_bsd.c
src/detection/bluetoothradio/bluetoothradio_nosupport.c
Expand Down Expand Up @@ -1356,6 +1359,7 @@ elseif(GNU)
src/common/impl/FFPlatform_unix.c
src/common/impl/binary_linux.c
src/common/impl/kmod_nosupport.c
src/common/keenetic/version.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_nosupport.c
src/detection/board/board_nosupport.c
Expand Down Expand Up @@ -1599,6 +1603,10 @@ elseif(DragonFly AND EXISTS "/usr/local/bin/objdump")
endif()
endif()

if(COMPATIBILITY_FORCE_DRM_DISABLE)
target_compile_definitions(libfastfetch PUBLIC COMPATIBILITY_FORCE_DRM_OFF=1)
endif()

if(LINUX)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _ATFILE_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 _TIME_BITS=64) # "$<$<CONFIG:Release>:_FORTIFY_SOURCE=3>"
elseif(ANDROID)
Expand Down
105 changes: 105 additions & 0 deletions src/common/keenetic/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "common/keenetic/version.h"
#include "common/processing.h"
#include "common/FFstrbuf.h"
#include <string.h>
#include <ctype.h>

static const char* getValueAfter(const char* line, const char* key)
{
const char* p = strstr(line, key);
if (!p) return NULL;

p += strlen(key);
while (*p == ' ' || *p == '\t') ++p;
return *p ? p : NULL;
}

const FFKeeneticInfo* ffDetectKeenetic(void)
{
static FFKeeneticInfo info;
static bool initialized = false;

if (initialized)
return &info;

initialized = true;
memset(&info, 0, sizeof(info));
ffStrbufInit(&info.vendor);
ffStrbufInit(&info.title);
ffStrbufInit(&info.model);

if (!ffPathExists("/bin/ndmc", FF_PATHTYPE_FILE))
return &info;

FF_STRBUF_AUTO_DESTROY output = ffStrbufCreate();
if (ffProcessAppendStdOut(&output, (char* const[]){
"/bin/ndmc", "-c", "show version", NULL
}) != NULL || output.length == 0)
{
return &info;
}

char* line = output.chars;
while (line && *line)
{
char* next = strchr(line, '\n');
if (next) *next = '\0';

const char* v = getValueAfter(line, "vendor:");
if (v) ffStrbufSetS(&info.vendor, v);

const char* t = getValueAfter(line, "title:");
if (t) ffStrbufSetS(&info.title, t);

const char* m = getValueAfter(line, "model:");
if (m) ffStrbufSetS(&info.model, m);

const char* f = getValueAfter(line, "manufacturer:");
if (f) ffStrbufSetS(&info.vendor_full, f);

const char* r = getValueAfter(line, "release:");
if (m) ffStrbufSetS(&info.version, r);

line = next ? next + 1 : NULL;
}

info.available = (info.vendor.length > 0);
info.id = "keenetic";
info.idLike = "keeneticos";
info.family = "linux";

return &info;
}

void ffKeeneticFormatOS(FFstrbuf* result)
{
const FFKeeneticInfo* k = ffDetectKeenetic();
if (!k->available) return;

if (k->title.length > 0)
ffStrbufSetF(result, "%s OS", k->vendor.chars);
else
ffStrbufSetS(result, k->vendor.chars);
}

void ffKeeneticFormatOSFull(FFstrbuf* result)
{
const FFKeeneticInfo* k = ffDetectKeenetic();
if (!k->available) return;

if (k->title.length > 0)
ffStrbufSetF(result, "%s OS %s", k->vendor.chars, k->title.chars);
else
ffStrbufSetS(result, k->vendor.chars);
}

void ffKeeneticFormatHost(FFstrbuf* result)
{
const FFKeeneticInfo* k = ffDetectKeenetic();
if (!k->available) return;

if (k->model.length > 0)
ffStrbufSetF(result, "%s %s", k->vendor.chars, k->model.chars);
else
ffStrbufSetS(result, k->vendor.chars);
}
23 changes: 23 additions & 0 deletions src/common/keenetic/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "common/FFstrbuf.h"
#include <stdbool.h>

typedef struct FFKeeneticInfo
{
bool available;
FFstrbuf vendor; // "Keenetic"
FFstrbuf vendor_full; // "Keenetic Ltd."
FFstrbuf title; // "5.1.6"
FFstrbuf model; // "Giant (KN-2610)"
FFstrbuf version; // "5.01.C.6.0-1"
const char* id; // "keenetic"
const char* idLike; // "keeneticos"
const char* family; // "linux"
} FFKeeneticInfo;

const FFKeeneticInfo* ffDetectKeenetic(void);

void ffKeeneticFormatOS(FFstrbuf* result); // "Keenetic OS"
void ffKeeneticFormatOSFull(FFstrbuf* result); // "Keenetic OS 5.1.6"
void ffKeeneticFormatHost(FFstrbuf* result); // "Keenetic Giant (KN-2610)"
2 changes: 1 addition & 1 deletion src/detection/displayserver/linux/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static inline const char* drmType2Name(uint32_t connector_type) {
return "DSI";
case DRM_MODE_CONNECTOR_DPI:
return "DPI";
case DRM_MODE_CONNECTOR_WRITEBACK:
case 18 /*DRM_MODE_CONNECTOR_WRITEBACK*/:
return "Writeback";
case 19 /*DRM_MODE_CONNECTOR_SPI*/:
return "SPI";
Expand Down
29 changes: 28 additions & 1 deletion src/detection/gpu/gpu_drm.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
#include "gpu.h"

#if FF_HAVE_DRM || __has_include(<drm/drm.h>)
#if COMPATIBILITY_FORCE_DRM_OFF
#if FF_HAVE_DRM || __has_include(<drm/drm.h>)
const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd) {
FF_UNUSED(gpu, fd);
return "Fastfetch is not compiled with GPU DRM support";
}

const char* ffDrmDetectXe(FFGPUResult* gpu, int fd) {
FF_UNUSED(gpu, fd);
return "Fastfetch is not compiled with GPU DRM support";
}

const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) {
FF_UNUSED(options, gpu, renderPath);
return "Fastfetch is not compiled with GPU DRM support";
}

const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) {
FF_UNUSED(gpu, fd);
return "Fastfetch is not compiled with GPU DRM support";
}

const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) {
FF_UNUSED(options, gpu, renderPath);
return "Fastfetch is not compiled with GPU DRM support";
}
#endif
#elif FF_HAVE_DRM || __has_include(<drm/drm.h>)
#include <fcntl.h>
#include <sys/ioctl.h>

Expand Down
14 changes: 14 additions & 0 deletions src/detection/host/host_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "common/io.h"
#include "common/processing.h"
#include "common/smbios.h"
#include "common/keenetic/version.h"

#include <stdlib.h>

Expand Down Expand Up @@ -113,5 +114,18 @@ const char* ffDetectHost(FFHostResult* host) {
}
}

// Keenetic OS / NDMS detection
const FFKeeneticInfo* keen = ffDetectKeenetic();
if (keen->available) {
ffKeeneticFormatHost(&host->name);
ffStrbufSetS(&host->family, keen->family);
if (keen->vendor_full.length > 0) {
ffStrbufSetS(&host->vendor, keen->vendor_full.chars);
}
if (keen->version.length > 0) {
ffStrbufSetS(&host->version, keen->version.chars);
}
}

return nullptr;
}
10 changes: 10 additions & 0 deletions src/detection/os/os_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common/io.h"
#include "common/processing.h"
#include "common/strutil.h"
#include "common/keenetic/version.h"

#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -398,6 +399,15 @@ static void detectOS(FFOSResult* os) {
ffStrbufSetS(&os->prettyName, "HarmonyOS");
}
}

// Keenetic OS / NDMS detection
const FFKeeneticInfo* keen = ffDetectKeenetic();
if (keen->available) {
ffStrbufSetS(&os->id, keen->id);
ffStrbufSetS(&os->idLike, keen->idLike);
ffKeeneticFormatOSFull(&os->prettyName);
ffKeeneticFormatOS(&os->name);
}
}

void ffDetectOSImpl(FFOSResult* os) {
Expand Down
15 changes: 15 additions & 0 deletions src/logo/ascii/k.inc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ static const FFlogo K[] = {
},
},
#endif
#ifdef FASTFETCH_DATATEXT_LOGO_KEENETIC_OS
// Keenetic OS
{
.names = { "Keenetic OS", "keenetic", "keeneticos", "keenetic_os", "KeeneticOS", "Keenetic" },
.lines = FASTFETCH_DATATEXT_LOGO_KEENETIC_OS,
.colors = {
FF_COLOR_FG_BLUE,
FF_COLOR_FG_WHITE,
FF_COLOR_BG_WHITE,
FF_COLOR_MODE_RESET
},
.colorKeys = FF_COLOR_FG_BLUE,
.colorTitle = FF_COLOR_FG_BLUE,
},
#endif
#ifdef FASTFETCH_DATATEXT_LOGO_KIBAOS
// KibaOS
{
Expand Down
14 changes: 14 additions & 0 deletions src/logo/ascii/k/keenetic_os.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$1 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
███████████████████████████
███████████████████████████
$3███ ██████████▀ ▄████$4$1
$3███ ████████▀ ▄██████$4$1
$3███ ██████▀ ▄████████$4$1
$3███ ▀▀████████$4$1
$3███ ▀█████$4$1
$3███ █████████▄▄▄ ████$4$1
$3███ █████████████ ███$4$1
$3███ █████████████ ███$4$1
███████████████████████████
███████████████████████████
███████████████████████████