mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-06 05:04:17 +01:00
Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev
This commit is contained in:
@@ -9,7 +9,6 @@ typedef struct FFSoundDevice
|
||||
{
|
||||
FFstrbuf identifier;
|
||||
FFstrbuf name;
|
||||
FFstrbuf manufacturer;
|
||||
uint8_t volume; // 0-100%
|
||||
bool main;
|
||||
bool active;
|
||||
|
||||
@@ -9,16 +9,16 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
|
||||
UInt32 dataSize = sizeof(mainDeviceId);
|
||||
if(AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress){
|
||||
kAudioHardwarePropertyDefaultOutputDevice,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
}, 0, NULL, &dataSize, &mainDeviceId) != kAudioHardwareNoError)
|
||||
return "AudioObjectGetPropertyData(kAudioHardwarePropertyDefaultOutputDevice) failed";
|
||||
|
||||
AudioDeviceID deviceIds[32];
|
||||
AudioObjectID deviceIds[32] = {};
|
||||
dataSize = sizeof(deviceIds);
|
||||
if(AudioObjectGetPropertyData(kAudioObjectSystemObject, &(AudioObjectPropertyAddress){
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
}, 0, NULL, &dataSize, &deviceIds) != kAudioHardwareNoError)
|
||||
return "AudioObjectGetPropertyData(kAudioHardwarePropertyDevices) failed";
|
||||
@@ -31,18 +31,26 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
|
||||
dataSize = sizeof(muted);
|
||||
if(AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
|
||||
kAudioDevicePropertyMute,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
0
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
}, 0, NULL, &dataSize, &muted) != kAudioHardwareNoError)
|
||||
continue;
|
||||
|
||||
FFSoundDevice* device = (FFSoundDevice*) ffListAdd(devices);
|
||||
device->main = deviceId == mainDeviceId;
|
||||
device->active = device->main;
|
||||
device->active = false;
|
||||
device->volume = 0;
|
||||
ffStrbufInitF(&device->identifier, "%u", (unsigned) deviceId);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->manufacturer);
|
||||
|
||||
uint32_t active;
|
||||
dataSize = sizeof(active);
|
||||
if(AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
|
||||
kAudioDevicePropertyDeviceIsAlive,
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
}, 0, NULL, &dataSize, &active) == kAudioHardwareNoError)
|
||||
device->active = !!active;
|
||||
|
||||
if (!muted)
|
||||
{
|
||||
@@ -50,8 +58,8 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
|
||||
dataSize = sizeof(volume);
|
||||
if(AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
|
||||
kAudioDevicePropertyVolumeScalar,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
0
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
}, 0, NULL, &dataSize, &volume) == kAudioHardwareNoError)
|
||||
device->volume = (uint8_t) (volume * 100 + 0.5);
|
||||
}
|
||||
@@ -60,19 +68,13 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
|
||||
dataSize = sizeof(name);
|
||||
if(AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
|
||||
kAudioObjectPropertyName,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
0
|
||||
kAudioObjectPropertyScopeOutput,
|
||||
kAudioObjectPropertyElementMain
|
||||
}, 0, NULL, &dataSize, &name) == kAudioHardwareNoError)
|
||||
{
|
||||
ffCfStrGetString(name, &device->name);
|
||||
|
||||
CFStringRef manufacturer;
|
||||
dataSize = sizeof(manufacturer);
|
||||
if(AudioObjectGetPropertyData(deviceId, &(AudioObjectPropertyAddress){
|
||||
kAudioObjectPropertyManufacturer,
|
||||
kAudioDevicePropertyScopeOutput,
|
||||
0
|
||||
}, 0, NULL, &dataSize, &manufacturer) == kAudioHardwareNoError)
|
||||
ffCfStrGetString(manufacturer, &device->manufacturer);
|
||||
CFRelease(name);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -14,9 +14,8 @@ static void paSinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, vo
|
||||
FFSoundDevice* device = ffListAdd(userdata);
|
||||
ffStrbufInitS(&device->identifier, i->name);
|
||||
ffStrbufInitS(&device->name, i->description);
|
||||
ffStrbufInitS(&device->manufacturer, i->driver);
|
||||
device->volume = i->mute ? 0 : (uint8_t) (i->volume.values[0] * 100 / PA_VOLUME_NORM);
|
||||
device->active = i->active_port && i->active_port->available == PA_PORT_AVAILABLE_YES;
|
||||
device->active = i->active_port && i->active_port->available != PA_PORT_AVAILABLE_NO;
|
||||
device->main = false;
|
||||
}
|
||||
|
||||
@@ -32,7 +31,6 @@ static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *u
|
||||
if(ffStrbufEqualS(&device->identifier, i->default_sink_name))
|
||||
{
|
||||
device->main = true;
|
||||
device->active = true; // Treat the default sink as always active
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +38,7 @@ static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *u
|
||||
|
||||
static const char* detectSound(const FFinstance* instance, FFlist* devices)
|
||||
{
|
||||
FF_LIBRARY_LOAD(pulse, &instance->config.libPulse, "Failed to load libpulse.so.0", "libpulse.so.0", 0)
|
||||
FF_LIBRARY_LOAD(pulse, &instance->config.libPulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_new)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_get_api)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_iterate)
|
||||
|
||||
@@ -65,7 +65,6 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U
|
||||
device->volume = 0;
|
||||
ffStrbufInit(&device->identifier);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->manufacturer);
|
||||
|
||||
ffStrbufSetWS(&device->identifier, immDeviceId);
|
||||
|
||||
@@ -74,8 +73,6 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U
|
||||
PropVariantInit(&friendlyName);
|
||||
if (SUCCEEDED(immPropStore->GetValue(PKEY_Device_FriendlyName, &friendlyName)))
|
||||
ffStrbufSetWS(&device->name, friendlyName.pwszVal);
|
||||
if (SUCCEEDED(immPropStore->GetValue(PKEY_DeviceInterface_FriendlyName, &friendlyName)))
|
||||
ffStrbufSetWS(&device->manufacturer, friendlyName.pwszVal);
|
||||
}
|
||||
|
||||
IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume;
|
||||
|
||||
@@ -385,7 +385,7 @@ const FFTerminalFontResult* ffDetectTerminalFont(const FFinstance* instance)
|
||||
const FFTerminalShellResult* terminalShell = ffDetectTerminalShell(instance);
|
||||
|
||||
if(terminalShell->terminalProcessName.length == 0)
|
||||
ffStrbufAppendS(&result.error, "Terminal font needs successfull terminal detection");
|
||||
ffStrbufAppendS(&result.error, "Terminal font needs successful terminal detection");
|
||||
|
||||
else if(!detectTerminalFontCommon(instance, terminalShell, &result))
|
||||
ffDetectTerminalFontPlatform(instance, terminalShell, &result);
|
||||
|
||||
@@ -60,64 +60,59 @@ const char* colorHexToString(DWORD hex)
|
||||
}
|
||||
}
|
||||
|
||||
bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError)
|
||||
bool ffDetectWmTheme(FF_MAYBE_UNUSED FFinstance* instance, FFstrbuf* themeOrError)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
{
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, NULL))
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY theme;
|
||||
ffStrbufInit(&theme);
|
||||
if(ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, NULL))
|
||||
{
|
||||
ffStrbufSubstrBeforeLastC(&theme, '.');
|
||||
ffStrbufSubstrAfterLastC(&theme, '\\');
|
||||
if(isalpha(theme.chars[0]))
|
||||
theme.chars[0] = (char)toupper(theme.chars[0]);
|
||||
|
||||
ffStrbufAppendF(themeOrError, "%s", theme.chars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
uint32_t rgbColor;
|
||||
uint32_t bgrColor;
|
||||
DWORD bufSize = sizeof(bgrColor);
|
||||
if(RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", L"AccentColor", RRF_RT_REG_DWORD, NULL, &bgrColor, &bufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "Accent Color - ");
|
||||
rgbColor = ((bgrColor & 0xFF) << 16) | (bgrColor & 0xFF00) | ((bgrColor >> 16) & 0xFF);
|
||||
|
||||
}
|
||||
else if(RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\DWM", L"ColorizationColor", RRF_RT_REG_DWORD, NULL, &rgbColor, &bufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
ffStrbufAppendS(themeOrError, "Colorization Color - ");
|
||||
rgbColor &= 0xFFFFFF;
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
if(themeOrError->length > 0) ffStrbufAppendS(themeOrError, " - ");
|
||||
const char* text = colorHexToString(rgbColor);
|
||||
if(text)
|
||||
ffStrbufAppendS(themeOrError, text);
|
||||
else
|
||||
ffStrbufAppendF(themeOrError, "#%06lX", (long)rgbColor);
|
||||
} while(false);
|
||||
} while (false);
|
||||
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", &hKey, NULL))
|
||||
{
|
||||
uint32_t value = 1;
|
||||
if(ffRegReadUint(hKey, L"SystemUsesLightTheme", &value, NULL))
|
||||
FF_HKEY_AUTO_DESTROY hKey = NULL;
|
||||
if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", &hKey, NULL))
|
||||
{
|
||||
if(themeOrError->length > 0) ffStrbufAppendS(themeOrError, ", ");
|
||||
ffStrbufAppendF(themeOrError, "System - %s", value ? "Light" : "Dark");
|
||||
}
|
||||
|
||||
if(ffRegReadUint(hKey, L"AppsUseLightTheme", &value, NULL))
|
||||
{
|
||||
if(themeOrError->length > 0) ffStrbufAppendS(themeOrError, ", ");
|
||||
ffStrbufAppendF(themeOrError, "Apps - %s", value ? "Light" : "Dark");
|
||||
}
|
||||
}
|
||||
else if(ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes", &hKey, NULL))
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY theme;
|
||||
ffStrbufInit(&theme);
|
||||
if(ffRegReadStrbuf(hKey, L"CurrentTheme", &theme, NULL))
|
||||
{
|
||||
ffStrbufSubstrBeforeLastC(&theme, '.');
|
||||
ffStrbufSubstrAfterLastC(&theme, '\\');
|
||||
if(isalpha(theme.chars[0]))
|
||||
theme.chars[0] = (char)toupper(theme.chars[0]);
|
||||
|
||||
if(themeOrError->length > 0) ffStrbufAppendS(themeOrError, ", ");
|
||||
ffStrbufAppendF(themeOrError, "Theme - %s", theme.chars);
|
||||
uint32_t system = 1, apps = 1;
|
||||
if (ffRegReadUint(hKey, L"SystemUsesLightTheme", &system, NULL) && ffRegReadUint(hKey, L"AppsUseLightTheme", &apps, NULL))
|
||||
{
|
||||
bool paren = themeOrError->length > 0;
|
||||
if (paren)
|
||||
ffStrbufAppendS(themeOrError, " (");
|
||||
ffStrbufAppendF(themeOrError, "System: %s, Apps: %s", system ? "Light" : "Dark", apps ? "Light" : "Dark");
|
||||
if (paren)
|
||||
ffStrbufAppendC(themeOrError, ')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user