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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ set_package_properties(Threads PROPERTIES TYPE REQUIRED)
# platform-specific logics
if(WIN32)
set(LIBRT wsock32 ws2_32 secur32)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
find_library(LIBM m REQUIRED)
set(LIBRT)
elseif(NOT APPLE)
find_library(LIBM m REQUIRED)
find_library(LIBRT rt REQUIRED)
Expand Down
3 changes: 3 additions & 0 deletions include/notcurses/ncport.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ extern "C" {
#define wcwidth(w) 1 // FIXME lol, no
#define wcswidth(w, s) (int)(wcslen(w)) // FIXME lol, no
#define htole(x) (x) // FIXME are all windows installs LE? ugh
#elif defined(__OpenBSD__)
#include <endian.h>
#define htole(x) (swap32(htonl(x)))
#else // BSDs
#include <sys/endian.h>
#define htole(x) (bswap32(htonl(x)))
Expand Down
26 changes: 26 additions & 0 deletions src/fetch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ linux_ncneofetch(fetched_info* fi){

typedef enum {
NCNEO_LINUX,
NCNEO_OPENBSD,
NCNEO_FREEBSD,
NCNEO_DRAGONFLY,
NCNEO_XNU,
Expand All @@ -348,6 +349,8 @@ get_kernel(fetched_info* fi){
fi->kernver = strdup(uts.release);
if(strcmp(uts.sysname, "Linux") == 0){
return NCNEO_LINUX;
}else if(strcmp(uts.sysname, "OpenBSD") == 0){
return NCNEO_OPENBSD;
}else if(strcmp(uts.sysname, "FreeBSD") == 0){
return NCNEO_FREEBSD;
}else if(strcmp(uts.sysname, "DragonFly") == 0){
Expand Down Expand Up @@ -426,6 +429,17 @@ windows_ncneofetch(fetched_info* fi){
return &mswin;
}

static const distro_info*
openbsd_ncneofetch(fetched_info* fi){
static distro_info obsd = {
.name = "OpenBSD",
};
obsd.logofile = find_data("freebsd.png"),
fi->neologo = get_neofetch_art("OpenBSD");
fi->distro_pretty = NULL;
return &obsd;
}

static const distro_info*
freebsd_ncneofetch(fetched_info* fi){
static distro_info fbsd = {
Expand Down Expand Up @@ -568,6 +582,15 @@ infoplane_notcurses(struct notcurses* nc, const fetched_info* fi,
ncbprefix(sinfo.totalram - sinfo.freeram, 1, usedmet, 1);
ncplane_printf_aligned(infop, 2, NCALIGN_RIGHT, "Processes: %hu ", sinfo.procs);
ncplane_printf_aligned(infop, 2, NCALIGN_LEFT, " RAM: %sB/%sB", usedmet, totalmet);
#elif defined(__OpenBSD__)
int mib[2] = { CTL_HW, HW_PHYSMEM64 };
int64_t ram;
size_t oldlenp = sizeof(ram);
if(sysctl(mib, 2, &ram, &oldlenp, NULL, 0) == 0){
char tram[NCBPREFIXSTRLEN + 1];
ncbprefix(ram, 1, tram, 1);
ncplane_printf_aligned(infop, 2, NCALIGN_LEFT, " RAM: %sB", tram);
}
#elif defined(BSD)
uint64_t ram;
size_t oldlenp = sizeof(ram);
Expand Down Expand Up @@ -777,6 +800,9 @@ ncneofetch(struct notcurses* nc){
case NCNEO_LINUX:
fi.distro = linux_ncneofetch(&fi);
break;
case NCNEO_OPENBSD:
fi.distro = openbsd_ncneofetch(&fi);
break;
case NCNEO_FREEBSD:
fi.distro = freebsd_ncneofetch(&fi);
break;
Expand Down
4 changes: 4 additions & 0 deletions src/lib/egcpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ utf8_egc_len(const char* gcluster, int* colcount){
logerror("invalid UTF8: %s", gcluster);
return -1;
}
// Handle NUL
if(r == 0){
break;
}
if(prevw && !injoin && uc_is_grapheme_break(prevw, wc)){
break; // starts a new EGC, exit and do not claim
}
Expand Down