mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Fastfetch: make it compile on SunOS
This commit is contained in:
@@ -18,6 +18,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
set(LINUX TRUE CACHE BOOL "..." FORCE) # LINUX means GNU/Linux, not just the kernel
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
|
||||
set(BSD TRUE CACHE BOOL "..." FORCE)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
|
||||
set(SunOS TRUE CACHE BOOL "..." FORCE)
|
||||
elseif(NOT APPLE AND NOT WIN32)
|
||||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
@@ -733,6 +735,77 @@ elseif(WIN32)
|
||||
src/util/windows/wmi.cpp
|
||||
src/util/platform/FFPlatform_windows.c
|
||||
)
|
||||
elseif(SunOS)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/common/dbus.c
|
||||
src/common/io/io_unix.c
|
||||
src/common/netif/netif_linux.c
|
||||
src/common/networking_linux.c
|
||||
src/common/processing_linux.c
|
||||
src/detection/battery/battery_nosupport.c
|
||||
src/detection/bios/bios_nosupport.c
|
||||
src/detection/board/board_nosupport.c
|
||||
src/detection/bootmgr/bootmgr_nosupport.c
|
||||
src/detection/brightness/brightness_nosupport.c
|
||||
src/detection/chassis/chassis_nosupport.c
|
||||
src/detection/cpu/cpu_nosupport.c
|
||||
src/detection/cpucache/cpucache_nosupport.c
|
||||
src/detection/cpuusage/cpuusage_nosupport.c
|
||||
src/detection/cursor/cursor_linux.c
|
||||
src/detection/bluetooth/bluetooth_nosupport.c
|
||||
src/detection/disk/disk_nosupport.c
|
||||
src/detection/dns/dns_linux.c
|
||||
src/detection/physicaldisk/physicaldisk_nosupport.c
|
||||
src/detection/physicalmemory/physicalmemory_nosupport.c
|
||||
src/detection/diskio/diskio_nosupport.c
|
||||
src/detection/displayserver/linux/displayserver_linux.c
|
||||
src/detection/displayserver/linux/drm.c
|
||||
src/detection/displayserver/linux/wayland/wayland.c
|
||||
src/detection/displayserver/linux/wayland/global-output.c
|
||||
src/detection/displayserver/linux/wayland/zwlr-output.c
|
||||
src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c
|
||||
src/detection/displayserver/linux/wmde.c
|
||||
src/detection/displayserver/linux/xcb.c
|
||||
src/detection/displayserver/linux/xlib.c
|
||||
src/detection/font/font_linux.c
|
||||
src/detection/gpu/gpu_nosupport.c
|
||||
src/detection/gpu/gpu_pci.c
|
||||
src/detection/gtk_qt/gtk.c
|
||||
src/detection/host/host_nosupport.c
|
||||
src/detection/icons/icons_nosupport.c
|
||||
src/detection/initsystem/initsystem_nosupport.c
|
||||
src/detection/libc/libc_nosupport.c
|
||||
src/detection/lm/lm_nosupport.c
|
||||
src/detection/loadavg/loadavg_nosupport.c
|
||||
src/detection/locale/locale_linux.c
|
||||
src/detection/localip/localip_linux.c
|
||||
src/detection/gamepad/gamepad_nosupport.c
|
||||
src/detection/media/media_linux.c
|
||||
src/detection/memory/memory_nosupport.c
|
||||
src/detection/monitor/monitor_nosupport.c
|
||||
src/detection/netio/netio_nosupport.c
|
||||
src/detection/opengl/opengl_linux.c
|
||||
src/detection/os/os_sunos.c
|
||||
src/detection/packages/packages_nosupport.c
|
||||
src/detection/poweradapter/poweradapter_nosupport.c
|
||||
src/detection/processes/processes_linux.c
|
||||
src/detection/gtk_qt/qt.c
|
||||
src/detection/sound/sound_nosupport.c
|
||||
src/detection/swap/swap_nosupport.c
|
||||
src/detection/terminalfont/terminalfont_linux.c
|
||||
src/detection/terminalshell/terminalshell_linux.c
|
||||
src/detection/terminalsize/terminalsize_linux.c
|
||||
src/detection/theme/theme_linux.c
|
||||
src/detection/uptime/uptime_sunos.c
|
||||
src/detection/users/users_linux.c
|
||||
src/detection/wallpaper/wallpaper_linux.c
|
||||
src/detection/wifi/wifi_nosupport.c
|
||||
src/detection/wm/wm_nosupport.c
|
||||
src/detection/de/de_linux.c
|
||||
src/detection/wmtheme/wmtheme_linux.c
|
||||
src/detection/camera/camera_nosupport.c
|
||||
src/util/platform/FFPlatform_unix.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ENABLE_DIRECTX_HEADERS)
|
||||
@@ -820,6 +893,8 @@ if(WIN32)
|
||||
target_compile_definitions(libfastfetch PUBLIC WIN32_LEAN_AND_MEAN=1)
|
||||
elseif(APPLE)
|
||||
target_compile_definitions(libfastfetch PUBLIC _DARWIN_C_SOURCE)
|
||||
elseif(SunOS)
|
||||
target_compile_definitions(libfastfetch PUBLIC __EXTENSIONS__ _POSIX_C_SOURCE=1)
|
||||
endif()
|
||||
|
||||
if(HAVE_STATX)
|
||||
@@ -1049,6 +1124,11 @@ elseif(BSD)
|
||||
PRIVATE "usbhid"
|
||||
PRIVATE "geom"
|
||||
)
|
||||
elseif(SunOS)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "m"
|
||||
PRIVATE "socket"
|
||||
)
|
||||
elseif(ANDROID)
|
||||
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
|
||||
if(HAVE_LIBANDROID_WORDEXP_STATIC)
|
||||
|
||||
+20
-2
@@ -204,7 +204,11 @@ bool ffSuppressIO(bool suppress)
|
||||
|
||||
void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indentation, const char* folderName, bool pretty)
|
||||
{
|
||||
DIR* dir = opendir(folder->chars);
|
||||
FF_AUTO_CLOSE_FD int dfd = open(folder->chars, O_RDONLY);
|
||||
if (dfd < 0)
|
||||
return;
|
||||
|
||||
DIR* dir = fdopendir(dfd);
|
||||
if(dir == NULL)
|
||||
return;
|
||||
|
||||
@@ -221,7 +225,21 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta
|
||||
|
||||
while((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if(entry->d_type == DT_DIR)
|
||||
bool isDir = false;
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if(entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK)
|
||||
isDir = entry->d_type == DT_DIR;
|
||||
else
|
||||
#else
|
||||
{
|
||||
struct stat stbuf;
|
||||
if (fstatat(dfd, entry->d_name, &stbuf, 0) < 0)
|
||||
isDir = false;
|
||||
else
|
||||
isDir = S_ISDIR(stbuf.st_mode);
|
||||
}
|
||||
#endif
|
||||
if (isDir)
|
||||
{
|
||||
if(ffStrEquals(entry->d_name, ".") || ffStrEquals(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "bios.h"
|
||||
|
||||
const char* ffDetectBios(FFBiosResult* bios)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "camera.h"
|
||||
|
||||
const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result)
|
||||
{
|
||||
return "Not support on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "cpu.h"
|
||||
|
||||
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "cpucache.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
const char* ffDetectCPUCache(FF_MAYBE_UNUSED FFCPUCacheResult* result)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/cpuusage/cpuusage.h"
|
||||
|
||||
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
|
||||
{
|
||||
return "Not support on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "disk.h"
|
||||
|
||||
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "diskio.h"
|
||||
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -302,7 +302,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
if(result->dePrettyName.length > 0 && result->wmPrettyName.length > 0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
#elif !defined(__sun)
|
||||
FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc");
|
||||
if(procdir == NULL)
|
||||
return "opendir(\"/proc\") failed";
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "host.h"
|
||||
|
||||
const char* ffDetectHost(FFHostResult* host)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "libc.h"
|
||||
|
||||
const char* ffDetectLibc(FFLibcResult* result)
|
||||
{
|
||||
result->name = "Unknown";
|
||||
result->version = NULL;
|
||||
return NULL;
|
||||
}
|
||||
@@ -162,6 +162,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
|
||||
if (ifAddrStruct) freeifaddrs(ifAddrStruct);
|
||||
|
||||
#ifdef SIOCGIFMTU
|
||||
FF_AUTO_CLOSE_FD int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd > 0)
|
||||
{
|
||||
@@ -173,6 +174,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
|
||||
iface->mtu = ifr.ifr_mtu;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "memory.h"
|
||||
|
||||
const char* ffDetectMemory(FFMemoryResult* ram)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "netio.h"
|
||||
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "os.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os)
|
||||
{
|
||||
if (!ffReadFileBuffer("/etc/release", &os->prettyName))
|
||||
return;
|
||||
|
||||
ffStrbufSubstrBeforeFirstC(&os->prettyName, '\n');
|
||||
ffStrbufSubstrBeforeLastC(&os->prettyName, '(');
|
||||
ffStrbufTrim(&os->prettyName, ' ');
|
||||
|
||||
// OpenIndiana Hipster 2024.04
|
||||
uint32_t idx = ffStrbufFirstIndexC(&os->prettyName, ' ');
|
||||
ffStrbufSetNS(&os->name, idx, os->prettyName.chars);
|
||||
uint32_t idx2 = ffStrbufNextIndexC(&os->prettyName, idx + 1, ' ');
|
||||
ffStrbufSetNS(&os->codename, idx2 - idx - 1, os->prettyName.chars + idx + 1);
|
||||
ffStrbufSetNS(&os->version, idx2 - idx - 1, os->prettyName.chars + idx2 + 1);
|
||||
ffStrbufSetStatic(&os->idLike, "sunos");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "packages.h"
|
||||
|
||||
void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "physicaldisk.h"
|
||||
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -14,7 +14,11 @@ const char* ffDetectProcesses(uint32_t* result)
|
||||
struct dirent* entry;
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (entry->d_type == DT_DIR && ffCharIsDigit(entry->d_name[0]))
|
||||
if (
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
entry->d_type == DT_DIR &&
|
||||
#endif
|
||||
ffCharIsDigit(entry->d_name[0]))
|
||||
++num;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "swap.h"
|
||||
|
||||
const char* ffDetectSwap(FFSwapResult* swap)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "terminalsize.h"
|
||||
#include "common/io/io.h"
|
||||
|
||||
#include <sys/termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "uptime.h"
|
||||
#include "common/time.h"
|
||||
#include <utmpx.h>
|
||||
|
||||
const char* ffDetectUptime(FFUptimeResult* result)
|
||||
{
|
||||
struct utmpx* ut;
|
||||
|
||||
setutxent();
|
||||
while (NULL != (ut = getutxent()))
|
||||
{
|
||||
if (ut->ut_type == BOOT_TIME)
|
||||
{
|
||||
result->bootTime = (uint64_t) ut->ut_tv.tv_sec * 1000 + (uint64_t) ut->ut_tv.tv_usec / 10000000;
|
||||
result->uptime = ffTimeGetNow() - result->bootTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endutxent();
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "wifi.h"
|
||||
|
||||
const char* ffDetectWifi(FFlist* result)
|
||||
{
|
||||
return "Not support on this platform";
|
||||
}
|
||||
@@ -22,7 +22,7 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va
|
||||
else if (ffStrEqualsIgnCase(key, "processingTimeout"))
|
||||
options->processingTimeout = (int32_t) yyjson_get_int(val);
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
|
||||
else if (ffStrEqualsIgnCase(key, "escapeBedrock"))
|
||||
options->escapeBedrock = yyjson_get_bool(val);
|
||||
else if (ffStrEqualsIgnCase(key, "playerName"))
|
||||
|
||||
@@ -15,7 +15,7 @@ typedef struct FFOptionsGeneral
|
||||
int32_t processingTimeout;
|
||||
|
||||
// Module options that cannot be put in module option structure
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
|
||||
FFstrbuf playerName;
|
||||
bool escapeBedrock;
|
||||
FFDsForceDrmType dsForceDrm;
|
||||
|
||||
@@ -34,6 +34,8 @@ static void getExePath(FFPlatform* platform)
|
||||
exePathLen = 0;
|
||||
else
|
||||
exePathLen--; // remove terminating NUL
|
||||
#else
|
||||
int exePathLen = 0;
|
||||
#endif
|
||||
if (exePathLen > 0)
|
||||
{
|
||||
@@ -181,7 +183,7 @@ void ffPlatformInitImpl(FFPlatform* platform)
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
|
||||
struct utsname uts;
|
||||
if(uname(&uts) != 0)
|
||||
if(uname(&uts) < 0)
|
||||
memset(&uts, 0, sizeof(uts));
|
||||
|
||||
getExePath(platform);
|
||||
|
||||
Reference in New Issue
Block a user