Hey @martin,
We've been doing this sort of thing for a while now:
Text Expansion: System & Hardware Info
I have text expansions for simple system info, 3 levels of more advanced system info, and various app's version info.
Simple macOS and Keyboard Maestro info can be obtained very swiftly thus:
tell application "Keyboard Maestro Engine" to ¬
set kmVersion to "Keyboard Maestro " & (its version)
tell (system info) to set macosVersion to "macOS " & (its system version)
set outputStr to macosVersion & " with " & kmVersion
I really like your method of using the macOS software license to get the marketing name of the OS and might just incorporate that into my own scripts.
Here's yet another way:
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/08/16 11:09
# dMod: 2021/08/16 16:26
# Appl: Keyboard Maestro Engine
# Task: Create macOS & Keyboard Maestro Version String.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Keyboard_Maestro_Engine, @Version_String
# Vers: 1.0.1
--------------------------------------------------------
use AppleScript version "2.4" --» Yosemite or later
use framework "Foundation"
use scripting additions
--------------------------------------------------------
property macOSXVersionTable : text 2 thru -2 of "
macOS 10.0 Cheetah
macOS 10.1 Puma
macOS 10.2 Jaguar
macOS 10.3 Panther
macOS 10.4 Tiger
macOS 10.5 Leopard
macOS 10.6 Snow Leopard
macOS 10.7 Lion
macOS 10.8 Mountain Lion
macOS 10.9 Mavericks
macOS 10.10 Yosemite
macOS 10.11 El Capitan
macOS 10.12 Sierra
macOS 10.13 High Sierra
macOS 10.14 Mojave
macOS 10.15 Catalina
macOS 11 Big Sur
macOS 12 Monterey
"
tell application "Keyboard Maestro Engine" to set kmVersion to "Keyboard Maestro " & (its version)
tell (system info) to set macosVersion to "macOS " & (its system version)
set findOSNameStr to my extractUsingPattern:"^(macOS \\d+\\.\\d+)" fromString:macosVersion resultTemplate:"$0"
set findOSNameStr to "(?m-s)^" & (findOSNameStr as text) & "[\\d.]*\\t+(\\w[\\w\\ ]+)$"
set macOSNameStr to item 1 of (my extractUsingPattern:findOSNameStr fromString:macOSXVersionTable resultTemplate:"$1")
set macosVersion to macosVersion & space & "(" & macOSNameStr & ")"
set outputStr to macosVersion & " with " & kmVersion
--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on extractUsingPattern:thePattern fromString:theString resultTemplate:templateStr
set theString to current application's NSString's stringWithString:theString
set theRegEx to current application's NSRegularExpression's regularExpressionWithPattern:thePattern options:0 |error|:(missing value)
set theFinds to theRegEx's matchesInString:theString options:0 range:{0, theString's |length|()}
set theResult to current application's NSMutableArray's array()
repeat with aFind in theFinds
set foundString to (theRegEx's replacementStringForResult:aFind inString:theString |offset|:0 template:templateStr)
(theResult's addObject:foundString)
end repeat
return theResult as list
end extractUsingPattern:fromString:resultTemplate:
--------------------------------------------------------
-Chris