Skip to content

Commit

Permalink
[Feat-macOS] Improve whisky discoverability on mac (#3747)
Browse files Browse the repository at this point in the history
* chore: improve whisky discoverability on mac

#3728 (comment)

* style: update path for whisky wine
  • Loading branch information
WangEdward authored Nov 18, 2024
1 parent acbb1a7 commit 2cc9cae
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions src/backend/utils/compatibility_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,29 +444,35 @@ export async function getWhisky(): Promise<Set<WineInstallation>> {
return whisky
}

await execAsync(
'mdfind kMDItemCFBundleIdentifier = "com.isaacmarovitz.Whisky"'
).then(async ({ stdout }) => {
stdout.split('\n').forEach((whiskyMacPath) => {
const infoFilePath = join(whiskyMacPath, 'Contents/Info.plist')
if (whiskyMacPath && existsSync(infoFilePath)) {
const info = plistParse(
readFileSync(infoFilePath, 'utf-8')
) as PlistObject
const version = info['CFBundleShortVersionString'] || ''
const whiskyWineBin = `${userHome}/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/Wine/bin/wine64`

whisky.add({
bin: whiskyWineBin,
name: `Whisky - ${version}`,
type: `toolkit`,
lib: `${dirname(whiskyWineBin)}/../lib`,
lib32: `${dirname(whiskyWineBin)}/../lib`,
...getWineExecs(whiskyWineBin)
})
}
})
})
const whiskyWinePath = join(
userHome,
'Library/Application Support/com.isaacmarovitz.Whisky/Libraries'
)
const whiskyVersionPlist = join(whiskyWinePath, 'WhiskyWineVersion.plist')
const whiskyWineBin = join(whiskyWinePath, 'Wine/bin/wine64')

if (existsSync(whiskyVersionPlist) && existsSync(whiskyWineBin)) {
try {
const info = plistParse(
readFileSync(whiskyVersionPlist, 'utf-8')
) as PlistObject
const version = info['version']
const versionString = `${version['major']}.${version['minor']}.${version['patch']}-${version['build']}`
whisky.add({
bin: whiskyWineBin,
name: `Whisky - ${versionString}`,
type: 'toolkit',
lib: join(whiskyWinePath, 'Wine/lib'),
lib32: join(whiskyWinePath, 'Wine/lib'),
...getWineExecs(whiskyWineBin)
})
} catch (error) {
logError(
`Error getting wine version for ${whiskyWineBin}`,
LogPrefix.GlobalConfig
)
}
}

return whisky
}
Expand Down

0 comments on commit 2cc9cae

Please sign in to comment.