diff --git a/CMakeLists.txt b/CMakeLists.txt index ad108cd95..140ff0620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,12 +11,12 @@ project(fastfetch # Target Platform # ################### -if("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Ll]inux.*") +if("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Ll]inux.*|MSYS") set(LINUX TRUE CACHE BOOL "..." FORCE) # LINUX means GNU/Linux, not just the kernel elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Bb][Ss][Dd].*") set(BSD TRUE CACHE BOOL "..." FORCE) elseif(NOT APPLE AND NOT ANDROID) - message(FATAL_ERROR "Unsupported platform") + message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}") endif() ##################### @@ -82,7 +82,10 @@ if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ENV{HOMEBREW_PREFIX}/lib") endif() -set(FASTFETCH_FLAGS_DEBUG "-fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined") +set(FASTFETCH_FLAGS_DEBUG "-fno-omit-frame-pointer") +if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "MSYS") + set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address -fsanitize=undefined") +endif() set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}") set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG} -rdynamic") diff --git a/README.md b/README.md index 8eb20f122..8f834a886 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fastfetch -Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in pure c, with performance and customizability in mind. Currently Linux, Android, BSD and MacOS are supported. +Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying them in a pretty way. It is written in pure c, with performance and customizability in mind. Currently Linux, Android, BSD, MacOS and Windows on [MSYS2](https://www.msys2.org/) are supported. @@ -82,7 +82,7 @@ KDE Plasma, Gnome, Cinnamon, Mate, XFCE4, LXQt ##### Terminal fonts ``` -Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, LXTerminal, iTerm2, Apple Terminal, TTY, Windows Terminal, Termux +Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, LXTerminal, iTerm2, Apple Terminal, TTY, Windows Terminal, Termux, mintty ``` ## Building diff --git a/src/common/init.c b/src/common/init.c index ec5dab5d3..5971b916d 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -257,7 +257,7 @@ void ffInitInstance(FFinstance* instance) defaultConfig(instance); } -#if !defined(__ANDROID__) +#if !defined(__ANDROID__) && !defined(__CYGWIN__) static void* connectDisplayServerThreadMain(void* instance) { diff --git a/src/detection/cpuUsage/cpuUsage_linux.c b/src/detection/cpuUsage/cpuUsage_linux.c index 3696a8d77..c3e9b37aa 100644 --- a/src/detection/cpuUsage/cpuUsage_linux.c +++ b/src/detection/cpuUsage/cpuUsage_linux.c @@ -5,7 +5,7 @@ const char* ffGetCpuUsageInfo(long* inUseAll, long* totalAll) { - long user, nice, system, idle, iowait, irq, softirq; + long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0; FILE* procStat = fopen("/proc/stat", "r"); if(procStat == NULL) diff --git a/src/detection/host/host.h b/src/detection/host/host.h index cdf2fbf53..02a1b9e6a 100644 --- a/src/detection/host/host.h +++ b/src/detection/host/host.h @@ -6,6 +6,7 @@ #include "fastfetch.h" #define FF_HOST_PRODUCT_NAME_WSL "Windows Subsystem for Linux" +#define FF_HOST_PRODUCT_NAME_MSYS "Windows on MSYS" typedef struct FFHostResult { diff --git a/src/detection/host/host_linux.c b/src/detection/host/host_linux.c index 80e048ae7..400d7f856 100644 --- a/src/detection/host/host_linux.c +++ b/src/detection/host/host_linux.c @@ -109,10 +109,12 @@ void ffDetectHostImpl(FFHostResult* host) if(ffStrbufStartsWithS(&host->productName, "Standard PC")) ffStrbufPrependS(&host->productName, "KVM/QEMU "); - //On WSL, the real host can't be detected. Instead use WSL as host. - if(host->productFamily.length == 0 && host->productName.length == 0 && ( - getenv("WSLENV") != NULL || - getenv("WSL_DISTRO") != NULL || - getenv("WSL_INTEROP") != NULL - )) ffStrbufAppendS(&host->productName, FF_HOST_PRODUCT_NAME_WSL); + if(host->productFamily.length == 0 && host->productName.length == 0) + { + //On WSL, the real host can't be detected. Instead use WSL as host. + if(getenv("WSL_DISTRO") != NULL || getenv("WSL_INTEROP") != NULL) + ffStrbufAppendS(&host->productName, FF_HOST_PRODUCT_NAME_WSL); + else if(getenv("MSYSTEM") != NULL && strcmp(getenv("MSYSTEM"), "MSYS") == 0) + ffStrbufAppendS(&host->productName, FF_HOST_PRODUCT_NAME_MSYS); + } } diff --git a/src/detection/terminalShell.c b/src/detection/terminalShell.c index cd3785a0f..26c37e159 100644 --- a/src/detection/terminalShell.c +++ b/src/detection/terminalShell.c @@ -1,4 +1,5 @@ #include "fastfetch.h" +#include "detection/host/host.h" #include "detection/terminalshell.h" #include "common/io.h" #include "common/parsing.h" @@ -149,17 +150,18 @@ static void getTerminalFromEnv(FFTerminalShellResult* result) getenv("KONSOLE_VERSION") != NULL )) term = "konsole"; - //MacOS + //MacOS, mintty if(!ffStrSet(term)) term = getenv("TERM_PROGRAM"); //We are in WSL but not in Windows Terminal - if(!ffStrSet(term) && ( - getenv("WSLENV") != NULL || - getenv("WSL_DISTRO") != NULL || - getenv("WSL_INTEROP") != NULL - )) + if(!ffStrSet(term)) + { + const FFHostResult* host = ffDetectHost(); + if(ffStrbufCompS(&host->productName, FF_HOST_PRODUCT_NAME_WSL) == 0 || + ffStrbufCompS(&host->productName, FF_HOST_PRODUCT_NAME_MSYS) == 0) term = "conhost"; + } //Normal Terminal if(!ffStrSet(term)) diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index f68d45744..ac3bb3a6a 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -312,6 +312,29 @@ static void detectFromWindowsTeriminal(const FFinstance* instance, FFTerminalFon #endif +static void detectMintty(const FFinstance* instance, FFTerminalFontResult* terminalFont) +{ + FFstrbuf fontName; + ffStrbufInit(&fontName); + + FFstrbuf fontSize; + ffStrbufInit(&fontSize); + + ffParsePropFileHomeValues(instance, ".minttyrc", 2, (FFpropquery[]) { + {"Font=", &fontName}, + {"FontHeight=", &fontSize} + }); + if(fontName.length == 0) + ffStrbufAppendS(&fontName, "Lucida Console"); + if(fontSize.length == 0) + ffStrbufAppendC(&fontSize, '9'); + + ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); + + ffStrbufDestroy(&fontName); + ffStrbufDestroy(&fontSize); +} + void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalShellResult* terminalShell, FFTerminalFontResult* terminalFont) { if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "konsole") == 0) @@ -326,4 +349,6 @@ void ffDetectTerminalFontPlatform(const FFinstance* instance, const FFTerminalSh detectFromGSettings(instance, "/org/gnome/terminal/legacy/profiles:/:", "org.gnome.Terminal.ProfilesList", "org.gnome.Terminal.Legacy.Profile", terminalFont); else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "Windows Terminal") == 0) detectFromWindowsTeriminal(instance, terminalFont); + else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "mintty") == 0) + detectMintty(instance, terminalFont); }