mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Packages (Linux): add install-release package count support (#2342)
* feat: add install-release package count support * Apply suggestion from @codacy-production[bot] Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com> * Fix formatting of ffParsePropFileValues call --------- Co-authored-by: Carter Li <CarterLi@users.noreply.github.com> Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,7 @@ typedef struct FFPackagesResult {
|
||||
uint32_t guixUser;
|
||||
uint32_t hpkgSystem;
|
||||
uint32_t hpkgUser;
|
||||
uint32_t installrelease;
|
||||
uint32_t kiss;
|
||||
uint32_t linglong;
|
||||
uint32_t lpkg;
|
||||
|
||||
@@ -676,4 +676,19 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
|
||||
result->appimage += getNumElementsBySuffix(&baseDir, "/AppImages", ".appimage");
|
||||
result->appimage += getNumElementsBySuffix(&baseDir, "/Applications", ".appimage");
|
||||
}
|
||||
|
||||
if (!(options->disabled & FF_PACKAGES_FLAG_INSTALLRELEASE_BIT)) {
|
||||
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy(&baseDir);
|
||||
ffStrbufAppendS(&path, ".config/install_release/state.json");
|
||||
if (ffPathExists(path.chars, FF_PATHTYPE_FILE)) {
|
||||
yyjson_doc* doc = yyjson_read_file(path.chars, YYJSON_READ_NOFLAG, NULL, NULL);
|
||||
if (doc != NULL) {
|
||||
yyjson_val* root = yyjson_doc_get_root(doc);
|
||||
if (yyjson_is_obj(root)) {
|
||||
result->installrelease = (uint32_t) yyjson_obj_size(root);
|
||||
}
|
||||
yyjson_doc_free(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef enum FF_A_PACKED FFPackagesFlags {
|
||||
FF_PACKAGES_FLAG_APPIMAGE_BIT = UINT64_C(1) << 33U,
|
||||
FF_PACKAGES_FLAG_CARDS_BIT = UINT64_C(1) << 34U,
|
||||
FF_PACKAGES_FLAG_PORG_BIT = UINT64_C(1) << 35U,
|
||||
FF_PACKAGES_FLAG_INSTALLRELEASE_BIT = UINT64_C(1) << 36U,
|
||||
FF_PACKAGES_FLAG_FORCE_UNSIGNED = UINT64_MAX,
|
||||
} FFPackagesFlags;
|
||||
static_assert(sizeof(FFPackagesFlags) == sizeof(uint64_t), "");
|
||||
|
||||
@@ -89,6 +89,7 @@ bool ffPrintPackages(FFPackagesOptions* options) {
|
||||
} else {
|
||||
FF_PRINT_PACKAGE_NAME(hpkgSystem, "hpkg")
|
||||
}
|
||||
FF_PRINT_PACKAGE_NAME(installrelease, "install-release")
|
||||
FF_PRINT_PACKAGE(kiss)
|
||||
FF_PRINT_PACKAGE(linglong)
|
||||
FF_PRINT_PACKAGE(lpkg)
|
||||
@@ -163,6 +164,7 @@ bool ffPrintPackages(FFPackagesOptions* options) {
|
||||
FF_ARG(counts.guixUser, "guix-user"),
|
||||
FF_ARG(counts.hpkgSystem, "hpkg-system"),
|
||||
FF_ARG(counts.hpkgUser, "hpkg-user"),
|
||||
FF_ARG(counts.installrelease, "install-release"),
|
||||
FF_ARG(counts.kiss, "kiss"),
|
||||
FF_ARG(counts.linglong, "linglong"),
|
||||
FF_ARG(counts.lpkg, "lpkg"),
|
||||
@@ -282,6 +284,11 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module) {
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(HPKG)
|
||||
break;
|
||||
case 'I':
|
||||
if (false)
|
||||
;
|
||||
FF_TEST_PACKAGE_NAME(INSTALLRELEASE)
|
||||
break;
|
||||
case 'K':
|
||||
if (false)
|
||||
;
|
||||
@@ -454,6 +461,7 @@ bool ffGeneratePackagesJsonResult(FFPackagesOptions* options, yyjson_mut_doc* do
|
||||
FF_APPEND_PACKAGE_COUNT(guixUser)
|
||||
FF_APPEND_PACKAGE_COUNT(hpkgSystem)
|
||||
FF_APPEND_PACKAGE_COUNT(hpkgUser)
|
||||
FF_APPEND_PACKAGE_COUNT(installrelease)
|
||||
FF_APPEND_PACKAGE_COUNT(kiss)
|
||||
FF_APPEND_PACKAGE_COUNT(linglong)
|
||||
FF_APPEND_PACKAGE_COUNT(lpkg)
|
||||
@@ -529,6 +537,7 @@ FFModuleBaseInfo ffPackagesModuleInfo = {
|
||||
{ "Number of guix-user packages", "guix-user" },
|
||||
{ "Number of hpkg-system packages", "hpkg-system" },
|
||||
{ "Number of hpkg-user packages", "hpkg-user" },
|
||||
{ "Number of install-release packages", "install-release" },
|
||||
{ "Number of kiss packages", "kiss" },
|
||||
{ "Number of linglong packages", "linglong" },
|
||||
{ "Number of lpkg packages", "lpkg" },
|
||||
|
||||
Reference in New Issue
Block a user