mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 16:26:39 +01:00
Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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, ')');
|
||||
}
|
||||
|
||||
+5
-3
@@ -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
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
+2
-2
@@ -113,7 +113,7 @@ Module specific options:
|
||||
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
|
||||
--disk-show-unknown <?value>: Set if unknown (unable to detect sizes) volumes should be printed. Default is false
|
||||
--bluetooth-show-disconnected: <?value>: Set if disconnected bluetooth devices should be printed. Default is false
|
||||
--sound-show-all: <?value>: Set if all sound devices should be printed. Default is false
|
||||
--sound-type: <value>: Set what type of sound devices should be printed. Should be either main, active or all. Default is main
|
||||
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
|
||||
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
|
||||
--gpu-temp <?value>: 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 <value>: Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
|
||||
--percent-type <value>: Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only. Default is 1
|
||||
--percent-type <value>: 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 <str>: Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others
|
||||
--command-key <str>: Set the module key to display, can be specified mulitple times
|
||||
--command-text <str>: Set the command text to be executed, can be specified mulitple times
|
||||
|
||||
@@ -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, ')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-5
@@ -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)
|
||||
|
||||
+8
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
+7
-5
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user