mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 23:54:32 +00:00
Restored files from old Mac, force pushing
This commit is contained in:
parent
5dd95228b8
commit
5040381840
126 changed files with 10431 additions and 67 deletions
67
DynamicIsland/helpers/AppIcons.swift
Normal file
67
DynamicIsland/helpers/AppIcons.swift
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// AppIcons.swift
|
||||
// boringNotch
|
||||
//
|
||||
// Created by Harsh Vardhan Goswami on 16/08/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
struct AppIcons {
|
||||
|
||||
func getIcon(file path: String) -> NSImage? {
|
||||
guard FileManager.default.fileExists(atPath: path)
|
||||
else { return nil }
|
||||
|
||||
return NSWorkspace.shared.icon(forFile: path)
|
||||
}
|
||||
|
||||
func getIcon(bundleID: String) -> NSImage? {
|
||||
guard let path = NSWorkspace.shared.urlForApplication(
|
||||
withBundleIdentifier: bundleID
|
||||
)?.absoluteString
|
||||
else { return nil }
|
||||
|
||||
return getIcon(file: path)
|
||||
}
|
||||
|
||||
func getIcon(application: String) -> NSImage? {
|
||||
guard let path = NSWorkspace.shared.fullPath(forApplication: application)
|
||||
else { return nil }
|
||||
|
||||
return getIcon(file: path)
|
||||
}
|
||||
|
||||
/// Easily read Info.plist as a Dictionary from any bundle by accessing .infoDictionary on Bundle
|
||||
func bundle(forBundleID: String) -> Bundle? {
|
||||
guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: forBundleID)
|
||||
else { return nil }
|
||||
|
||||
return Bundle(url: url)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func AppIcon(for bundleID: String) -> Image {
|
||||
let workspace = NSWorkspace.shared
|
||||
|
||||
if let appURL = workspace.urlForApplication(withBundleIdentifier: bundleID) {
|
||||
let appIcon = workspace.icon(forFile: appURL.path)
|
||||
return Image(nsImage: appIcon)
|
||||
}
|
||||
|
||||
return Image(nsImage: workspace.icon(for: .applicationBundle))
|
||||
}
|
||||
|
||||
|
||||
func AppIconAsNSImage(for bundleID: String) -> NSImage? {
|
||||
let workspace = NSWorkspace.shared
|
||||
|
||||
if let appURL = workspace.urlForApplication(withBundleIdentifier: bundleID) {
|
||||
let appIcon = workspace.icon(forFile: appURL.path)
|
||||
return appIcon
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue