mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Global: support DragonFly BSD
This commit is contained in:
parent
540239fe03
commit
f7288fec01
@ -22,6 +22,9 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
|
||||
set(OpenBSD TRUE CACHE BOOL "..." FORCE)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "NetBSD")
|
||||
set(NetBSD TRUE CACHE BOOL "..." FORCE)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
|
||||
set(FreeBSD TRUE CACHE BOOL "..." FORCE)
|
||||
set(DragonFly TRUE CACHE BOOL "..." FORCE)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
|
||||
set(SunOS TRUE CACHE BOOL "..." FORCE)
|
||||
elseif(NOT APPLE AND NOT WIN32)
|
||||
@ -74,7 +77,7 @@ cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR OpenBSD OR NetBSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly" OFF)
|
||||
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
|
||||
cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "LINUX OR FreeBSD OR SunOS" OFF)
|
||||
cmake_dependent_option(ENABLE_PCIACCESS "Enable libpciaccess" ON "NetBSD OR OpenBSD OR SunOS" OFF)
|
||||
@ -1139,6 +1142,8 @@ elseif(APPLE)
|
||||
elseif(OpenBSD)
|
||||
target_compile_definitions(libfastfetch PUBLIC _XOPEN_SOURCE=700 _FILE_OFFSET_BITS=64 _BSD_SOURCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R6/lib") # detect x11 lib path automatically
|
||||
elseif(DragonFly)
|
||||
target_compile_definitions(libfastfetch PUBLIC __FreeBSD__)
|
||||
elseif(SunOS)
|
||||
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 __EXTENSIONS__ _POSIX_C_SOURCE)
|
||||
elseif(NetBSD)
|
||||
@ -1418,8 +1423,12 @@ elseif(FreeBSD)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "m"
|
||||
PRIVATE "usbhid"
|
||||
PRIVATE "geom"
|
||||
)
|
||||
if(NOT DragonFly)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "geom"
|
||||
)
|
||||
endif()
|
||||
elseif(OpenBSD)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "m"
|
||||
|
@ -245,7 +245,7 @@ void ffListFeatures(void)
|
||||
#if FF_HAVE_DDCUTIL
|
||||
"libddcutil\n"
|
||||
#endif
|
||||
#if FF_HAVE_ELF || __sun || __FreeBSD__ || __OpenBSD__ || __NetBSD__
|
||||
#if FF_HAVE_ELF || __sun || (__FreeBSD__ && !__DragonFly__) || __OpenBSD__ || __NetBSD__
|
||||
"libelf\n"
|
||||
#endif
|
||||
#if FF_HAVE_LIBZFS
|
||||
|
@ -91,7 +91,7 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex)
|
||||
if (rtmsg.hdr.rtm_seq == 1 && rtmsg.hdr.rtm_pid == pid)
|
||||
{
|
||||
struct sockaddr_dl* sdl = (struct sockaddr_dl *)get_rt_address(&rtmsg.hdr, RTA_IFP);
|
||||
if (sdl)
|
||||
if (sdl && sdl->sdl_len)
|
||||
{
|
||||
assert(sdl->sdl_nlen <= IF_NAMESIZE);
|
||||
memcpy(iface, sdl->sdl_data, sdl->sdl_nlen);
|
||||
|
@ -367,6 +367,13 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
#ifdef __DragonFly__
|
||||
#define ki_comm kp_comm
|
||||
#define ki_ppid kp_ppid
|
||||
#define ki_tdev kp_tdev
|
||||
#define ki_flag kp_flags
|
||||
#endif
|
||||
|
||||
struct kinfo_proc proc;
|
||||
size_t size = sizeof(proc);
|
||||
if(sysctl(
|
||||
|
@ -70,14 +70,26 @@ const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* r
|
||||
ffStrbufTrimRight(&battery->status, ',');
|
||||
}
|
||||
|
||||
#ifdef ACPIIO_BATT_GET_BIX
|
||||
battio.unit = i;
|
||||
if (ioctl(acpifd, ACPIIO_BATT_GET_BIX, &battio) >= 0)
|
||||
{
|
||||
ffStrbufAppendS(&battery->manufacturer, battio.bix.oeminfo);
|
||||
ffStrbufAppendS(&battery->modelName, battio.bix.model);
|
||||
ffStrbufAppendS(&battery->technology, battio.bix.type);
|
||||
ffStrbufAppendS(&battery->serial, battio.bix.serial);
|
||||
battery->cycleCount = battio.bix.cycles;
|
||||
}
|
||||
#elif defined(ACPIIO_BATT_GET_BIF)
|
||||
battio.unit = i;
|
||||
if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) >= 0)
|
||||
{
|
||||
ffStrbufAppendS(&battery->manufacturer, battio.bif.oeminfo);
|
||||
ffStrbufAppendS(&battery->modelName, battio.bif.model);
|
||||
ffStrbufAppendS(&battery->technology, battio.bif.type);
|
||||
ffStrbufAppendS(&battery->serial, battio.bif.serial);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if __has_include(<libgeom.h>)
|
||||
#include <libgeom.h>
|
||||
|
||||
static const char* detectFsLabel(struct statfs* fs, FFDisk* disk)
|
||||
@ -51,6 +52,12 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
static const char* detectFsLabel(struct statfs* fs, FFDisk* disk)
|
||||
{
|
||||
return "Fastfetch was compiled without libgeom support";
|
||||
}
|
||||
#endif
|
||||
|
||||
static void detectFsInfo(struct statfs* fs, FFDisk* disk)
|
||||
{
|
||||
@ -134,7 +141,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
if(!ffDiskMatchMountpoint(options, fs->f_mntonname))
|
||||
continue;
|
||||
}
|
||||
else if(!ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs"))
|
||||
else if(!ffStrEquals(fs->f_mntonname, "/") && !ffStrStartsWith(fs->f_mntfromname, "/dev/") && !ffStrEquals(fs->f_fstypename, "zfs"))
|
||||
continue;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
@ -168,10 +175,11 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
|
||||
#ifdef __OpenBSD__
|
||||
#define st_birthtimespec __st_birthtim
|
||||
#endif
|
||||
|
||||
#ifndef __DragonFly__
|
||||
struct stat st;
|
||||
if(stat(fs->f_mntonname, &st) == 0 && st.st_birthtimespec.tv_sec > 0)
|
||||
disk->createTime = (uint64_t)((st.st_birthtimespec.tv_sec * 1000) + (st.st_birthtimespec.tv_nsec / 1000000));
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "diskio.h"
|
||||
|
||||
#if __has_include(<libgeom.h>)
|
||||
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <devstat.h>
|
||||
@ -58,3 +61,9 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
|
||||
{
|
||||
return "Fastfetch was compiled without libgeom support";
|
||||
}
|
||||
#endif
|
||||
|
@ -257,6 +257,10 @@ static const char* getFromProcesses(FFDisplayServerResult* result)
|
||||
uint32_t userId = getuid();
|
||||
|
||||
#if __FreeBSD__
|
||||
#ifdef __DragonFly__
|
||||
#define ki_comm kp_comm
|
||||
#endif
|
||||
|
||||
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId};
|
||||
size_t length = 0;
|
||||
|
||||
|
@ -4,7 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <usbhid.h>
|
||||
#include <dev/usb/usb_ioctl.h>
|
||||
|
||||
#if __has_include(<dev/usb/usb_ioctl.h>)
|
||||
#include <dev/usb/usb_ioctl.h> // FreeBSD
|
||||
#else
|
||||
#include <bus/u4b/usb_ioctl.h> // DragonFly
|
||||
#endif
|
||||
|
||||
#define MAX_UHID_JOYS 64
|
||||
|
||||
|
@ -2,12 +2,14 @@
|
||||
|
||||
#include "common/io/io.h"
|
||||
#include "common/properties.h"
|
||||
#include "util/mallocHelper.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <sys/pciio.h>
|
||||
#include <fcntl.h>
|
||||
#if __has_include(<dev/pci/pcireg.h>)
|
||||
#include <dev/pci/pcireg.h> // FreeBSD
|
||||
#else
|
||||
#include <bus/pci/pcireg.h> // DragonFly
|
||||
#endif
|
||||
|
||||
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
|
||||
{
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <stdlib.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <paths.h>
|
||||
#ifndef _PATH_LOCALBASE
|
||||
#define _PATH_LOCALBASE "/usr/local"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if FF_HAVE_EMBEDDED_PCIIDS
|
||||
|
@ -4,7 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <usbhid.h>
|
||||
#include <dev/usb/usb_ioctl.h>
|
||||
|
||||
#if __has_include(<dev/usb/usb_ioctl.h>)
|
||||
#include <dev/usb/usb_ioctl.h> // FreeBSD
|
||||
#else
|
||||
#include <bus/u4b/usb_ioctl.h> // DragonFly
|
||||
#endif
|
||||
|
||||
#define MAX_UHID_JOYS 64
|
||||
|
||||
|
@ -39,7 +39,7 @@ static const FFLocalIpNIFlag niFlagOptions[] = {
|
||||
{ IFF_PROMISC, "PROMISC" },
|
||||
{ IFF_ALLMULTI, "ALLMULTI" },
|
||||
{ IFF_MULTICAST, "MULTICAST" },
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__sun)
|
||||
#ifdef IFF_NOTRAILERS
|
||||
{ IFF_NOTRAILERS, "NOTRAILERS" },
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
@ -59,10 +59,10 @@ static const FFLocalIpNIFlag niFlagOptions[] = {
|
||||
{ IFF_LINK1, "LINK1" },
|
||||
{ IFF_LINK2, "LINK2" },
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
#ifdef IFF_ALTPHYS
|
||||
{ IFF_ALTPHYS, "ALTPHYS" },
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef IFF_CANTCONFIG
|
||||
{ IFF_CANTCONFIG, "CANTCONFIG" },
|
||||
#endif
|
||||
// sentinel
|
||||
|
@ -4,7 +4,12 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <usbhid.h>
|
||||
#include <dev/usb/usb_ioctl.h>
|
||||
|
||||
#if __has_include(<dev/usb/usb_ioctl.h>)
|
||||
#include <dev/usb/usb_ioctl.h> // FreeBSD
|
||||
#else
|
||||
#include <bus/u4b/usb_ioctl.h> // DragonFly
|
||||
#endif
|
||||
|
||||
#define MAX_UHID_JOYS 64
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "physicaldisk.h"
|
||||
|
||||
#if __has_include(<libgeom.h>)
|
||||
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <devstat.h>
|
||||
@ -92,3 +95,9 @@ const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options)
|
||||
{
|
||||
return "Fastfetch was compiled without libgeom support";
|
||||
}
|
||||
#endif
|
||||
|
@ -10,6 +10,9 @@ const char* ffDetectSound(FFlist* devices)
|
||||
char path[] = "/dev/mixer0";
|
||||
int defaultDev = ffSysctlGetInt("hw.snd.default_unit", -1);
|
||||
|
||||
if (defaultDev == -1)
|
||||
return "sysctl(hw.snd.default_unit) failed";
|
||||
|
||||
for (int idev = 0; idev <= 9; ++idev)
|
||||
{
|
||||
path[strlen("/dev/mixer")] = (char) ('0' + idev);
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <ctype.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <paths.h>
|
||||
#ifndef _PATH_LOCALBASE
|
||||
#define _PATH_LOCALBASE "/usr/local"
|
||||
#endif
|
||||
#elif __OpenBSD__
|
||||
#define _PATH_LOCALBASE "/usr/local"
|
||||
#elif __NetBSD__
|
||||
|
@ -530,7 +530,7 @@ void ffInitLocalIpOptions(FFLocalIpOptions* options)
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->showType = FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_PREFIX_LEN_BIT
|
||||
#if !__ANDROID__ /*Permission denied*/ && !__OpenBSD__ /*Report invalid argument for some reason*/
|
||||
#if !__ANDROID__ /*Permission denied*/ && !__OpenBSD__ /*Report invalid argument for some reason*/ && !__DragonFly__ /*Doesn't work*/
|
||||
| FF_LOCALIP_TYPE_DEFAULT_ROUTE_ONLY_BIT
|
||||
#endif
|
||||
;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "binary.h"
|
||||
|
||||
#if defined(FF_HAVE_ELF) || defined(__sun) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
#if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
|
||||
#include "common/io/io.h"
|
||||
#include "common/library.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user