mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Sound(linux): Implement using libpulse
Also differentiate between active and main device(s)
This commit is contained in:
+30
-26
@@ -15,10 +15,11 @@ static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8
|
||||
printf(" (%d%%)", device->volume);
|
||||
else
|
||||
fputs(" (muted)", stdout);
|
||||
if(device->main && instance->config.soundShowAll)
|
||||
puts(" (*)");
|
||||
else
|
||||
putchar('\n');
|
||||
|
||||
if(device->main && index > 0)
|
||||
fputs(" (*)", stdout);
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -31,6 +32,30 @@ static void printDevice(FFinstance* instance, const FFSoundDevice* device, uint8
|
||||
}
|
||||
}
|
||||
|
||||
static void printSound(FFinstance* instance, FFlist* devices)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY filtered;
|
||||
ffListInit(&filtered, sizeof(FFSoundDevice*));
|
||||
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, *devices)
|
||||
{
|
||||
if(!device->active && !instance->config.soundShowAll)
|
||||
continue;
|
||||
|
||||
*(FFSoundDevice**)ffListAdd(&filtered) = device;
|
||||
}
|
||||
|
||||
if(filtered.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &instance->config.sound, "No active sound devices found");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 1;
|
||||
FF_LIST_FOR_EACH(FFSoundDevice*, device, filtered)
|
||||
printDevice(instance, *device, filtered.length == 1 ? 0 : index++);
|
||||
}
|
||||
|
||||
void ffPrintSound(FFinstance* instance)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result;
|
||||
@@ -43,28 +68,7 @@ void ffPrintSound(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
if(result.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_SOUND_MODULE_NAME, 0, &instance->config.sound, "No sound devices found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(instance->config.soundShowAll)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, result)
|
||||
{
|
||||
printDevice(instance, device, result.length == 1 ? 0 : ++index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, result)
|
||||
{
|
||||
if (!device->main) continue;
|
||||
printDevice(instance, device, 0);
|
||||
}
|
||||
}
|
||||
printSound(instance, &result);
|
||||
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, result)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user