Skip to content

Commit

Permalink
✨ Use refreshCurrentAppIcon() inside setAppIcon()
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Sep 17, 2023
1 parent 8cb8f1c commit 6a102ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Loop/LoopApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// Check & ask for accessibility access
PermissionsManager.Accessibility.requestAccess()

iconManager.restoreCurrentAppIcon()
iconManager.refreshCurrentAppIcon()

if Defaults[.windowSnapping] {
SnappingManager.shared.addObservers()
Expand Down
8 changes: 3 additions & 5 deletions Loop/Managers/IconManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,18 @@ class IconManager {
}

func setAppIcon(to icon: Icon) {
NSWorkspace.shared.setIcon(NSImage(named: icon.name), forFile: Bundle.main.bundlePath, options: [])
NSApp.applicationIconImage = NSImage(named: icon.name)
Defaults[.currentIcon] = icon.name
self.refreshCurrentAppIcon()

let alert = NSAlert()
alert.messageText = "\(Bundle.main.appName)"
alert.informativeText = "Current icon is now \(nameWithoutPrefix(name: icon.name))!"
alert.icon = NSImage(named: icon.name)
alert.runModal()

Defaults[.currentIcon] = icon.name
}

// This function is run at startup to set the current icon to the user's set icon.
func restoreCurrentAppIcon() {
func refreshCurrentAppIcon() {
NSWorkspace.shared.setIcon(NSImage(named: Defaults[.currentIcon]), forFile: Bundle.main.bundlePath, options: [])
NSApp.applicationIconImage = NSImage(named: Defaults[.currentIcon])
}
Expand Down

0 comments on commit 6a102ca

Please sign in to comment.