From a899f76da27c9e1212c6dabb1ab63b4db2fc2894 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Sun, 6 Aug 2023 20:00:52 +0900 Subject: [PATCH] [users] Clean up DMI model more for hostname Remove anything in parentheses, and also drop the "Apple" prefix for Apple machines. This converts: "Apple MacBook Air (13-inch, M2, 2022)" into: "MacBookAir" which is a lot more reasonable. Other vendors could be added as needed (it's inconsistent whether DT platforms prefix the model with the vendor or not). Signed-off-by: Hector Martin --- src/modules/users/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 72d765f4b..8c7316efd 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -321,7 +321,7 @@ Config::hostnameStatus() const static QString cleanupForHostname( const QString& s ) { - QRegExp dmirx( "[^a-zA-Z0-9]", Qt::CaseInsensitive ); + QRegExp dmirx( "(^Apple|\\(.*\\)|[^a-zA-Z0-9])", Qt::CaseInsensitive ); return s.toLower().replace( dmirx, " " ).remove( ' ' ); }