mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
@@ -8,6 +8,7 @@ typedef struct FFSoundDevice
|
||||
{
|
||||
FFstrbuf identifier;
|
||||
FFstrbuf name;
|
||||
FFstrbuf platformApi;
|
||||
uint8_t volume; // 0-100%
|
||||
bool main;
|
||||
bool active;
|
||||
|
||||
@@ -73,6 +73,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
device->volume = FF_SOUND_VOLUME_UNKNOWN;
|
||||
ffStrbufInitF(&device->identifier, "%u", (unsigned) deviceId);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInitStatic(&device->platformApi, "Core Audio");
|
||||
ffCfStrGetString(name, &device->name);
|
||||
|
||||
uint32_t muted;
|
||||
|
||||
@@ -39,7 +39,8 @@ const char* ffDetectSound(FFlist* devices)
|
||||
FFSoundDevice* device = ffListAdd(devices);
|
||||
ffStrbufInitS(&device->identifier, path);
|
||||
ffStrbufInitF(&device->name, "%s %s", ci.longname, ci.hw_info);
|
||||
ffStrbufTrimRightSpace(&device->name);
|
||||
ffStrbufTrimRightSpace(&device->name);
|
||||
ffStrbufInitStatic(&device->platformApi, "OSS");
|
||||
device->volume = mutemask & SOUND_MASK_VOLUME
|
||||
? 0
|
||||
: ((uint8_t) volume /*left*/ + (uint8_t) (volume >> 8) /*right*/) / 2;
|
||||
|
||||
@@ -13,6 +13,7 @@ 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->platformApi, "PulseAudio");
|
||||
ffStrbufTrimRightSpace(&device->identifier);
|
||||
ffStrbufInitS(&device->name, i->description);
|
||||
ffStrbufTrimRightSpace(&device->name);
|
||||
@@ -22,20 +23,24 @@ static void paSinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, vo
|
||||
device->main = false;
|
||||
}
|
||||
|
||||
static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *userdata)
|
||||
static void paServerInfoCallback(FF_MAYBE_UNUSED pa_context *c, const pa_server_info *i, void *userdata)
|
||||
{
|
||||
FF_UNUSED(c);
|
||||
if(!i) return;
|
||||
|
||||
if(!i)
|
||||
return;
|
||||
FF_STRBUF_AUTO_DESTROY api = ffStrbufCreate();
|
||||
const char* realServer = strstr(i->server_name, "(on ");
|
||||
if (realServer)
|
||||
{
|
||||
ffStrbufSetS(&api, realServer + strlen("(on "));
|
||||
ffStrbufTrimRight(&api, ')');
|
||||
}
|
||||
else
|
||||
ffStrbufSetF(&api, "%s %s", i->server_name, i->server_version);
|
||||
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, *(FFlist*)userdata)
|
||||
{
|
||||
if(ffStrbufEqualS(&device->identifier, i->default_sink_name))
|
||||
{
|
||||
device->main = true;
|
||||
break;
|
||||
}
|
||||
device->main = ffStrbufEqualS(&device->identifier, i->default_sink_name);
|
||||
ffStrbufSet(&device->platformApi, &api);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
device->volume = FF_SOUND_VOLUME_UNKNOWN;
|
||||
ffStrbufInitWS(&device->identifier, immDeviceId);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInitStatic(&device->platformApi, "Core Audio APIs");
|
||||
|
||||
{
|
||||
PROPVARIANT __attribute__((__cleanup__(PropVariantClear))) friendlyName;
|
||||
|
||||
@@ -58,6 +58,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
|
||||
FF_FORMAT_ARG(percentageNum, "volume-percentage"),
|
||||
FF_FORMAT_ARG(device->identifier, "identifier"),
|
||||
FF_FORMAT_ARG(percentageBar, "volume-percentage-bar"),
|
||||
FF_FORMAT_ARG(device->platformApi, "platform-api"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -218,6 +219,7 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m
|
||||
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "identifier", &item->identifier);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "platformApi", &item->platformApi);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFSoundDevice, device, result)
|
||||
@@ -241,6 +243,7 @@ static FFModuleBaseInfo ffModuleInfo = {
|
||||
{"Volume (in percentage num)", "volume-percentage"},
|
||||
{"Identifier", "identifier"},
|
||||
{"Volume (in percentage bar)", "volume-percentage-bar"},
|
||||
{"Platform API used", "platform-api"},
|
||||
}))
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user