Skip to content

Commit 2f9f16b

Browse files
authored
Merge pull request #19 from TeamDev-IP/fix-new-bundles-icon
Restore icon branding in the recent macOS bundles
2 parents 917eb5f + 24ea3f2 commit 2f9f16b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

pkg/mac/branding.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ func (branding *MacBranding) ApplyToBundle(params *common.BrandingParams, appBun
7171
if err := configureBundleIcon(appBundle, iconPath); err != nil {
7272
return err
7373
}
74+
plistFile, err := appBundle.PlistFilePath().AsFile()
75+
if err != nil {
76+
return err
77+
}
78+
if _, err := getPlistProperty(plistFile, bundleIconNameAssetProperty); err == nil {
79+
// Delete the property only in the newer Chromium bundles where it's present.
80+
if err := deletePlistProperty(plistFile, bundleIconNameAssetProperty); err != nil {
81+
return err
82+
}
83+
}
7484
}
7585

7686
return nil
@@ -131,6 +141,8 @@ func (branding *MacBranding) ExecutableName(params *common.BrandingParams) strin
131141
return "Chromium"
132142
}
133143

144+
const bundleIconNameAssetProperty = "CFBundleIconName"
145+
134146
var bundleIdProperties = []string{
135147
"CFBundleIdentifier",
136148
}
@@ -207,10 +219,19 @@ func overrideBundleProperties(bundle ChromiumAppBundle, properties []string, val
207219
return nil
208220
}
209221

222+
func getPlistProperty(plist base.File, key string) (string, error) {
223+
return base.ExecCommandAndGetOutput("defaults", []string{"read", plist.AbsPath().String(), key})
224+
}
225+
210226
func setPlistProperty(plist base.File, key, value string) error {
211227
return base.ExecCommand("defaults", []string{"write", plist.AbsPath().String(), key, "\"" + value + "\""})
212228
}
213229

230+
func deletePlistProperty(plist base.File, key string) error {
231+
base.ExecCommand("defaults", []string{"delete", plist.AbsPath().String(), key})
232+
return nil
233+
}
234+
214235
func overrideBundleName(bundle ChromiumAppBundle, name *string) error {
215236
if name == nil {
216237
return nil

0 commit comments

Comments
 (0)