mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Merge pull request #274 from CarterLi/master
macOS: respect CMAKE_INSTALL_SYSCONFDIR; use Cocoa API to parse plist files
This commit is contained in:
@@ -64,7 +64,7 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: install required packages
|
||||
run: brew install vulkan-loader libplist
|
||||
run: brew install vulkan-loader molten-vk
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
|
||||
+7
-5
@@ -46,7 +46,6 @@ cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD" OFF)
|
||||
cmake_dependent_option(ENABLE_LIBPLIST "Enable libplist" ON "APPLE" OFF)
|
||||
cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
|
||||
|
||||
@@ -123,6 +122,10 @@ if(NOT TARGET_DIR_HOME)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET_DIR_ETC)
|
||||
set(TARGET_DIR_ETC "${CMAKE_INSTALL_SYSCONFDIR}")
|
||||
endif()
|
||||
|
||||
#################
|
||||
# Tweak version #
|
||||
#################
|
||||
@@ -294,17 +297,17 @@ if(APPLE)
|
||||
src/util/apple/cf_helpers.c
|
||||
src/util/apple/osascript.m
|
||||
src/detection/host/host_apple.c
|
||||
src/detection/os/os_apple.c
|
||||
src/detection/os/os_apple.m
|
||||
src/detection/cpu/cpu_apple.c
|
||||
src/detection/gpu/gpu_apple.c
|
||||
src/detection/battery/battery_apple.c
|
||||
src/detection/poweradapter/poweradapter_apple.c
|
||||
src/detection/memory/memory_apple.c
|
||||
src/detection/displayserver/displayserver_apple.c
|
||||
src/detection/terminalfont/terminalfont_apple.c
|
||||
src/detection/terminalfont/terminalfont_apple.m
|
||||
src/detection/media/media_apple.m
|
||||
src/detection/disk/disk_apple.m
|
||||
src/detection/wmtheme/wmtheme_apple.c
|
||||
src/detection/wmtheme/wmtheme_apple.m
|
||||
src/detection/temps/temps_apple.c
|
||||
src/detection/font/font_apple.m
|
||||
)
|
||||
@@ -392,7 +395,6 @@ ff_lib_enable(EGL egl)
|
||||
ff_lib_enable(GLX glx)
|
||||
ff_lib_enable(OSMESA osmesa)
|
||||
ff_lib_enable(OPENCL OpenCL)
|
||||
ff_lib_enable(LIBPLIST libplist-2.0)
|
||||
ff_lib_enable(LIBCJSON libcjson)
|
||||
ff_lib_enable(FREETYPE freetype2)
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ The following libraries are used if present at runtime:
|
||||
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
|
||||
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for pkg & rpm package count.
|
||||
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
|
||||
* [`libplist`](https://github.com/libimobiledevice/libplist): Binary `plist` file parser ( macOS ). Needed for iTerm2 Terminal font and WM Theme.
|
||||
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Needed for Windows Terminal font ( WSL ).
|
||||
* [`freetype`](https://www.freetype.org/): Needed for Termux font detection ( Android ).
|
||||
|
||||
|
||||
@@ -219,7 +219,6 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInitA(&instance->config.libGLX, 0);
|
||||
ffStrbufInitA(&instance->config.libOSMesa, 0);
|
||||
ffStrbufInitA(&instance->config.libOpenCL, 0);
|
||||
ffStrbufInitA(&instance->config.libplist, 0);
|
||||
ffStrbufInitA(&instance->config.libcJSON, 0);
|
||||
ffStrbufInitA(&instance->config.libfreetype, 0);
|
||||
|
||||
@@ -482,9 +481,6 @@ void ffListFeatures()
|
||||
#ifdef FF_HAVE_OPENCL
|
||||
"opencl\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_LIBPLIST
|
||||
"libplist\n"
|
||||
#endif
|
||||
#ifdef FF_HAVE_LIBCJSON
|
||||
"libcjson\n"
|
||||
#endif
|
||||
|
||||
@@ -347,6 +347,5 @@
|
||||
#--lib-glx /usr/lib/libGLX.so
|
||||
#--lib-osmesa /usr/lib/libOSMesa.so
|
||||
#--lib-opencl /usr/lib/libOpenCL.so
|
||||
#--lib-plist /usr/local/bin/libplist-2.0.dylib
|
||||
#--lib-cjson /usr/lib/libcjson.so
|
||||
#--lib-freetype /data/data/com.termux/files/usr/lib
|
||||
|
||||
@@ -84,7 +84,6 @@ Library options: Set the path of a library to load
|
||||
--lib-glx <path>
|
||||
--lib-osmesa <path>
|
||||
--lib-opencl <path>
|
||||
--lib-plist <path>
|
||||
--lib-cjson <path>
|
||||
|
||||
Module specific options:
|
||||
|
||||
@@ -1,62 +1,27 @@
|
||||
#include "os.h"
|
||||
#include "common/properties.h"
|
||||
#include "common/sysctl.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef enum PListKey
|
||||
{
|
||||
PLIST_KEY_NAME,
|
||||
PLIST_KEY_VERSION,
|
||||
PLIST_KEY_BUILD,
|
||||
PLIST_KEY_OTHER
|
||||
} PListKey;
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static void parseSystemVersion(FFOSResult* os)
|
||||
{
|
||||
FILE* plist = fopen("/System/Library/CoreServices/SystemVersion.plist", "r");
|
||||
if(plist == NULL)
|
||||
return;
|
||||
NSError* error;
|
||||
NSString* fileName = @"file:///System/Library/CoreServices/SystemVersion.plist";
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
|
||||
error:&error];
|
||||
if(error)
|
||||
return;
|
||||
|
||||
char* line = NULL;
|
||||
size_t len = 0;
|
||||
PListKey key = PLIST_KEY_OTHER;
|
||||
NSString* value;
|
||||
|
||||
FFstrbuf keyBuffer;
|
||||
ffStrbufInit(&keyBuffer);
|
||||
|
||||
while(getline(&line, &len, plist) != EOF)
|
||||
{
|
||||
if(ffParsePropLine(line, "<key>", &keyBuffer))
|
||||
{
|
||||
if(ffStrbufIgnCaseCompS(&keyBuffer, "ProductName") == 0)
|
||||
key = PLIST_KEY_NAME;
|
||||
else if(ffStrbufIgnCaseCompS(&keyBuffer, "ProductUserVisibleVersion") == 0)
|
||||
key = PLIST_KEY_VERSION;
|
||||
else if(ffStrbufIgnCaseCompS(&keyBuffer, "ProductBuildVersion") == 0)
|
||||
key = PLIST_KEY_BUILD;
|
||||
else
|
||||
key = PLIST_KEY_OTHER;
|
||||
|
||||
ffStrbufClear(&keyBuffer);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(key == PLIST_KEY_NAME)
|
||||
ffParsePropLine(line, "<string>", &os->name);
|
||||
else if(key == PLIST_KEY_VERSION)
|
||||
ffParsePropLine(line, "<string>", &os->version);
|
||||
else if(key == PLIST_KEY_BUILD)
|
||||
ffParsePropLine(line, "<string>", &os->buildID);
|
||||
}
|
||||
|
||||
ffStrbufDestroy(&keyBuffer);
|
||||
|
||||
if(line != NULL)
|
||||
free(line);
|
||||
|
||||
fclose(plist);
|
||||
if((value = [dict valueForKey:@"ProductName"]))
|
||||
ffStrbufInitS(&os->name, value.UTF8String);
|
||||
if((value = [dict valueForKey:@"ProductUserVisibleVersion"]))
|
||||
ffStrbufInitS(&os->version, value.UTF8String);
|
||||
if((value = [dict valueForKey:@"ProductBuildVersion"]))
|
||||
ffStrbufInitS(&os->buildID, value.UTF8String);
|
||||
}
|
||||
|
||||
void parseOSXSoftwareLicense(FFOSResult* os)
|
||||
@@ -1,146 +0,0 @@
|
||||
#include "terminalfont.h"
|
||||
#include "common/printing.h"
|
||||
#include "common/font.h"
|
||||
#include "common/io.h"
|
||||
#include "common/library.h"
|
||||
#include "detection/terminalshell.h"
|
||||
#include "util/apple/osascript.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef FF_HAVE_LIBPLIST
|
||||
#include <plist/plist.h>
|
||||
|
||||
static const char* iterm2ParsePList(const FFinstance* instance, const FFstrbuf* content, const char* profile, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FF_LIBRARY_LOAD(libplist, &instance->config.libplist, "dlopen libplist failed", "libplist-2.0"FF_LIBRARY_EXTENSION, 2);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_is_binary);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_from_bin);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_from_xml);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_array_new_iter);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_access_path);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_array_next_item);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_string_val_compare);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_dict_get_item);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_get_string_ptr);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_free);
|
||||
|
||||
plist_t root_node = NULL;
|
||||
if (ffplist_is_binary(content->chars, content->length))
|
||||
ffplist_from_bin(content->chars, content->length, &root_node);
|
||||
else
|
||||
ffplist_from_xml(content->chars, content->length, &root_node);
|
||||
|
||||
const char* error = NULL;
|
||||
|
||||
if(root_node == NULL)
|
||||
{
|
||||
error = "parsing iTerm preference file failed";
|
||||
goto exit;
|
||||
}
|
||||
|
||||
plist_t bookmarks = ffplist_access_path(root_node, 1, "New Bookmarks");
|
||||
|
||||
plist_array_iter iter = NULL;
|
||||
ffplist_array_new_iter(bookmarks, &iter);
|
||||
plist_t item = NULL;
|
||||
do
|
||||
{
|
||||
ffplist_array_next_item(bookmarks, iter, &item);
|
||||
if(ffplist_string_val_compare(ffplist_dict_get_item(item, "Name"), profile) == 0)
|
||||
break;
|
||||
} while(item != NULL);
|
||||
free(iter);
|
||||
|
||||
if(item == NULL)
|
||||
{
|
||||
error = "find profile bookmark failed";
|
||||
goto exit;
|
||||
}
|
||||
|
||||
item = ffplist_dict_get_item(item, "Normal Font");
|
||||
if (item == NULL)
|
||||
{
|
||||
error = "find Normal Font key failed";
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ffFontInitWithSpace(&terminalFont->font, ffplist_get_string_ptr(item, NULL));
|
||||
|
||||
exit:
|
||||
ffplist_free(root_node);
|
||||
dlclose(libplist);
|
||||
return error;
|
||||
}
|
||||
|
||||
static void detectIterm2(const FFinstance* instance, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
const char* profile = getenv("ITERM_PROFILE");
|
||||
if (profile == NULL)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "environment variable ITERM_PROFILE not set");
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf fileName;
|
||||
ffStrbufInit(&fileName);
|
||||
ffStrbufAppendS(&fileName, instance->state.passwd->pw_dir);
|
||||
ffStrbufAppendS(&fileName, "/Library/Preferences/com.googlecode.iterm2.plist");
|
||||
|
||||
FFstrbuf content;
|
||||
ffStrbufInit(&content);
|
||||
ffAppendFileBuffer(fileName.chars, &content);
|
||||
ffStrbufDestroy(&fileName);
|
||||
if(content.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "reading iTerm preference file failed");
|
||||
ffStrbufDestroy(&content);
|
||||
return;
|
||||
}
|
||||
|
||||
const char* error = iterm2ParsePList(instance, &content, profile, terminalFont);
|
||||
if(error != NULL)
|
||||
ffStrbufAppendS(&terminalFont->error, error);
|
||||
|
||||
ffStrbufDestroy(&content);
|
||||
}
|
||||
|
||||
#else
|
||||
static void detectIterm2(const FFinstance* instance, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
ffStrbufAppendS(&terminalFont->error, "Fastfetch was compiled without libplist support");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void detectAppleTerminal(FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FFstrbuf fontName;
|
||||
ffStrbufInit(&fontName);
|
||||
ffOsascript("tell application \"Terminal\" to font name of window frontmost", &fontName);
|
||||
|
||||
if(fontName.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "executing osascript failed");
|
||||
ffStrbufDestroy(&fontName);
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf fontSize;
|
||||
ffStrbufInit(&fontSize);
|
||||
ffOsascript("tell application \"Terminal\" to font size of window frontmost", &fontSize);
|
||||
|
||||
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, "iterm.app") == 0)
|
||||
detectIterm2(instance, terminalFont);
|
||||
else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "Apple_Terminal") == 0)
|
||||
detectAppleTerminal(terminalFont);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
#include "terminalfont.h"
|
||||
#include "common/font.h"
|
||||
#include "detection/terminalshell.h"
|
||||
#include "util/apple/osascript.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static void detectIterm2(const FFinstance* instance, FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
const char* profile = getenv("ITERM_PROFILE");
|
||||
if (profile == NULL)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "environment variable ITERM_PROFILE not set");
|
||||
return;
|
||||
}
|
||||
|
||||
NSError* error;
|
||||
NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/com.googlecode.iterm2.plist", instance->state.passwd->pw_dir];
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
|
||||
error:&error];
|
||||
if(error)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, [error localizedDescription].UTF8String);
|
||||
return;
|
||||
}
|
||||
|
||||
for(NSDictionary* bookmark in [dict valueForKey:@"New Bookmarks"])
|
||||
{
|
||||
if(![[bookmark valueForKey:@"Name"] isEqualToString:@(profile)])
|
||||
continue;
|
||||
|
||||
NSString* normalFont = [bookmark valueForKey:@"Normal Font"];
|
||||
if(!normalFont)
|
||||
{
|
||||
ffStrbufAppendF(&terminalFont->error, "`Normal Font` key in profile `%s` doesn't exist", profile);
|
||||
return;
|
||||
}
|
||||
ffFontInitWithSpace(&terminalFont->font, normalFont.UTF8String);
|
||||
return;
|
||||
}
|
||||
|
||||
ffStrbufAppendF(&terminalFont->error, "find profile `%s` bookmark failed", profile);
|
||||
}
|
||||
|
||||
static void detectAppleTerminal(FFTerminalFontResult* terminalFont)
|
||||
{
|
||||
FFstrbuf fontName;
|
||||
ffStrbufInit(&fontName);
|
||||
ffOsascript("tell application \"Terminal\" to font name of window frontmost", &fontName);
|
||||
|
||||
if(fontName.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(&terminalFont->error, "executing osascript failed");
|
||||
ffStrbufDestroy(&fontName);
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf fontSize;
|
||||
ffStrbufInit(&fontSize);
|
||||
ffOsascript("tell application \"Terminal\" to font size of window frontmost", &fontSize);
|
||||
|
||||
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, "iterm.app") == 0)
|
||||
detectIterm2(instance, terminalFont);
|
||||
else if(ffStrbufIgnCaseCompS(&terminalShell->terminalProcessName, "Apple_Terminal") == 0)
|
||||
detectAppleTerminal(terminalFont);
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "wmtheme.h"
|
||||
|
||||
#ifdef FF_HAVE_LIBPLIST
|
||||
#include "common/library.h"
|
||||
#include "common/io.h"
|
||||
#include <plist/plist.h>
|
||||
|
||||
static const char* quartzCompositorParsePlist(FFinstance* instance, const FFstrbuf* content, FFstrbuf* theme)
|
||||
{
|
||||
FF_LIBRARY_LOAD(libplist, &instance->config.libplist, "dlopen libplist failed", "libplist-2.0"FF_LIBRARY_EXTENSION, 2);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_is_binary);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_from_bin);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_from_xml);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_dict_get_item);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_get_string_ptr);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_get_uint_val);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libplist, plist_free);
|
||||
|
||||
plist_t root_node = NULL;
|
||||
if (ffplist_is_binary(content->chars, content->length))
|
||||
ffplist_from_bin(content->chars, content->length, &root_node);
|
||||
else
|
||||
ffplist_from_xml(content->chars, content->length, &root_node);
|
||||
|
||||
if(root_node == NULL)
|
||||
return "parsing Quartz Compositor preference file failed";
|
||||
|
||||
plist_t pWmThemeColor = ffplist_dict_get_item(root_node, "AppleAccentColor");
|
||||
uint64_t wmThemeColor = 100;
|
||||
if (pWmThemeColor != NULL)
|
||||
ffplist_get_uint_val(pWmThemeColor, &wmThemeColor);
|
||||
switch (wmThemeColor)
|
||||
{
|
||||
case (uint64_t)-1: ffStrbufAppendS(theme, "Graphite"); break;
|
||||
case 0: ffStrbufAppendS(theme, "Red"); break;
|
||||
case 1: ffStrbufAppendS(theme, "Orange"); break;
|
||||
case 2: ffStrbufAppendS(theme, "Yellow"); break;
|
||||
case 3: ffStrbufAppendS(theme, "Green"); break;
|
||||
case 4: ffStrbufAppendS(theme, "Blue"); break;
|
||||
case 5: ffStrbufAppendS(theme, "Purple"); break;
|
||||
case 6: ffStrbufAppendS(theme, "Pink"); break;
|
||||
default: ffStrbufAppendS(theme, "Multicolor"); break;
|
||||
}
|
||||
|
||||
plist_t pWmTheme = ffplist_dict_get_item(root_node, "AppleInterfaceStyle");
|
||||
ffStrbufAppendF(theme, " (%s)", pWmTheme != NULL ? ffplist_get_string_ptr(pWmTheme, NULL) : "Light");
|
||||
|
||||
ffplist_free(root_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool detectQuartzCompositor(FFinstance* instance, FFstrbuf* themeOrError)
|
||||
{
|
||||
FFstrbuf fileName;
|
||||
ffStrbufInitS(&fileName, instance->state.passwd->pw_dir);
|
||||
ffStrbufAppendS(&fileName, "/Library/Preferences/.GlobalPreferences.plist");
|
||||
|
||||
FFstrbuf content;
|
||||
ffStrbufInit(&content);
|
||||
ffAppendFileBuffer(fileName.chars, &content);
|
||||
ffStrbufDestroy(&fileName);
|
||||
if(content.length == 0)
|
||||
{
|
||||
ffStrbufDestroy(&content);
|
||||
ffStrbufSetS(themeOrError, "reading Quartz Compositor preference file failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* error = quartzCompositorParsePlist(instance, &content, themeOrError);
|
||||
ffStrbufDestroy(&content);
|
||||
if(error)
|
||||
{
|
||||
ffStrbufSetS(themeOrError, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static bool detectQuartzCompositor(FFinstance* instance, FFstrbuf* theme)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
ffStrbufSetS("Fastfetch was compiled without libplist support");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError)
|
||||
{
|
||||
const FFDisplayServerResult* wm = ffConnectDisplayServer(instance);
|
||||
|
||||
if(wm->wmPrettyName.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "WM Theme needs sucessfull WM detection");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, "Quartz Compositor") == 0)
|
||||
return detectQuartzCompositor(instance, themeOrError);
|
||||
|
||||
ffStrbufAppendS(themeOrError, "Unknown WM: ");
|
||||
ffStrbufAppend(themeOrError, &wm->dePrettyName);
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#include "fastfetch.h"
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
#include "wmtheme.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
static bool detectQuartzCompositor(FFinstance* instance, FFstrbuf* themeOrError)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
|
||||
NSError* error;
|
||||
NSString* fileName = [NSString stringWithFormat:@"file://%s/Library/Preferences/.GlobalPreferences.plist", instance->state.passwd->pw_dir];
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithContentsOfURL:[NSURL URLWithString:fileName]
|
||||
error:&error];
|
||||
if(error)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, error.localizedDescription.UTF8String);
|
||||
return false;
|
||||
}
|
||||
|
||||
NSNumber* wmThemeColor = [dict valueForKey:@"AppleAccentColor"];
|
||||
if(!wmThemeColor)
|
||||
ffStrbufAppendS(themeOrError, "Multicolor");
|
||||
else
|
||||
{
|
||||
switch(wmThemeColor.intValue)
|
||||
{
|
||||
case -1: ffStrbufAppendS(themeOrError, "Graphite"); break;
|
||||
case 0: ffStrbufAppendS(themeOrError, "Red"); break;
|
||||
case 1: ffStrbufAppendS(themeOrError, "Orange"); break;
|
||||
case 2: ffStrbufAppendS(themeOrError, "Yellow"); break;
|
||||
case 3: ffStrbufAppendS(themeOrError, "Green"); break;
|
||||
case 4: ffStrbufAppendS(themeOrError, "Blue"); break;
|
||||
case 5: ffStrbufAppendS(themeOrError, "Purple"); break;
|
||||
case 6: ffStrbufAppendS(themeOrError, "Pink"); break;
|
||||
default: ffStrbufAppendS(themeOrError, "Unknown"); break;
|
||||
}
|
||||
}
|
||||
|
||||
NSString* wmTheme = [dict valueForKey:@"AppleInterfaceStyle"];
|
||||
ffStrbufAppendF(themeOrError, " (%s)", wmTheme ? wmTheme.UTF8String : "Light");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError)
|
||||
{
|
||||
const FFDisplayServerResult* wm = ffConnectDisplayServer(instance);
|
||||
|
||||
if(wm->wmPrettyName.length == 0)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "WM Theme needs sucessfull WM detection");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ffStrbufIgnCaseCompS(&wm->wmPrettyName, "Quartz Compositor") == 0)
|
||||
return detectQuartzCompositor(instance, themeOrError);
|
||||
|
||||
ffStrbufAppendS(themeOrError, "Unknown WM: ");
|
||||
ffStrbufAppend(themeOrError, &wm->dePrettyName);
|
||||
return false;
|
||||
}
|
||||
+1
-3
@@ -1241,8 +1241,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
optionParseString(key, value, &instance->config.libOSMesa);
|
||||
else if(strcasecmp(key, "--lib-opencl") == 0)
|
||||
optionParseString(key, value, &instance->config.libOpenCL);
|
||||
else if(strcasecmp(key, "--lib-plist") == 0)
|
||||
optionParseString(key, value, &instance->config.libplist);
|
||||
else if(strcasecmp(key, "--lib-cjson") == 0)
|
||||
optionParseString(key, value, &instance->config.libcJSON);
|
||||
|
||||
@@ -1310,7 +1308,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
|
||||
static void parseConfigFileSystem(FFinstance* instance, FFdata* data)
|
||||
{
|
||||
parseConfigFile(instance, data, FASTFETCH_TARGET_DIR_ROOT"/etc/fastfetch/config.conf");
|
||||
parseConfigFile(instance, data, FASTFETCH_TARGET_DIR_ETC"/fastfetch/config.conf");
|
||||
}
|
||||
|
||||
static void parseConfigFileUser(FFinstance* instance, FFdata* data)
|
||||
|
||||
@@ -151,7 +151,6 @@ typedef struct FFconfig
|
||||
FFstrbuf libGLX;
|
||||
FFstrbuf libOSMesa;
|
||||
FFstrbuf libOpenCL;
|
||||
FFstrbuf libplist;
|
||||
FFstrbuf libcJSON;
|
||||
FFstrbuf libfreetype;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define FASTFETCH_TARGET_DIR_ROOT "@TARGET_DIR_ROOT@"
|
||||
#define FASTFETCH_TARGET_DIR_USR "@TARGET_DIR_USR@"
|
||||
#define FASTFETCH_TARGET_DIR_HOME "@TARGET_DIR_HOME@"
|
||||
#define FASTFETCH_TARGET_DIR_ETC "@TARGET_DIR_ETC@"
|
||||
|
||||
#define FASTFETCH_DATATEXT_STRUCTURE "@DATATEXT_STRUCTURE@"
|
||||
#define FASTFETCH_DATATEXT_CONFIG_SYSTEM "@DATATEXT_CONFIG_SYSTEM@" //Requires FASTFETCH_PROJECT_VERSION to be set
|
||||
|
||||
@@ -39,6 +39,14 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
|
||||
ffStrbufAppend(result, &os->version);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
if(os->buildID.length > 0)
|
||||
{
|
||||
ffStrbufAppendC(result, ' ');
|
||||
ffStrbufAppend(result, &os->buildID);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Append variant if it is missing
|
||||
if(os->variant.length > 0 && ffStrbufFirstIndex(result, &os->variant) == result->length)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user