diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d79318a8..0c7af9af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,16 @@ Features: * Bluetooth module * Sound module +* Support colored percentage numbers output Bugfixes: * Fix a rare case that fails to detect terminal +Other: + +* Simplified wmtheme output format (Windows) + # 1.9.1 Bugfixes: diff --git a/src/common/bar.c b/src/common/bar.c index 34b14aa7a..d4a8cf0f1 100644 --- a/src/common/bar.c +++ b/src/common/bar.c @@ -47,3 +47,53 @@ void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, else ffStrbufAppendS(buffer, " ]"); } + +// if (green < yellow) +// [0, green]: print green +// (green, yellow]: print yellow +// (yellow, 100]: print red +// +// if (green > yellow) +// [green, 100]: print green +// [yellow, green): print yellow +// [0, yellow): PRINT RED +void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses) +{ + assert(green <= 100 && yellow <= 100); + + bool colored = !!(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_COLOR_BIT); + + if (parentheses) + ffStrbufAppendC(buffer, '('); + + if (colored && !instance->config.pipe) + { + if(green < yellow) + { + if (percent <= green) + ffStrbufAppendS(buffer, "\033[32m"); + else if (percent <= yellow) + ffStrbufAppendS(buffer, "\033[93m"); + else + ffStrbufAppendS(buffer, "\033[91m"); + } + else + { + if (percent >= green) + ffStrbufAppendS(buffer, "\033[32m"); + else if (percent >= yellow) + ffStrbufAppendS(buffer, "\033[93m"); + else + ffStrbufAppendS(buffer, "\033[91m"); + } + } + ffStrbufAppendF(buffer, "%u%%", (unsigned) percent); + + if (colored && !instance->config.pipe) + { + ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET); + } + + if (parentheses) + ffStrbufAppendC(buffer, ')'); +} diff --git a/src/common/bar.h b/src/common/bar.h index 575adc01d..f28cbe777 100644 --- a/src/common/bar.h +++ b/src/common/bar.h @@ -7,11 +7,13 @@ enum { - FF_PERCENTAGE_TYPE_NUM_BIT = 1, - FF_PERCENTAGE_TYPE_BAR_BIT = 2, - FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT = 4, + FF_PERCENTAGE_TYPE_NUM_BIT = 1 << 0, + FF_PERCENTAGE_TYPE_BAR_BIT = 1 << 1, + FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT = 1 << 2, + FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3, }; void ffAppendPercentBar(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, uint8_t red); +void ffAppendPercentNum(FFinstance* instance, FFstrbuf* buffer, uint8_t percent, uint8_t green, uint8_t yellow, bool parentheses); #endif diff --git a/src/common/init.c b/src/common/init.c index 7eabe0948..0125c4b75 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -164,7 +164,7 @@ static void defaultConfig(FFinstance* instance) instance->config.bluetoothShowDisconnected = false; - instance->config.soundShowAll = false; + instance->config.soundType = FF_SOUND_TYPE_MAIN; ffStrbufInitA(&instance->config.batteryDir, 0); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 1b9ac9635..e4fcef289 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -262,7 +262,7 @@ # Percentage output type option # Applies to all modules that prints percentage values. Currently memory, swap, disk, battery and CPU usage are supported. # Only works with default format ( without --module-format option ). -# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar; 6: prints bar and hide other texts +# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar; 6: prints bar and hide other texts; 9: prints colored number #--percent-type 1 # Key options: diff --git a/src/data/help.txt b/src/data/help.txt index c4fd1acd3..3eeaf662b 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -113,7 +113,7 @@ Module specific options: --disk-show-subvolumes : Set if subvolumes should be printed. Default is false --disk-show-unknown : Set if unknown (unable to detect sizes) volumes should be printed. Default is false --bluetooth-show-disconnected: : Set if disconnected bluetooth devices should be printed. Default is false - --sound-show-all: : Set if all sound devices should be printed. Default is false + --sound-type: : Set what type of sound devices should be printed. Should be either main, active or all. Default is main --battery-dir : The directory where the battery folders are. Standard: /sys/class/power_supply/ --cpu-temp : Detect and display CPU temperature if supported. Default is false --gpu-temp : Detect and display GPU temperature if supported. Default is false @@ -130,7 +130,7 @@ Module specific options: --weather-output-format: The output weather format to be used. It must be URI encoded. --player-name: The name of the player to use --gl : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto - --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only. Default is 1 + --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only, 9 for colored number. Default is 1 --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others --command-key : Set the module key to display, can be specified mulitple times --command-text : Set the command text to be executed, can be specified mulitple times diff --git a/src/detection/sound/sound.h b/src/detection/sound/sound.h index 76c17627c..9a89ab694 100644 --- a/src/detection/sound/sound.h +++ b/src/detection/sound/sound.h @@ -9,7 +9,6 @@ typedef struct FFSoundDevice { FFstrbuf identifier; FFstrbuf name; - FFstrbuf manufacturer; uint8_t volume; // 0-100% bool main; bool active; diff --git a/src/detection/sound/sound_apple.c b/src/detection/sound/sound_apple.c index 305e991bf..a9ec04703 100644 --- a/src/detection/sound/sound_apple.c +++ b/src/detection/sound/sound_apple.c @@ -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; diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index 0aa10b753..a752a6b5f 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -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) diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index 2b9e95be1..5221c8368 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -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; diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index 1d3503da2..d4c1359ad 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -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); diff --git a/src/detection/wmtheme/wmtheme_windows.c b/src/detection/wmtheme/wmtheme_windows.c index cf070be69..0522b933b 100644 --- a/src/detection/wmtheme/wmtheme_windows.c +++ b/src/detection/wmtheme/wmtheme_windows.c @@ -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, ')'); + } } } diff --git a/src/fastfetch.c b/src/fastfetch.c index 012f5da68..ded937466 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -460,7 +460,6 @@ static inline void printCommandHelp(const char* command) "Main", "Name", "Volume", - "Manufacturer", "Identifier" ); } @@ -928,8 +927,6 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0) instance->config.recache = optionParseBoolean(value); - else if(strcasecmp(key, "--nocache") == 0) - fputs("`--nocache` are obsoleted. Caching functions other than image caching are removed.\n\n", stderr); else if(strcasecmp(key, "--load-config") == 0) optionParseConfigFile(instance, data, key, value); else if(strcasecmp(key, "--gen-config") == 0) @@ -1263,8 +1260,15 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.diskShowUnknown = optionParseBoolean(value); else if(strcasecmp(key, "--bluetooth-show-disconnected") == 0) instance->config.bluetoothShowDisconnected = optionParseBoolean(value); - else if(strcasecmp(key, "--sound-show-all") == 0) - instance->config.soundShowAll = optionParseBoolean(value); + else if(strcasecmp(key, "--sound-type") == 0) + { + optionParseEnum(key, value, &instance->config.soundType, + "main", FF_SOUND_TYPE_MAIN, + "active", FF_SOUND_TYPE_ACTIVE, + "all", FF_SOUND_TYPE_ALL, + NULL + ); + } else if(strcasecmp(key, "--battery-dir") == 0) optionParseString(key, value, &instance->config.batteryDir); else if(strcasecmp(key, "--separator-string") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index e1d5be954..0d57902c6 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -34,6 +34,13 @@ typedef enum FFLogoType FF_LOGO_TYPE_NONE, //--logo none } FFLogoType; +typedef enum FFSoundType +{ + FF_SOUND_TYPE_MAIN, + FF_SOUND_TYPE_ACTIVE, + FF_SOUND_TYPE_ALL, +} FFSoundType; + typedef enum FFBinaryPrefixType { FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard) @@ -203,7 +210,7 @@ typedef struct FFconfig FFstrbuf weatherOutputFormat; uint32_t weatherTimeout; - bool soundShowAll; + FFSoundType soundType; FFstrbuf osFile; diff --git a/src/modules/battery.c b/src/modules/battery.c index 79cdf4c79..6bafb0ee7 100644 --- a/src/modules/battery.c +++ b/src/modules/battery.c @@ -36,7 +36,8 @@ static void printBattery(FFinstance* instance, BatteryResult* result, uint8_t in { if(str.length > 0) ffStrbufAppendC(&str, ' '); - ffStrbufAppendF(&str, str.length > 0 ? "(%u%%)" : "%u%%", (unsigned) result->capacity); + + ffAppendPercentNum(instance, &str, (uint8_t) result->capacity, 51, 21, str.length > 0); } } diff --git a/src/modules/cpuUsage.c b/src/modules/cpuUsage.c index 3e4165b90..f46de6259 100644 --- a/src/modules/cpuUsage.c +++ b/src/modules/cpuUsage.c @@ -29,7 +29,7 @@ void ffPrintCPUUsage(FFinstance* instance) { if(str.length > 0) ffStrbufAppendC(&str, ' '); - ffStrbufAppendF(&str, "%.2lf%%", percentage); + ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); } ffStrbufPutTo(&str, stdout); ffStrbufDestroy(&str); diff --git a/src/modules/disk.c b/src/modules/disk.c index c1e074812..d2311f11f 100644 --- a/src/modules/disk.c +++ b/src/modules/disk.c @@ -53,7 +53,8 @@ static void printDisk(FFinstance* instance, const FFDisk* disk) if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) { - ffStrbufAppendF(&str, str.length > 0 ? "(%u%%) " : "%u%% ", bytesPercentage); + ffAppendPercentNum(instance, &str, (uint8_t) bytesPercentage, 50, 80, str.length > 0); + ffStrbufAppendC(&str, ' '); } } else diff --git a/src/modules/memory.c b/src/modules/memory.c index fbb893f02..05d7c33cf 100644 --- a/src/modules/memory.c +++ b/src/modules/memory.c @@ -56,7 +56,7 @@ static void printMemory(FFinstance* instance, const char* name, const FFModuleAr ffStrbufAppendF(&str, "%s / %s ", usedPretty.chars, totalPretty.chars); if(instance->config.percentType & FF_PERCENTAGE_TYPE_NUM_BIT) - ffStrbufAppendF(&str, str.length > 0 ? "(%u%%)" : "%u%%", percentage); + ffAppendPercentNum(instance, &str, (uint8_t) percentage, 50, 80, str.length > 0); ffStrbufTrimRight(&str, ' '); ffStrbufPutTo(&str, stdout); diff --git a/src/modules/sound.c b/src/modules/sound.c index d9ee35d37..4ef58cdc2 100644 --- a/src/modules/sound.c +++ b/src/modules/sound.c @@ -2,7 +2,7 @@ #include "detection/sound/sound.h" #define FF_SOUND_MODULE_NAME "Sound" -#define FF_SOUND_NUM_FORMAT_ARGS 5 +#define FF_SOUND_NUM_FORMAT_ARGS 4 static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8_t index) { @@ -27,7 +27,6 @@ static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8 {FF_FORMAT_ARG_TYPE_BOOL, &device->main}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_UINT8, &device->volume}, - {FF_FORMAT_ARG_TYPE_STRBUF, &device->manufacturer}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier} }); } @@ -40,8 +39,12 @@ static void printSound(FFinstance* instance, FFlist* devices) FF_LIST_FOR_EACH(FFSoundDevice, device, *devices) { - if(!device->active && !instance->config.soundShowAll) - continue; + switch (instance->config.soundType) + { + case FF_SOUND_TYPE_MAIN: if (!device->main) continue; break; + case FF_SOUND_TYPE_ACTIVE: if (!device->active) continue; break; + case FF_SOUND_TYPE_ALL: break; + } *(FFSoundDevice**)ffListAdd(&filtered) = device; } @@ -75,6 +78,5 @@ void ffPrintSound(FFinstance* instance) { ffStrbufDestroy(&device->identifier); ffStrbufDestroy(&device->name); - ffStrbufDestroy(&device->manufacturer); } }