aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-17 19:09:41 +0200
committerDanilo M. <danix@danix.xyz>2026-09-17 19:09:41 +0200
commit63d8dc8c4ec7a641efb614265478edfa7b7f0906 (patch)
treefe4c29a036db0a3512561abcbc539887188296c0
parent9b18e17eee451a9a900f792add2c4c2eeb2af533 (diff)
downloadconky-theme-udt-63d8dc8c4ec7a641efb614265478edfa7b7f0906.tar.gz
conky-theme-udt-63d8dc8c4ec7a641efb614265478edfa7b7f0906.zip
fix: strip the clock from every Intel form, not just the fixture's
The pattern required a literal CPU token immediately before the @, which the one Intel fixture happens to carry. A Xeon reads 'E5-2680 v4 @ 2.40GHz' and a Tiger Lake 'i7-1165G7 @ 2.80GHz', so both kept their clock on the card. A generation prefix hid the vendor word from its anchor for the same reason: '11th Gen Intel Core i7-1165G7' kept 'Intel'. Three more forms added as tests. The Intel fixture was meant to keep the stripping a rule, and one fixture was not enough to do it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
-rw-r--r--lib/data.lua13
-rw-r--r--test/test_data.lua14
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/data.lua b/lib/data.lua
index 1afc9c9..d5203a8 100644
--- a/lib/data.lua
+++ b/lib/data.lua
@@ -312,9 +312,20 @@ function M.cpu_model(cpuinfo)
local s = cpuinfo:match('model name%s*:%s*([^\n]+)')
if not s then return nil end
s = s:gsub('%(R%)', ''):gsub('%(TM%)', ''):gsub('%(tm%)', '')
+ -- The vendor word can sit behind a generation prefix ('11th Gen Intel Core
+ -- i7-1165G7'), so the prefix goes first and the vendor anchor is applied
+ -- after it rather than only at the very start.
+ s = s:gsub('^%s*%d+th Gen%s+', '')
s = s:gsub('^%s*AMD%s+', ''):gsub('^%s*Intel%s+', '')
s = s:gsub('%s+%d+%-Core Processor.*$', '')
- s = s:gsub('%s+CPU%s*@.*$', '')
+ -- The clock tail, with or without a literal 'CPU' before the '@'. A Xeon
+ -- reads 'E5-2680 v4 @ 2.40GHz' and a Tiger Lake 'i7-1165G7 @ 2.80GHz', so
+ -- requiring the CPU token leaves the clock on the card for everything but
+ -- the one form the fixture happens to carry.
+ -- The clock tail goes first, then the bare 'CPU' token wherever it sits: a
+ -- Xeon reads 'Xeon CPU E5-2680 v4 @ 2.40GHz', so the token is mid-string,
+ -- not trailing.
+ s = s:gsub('%s*@.*$', ''):gsub('%s+CPU%f[%A]', '')
s = s:gsub('%s+Processor%s*$', '')
s = s:gsub('%s+', ' '):gsub('^%s+', ''):gsub('%s+$', '')
if s == '' then return nil end
diff --git a/test/test_data.lua b/test/test_data.lua
index 3e741e6..4def123 100644
--- a/test/test_data.lua
+++ b/test/test_data.lua
@@ -274,4 +274,18 @@ assert(data.board_name(nil, nil) == nil, 'neither gives nil')
assert(data.board_name('To Be Filled By O.E.M.\n', 'To Be Filled By O.E.M.\n') == nil,
'placeholder DMI gives nil')
+-- Three Intel forms the single fixture does not cover. The first fixture
+-- happens to carry a literal 'CPU' before the clock, so a pattern requiring
+-- that token passes the fixture and still leaves '@ 2.40GHz' on the card for
+-- every other Intel part. These exist so the stripping stays a rule.
+assert(data.cpu_model('model name\t: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz\n')
+ == 'Xeon E5-2680 v4',
+ 'xeon, got ' .. tostring(data.cpu_model('model name\t: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz\n')))
+assert(data.cpu_model('model name\t: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz\n')
+ == 'Core i7-1165G7',
+ 'tiger lake, got ' .. tostring(data.cpu_model('model name\t: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz\n')))
+assert(data.cpu_model('model name\t: AMD Ryzen 9 7950X3D 16-Core Processor\n')
+ == 'Ryzen 9 7950X3D',
+ 'x3d, got ' .. tostring(data.cpu_model('model name\t: AMD Ryzen 9 7950X3D 16-Core Processor\n')))
+
print('test_data: all assertions passed')