mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
OS (Linux): enhances Deepin version detection using /etc/os-version (#2300)
* feat(os): enhance Deepin detection with os-version data Add a Deepin-specific enhancement in Linux OS detection that reads `/etc/os-version` for `MinorVersion` and `EditionName`. When available, it now: - sets `versionID` to `MinorVersion` - updates `prettyName` to include version and optional edition This improves Deepin version accuracy and provides a clearer OS name than relying solely on generic `os-release` fields.feat(os): enhance Deepin detection with os-version data Add a Deepin-specific enhancement in Linux OS detection that reads `/etc/os-version` for `MinorVersion` and `EditionName`. When available, it now: - sets `versionID` to `MinorVersion` - updates `prettyName` to include version and optional edition This improves Deepin version accuracy and provides a clearer OS name than relying solely on generic `os-release` fields. * fix(os): use distro name when formatting Deepin prettyName Update Deepin enhancement formatting to build `prettyName` from `result->name` instead of hardcoding "Deepin". This keeps output consistent with the detected distro name while still appending version and edition details.fix(os): use distro name when formatting Deepin prettyName Update Deepin enhancement formatting to build `prettyName` from `result->name` instead of hardcoding "Deepin". This keeps output consistent with the detected distro name while still appending version and edition details. * fix(os/linux): guard Deepin minor version override Only apply Deepin’s `minor` value to `versionID` when an edition is present and `prettyName` does not already include parenthesized details. This avoids incorrectly overriding parsed version info in enhanced names.fix(os/linux): guard Deepin minor version override Only apply Deepin’s `minor` value to `versionID` when an edition is present and `prettyName` does not already include parenthesized details. This avoids incorrectly overriding parsed version info in enhanced names. Co-authored-by: Copilot <copilot@github.com> * Refactor Deepin enhancement detection logic * Refactor detectDeepinEnhancement function --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Carter Li <CarterLi@users.noreply.github.com>
This commit is contained in:
@@ -95,8 +95,7 @@ FF_A_UNUSED static bool getUbuntuFlavour(FFOSResult* result) {
|
||||
}
|
||||
|
||||
// xdgConfigDirs contains plasma only
|
||||
if (ffPathExists("/var/lib/dpkg/info/ubuntustudio-desktop.list", FF_PATHTYPE_FILE))
|
||||
{
|
||||
if (ffPathExists("/var/lib/dpkg/info/ubuntustudio-desktop.list", FF_PATHTYPE_FILE)) {
|
||||
ffStrbufSetStatic(&result->name, "Ubuntu Studio");
|
||||
ffStrbufSetStatic(&result->id, "ubuntu-studio");
|
||||
ffStrbufSetStatic(&result->idLike, "ubuntu");
|
||||
@@ -306,6 +305,34 @@ static bool detectBedrock(FFOSResult* os) {
|
||||
return parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock/strata/bedrock/etc/os-release", os);
|
||||
}
|
||||
|
||||
static void detectDeepinEnhancement(FFOSResult* result) {
|
||||
if (ffStrbufContainC(&result->prettyName, '(')) {
|
||||
return;
|
||||
}
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate();
|
||||
FF_STRBUF_AUTO_DESTROY edition = ffStrbufCreate();
|
||||
|
||||
if (!ffParsePropFileValues(
|
||||
FASTFETCH_TARGET_DIR_ETC "/os-version",
|
||||
2,
|
||||
(FFpropquery[]) {
|
||||
{ "MinorVersion=", &minor },
|
||||
{ "EditionName=", &edition },
|
||||
}) ||
|
||||
minor.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ffStrbufSet(&result->versionID, &minor);
|
||||
|
||||
if (edition.length > 0) {
|
||||
ffStrbufSetF(&result->prettyName, "%s %s (%s)", result->name.chars, minor.chars, edition.chars);
|
||||
} else {
|
||||
ffStrbufSetF(&result->prettyName, "%s %s", result->name.chars, minor.chars);
|
||||
}
|
||||
}
|
||||
|
||||
static void detectOS(FFOSResult* os) {
|
||||
#ifdef FF_CUSTOM_OS_RELEASE_PATH
|
||||
parseOsRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os);
|
||||
@@ -322,6 +349,7 @@ static void detectOS(FFOSResult* os) {
|
||||
// Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff
|
||||
|
||||
parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os);
|
||||
|
||||
if (os->id.length == 0 || os->version.length == 0 || os->prettyName.length == 0 || os->codename.length == 0) {
|
||||
parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os);
|
||||
}
|
||||
@@ -360,6 +388,8 @@ void ffDetectOSImpl(FFOSResult* os) {
|
||||
ffStrbufSetS(&os->id, "lmde");
|
||||
ffStrbufSetS(&os->idLike, "linuxmint");
|
||||
}
|
||||
} else if (ffStrbufEqualS(&os->id, "deepin")) {
|
||||
detectDeepinEnhancement(os);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user