├── .gitignore ├── FinderEx Context Menu ├── FinderEx_ContextMenu.entitlements ├── FinderSync.swift └── Info.plist ├── FinderEx Helper ├── FinderExHelper.swift ├── FinderExHelperProtocol.swift ├── Info.plist └── main.swift ├── FinderEx.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── FinderEx Context Menu.xcscheme │ └── FinderEx.xcscheme ├── FinderEx ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon_128x128.png │ │ ├── icon_16x16.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256-1.png │ │ ├── icon_256x256.png │ │ ├── icon_32x32.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512-1.png │ │ ├── icon_512x512.png │ │ └── icon_512x512@2x-1.png │ └── Contents.json ├── Base.lproj │ └── MainMenu.xib ├── ConfigManager.swift ├── FinderEx.entitlements └── XPCWrapper.swift ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *.lock 4 | 5 | xcuserdata 6 | 7 | build/ 8 | -------------------------------------------------------------------------------- /FinderEx Context Menu/FinderEx_ContextMenu.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FinderEx Context Menu/FinderSync.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FinderSync.swift 3 | // FinderEx Context Menu 4 | // 5 | // Created by Yanto Suryono on 2021/12/28. 6 | // 7 | 8 | import Cocoa 9 | import FinderSync 10 | 11 | extension Menu { 12 | 13 | func run(input: [String]) { 14 | 15 | if let a = action, let c = content { 16 | 17 | let exec: String = "/usr/bin/env" 18 | var args: [String] 19 | var stdin: String 20 | 21 | switch a { 22 | case "bash": 23 | // bash [options] [file] 24 | if fromfile { 25 | if path == nil { return } 26 | if path!.isEmpty { return } 27 | args = ["bash", path!] + input 28 | stdin = "" 29 | } 30 | else { 31 | args = ["bash", "/dev/stdin"] + input 32 | stdin = c 33 | } 34 | case "applescript": 35 | // osascript [-l language] [-i] [-s flags] [-e statement | programfile] [argument ...] 36 | if fromfile { 37 | if path == nil { return } 38 | if path!.isEmpty { return } 39 | args = ["osascript", path!] + input 40 | stdin = "" 41 | } 42 | else { 43 | args = ["osascript", "-"] + input 44 | stdin = c 45 | } 46 | case "workflow": 47 | // automator [-v] [-i input] [-D name=value ...] workflow 48 | if !fromfile { return } 49 | if path == nil { return } 50 | if path!.isEmpty { return } 51 | args = ["automator", "-i", "-", path!] 52 | stdin = input.joined(separator: "\n") 53 | default: 54 | return 55 | } 56 | XPCWrapper.run(exec: exec, input: stdin, args: args) 57 | } 58 | } 59 | } 60 | 61 | class FinderSync: FIFinderSync { 62 | 63 | var config: [ConfigItem] = [] 64 | var menus: [Menu] = [] 65 | var folder: URL? 66 | var items: [URL] = [] 67 | let alwaysLoadConfig = true 68 | 69 | override init() { 70 | 71 | super.init() 72 | NSLog("FinderSync() launched from %@", Bundle.main.bundlePath as NSString) 73 | 74 | config = loadConfig() 75 | 76 | let fs = FIFinderSyncController.default() 77 | 78 | // Monitor all currently visible mounted volumes 79 | // TODO: make this user configurable 80 | if let mountedVolumes = FileManager.default.mountedVolumeURLs( 81 | includingResourceValuesForKeys: nil, 82 | options: .skipHiddenVolumes) { 83 | fs.directoryURLs = Set(mountedVolumes) 84 | } 85 | 86 | // Also handle changes in mounted volumes 87 | // TODO: make this user configurable 88 | let nc = NSWorkspace.shared.notificationCenter 89 | nc.addObserver(forName: NSWorkspace.didMountNotification, object: nil, queue: .main) { n in 90 | if let url = n.userInfo?[NSWorkspace.volumeURLUserInfoKey] as? URL { 91 | fs.directoryURLs.insert(url) 92 | } 93 | } 94 | nc.addObserver(forName: NSWorkspace.didUnmountNotification, object: nil, queue: .main) { n in 95 | if let url = n.userInfo?[NSWorkspace.volumeURLUserInfoKey] as? URL { 96 | fs.directoryURLs.remove(url) 97 | } 98 | } 99 | nc.addObserver(forName: NSWorkspace.didRenameVolumeNotification, object: nil, queue: .main) { n in 100 | if let url = n.userInfo?[NSWorkspace.oldVolumeURLUserInfoKey] as? URL { 101 | fs.directoryURLs.remove(url) 102 | } 103 | if let url = n.userInfo?[NSWorkspace.volumeURLUserInfoKey] as? URL { 104 | fs.directoryURLs.insert(url) 105 | } 106 | } 107 | } 108 | 109 | private func loadConfig() -> [ConfigItem] { 110 | return ConfigManager.loadConfigAsArray(includeSystemWide: true) 111 | } 112 | 113 | private func askFolder(withReply reply: @escaping (URL?) -> Void) { 114 | 115 | // Need to steal active state in order to open dialog 116 | NSApp.activate(ignoringOtherApps: true) 117 | DispatchQueue.main.async { 118 | 119 | let dialog = NSOpenPanel() 120 | 121 | dialog.title = "Select folder ..." 122 | dialog.showsResizeIndicator = true 123 | dialog.showsHiddenFiles = false 124 | dialog.allowsMultipleSelection = false 125 | dialog.canChooseDirectories = true 126 | dialog.canChooseFiles = false 127 | 128 | if (dialog.runModal() == NSApplication.ModalResponse.OK) { 129 | reply(dialog.url) 130 | } 131 | else { 132 | reply(nil) 133 | } 134 | } 135 | } 136 | 137 | override func menu(for menuKind: FIMenuKind) -> NSMenu { 138 | 139 | let menu = NSMenu(title: "") 140 | let target = FIFinderSyncController.default().targetedURL() 141 | let items = FIFinderSyncController.default().selectedItemURLs() 142 | 143 | func addMenuItem(forType: String) { 144 | var item : ConfigItem? 145 | for c in config { 146 | if c.type == forType { 147 | item = c 148 | } 149 | } 150 | if let i = item { 151 | for j in 0.. 0 { 205 | 206 | var type: String? 207 | var isDir: ObjCBool = true 208 | 209 | // Test if selected items are all folders or all files 210 | for item in self.items { 211 | if FileManager.default.fileExists(atPath: item.path, isDirectory: &isDir) { 212 | let thisType = isDir.boolValue ? "d" : "f" 213 | if thisType != type { 214 | if type == nil { 215 | type = thisType 216 | } 217 | else { 218 | type = nil 219 | break 220 | } 221 | } 222 | } 223 | } 224 | 225 | // Only proceed if selected items are all folders or all files 226 | if let t = type { 227 | 228 | // Add menu items for folders / files 229 | addMenuItem(forType: t) 230 | 231 | // Only proceed if all selected items are files 232 | if t == "f" { 233 | 234 | // Check if all selected items are member of a category 235 | // If yes, then add menu items for the category 236 | for i in 0..= self.menus.count { 256 | // TODO: handle error 257 | return 258 | } 259 | let menu = self.menus[item.tag] 260 | 261 | var items: [String] = [] 262 | for i in self.items { 263 | items.append(i.path) 264 | } 265 | 266 | if menu.askfolder { 267 | askFolder() { response in 268 | if let folder = response { 269 | // Prepend folder to items 270 | items = [folder.path] + items 271 | menu.run(input: items) 272 | } 273 | } 274 | } 275 | else { 276 | menu.run(input: items) 277 | } 278 | } 279 | } 280 | 281 | -------------------------------------------------------------------------------- /FinderEx Context Menu/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSUIElement 6 | 7 | NSExtension 8 | 9 | NSExtensionAttributes 10 | 11 | NSExtensionPointIdentifier 12 | com.apple.FinderSync 13 | NSExtensionPrincipalClass 14 | $(PRODUCT_MODULE_NAME).FinderSync 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /FinderEx Helper/FinderExHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FinderExHelper.swift 3 | // FinderEx Helper 4 | // 5 | // Created by Yanto Suryono on 2021/12/31. 6 | // 7 | 8 | import Foundation 9 | 10 | class FinderExHelper: NSObject, FinderExHelperProtocol { 11 | 12 | static let configFile = "Library/FinderEx/config.yaml" 13 | 14 | func homeDir(withReply reply: @escaping (String) -> Void) { 15 | reply(NSHomeDirectory()) 16 | } 17 | 18 | func loadConfig(user: Bool, withReply reply: @escaping (String) -> Void) { 19 | 20 | var filepath: URL 21 | 22 | if user { 23 | filepath = URL(fileURLWithPath: NSHomeDirectory()) 24 | } 25 | else { 26 | filepath = URL(fileURLWithPath: "/") 27 | } 28 | filepath = filepath.appendingPathComponent(Self.configFile) 29 | 30 | if let content = try? String(contentsOf: filepath) { 31 | reply(content) 32 | } 33 | else { 34 | reply("") 35 | } 36 | } 37 | 38 | func saveConfig(content: String, withReply reply: @escaping (Bool) -> Void) { 39 | 40 | let filepath = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(Self.configFile) 41 | let dir = filepath.deletingLastPathComponent() 42 | 43 | // Create file path if it does not exist 44 | if !FileManager.default.fileExists(atPath: dir.path) { 45 | do { 46 | try FileManager.default.createDirectory(atPath: dir.path, withIntermediateDirectories: true, attributes: nil) 47 | } catch { 48 | reply(false) 49 | return 50 | } 51 | } 52 | 53 | // Create file if it does not exist 54 | if !FileManager.default.fileExists(atPath: filepath.path) { 55 | FileManager.default.createFile(atPath: filepath.path, contents:Data("".utf8), attributes: nil) 56 | } 57 | 58 | // Open file for writing and clear its content 59 | guard let fileHandle = FileHandle(forWritingAtPath: filepath.path) else { 60 | reply(false) 61 | return 62 | } 63 | fileHandle.truncateFile(atOffset: 0) 64 | 65 | // Write file content and close 66 | fileHandle.write(content.data(using: String.Encoding.utf8)!) 67 | fileHandle.closeFile() 68 | 69 | reply(true) 70 | } 71 | 72 | func run(exec: String, input: String, args: [String], withReply reply: @escaping (String?, Int32) -> Void) { 73 | 74 | let task = Process() 75 | task.executableURL = URL(fileURLWithPath: exec) 76 | task.arguments = args 77 | 78 | let pipeIn = Pipe() 79 | let pipeOut = Pipe() 80 | 81 | task.standardInput = pipeIn 82 | task.standardOutput = pipeOut 83 | task.standardError = pipeOut 84 | 85 | pipeIn.fileHandleForWriting.write(input.data(using: .utf8)!) 86 | pipeIn.fileHandleForWriting.closeFile() 87 | 88 | task.launch() 89 | task.waitUntilExit() 90 | 91 | let data = pipeOut.fileHandleForReading.readDataToEndOfFile() 92 | let output = String(data: data, encoding: String.Encoding.utf8) 93 | 94 | reply(output, task.terminationStatus) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /FinderEx Helper/FinderExHelperProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FinderExHelperProtocol.swift 3 | // FinderEx Helper 4 | // 5 | // Created by Yanto Suryono on 2021/12/31. 6 | // 7 | 8 | import Foundation 9 | 10 | @objc public protocol FinderExHelperProtocol { 11 | func homeDir(withReply reply: @escaping (String) -> Void) 12 | func loadConfig(user: Bool, withReply reply: @escaping (String) -> Void) 13 | func saveConfig(content: String, withReply reply: @escaping (Bool) -> Void) 14 | func run(exec: String, input: String, args: [String], withReply reply: @escaping (String?, Int32) -> Void) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /FinderEx Helper/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | XPCService 6 | 7 | ServiceType 8 | Application 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /FinderEx Helper/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // FinderEx Helper 4 | // 5 | // Created by Yanto Suryono on 2021/12/31. 6 | // 7 | 8 | import Foundation 9 | 10 | class FinderExHelperDelegate: NSObject, NSXPCListenerDelegate { 11 | func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool { 12 | let exportedObject = FinderExHelper() 13 | newConnection.exportedInterface = NSXPCInterface(with: FinderExHelperProtocol.self) 14 | newConnection.exportedObject = exportedObject 15 | newConnection.resume() 16 | return true 17 | } 18 | } 19 | 20 | let delegate = FinderExHelperDelegate() 21 | let listener = NSXPCListener.service() 22 | listener.delegate = delegate 23 | listener.resume() 24 | 25 | -------------------------------------------------------------------------------- /FinderEx.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 455D4B46277EC29900E75525 /* FinderExHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455D4B45277EC29900E75525 /* FinderExHelper.swift */; }; 11 | 455D4B48277EC29900E75525 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455D4B47277EC29900E75525 /* main.swift */; }; 12 | 455D4B4C277EC29900E75525 /* FinderEx Helper.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 455D4B41277EC29900E75525 /* FinderEx Helper.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 13 | 455D4B50277EC3BB00E75525 /* FinderExHelperProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455D4B43277EC29900E75525 /* FinderExHelperProtocol.swift */; }; 14 | 455D4B51277EC64500E75525 /* FinderExHelperProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455D4B43277EC29900E75525 /* FinderExHelperProtocol.swift */; }; 15 | 455D4B52277EC64600E75525 /* FinderExHelperProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455D4B43277EC29900E75525 /* FinderExHelperProtocol.swift */; }; 16 | 455E98F4277EF6F5006BF2F7 /* XPCWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455E98F3277EF6F5006BF2F7 /* XPCWrapper.swift */; }; 17 | 455E98F6277EFB4D006BF2F7 /* Yaml in Frameworks */ = {isa = PBXBuildFile; productRef = 455E98F5277EFB4D006BF2F7 /* Yaml */; }; 18 | 455E98F8277EFB55006BF2F7 /* Yaml in Frameworks */ = {isa = PBXBuildFile; productRef = 455E98F7277EFB55006BF2F7 /* Yaml */; }; 19 | 455E98FA277EFB5B006BF2F7 /* Yaml in Frameworks */ = {isa = PBXBuildFile; productRef = 455E98F9277EFB5B006BF2F7 /* Yaml */; }; 20 | 455E98FB277F0196006BF2F7 /* XPCWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455E98F3277EF6F5006BF2F7 /* XPCWrapper.swift */; }; 21 | 4571186A277AA8AA00AE81FE /* FinderSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45711869277AA8AA00AE81FE /* FinderSync.swift */; }; 22 | 4571186F277AA8AA00AE81FE /* FinderEx Context Menu.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 45711867277AA8AA00AE81FE /* FinderEx Context Menu.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 23 | 45711873277AA8EE00AE81FE /* ConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A629EC27753FCF006F8AFA /* ConfigManager.swift */; }; 24 | 4599D7AB2781A3F500317FA1 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 4599D7AA2781A3F400317FA1 /* LICENSE */; }; 25 | 45A629ED27753FCF006F8AFA /* ConfigManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45A629EC27753FCF006F8AFA /* ConfigManager.swift */; }; 26 | 45E88785277EF1DB0062CD3F /* FinderEx Helper.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 455D4B41277EC29900E75525 /* FinderEx Helper.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 27 | 45FC83C8277532BF00474536 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45FC83C7277532BF00474536 /* AppDelegate.swift */; }; 28 | 45FC83CA277532C100474536 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 45FC83C9277532C100474536 /* Assets.xcassets */; }; 29 | 45FC83CD277532C100474536 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 45FC83CB277532C100474536 /* MainMenu.xib */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXContainerItemProxy section */ 33 | 455D4B4A277EC29900E75525 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 45FC83BC277532BE00474536 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 455D4B40277EC29800E75525; 38 | remoteInfo = "FinderEx Helper"; 39 | }; 40 | 4571186D277AA8AA00AE81FE /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = 45FC83BC277532BE00474536 /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = 45711866277AA8AA00AE81FE; 45 | remoteInfo = "FinderEx Context Menu"; 46 | }; 47 | 45E88782277EF1620062CD3F /* PBXContainerItemProxy */ = { 48 | isa = PBXContainerItemProxy; 49 | containerPortal = 45FC83BC277532BE00474536 /* Project object */; 50 | proxyType = 1; 51 | remoteGlobalIDString = 455D4B40277EC29800E75525; 52 | remoteInfo = "FinderEx Helper"; 53 | }; 54 | /* End PBXContainerItemProxy section */ 55 | 56 | /* Begin PBXCopyFilesBuildPhase section */ 57 | 456C3F33277AA6C3001B346E /* Embed App Extensions */ = { 58 | isa = PBXCopyFilesBuildPhase; 59 | buildActionMask = 2147483647; 60 | dstPath = ""; 61 | dstSubfolderSpec = 13; 62 | files = ( 63 | 4571186F277AA8AA00AE81FE /* FinderEx Context Menu.appex in Embed App Extensions */, 64 | ); 65 | name = "Embed App Extensions"; 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | 458A15CA277DA0400014A244 /* Embed XPC Services */ = { 69 | isa = PBXCopyFilesBuildPhase; 70 | buildActionMask = 2147483647; 71 | dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices"; 72 | dstSubfolderSpec = 16; 73 | files = ( 74 | 455D4B4C277EC29900E75525 /* FinderEx Helper.xpc in Embed XPC Services */, 75 | ); 76 | name = "Embed XPC Services"; 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | 45E88784277EF1B00062CD3F /* Embed XPC Services */ = { 80 | isa = PBXCopyFilesBuildPhase; 81 | buildActionMask = 2147483647; 82 | dstPath = "$(CONTENTS_FOLDER_PATH)/XPCServices"; 83 | dstSubfolderSpec = 16; 84 | files = ( 85 | 45E88785277EF1DB0062CD3F /* FinderEx Helper.xpc in Embed XPC Services */, 86 | ); 87 | name = "Embed XPC Services"; 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | /* End PBXCopyFilesBuildPhase section */ 91 | 92 | /* Begin PBXFileReference section */ 93 | 455D4B41277EC29900E75525 /* FinderEx Helper.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = "FinderEx Helper.xpc"; sourceTree = BUILT_PRODUCTS_DIR; }; 94 | 455D4B43277EC29900E75525 /* FinderExHelperProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderExHelperProtocol.swift; sourceTree = ""; }; 95 | 455D4B45277EC29900E75525 /* FinderExHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderExHelper.swift; sourceTree = ""; }; 96 | 455D4B47277EC29900E75525 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; 97 | 455D4B49277EC29900E75525 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 98 | 455E98F3277EF6F5006BF2F7 /* XPCWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XPCWrapper.swift; sourceTree = ""; }; 99 | 45711867277AA8AA00AE81FE /* FinderEx Context Menu.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "FinderEx Context Menu.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 100 | 45711869277AA8AA00AE81FE /* FinderSync.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderSync.swift; sourceTree = ""; }; 101 | 4571186B277AA8AA00AE81FE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 102 | 4571186C277AA8AA00AE81FE /* FinderEx_ContextMenu.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FinderEx_ContextMenu.entitlements; sourceTree = ""; }; 103 | 4599D7AA2781A3F400317FA1 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 104 | 45A629EC27753FCF006F8AFA /* ConfigManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigManager.swift; sourceTree = ""; }; 105 | 45FC83C4277532BF00474536 /* FinderEx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FinderEx.app; sourceTree = BUILT_PRODUCTS_DIR; }; 106 | 45FC83C7277532BF00474536 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 107 | 45FC83C9277532C100474536 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 108 | 45FC83CC277532C100474536 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 109 | 45FC83CE277532C100474536 /* FinderEx.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = FinderEx.entitlements; sourceTree = ""; }; 110 | /* End PBXFileReference section */ 111 | 112 | /* Begin PBXFrameworksBuildPhase section */ 113 | 455D4B3E277EC29800E75525 /* Frameworks */ = { 114 | isa = PBXFrameworksBuildPhase; 115 | buildActionMask = 2147483647; 116 | files = ( 117 | 455E98F6277EFB4D006BF2F7 /* Yaml in Frameworks */, 118 | ); 119 | runOnlyForDeploymentPostprocessing = 0; 120 | }; 121 | 45711864277AA8AA00AE81FE /* Frameworks */ = { 122 | isa = PBXFrameworksBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | 455E98F8277EFB55006BF2F7 /* Yaml in Frameworks */, 126 | ); 127 | runOnlyForDeploymentPostprocessing = 0; 128 | }; 129 | 45FC83C1277532BF00474536 /* Frameworks */ = { 130 | isa = PBXFrameworksBuildPhase; 131 | buildActionMask = 2147483647; 132 | files = ( 133 | 455E98FA277EFB5B006BF2F7 /* Yaml in Frameworks */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXFrameworksBuildPhase section */ 138 | 139 | /* Begin PBXGroup section */ 140 | 454318122779B96A008AE3FF /* Frameworks */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | ); 144 | name = Frameworks; 145 | sourceTree = ""; 146 | }; 147 | 455D4B42277EC29900E75525 /* FinderEx Helper */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 455D4B43277EC29900E75525 /* FinderExHelperProtocol.swift */, 151 | 455D4B45277EC29900E75525 /* FinderExHelper.swift */, 152 | 455D4B47277EC29900E75525 /* main.swift */, 153 | 455D4B49277EC29900E75525 /* Info.plist */, 154 | ); 155 | path = "FinderEx Helper"; 156 | sourceTree = ""; 157 | }; 158 | 45711868277AA8AA00AE81FE /* FinderEx Context Menu */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 45711869277AA8AA00AE81FE /* FinderSync.swift */, 162 | 4571186B277AA8AA00AE81FE /* Info.plist */, 163 | 4571186C277AA8AA00AE81FE /* FinderEx_ContextMenu.entitlements */, 164 | ); 165 | path = "FinderEx Context Menu"; 166 | sourceTree = ""; 167 | }; 168 | 45FC83BB277532BE00474536 = { 169 | isa = PBXGroup; 170 | children = ( 171 | 4599D7AA2781A3F400317FA1 /* LICENSE */, 172 | 45FC83C6277532BF00474536 /* FinderEx */, 173 | 45711868277AA8AA00AE81FE /* FinderEx Context Menu */, 174 | 455D4B42277EC29900E75525 /* FinderEx Helper */, 175 | 45FC83C5277532BF00474536 /* Products */, 176 | 454318122779B96A008AE3FF /* Frameworks */, 177 | ); 178 | sourceTree = ""; 179 | }; 180 | 45FC83C5277532BF00474536 /* Products */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | 45FC83C4277532BF00474536 /* FinderEx.app */, 184 | 45711867277AA8AA00AE81FE /* FinderEx Context Menu.appex */, 185 | 455D4B41277EC29900E75525 /* FinderEx Helper.xpc */, 186 | ); 187 | name = Products; 188 | sourceTree = ""; 189 | }; 190 | 45FC83C6277532BF00474536 /* FinderEx */ = { 191 | isa = PBXGroup; 192 | children = ( 193 | 45FC83C7277532BF00474536 /* AppDelegate.swift */, 194 | 45FC83C9277532C100474536 /* Assets.xcassets */, 195 | 45FC83CB277532C100474536 /* MainMenu.xib */, 196 | 45FC83CE277532C100474536 /* FinderEx.entitlements */, 197 | 45A629EC27753FCF006F8AFA /* ConfigManager.swift */, 198 | 455E98F3277EF6F5006BF2F7 /* XPCWrapper.swift */, 199 | ); 200 | path = FinderEx; 201 | sourceTree = ""; 202 | }; 203 | /* End PBXGroup section */ 204 | 205 | /* Begin PBXNativeTarget section */ 206 | 455D4B40277EC29800E75525 /* FinderEx Helper */ = { 207 | isa = PBXNativeTarget; 208 | buildConfigurationList = 455D4B4F277EC29900E75525 /* Build configuration list for PBXNativeTarget "FinderEx Helper" */; 209 | buildPhases = ( 210 | 455D4B3D277EC29800E75525 /* Sources */, 211 | 455D4B3E277EC29800E75525 /* Frameworks */, 212 | 455D4B3F277EC29800E75525 /* Resources */, 213 | ); 214 | buildRules = ( 215 | ); 216 | dependencies = ( 217 | 455E98F2277EF628006BF2F7 /* PBXTargetDependency */, 218 | ); 219 | name = "FinderEx Helper"; 220 | packageProductDependencies = ( 221 | 455E98F5277EFB4D006BF2F7 /* Yaml */, 222 | ); 223 | productName = "FinderEx Helper"; 224 | productReference = 455D4B41277EC29900E75525 /* FinderEx Helper.xpc */; 225 | productType = "com.apple.product-type.xpc-service"; 226 | }; 227 | 45711866277AA8AA00AE81FE /* FinderEx Context Menu */ = { 228 | isa = PBXNativeTarget; 229 | buildConfigurationList = 45711872277AA8AA00AE81FE /* Build configuration list for PBXNativeTarget "FinderEx Context Menu" */; 230 | buildPhases = ( 231 | 45711863277AA8AA00AE81FE /* Sources */, 232 | 45711864277AA8AA00AE81FE /* Frameworks */, 233 | 45711865277AA8AA00AE81FE /* Resources */, 234 | 45E88784277EF1B00062CD3F /* Embed XPC Services */, 235 | ); 236 | buildRules = ( 237 | ); 238 | dependencies = ( 239 | 455E98F0277EF622006BF2F7 /* PBXTargetDependency */, 240 | 45E88783277EF1620062CD3F /* PBXTargetDependency */, 241 | ); 242 | name = "FinderEx Context Menu"; 243 | packageProductDependencies = ( 244 | 455E98F7277EFB55006BF2F7 /* Yaml */, 245 | ); 246 | productName = "FinderEx Context Menu"; 247 | productReference = 45711867277AA8AA00AE81FE /* FinderEx Context Menu.appex */; 248 | productType = "com.apple.product-type.app-extension"; 249 | }; 250 | 45FC83C3277532BF00474536 /* FinderEx */ = { 251 | isa = PBXNativeTarget; 252 | buildConfigurationList = 45FC83D1277532C100474536 /* Build configuration list for PBXNativeTarget "FinderEx" */; 253 | buildPhases = ( 254 | 45FC83C0277532BF00474536 /* Sources */, 255 | 45FC83C1277532BF00474536 /* Frameworks */, 256 | 45FC83C2277532BF00474536 /* Resources */, 257 | 456C3F33277AA6C3001B346E /* Embed App Extensions */, 258 | 458A15CA277DA0400014A244 /* Embed XPC Services */, 259 | ); 260 | buildRules = ( 261 | ); 262 | dependencies = ( 263 | 455E98EE277EF61B006BF2F7 /* PBXTargetDependency */, 264 | 4571186E277AA8AA00AE81FE /* PBXTargetDependency */, 265 | 455D4B4B277EC29900E75525 /* PBXTargetDependency */, 266 | ); 267 | name = FinderEx; 268 | packageProductDependencies = ( 269 | 455E98F9277EFB5B006BF2F7 /* Yaml */, 270 | ); 271 | productName = FinderEx; 272 | productReference = 45FC83C4277532BF00474536 /* FinderEx.app */; 273 | productType = "com.apple.product-type.application"; 274 | }; 275 | /* End PBXNativeTarget section */ 276 | 277 | /* Begin PBXProject section */ 278 | 45FC83BC277532BE00474536 /* Project object */ = { 279 | isa = PBXProject; 280 | attributes = { 281 | BuildIndependentTargetsInParallel = 1; 282 | LastSwiftUpdateCheck = 1320; 283 | LastUpgradeCheck = 1320; 284 | TargetAttributes = { 285 | 455D4B40277EC29800E75525 = { 286 | CreatedOnToolsVersion = 13.2.1; 287 | }; 288 | 45711866277AA8AA00AE81FE = { 289 | CreatedOnToolsVersion = 13.2.1; 290 | }; 291 | 45FC83C3277532BF00474536 = { 292 | CreatedOnToolsVersion = 13.2.1; 293 | }; 294 | }; 295 | }; 296 | buildConfigurationList = 45FC83BF277532BE00474536 /* Build configuration list for PBXProject "FinderEx" */; 297 | compatibilityVersion = "Xcode 13.0"; 298 | developmentRegion = en; 299 | hasScannedForEncodings = 0; 300 | knownRegions = ( 301 | en, 302 | Base, 303 | ); 304 | mainGroup = 45FC83BB277532BE00474536; 305 | packageReferences = ( 306 | 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */, 307 | ); 308 | productRefGroup = 45FC83C5277532BF00474536 /* Products */; 309 | projectDirPath = ""; 310 | projectRoot = ""; 311 | targets = ( 312 | 45FC83C3277532BF00474536 /* FinderEx */, 313 | 45711866277AA8AA00AE81FE /* FinderEx Context Menu */, 314 | 455D4B40277EC29800E75525 /* FinderEx Helper */, 315 | ); 316 | }; 317 | /* End PBXProject section */ 318 | 319 | /* Begin PBXResourcesBuildPhase section */ 320 | 455D4B3F277EC29800E75525 /* Resources */ = { 321 | isa = PBXResourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | 45711865277AA8AA00AE81FE /* Resources */ = { 328 | isa = PBXResourcesBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | }; 334 | 45FC83C2277532BF00474536 /* Resources */ = { 335 | isa = PBXResourcesBuildPhase; 336 | buildActionMask = 2147483647; 337 | files = ( 338 | 4599D7AB2781A3F500317FA1 /* LICENSE in Resources */, 339 | 45FC83CA277532C100474536 /* Assets.xcassets in Resources */, 340 | 45FC83CD277532C100474536 /* MainMenu.xib in Resources */, 341 | ); 342 | runOnlyForDeploymentPostprocessing = 0; 343 | }; 344 | /* End PBXResourcesBuildPhase section */ 345 | 346 | /* Begin PBXSourcesBuildPhase section */ 347 | 455D4B3D277EC29800E75525 /* Sources */ = { 348 | isa = PBXSourcesBuildPhase; 349 | buildActionMask = 2147483647; 350 | files = ( 351 | 455D4B50277EC3BB00E75525 /* FinderExHelperProtocol.swift in Sources */, 352 | 455D4B46277EC29900E75525 /* FinderExHelper.swift in Sources */, 353 | 455D4B48277EC29900E75525 /* main.swift in Sources */, 354 | ); 355 | runOnlyForDeploymentPostprocessing = 0; 356 | }; 357 | 45711863277AA8AA00AE81FE /* Sources */ = { 358 | isa = PBXSourcesBuildPhase; 359 | buildActionMask = 2147483647; 360 | files = ( 361 | 4571186A277AA8AA00AE81FE /* FinderSync.swift in Sources */, 362 | 45711873277AA8EE00AE81FE /* ConfigManager.swift in Sources */, 363 | 455D4B52277EC64600E75525 /* FinderExHelperProtocol.swift in Sources */, 364 | 455E98FB277F0196006BF2F7 /* XPCWrapper.swift in Sources */, 365 | ); 366 | runOnlyForDeploymentPostprocessing = 0; 367 | }; 368 | 45FC83C0277532BF00474536 /* Sources */ = { 369 | isa = PBXSourcesBuildPhase; 370 | buildActionMask = 2147483647; 371 | files = ( 372 | 45FC83C8277532BF00474536 /* AppDelegate.swift in Sources */, 373 | 45A629ED27753FCF006F8AFA /* ConfigManager.swift in Sources */, 374 | 455D4B51277EC64500E75525 /* FinderExHelperProtocol.swift in Sources */, 375 | 455E98F4277EF6F5006BF2F7 /* XPCWrapper.swift in Sources */, 376 | ); 377 | runOnlyForDeploymentPostprocessing = 0; 378 | }; 379 | /* End PBXSourcesBuildPhase section */ 380 | 381 | /* Begin PBXTargetDependency section */ 382 | 455D4B4B277EC29900E75525 /* PBXTargetDependency */ = { 383 | isa = PBXTargetDependency; 384 | target = 455D4B40277EC29800E75525 /* FinderEx Helper */; 385 | targetProxy = 455D4B4A277EC29900E75525 /* PBXContainerItemProxy */; 386 | }; 387 | 455E98EE277EF61B006BF2F7 /* PBXTargetDependency */ = { 388 | isa = PBXTargetDependency; 389 | productRef = 455E98ED277EF61B006BF2F7 /* Yaml */; 390 | }; 391 | 455E98F0277EF622006BF2F7 /* PBXTargetDependency */ = { 392 | isa = PBXTargetDependency; 393 | productRef = 455E98EF277EF622006BF2F7 /* Yaml */; 394 | }; 395 | 455E98F2277EF628006BF2F7 /* PBXTargetDependency */ = { 396 | isa = PBXTargetDependency; 397 | productRef = 455E98F1277EF628006BF2F7 /* Yaml */; 398 | }; 399 | 4571186E277AA8AA00AE81FE /* PBXTargetDependency */ = { 400 | isa = PBXTargetDependency; 401 | target = 45711866277AA8AA00AE81FE /* FinderEx Context Menu */; 402 | targetProxy = 4571186D277AA8AA00AE81FE /* PBXContainerItemProxy */; 403 | }; 404 | 45E88783277EF1620062CD3F /* PBXTargetDependency */ = { 405 | isa = PBXTargetDependency; 406 | target = 455D4B40277EC29800E75525 /* FinderEx Helper */; 407 | targetProxy = 45E88782277EF1620062CD3F /* PBXContainerItemProxy */; 408 | }; 409 | /* End PBXTargetDependency section */ 410 | 411 | /* Begin PBXVariantGroup section */ 412 | 45FC83CB277532C100474536 /* MainMenu.xib */ = { 413 | isa = PBXVariantGroup; 414 | children = ( 415 | 45FC83CC277532C100474536 /* Base */, 416 | ); 417 | name = MainMenu.xib; 418 | sourceTree = ""; 419 | }; 420 | /* End PBXVariantGroup section */ 421 | 422 | /* Begin XCBuildConfiguration section */ 423 | 455D4B4D277EC29900E75525 /* Debug */ = { 424 | isa = XCBuildConfiguration; 425 | buildSettings = { 426 | CODE_SIGN_IDENTITY = "-"; 427 | CODE_SIGN_STYLE = Automatic; 428 | COMBINE_HIDPI_IMAGES = YES; 429 | CURRENT_PROJECT_VERSION = 1; 430 | GENERATE_INFOPLIST_FILE = YES; 431 | INFOPLIST_FILE = "FinderEx Helper/Info.plist"; 432 | INFOPLIST_KEY_CFBundleDisplayName = "FinderEx Helper"; 433 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 434 | MARKETING_VERSION = 1.0; 435 | PRODUCT_BUNDLE_IDENTIFIER = app.yantoz.FinderEx.Helper; 436 | PRODUCT_NAME = "$(TARGET_NAME)"; 437 | SKIP_INSTALL = YES; 438 | SWIFT_EMIT_LOC_STRINGS = YES; 439 | SWIFT_VERSION = 5.0; 440 | }; 441 | name = Debug; 442 | }; 443 | 455D4B4E277EC29900E75525 /* Release */ = { 444 | isa = XCBuildConfiguration; 445 | buildSettings = { 446 | CODE_SIGN_IDENTITY = "-"; 447 | CODE_SIGN_STYLE = Automatic; 448 | COMBINE_HIDPI_IMAGES = YES; 449 | CURRENT_PROJECT_VERSION = 1; 450 | GENERATE_INFOPLIST_FILE = YES; 451 | INFOPLIST_FILE = "FinderEx Helper/Info.plist"; 452 | INFOPLIST_KEY_CFBundleDisplayName = "FinderEx Helper"; 453 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 454 | MARKETING_VERSION = 1.0; 455 | PRODUCT_BUNDLE_IDENTIFIER = app.yantoz.FinderEx.Helper; 456 | PRODUCT_NAME = "$(TARGET_NAME)"; 457 | SKIP_INSTALL = YES; 458 | SWIFT_EMIT_LOC_STRINGS = YES; 459 | SWIFT_VERSION = 5.0; 460 | }; 461 | name = Release; 462 | }; 463 | 45711870277AA8AA00AE81FE /* Debug */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | CODE_SIGN_ENTITLEMENTS = "FinderEx Context Menu/FinderEx_ContextMenu.entitlements"; 467 | CODE_SIGN_STYLE = Automatic; 468 | COMBINE_HIDPI_IMAGES = YES; 469 | CURRENT_PROJECT_VERSION = 1; 470 | GENERATE_INFOPLIST_FILE = YES; 471 | INFOPLIST_FILE = "FinderEx Context Menu/Info.plist"; 472 | INFOPLIST_KEY_CFBundleDisplayName = "FinderEx Context Menu"; 473 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 474 | LD_RUNPATH_SEARCH_PATHS = ( 475 | "$(inherited)", 476 | "@executable_path/../Frameworks", 477 | "@executable_path/../../../../Frameworks", 478 | ); 479 | MARKETING_VERSION = 1.0; 480 | PRODUCT_BUNDLE_IDENTIFIER = app.yantoz.FinderEx.ContextMenu; 481 | PRODUCT_NAME = "$(TARGET_NAME)"; 482 | SKIP_INSTALL = YES; 483 | SWIFT_EMIT_LOC_STRINGS = YES; 484 | SWIFT_VERSION = 5.0; 485 | }; 486 | name = Debug; 487 | }; 488 | 45711871277AA8AA00AE81FE /* Release */ = { 489 | isa = XCBuildConfiguration; 490 | buildSettings = { 491 | CODE_SIGN_ENTITLEMENTS = "FinderEx Context Menu/FinderEx_ContextMenu.entitlements"; 492 | CODE_SIGN_STYLE = Automatic; 493 | COMBINE_HIDPI_IMAGES = YES; 494 | CURRENT_PROJECT_VERSION = 1; 495 | GENERATE_INFOPLIST_FILE = YES; 496 | INFOPLIST_FILE = "FinderEx Context Menu/Info.plist"; 497 | INFOPLIST_KEY_CFBundleDisplayName = "FinderEx Context Menu"; 498 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 499 | LD_RUNPATH_SEARCH_PATHS = ( 500 | "$(inherited)", 501 | "@executable_path/../Frameworks", 502 | "@executable_path/../../../../Frameworks", 503 | ); 504 | MARKETING_VERSION = 1.0; 505 | PRODUCT_BUNDLE_IDENTIFIER = app.yantoz.FinderEx.ContextMenu; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | SKIP_INSTALL = YES; 508 | SWIFT_EMIT_LOC_STRINGS = YES; 509 | SWIFT_VERSION = 5.0; 510 | }; 511 | name = Release; 512 | }; 513 | 45FC83CF277532C100474536 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ALWAYS_SEARCH_USER_PATHS = NO; 517 | CLANG_ANALYZER_NONNULL = YES; 518 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 519 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 520 | CLANG_CXX_LIBRARY = "libc++"; 521 | CLANG_ENABLE_MODULES = YES; 522 | CLANG_ENABLE_OBJC_ARC = YES; 523 | CLANG_ENABLE_OBJC_WEAK = YES; 524 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 525 | CLANG_WARN_BOOL_CONVERSION = YES; 526 | CLANG_WARN_COMMA = YES; 527 | CLANG_WARN_CONSTANT_CONVERSION = YES; 528 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 529 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 530 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 531 | CLANG_WARN_EMPTY_BODY = YES; 532 | CLANG_WARN_ENUM_CONVERSION = YES; 533 | CLANG_WARN_INFINITE_RECURSION = YES; 534 | CLANG_WARN_INT_CONVERSION = YES; 535 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 536 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 537 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 538 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 539 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 540 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 541 | CLANG_WARN_STRICT_PROTOTYPES = YES; 542 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 543 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 544 | CLANG_WARN_UNREACHABLE_CODE = YES; 545 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 546 | COPY_PHASE_STRIP = NO; 547 | DEBUG_INFORMATION_FORMAT = dwarf; 548 | ENABLE_STRICT_OBJC_MSGSEND = YES; 549 | ENABLE_TESTABILITY = YES; 550 | GCC_C_LANGUAGE_STANDARD = gnu11; 551 | GCC_DYNAMIC_NO_PIC = NO; 552 | GCC_NO_COMMON_BLOCKS = YES; 553 | GCC_OPTIMIZATION_LEVEL = 0; 554 | GCC_PREPROCESSOR_DEFINITIONS = ( 555 | "DEBUG=1", 556 | "$(inherited)", 557 | ); 558 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 559 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 560 | GCC_WARN_UNDECLARED_SELECTOR = YES; 561 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 562 | GCC_WARN_UNUSED_FUNCTION = YES; 563 | GCC_WARN_UNUSED_VARIABLE = YES; 564 | MACOSX_DEPLOYMENT_TARGET = 12.1; 565 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 566 | MTL_FAST_MATH = YES; 567 | ONLY_ACTIVE_ARCH = YES; 568 | SDKROOT = macosx; 569 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 570 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 571 | }; 572 | name = Debug; 573 | }; 574 | 45FC83D0277532C100474536 /* Release */ = { 575 | isa = XCBuildConfiguration; 576 | buildSettings = { 577 | ALWAYS_SEARCH_USER_PATHS = NO; 578 | CLANG_ANALYZER_NONNULL = YES; 579 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 580 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 581 | CLANG_CXX_LIBRARY = "libc++"; 582 | CLANG_ENABLE_MODULES = YES; 583 | CLANG_ENABLE_OBJC_ARC = YES; 584 | CLANG_ENABLE_OBJC_WEAK = YES; 585 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 586 | CLANG_WARN_BOOL_CONVERSION = YES; 587 | CLANG_WARN_COMMA = YES; 588 | CLANG_WARN_CONSTANT_CONVERSION = YES; 589 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 590 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 591 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 592 | CLANG_WARN_EMPTY_BODY = YES; 593 | CLANG_WARN_ENUM_CONVERSION = YES; 594 | CLANG_WARN_INFINITE_RECURSION = YES; 595 | CLANG_WARN_INT_CONVERSION = YES; 596 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 597 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 598 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 599 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 600 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 601 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 602 | CLANG_WARN_STRICT_PROTOTYPES = YES; 603 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 604 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 605 | CLANG_WARN_UNREACHABLE_CODE = YES; 606 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 607 | COPY_PHASE_STRIP = NO; 608 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 609 | ENABLE_NS_ASSERTIONS = NO; 610 | ENABLE_STRICT_OBJC_MSGSEND = YES; 611 | GCC_C_LANGUAGE_STANDARD = gnu11; 612 | GCC_NO_COMMON_BLOCKS = YES; 613 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 614 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 615 | GCC_WARN_UNDECLARED_SELECTOR = YES; 616 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 617 | GCC_WARN_UNUSED_FUNCTION = YES; 618 | GCC_WARN_UNUSED_VARIABLE = YES; 619 | MACOSX_DEPLOYMENT_TARGET = 12.1; 620 | MTL_ENABLE_DEBUG_INFO = NO; 621 | MTL_FAST_MATH = YES; 622 | SDKROOT = macosx; 623 | SWIFT_COMPILATION_MODE = wholemodule; 624 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 625 | }; 626 | name = Release; 627 | }; 628 | 45FC83D2277532C100474536 /* Debug */ = { 629 | isa = XCBuildConfiguration; 630 | buildSettings = { 631 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 632 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 633 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 634 | CODE_SIGN_ENTITLEMENTS = FinderEx/FinderEx.entitlements; 635 | CODE_SIGN_IDENTITY = "-"; 636 | CODE_SIGN_STYLE = Automatic; 637 | COMBINE_HIDPI_IMAGES = YES; 638 | CURRENT_PROJECT_VERSION = 1; 639 | GENERATE_INFOPLIST_FILE = YES; 640 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; 641 | INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright 2021-2022 Yanto Suryono"; 642 | INFOPLIST_KEY_NSMainNibFile = MainMenu; 643 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 644 | LD_RUNPATH_SEARCH_PATHS = ( 645 | "$(inherited)", 646 | "@executable_path/../Frameworks", 647 | ); 648 | MARKETING_VERSION = 1.0; 649 | PRODUCT_BUNDLE_IDENTIFIER = app.yantoz.FinderEx; 650 | PRODUCT_NAME = "$(TARGET_NAME)"; 651 | SWIFT_EMIT_LOC_STRINGS = YES; 652 | SWIFT_VERSION = 5.0; 653 | }; 654 | name = Debug; 655 | }; 656 | 45FC83D3277532C100474536 /* Release */ = { 657 | isa = XCBuildConfiguration; 658 | buildSettings = { 659 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 660 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 661 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 662 | CODE_SIGN_ENTITLEMENTS = FinderEx/FinderEx.entitlements; 663 | CODE_SIGN_IDENTITY = "-"; 664 | CODE_SIGN_STYLE = Automatic; 665 | COMBINE_HIDPI_IMAGES = YES; 666 | CURRENT_PROJECT_VERSION = 1; 667 | GENERATE_INFOPLIST_FILE = YES; 668 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; 669 | INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright 2021-2022 Yanto Suryono"; 670 | INFOPLIST_KEY_NSMainNibFile = MainMenu; 671 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 672 | LD_RUNPATH_SEARCH_PATHS = ( 673 | "$(inherited)", 674 | "@executable_path/../Frameworks", 675 | ); 676 | MARKETING_VERSION = 1.0; 677 | PRODUCT_BUNDLE_IDENTIFIER = app.yantoz.FinderEx; 678 | PRODUCT_NAME = "$(TARGET_NAME)"; 679 | SWIFT_EMIT_LOC_STRINGS = YES; 680 | SWIFT_VERSION = 5.0; 681 | }; 682 | name = Release; 683 | }; 684 | /* End XCBuildConfiguration section */ 685 | 686 | /* Begin XCConfigurationList section */ 687 | 455D4B4F277EC29900E75525 /* Build configuration list for PBXNativeTarget "FinderEx Helper" */ = { 688 | isa = XCConfigurationList; 689 | buildConfigurations = ( 690 | 455D4B4D277EC29900E75525 /* Debug */, 691 | 455D4B4E277EC29900E75525 /* Release */, 692 | ); 693 | defaultConfigurationIsVisible = 0; 694 | defaultConfigurationName = Release; 695 | }; 696 | 45711872277AA8AA00AE81FE /* Build configuration list for PBXNativeTarget "FinderEx Context Menu" */ = { 697 | isa = XCConfigurationList; 698 | buildConfigurations = ( 699 | 45711870277AA8AA00AE81FE /* Debug */, 700 | 45711871277AA8AA00AE81FE /* Release */, 701 | ); 702 | defaultConfigurationIsVisible = 0; 703 | defaultConfigurationName = Release; 704 | }; 705 | 45FC83BF277532BE00474536 /* Build configuration list for PBXProject "FinderEx" */ = { 706 | isa = XCConfigurationList; 707 | buildConfigurations = ( 708 | 45FC83CF277532C100474536 /* Debug */, 709 | 45FC83D0277532C100474536 /* Release */, 710 | ); 711 | defaultConfigurationIsVisible = 0; 712 | defaultConfigurationName = Release; 713 | }; 714 | 45FC83D1277532C100474536 /* Build configuration list for PBXNativeTarget "FinderEx" */ = { 715 | isa = XCConfigurationList; 716 | buildConfigurations = ( 717 | 45FC83D2277532C100474536 /* Debug */, 718 | 45FC83D3277532C100474536 /* Release */, 719 | ); 720 | defaultConfigurationIsVisible = 0; 721 | defaultConfigurationName = Release; 722 | }; 723 | /* End XCConfigurationList section */ 724 | 725 | /* Begin XCRemoteSwiftPackageReference section */ 726 | 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */ = { 727 | isa = XCRemoteSwiftPackageReference; 728 | repositoryURL = "https://github.com/behrang/YamlSwift.git"; 729 | requirement = { 730 | branch = master; 731 | kind = branch; 732 | }; 733 | }; 734 | /* End XCRemoteSwiftPackageReference section */ 735 | 736 | /* Begin XCSwiftPackageProductDependency section */ 737 | 455E98ED277EF61B006BF2F7 /* Yaml */ = { 738 | isa = XCSwiftPackageProductDependency; 739 | package = 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */; 740 | productName = Yaml; 741 | }; 742 | 455E98EF277EF622006BF2F7 /* Yaml */ = { 743 | isa = XCSwiftPackageProductDependency; 744 | package = 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */; 745 | productName = Yaml; 746 | }; 747 | 455E98F1277EF628006BF2F7 /* Yaml */ = { 748 | isa = XCSwiftPackageProductDependency; 749 | package = 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */; 750 | productName = Yaml; 751 | }; 752 | 455E98F5277EFB4D006BF2F7 /* Yaml */ = { 753 | isa = XCSwiftPackageProductDependency; 754 | package = 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */; 755 | productName = Yaml; 756 | }; 757 | 455E98F7277EFB55006BF2F7 /* Yaml */ = { 758 | isa = XCSwiftPackageProductDependency; 759 | package = 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */; 760 | productName = Yaml; 761 | }; 762 | 455E98F9277EFB5B006BF2F7 /* Yaml */ = { 763 | isa = XCSwiftPackageProductDependency; 764 | package = 4543180F2779B8F2008AE3FF /* XCRemoteSwiftPackageReference "YamlSwift" */; 765 | productName = Yaml; 766 | }; 767 | /* End XCSwiftPackageProductDependency section */ 768 | }; 769 | rootObject = 45FC83BC277532BE00474536 /* Project object */; 770 | } 771 | -------------------------------------------------------------------------------- /FinderEx.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FinderEx.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /FinderEx.xcodeproj/xcshareddata/xcschemes/FinderEx Context Menu.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 16 | 22 | 23 | 24 | 30 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 60 | 62 | 68 | 69 | 70 | 71 | 79 | 81 | 87 | 88 | 89 | 90 | 92 | 93 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /FinderEx.xcodeproj/xcshareddata/xcschemes/FinderEx.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /FinderEx/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // FinderEx Editor 4 | // 5 | // Created by Yanto Suryono on 2021/12/24. 6 | // 7 | 8 | import Cocoa 9 | import FinderSync 10 | 11 | extension Menu { 12 | 13 | func startEditing() -> Menu { 14 | initTitle = title 15 | initAction = action 16 | initContent = content 17 | initAskFolder = askfolder 18 | initFromFile = fromfile 19 | initPath = path 20 | return self 21 | } 22 | 23 | func revisitEnabled() { 24 | self.willChangeValue(forKey: "enabled") 25 | self.didChangeValue(forKey: "enabled") 26 | } 27 | 28 | func revisitModified() { 29 | self.willChangeValue(forKey: "modified") 30 | self.didChangeValue(forKey: "modified") 31 | } 32 | 33 | func revisitPath() { 34 | self.willChangeValue(forKey: "pathValid") 35 | self.willChangeValue(forKey: "pathValue") 36 | self.willChangeValue(forKey: "pathColor") 37 | self.didChangeValue(forKey: "pathValid") 38 | self.didChangeValue(forKey: "pathValue") 39 | self.didChangeValue(forKey: "pathColor") 40 | } 41 | 42 | @objc dynamic var enabled: Bool { 43 | get { 44 | return !(title == nil || action == nil) 45 | } 46 | } 47 | 48 | @objc dynamic var modified: Bool { 49 | get { 50 | return (title != initTitle || action != initAction || fromfile != initFromFile || path != initPath || content != initContent) 51 | } 52 | } 53 | 54 | @objc dynamic var pathValid: Bool { 55 | get { 56 | if let p = path { 57 | return FileManager.default.fileExists(atPath: p) 58 | } 59 | return false 60 | } 61 | } 62 | 63 | @objc dynamic var pathValue: String { 64 | get { 65 | if let p = path { 66 | if !p.isEmpty { return p } 67 | } 68 | return "No file selected" 69 | } 70 | } 71 | 72 | @objc dynamic var pathColor: NSColor { 73 | get { 74 | if pathValid { 75 | return NSColor.controlTextColor 76 | } 77 | else { 78 | return NSColor.secondaryLabelColor 79 | } 80 | } 81 | } 82 | } 83 | 84 | @main 85 | class AppDelegate: NSObject, NSApplicationDelegate { 86 | 87 | let defaultCategory = "Category" 88 | let defaultMenuTitle = "Title" 89 | 90 | @IBOutlet weak var configTableView: NSTableView! 91 | @IBOutlet weak var modifyConfigArrayButtons: NSSegmentedCell! 92 | @IBOutlet weak var contextMenu: NSMenu! 93 | @IBOutlet weak var menuObjectController: NSObjectController! 94 | 95 | @IBOutlet weak var actionContentView: NSTextView! 96 | @IBOutlet weak var configArrayController: NSArrayController! 97 | @IBOutlet weak var configTestBox: NSBox! 98 | 99 | @IBOutlet weak var contextMenuActionTypeComboBox: NSComboBox! 100 | @IBOutlet weak var contextMenuRemoveButton: NSButton! 101 | @IBOutlet weak var contextMenuActionSourceFile: NSButton! 102 | @IBOutlet weak var contextMenuActionSourceContent: NSButton! 103 | 104 | @IBOutlet weak var fileSaveMenuItem: NSMenuItem! 105 | 106 | var textFieldValueBeforeEdit: String? 107 | var confirmedExit: Bool = false 108 | 109 | func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 110 | return true 111 | } 112 | 113 | func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply { 114 | if confirmSaveBeforeExit() { 115 | return .terminateNow 116 | } 117 | else { 118 | return .terminateCancel 119 | } 120 | } 121 | 122 | func applicationDidFinishLaunching(_ aNotification: Notification) { 123 | 124 | actionContentView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular) 125 | actionContentView.isAutomaticQuoteSubstitutionEnabled = false 126 | actionContentView.isAutomaticDashSubstitutionEnabled = false 127 | actionContentView.isRichText = false 128 | 129 | contextMenuActionTypeComboBox.removeAllItems() 130 | contextMenuActionTypeComboBox.addItems(withObjectValues: Menu.validActions) 131 | 132 | contextMenuActionSourceContent.wantsLayer = true 133 | contextMenuActionSourceContent.layer?.borderWidth = 0 134 | contextMenuActionSourceContent.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor 135 | 136 | var config = ConfigManager.loadConfigAsArray(includeSystemWide: false) 137 | if config.isEmpty { 138 | config = ConfigManager.generateDefault() 139 | setConfigDirty(isDirty: true) 140 | } 141 | else { 142 | setConfigDirty(isDirty: false) 143 | } 144 | configArrayController.content = config 145 | 146 | menuObjectController.content = nil 147 | contextMenuRemoveButton.isEnabled = false 148 | 149 | assignContextMenu(menu: nil) 150 | 151 | // Show "Extensions Preference" if FinderEx is not enabled yet 152 | if !FIFinderSyncController.isExtensionEnabled { 153 | FIFinderSyncController.showExtensionManagementInterface() 154 | } 155 | } 156 | } 157 | 158 | extension AppDelegate: NSWindowDelegate { 159 | 160 | // Give user chance to save config before exit 161 | // Returns true to continue exiting, false to cancel 162 | func confirmSaveBeforeExit() -> Bool { 163 | 164 | if confirmedExit { 165 | return true 166 | } 167 | 168 | if !fileSaveMenuItem.isEnabled { 169 | return true 170 | } 171 | 172 | let alert = NSAlert() 173 | alert.messageText = "You may have unsaved changes!" 174 | alert.informativeText = "Do you want to save it before exiting?" 175 | alert.addButton(withTitle: "Save") 176 | alert.addButton(withTitle: "Quit without saving") 177 | alert.addButton(withTitle: "Cancel") 178 | alert.alertStyle = .warning 179 | let modalResponse = alert.runModal() 180 | if (modalResponse == NSApplication.ModalResponse.alertFirstButtonReturn) { 181 | fileSaveAction(self) 182 | confirmedExit = true 183 | return true 184 | } else if (modalResponse == NSApplication.ModalResponse.alertSecondButtonReturn) { 185 | confirmedExit = true 186 | return true 187 | } 188 | else { 189 | return false 190 | } 191 | } 192 | 193 | func windowShouldClose(_ sender: NSWindow) -> Bool { 194 | return confirmSaveBeforeExit() 195 | } 196 | } 197 | 198 | // Configuration editor and controller 199 | extension AppDelegate { 200 | 201 | func currentConfig() -> ConfigItem? { 202 | let config = configArrayController.content as! [ConfigItem] 203 | if configTableView.selectedRow == -1 { 204 | return nil 205 | } 206 | return config[configTableView.selectedRow] 207 | } 208 | 209 | @IBAction func modifyConfigArray(_ sender: Any) { 210 | var config = configArrayController.content as! [ConfigItem] 211 | switch modifyConfigArrayButtons.selectedSegment { 212 | case 0: 213 | let newconfig = ConfigItem(name: defaultCategory, type: "", ext: "", allowedit: true) 214 | config.append(newconfig) 215 | setConfigDirty(isDirty: true) 216 | case 1: 217 | if configTableView.selectedRow == -1 { 218 | return 219 | } 220 | if config[configTableView.selectedRow].allowedit { 221 | config.remove(at: configTableView.selectedRow) 222 | setConfigDirty(isDirty: true) 223 | } 224 | default: 225 | break 226 | } 227 | configArrayController.content = config 228 | populateContextMenu() 229 | } 230 | 231 | @IBAction func configTextFieldCategoryAction(_ sender: Any) { 232 | guard let textField = sender as? NSTextField else { 233 | return 234 | } 235 | var trimmedValue = textField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines) 236 | if trimmedValue.isEmpty { 237 | if let t = textFieldValueBeforeEdit { 238 | trimmedValue = t 239 | } 240 | else { 241 | trimmedValue = defaultCategory 242 | } 243 | } 244 | textField.stringValue = trimmedValue 245 | self.populateContextMenu() 246 | setConfigDirty(isDirty: true) 247 | } 248 | 249 | @IBAction func configTextFieldExtAction(_ sender: Any) { 250 | self.populateContextMenu() 251 | setConfigDirty(isDirty: true) 252 | } 253 | } 254 | 255 | // Context menu editor and controller 256 | extension AppDelegate: NSTextViewDelegate, NSMenuDelegate { 257 | 258 | func menuWillOpen(_ menu: NSMenu) { 259 | if menu == contextMenu { 260 | 261 | // Allow if not triggered from config table view 262 | if configTableView.clickedRow == -1 { return } 263 | 264 | // Allow if (right) clicked row is the currently selected row 265 | if (configTableView.clickedRow == configTableView.selectedRow) { return } 266 | 267 | // Disallow by cancelling menu opening 268 | menu.cancelTrackingWithoutAnimation() 269 | } 270 | } 271 | 272 | func assignContextMenu(menu: NSMenu?) { 273 | configTestBox.menu = menu 274 | configTableView.menu = menu 275 | } 276 | 277 | func populateContextMenu() { 278 | 279 | if let config = currentConfig() { 280 | 281 | // Remove everything but the last one 282 | if contextMenu.items.count > 1 { 283 | for _ in 1...(contextMenu.items.count-1) { 284 | contextMenu.removeItem(at: 0) 285 | } 286 | } 287 | 288 | // Add relevant items 289 | var i : Int = 0 290 | for menu in config.menus { 291 | if menu.valid() { 292 | let menuitem = contextMenu.insertItem(withTitle: menu.title!, action: #selector(AppDelegate.contextMenuUserItemAction(sender:)), keyEquivalent: "", at: i) 293 | menuitem.target = self 294 | i += 1 295 | } 296 | } 297 | 298 | // Add separator if there was at least one menu item 299 | if i > 0 { 300 | let separator = NSMenuItem.separator() 301 | contextMenu.insertItem(separator, at: i) 302 | } 303 | 304 | assignContextMenu(menu: contextMenu) 305 | } 306 | else { 307 | assignContextMenu(menu: nil) 308 | } 309 | } 310 | 311 | @objc func contextMenuUserItemAction(sender: NSMenuItem) { 312 | let i = sender.menu?.index(of: sender) 313 | if let config = currentConfig() { 314 | let item = config.menus[i!] 315 | menuObjectController.content = item.startEditing() 316 | contextMenuSelectActionSource(fromfile: item.fromfile) 317 | contextMenuRemoveButton.isEnabled = true 318 | } 319 | else { 320 | menuObjectController.content = nil 321 | contextMenuRemoveButton.isEnabled = false 322 | } 323 | } 324 | 325 | @IBAction func contextMenuAddItemAction(_ sender: NSMenuItem) { 326 | NSLog("add menu item") 327 | if let config = currentConfig() { 328 | let newitem = Menu(title: defaultMenuTitle, action: "bash", path: "", content: "", askfolder: false, fromfile: false) 329 | config.menus.append(newitem) 330 | menuObjectController.content = newitem.startEditing() 331 | contextMenuSelectActionSource(fromfile: newitem.fromfile) 332 | populateContextMenu() 333 | setConfigDirty(isDirty: true) 334 | contextMenuRemoveButton.isEnabled = true 335 | } 336 | } 337 | 338 | @IBAction func contextMenuRemoveAction(_ sender: Any) { 339 | if let m = menuObjectController.content as? Menu, let config = currentConfig() { 340 | for i in 0.. 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 433 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 647 | 648 | 649 | 650 | 651 | 652 | 664 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | type 702 | ext 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | -------------------------------------------------------------------------------- /FinderEx/ConfigManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConfigManager.swift 3 | // FinderEx 4 | // 5 | // Created by Yanto Suryono on 2021/12/24. 6 | // 7 | 8 | import Cocoa 9 | import Yaml 10 | 11 | extension StringProtocol { 12 | var lines: [SubSequence] { 13 | split(omittingEmptySubsequences: false, whereSeparator: \.isNewline) 14 | } 15 | } 16 | 17 | class Menu: NSObject { 18 | 19 | @objc dynamic var title: String? 20 | @objc dynamic var action: String? 21 | @objc dynamic var path: String? 22 | @objc dynamic var content: String? 23 | @objc dynamic var askfolder: Bool 24 | @objc dynamic var fromfile: Bool 25 | 26 | static let validActions = ["applescript", "bash", "workflow"] 27 | 28 | var initTitle: String? 29 | var initAction: String? 30 | var initPath: String? 31 | var initContent: String? 32 | var initAskFolder: Bool = false 33 | var initFromFile: Bool = false 34 | 35 | init(title: String?, action: String?, path: String?, content: String?, askfolder: Bool?, fromfile: Bool?) { 36 | self.title = title 37 | self.action = action 38 | self.path = path 39 | self.content = content 40 | self.askfolder = askfolder ?? false 41 | self.fromfile = fromfile ?? false 42 | } 43 | 44 | func valid() -> Bool { 45 | return ( 46 | self.title != nil && 47 | self.action != nil && 48 | ( 49 | (self.fromfile && self.path != nil) || 50 | (!self.fromfile && self.content != nil) 51 | ) && 52 | Self.validActions.contains(self.action!) 53 | ) 54 | } 55 | } 56 | 57 | class ConfigItem: NSObject { 58 | 59 | @objc dynamic var name: String 60 | @objc dynamic var type: String 61 | @objc dynamic var ext: String 62 | @objc dynamic var allowedit: Bool 63 | 64 | var menus: [Menu] = [] 65 | 66 | init(name: String, type: String, ext: String, allowedit: Bool) { 67 | self.name = name 68 | self.type = type 69 | self.ext = ext 70 | self.allowedit = allowedit 71 | } 72 | 73 | init(name: String, type: String, ext: String) { 74 | self.name = name 75 | self.type = type 76 | self.ext = ext 77 | self.allowedit = true 78 | } 79 | 80 | func isMember(path: String) -> Bool { 81 | for i in extensions { 82 | if path.hasSuffix(i) { 83 | return true 84 | } 85 | } 86 | return false 87 | } 88 | 89 | var extensions: [String] { 90 | get { 91 | return ext.split(separator: ";", omittingEmptySubsequences: true) 92 | .map { 93 | String($0).trimmingCharacters(in: .whitespacesAndNewlines) 94 | } 95 | .filter { 96 | !$0.isEmpty 97 | } 98 | } 99 | } 100 | } 101 | 102 | class ConfigManager: NSObject { 103 | 104 | static func loadConfig(includeSystemWide: Bool) -> [Yaml] { 105 | 106 | var systemNodes: Yaml? 107 | var userNodes: Yaml? 108 | 109 | func loadConfigFromFile(user: Bool) -> Yaml? { 110 | var nodes: Yaml? 111 | if let yaml = XPCWrapper.loadConfig(user: user) { 112 | nodes = try! Yaml.load(yaml) 113 | if nodes == Yaml.null { 114 | nodes = nil 115 | } 116 | } 117 | return nodes 118 | } 119 | 120 | if includeSystemWide { 121 | systemNodes = loadConfigFromFile(user: false) 122 | } 123 | userNodes = loadConfigFromFile(user: true) 124 | 125 | var nodes: [Yaml] = [] 126 | 127 | // combine system and user nodes 128 | if systemNodes != nil { 129 | for n in systemNodes!.array! { 130 | nodes.append(n) 131 | } 132 | } 133 | if userNodes != nil { 134 | for n in userNodes!.array! { 135 | nodes.append(n) 136 | } 137 | } 138 | 139 | return nodes 140 | } 141 | 142 | static private func nodeAsArray(node: [Yaml]) -> [ConfigItem] { 143 | 144 | var configArray: [ConfigItem] = [] 145 | 146 | for n in node { 147 | let item = ConfigItem( 148 | name: n["name"].string!, 149 | type: n["type"].string ?? "", 150 | ext: n["ext"].string ?? "") 151 | item.allowedit = n["allowedit"].bool ?? true 152 | if let menus = n["menus"].array { 153 | for menu in menus { 154 | item.menus.append(Menu( 155 | title: menu["title"].string, 156 | action: menu["action"].string, 157 | path: menu["path"].string, 158 | content: menu["content"].string, 159 | askfolder: menu["askfolder"].bool, 160 | fromfile: menu["fromfile"].bool 161 | )) 162 | } 163 | } 164 | configArray.append(item) 165 | } 166 | 167 | return configArray 168 | } 169 | 170 | static func loadConfigAsArray(includeSystemWide: Bool) -> [ConfigItem] { 171 | 172 | let node = Self.loadConfig(includeSystemWide: includeSystemWide) 173 | return Self.nodeAsArray(node: node) 174 | } 175 | 176 | static func generateDefault() -> [ConfigItem] { 177 | 178 | let yaml = """ 179 | - name: "Container" 180 | type: c 181 | allowedit: false 182 | - name: "All Items" 183 | type: a 184 | allowedit: false 185 | menus: 186 | - title: "Show Selected Items ..." 187 | action: applescript 188 | content: | 189 | on run argv 190 | set theText to "" 191 | repeat with theArg in argv 192 | set theText to (theText & theArg & "\\n") 193 | end repeat 194 | display dialog theText 195 | end run 196 | 197 | - name: "Folders" 198 | type: d 199 | allowedit: false 200 | - name: "Files" 201 | type: f 202 | allowedit: false 203 | - name: "Image Files" 204 | ext: ".png;.gif;.jpg;.jpeg" 205 | """ 206 | print(yaml) 207 | var node: [Yaml] = [] 208 | for n in (try! Yaml.load(yaml)).array! { 209 | node.append(n) 210 | } 211 | return Self.nodeAsArray(node: node) 212 | } 213 | 214 | @discardableResult static func saveConfigFromArray(configArray: [ConfigItem]?) -> Bool { 215 | 216 | var content: String = "" 217 | 218 | func appendLine(str: String, indent: Int) { 219 | content += (String(repeating: " ", count: indent*2) + str + "\n") 220 | } 221 | 222 | if let config = configArray { 223 | for item in config { 224 | appendLine(str:String(format:"- name: \"%@\"", item.name), indent:0) 225 | if item.type != "" { // default is blank 226 | appendLine(str:String(format:" type: %@", item.type), indent:0) 227 | } 228 | if item.ext != "" { // default is blank 229 | appendLine(str:String(format:" ext: \"%@\"", item.ext), indent:0) 230 | } 231 | if !item.allowedit { // default is true 232 | appendLine(str:" allowedit: false", indent:0) 233 | } 234 | if item.menus.count > 0 { 235 | var first: Bool = true 236 | for menu in item.menus { 237 | if let title = menu.title, let action = menu.action, let content = menu.content { 238 | if first { 239 | appendLine(str:" menus:", indent:0) 240 | first = false 241 | } 242 | appendLine(str:String(format:"- title: \"%@\"", title), indent: 2) 243 | appendLine(str:String(format:" action: %@", action), indent: 2) 244 | if menu.askfolder { // default is false 245 | appendLine(str:" askfolder: true", indent: 2) 246 | } 247 | if menu.fromfile { // default is false 248 | appendLine(str:" fromfile: true", indent: 2) 249 | if let path = menu.path { 250 | appendLine(str:String(format:" path: \"%@\"", path), indent: 2) 251 | } 252 | } 253 | appendLine(str:" content: |", indent: 2) 254 | for line in content.lines { 255 | appendLine(str:String(line), indent: 4) 256 | } 257 | } 258 | } 259 | } 260 | } 261 | if let res = XPCWrapper.saveConfig(content: content) { 262 | return res 263 | } 264 | } 265 | return false 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /FinderEx/FinderEx.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FinderEx/XPCWrapper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XPCWrapper.swift 3 | // FinderEx 4 | // 5 | // Created by Yanto Suryono on 2021/12/31. 6 | // 7 | 8 | import Foundation 9 | 10 | class XPCWrapper { 11 | 12 | static let XPCProtocol: Protocol = FinderExHelperProtocol.self 13 | static let serviceName = "app.yantoz.FinderEx.Helper" 14 | static let connection: NSXPCConnection = XPCWrapper.initConnection() 15 | 16 | static func initConnection() -> NSXPCConnection { 17 | let connection = NSXPCConnection(serviceName: XPCWrapper.serviceName) 18 | connection.remoteObjectInterface = NSXPCInterface(with: FinderExHelperProtocol.self) 19 | connection.resume() 20 | return connection 21 | } 22 | 23 | static func initSettings(connection: NSXPCConnection) -> FinderExHelperProtocol? { 24 | let service = connection.synchronousRemoteObjectProxyWithErrorHandler { error in 25 | NSLog("\(XPCWrapper.serviceName) error: %@", error.localizedDescription) 26 | print("Error establishing XPC connection:", error) 27 | } as? FinderExHelperProtocol 28 | return service 29 | } 30 | 31 | static let service: FinderExHelperProtocol? = XPCWrapper.initSettings(connection: XPCWrapper.connection) 32 | 33 | static func homeDir() -> String? { 34 | 35 | guard let service = Self.service else { 36 | return nil 37 | } 38 | 39 | let semaphore = DispatchSemaphore(value: 0) 40 | 41 | var ret: String? = nil 42 | service.homeDir() { data in 43 | defer { 44 | semaphore.signal() 45 | } 46 | ret = data 47 | } 48 | 49 | if !Thread.isMainThread { 50 | _ = semaphore.wait(timeout: .distantFuture) 51 | } else { 52 | while semaphore.wait(timeout: .now()) == .timedOut { 53 | RunLoop.current.run(mode: .default, before: Date(timeIntervalSinceNow: 0)) 54 | } 55 | } 56 | return ret 57 | } 58 | 59 | static func loadConfig(user: Bool) -> String? { 60 | 61 | guard let service = Self.service else { 62 | return nil 63 | } 64 | 65 | let semaphore = DispatchSemaphore(value: 0) 66 | 67 | var ret: String? = nil 68 | service.loadConfig(user: user) { data in 69 | defer { 70 | semaphore.signal() 71 | } 72 | ret = data 73 | } 74 | 75 | if !Thread.isMainThread { 76 | _ = semaphore.wait(timeout: .distantFuture) 77 | } else { 78 | while semaphore.wait(timeout: .now()) == .timedOut { 79 | RunLoop.current.run(mode: .default, before: Date(timeIntervalSinceNow: 0)) 80 | } 81 | } 82 | return ret 83 | } 84 | 85 | @discardableResult static func saveConfig(content: String) -> Bool? { 86 | 87 | guard let service = Self.service else { 88 | return nil 89 | } 90 | 91 | let semaphore = DispatchSemaphore(value: 0) 92 | 93 | var ret: Bool? = nil 94 | service.saveConfig(content: content) { data in 95 | defer { 96 | semaphore.signal() 97 | } 98 | ret = data 99 | } 100 | 101 | if !Thread.isMainThread { 102 | _ = semaphore.wait(timeout: .distantFuture) 103 | } else { 104 | while semaphore.wait(timeout: .now()) == .timedOut { 105 | RunLoop.current.run(mode: .default, before: Date(timeIntervalSinceNow: 0)) 106 | } 107 | } 108 | return ret 109 | } 110 | 111 | @discardableResult static func run(exec: String, input: String, args: [String]) -> Int32? { 112 | 113 | guard let service = Self.service else { 114 | return nil 115 | } 116 | 117 | let semaphore = DispatchSemaphore(value: 0) 118 | 119 | var ret: Int32? = nil 120 | service.run(exec: exec, input: input, args: args) { output, status in 121 | defer { 122 | semaphore.signal() 123 | } 124 | ret = status 125 | } 126 | 127 | if !Thread.isMainThread { 128 | _ = semaphore.wait(timeout: .distantFuture) 129 | } else { 130 | while semaphore.wait(timeout: .now()) == .timedOut { 131 | RunLoop.current.run(mode: .default, before: Date(timeIntervalSinceNow: 0)) 132 | } 133 | } 134 | return ret 135 | } 136 | } 137 | 138 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FinderEx 2 | MacOS Finder Sync Extension to Allow Adding Custom Actions 3 | 4 | ## Description 5 | 6 | FinderEx is a small tool to allow adding custom actios to context menu which is shown when one right clicked inside folder or folder items (folders and files). It consists of two parts: the menu items editor and the finder sync extension that adds context menu items depending on what finder items one selected and then right clicked. 7 | 8 | ## Motivation 9 | 10 | I came from Windows world, and I missed Windows Explorer's context menu to quickly apply actions on folders and files. This is my first project with Xcode and OSX, so it also serves as my playground to learn Swift, Cocoa, Interface Builder, Delegations, Controllers, FinderSync, XPC and all other Mac specific things that I was not exposed to before I joined the Mac world. 11 | 12 | It took me countless visits to Stack Overflow as Mac newbie to get experts help to make this happen, so I would like to give it back to the community by making it free and open source. 13 | 14 | ## How to Use 15 | 16 | Just clone this repository, open the Xcode project and build. 17 | 18 | FinderEx embeds FinderSync extension component, which would be installed when the program runs. It would check if the extension was enabled and if not, it would open the Preference window for you to enable it. Please do so to allow it to do its job. 19 | 20 | The main window is the menu items editor where you can define your files categories (Image files, Document files, etc.). 21 | There are several predefined categories that are created automatically and cannot be deleted. 22 | Other categories can be added and specifies group of files based on extensions (file suffixes). 23 | Several extensions can be defined for a category by joining them with semicolons. 24 | 25 | 26 | 27 | When item(s) are right clicked in Finder, all menu items from all matched categories would be added to the context menu, so at least all menu items in the "All Items" category will always be added. When a container (blank space in Finder is right clicked, only menu items from "Container" category would be added. 28 | 29 | Menu items for each category can be added/edited/deleted by selecting the category and then right clicking the category or the "Right-click Here ..." area. This would bring up the menu. Select an item to edit or delete it or select "Add New Item ..." to add new item. 30 | 31 | 32 | 33 | 34 | Each menu item, when selected, can be defined to do action that you choose: run an Applescript, a Bash script or an Automator workflow. 35 | They would get selected items' path as their input, as arguments to Applescripts and Bash scripts and as standard input to Automator workflows. 36 | Applescripts and Bash scripts can be written directly in the editor so you do not have to create and store script files, although you can do so as well. Automator workflows need to be pre-created, and you need to tell FinderEx which .wflow file to launch. 37 | 38 | 39 | 40 | FinderEx editor loads and saves configuration as YAML file in ~/Library/FinderEx/config.yaml but the FinderSync extension loads configurations from both /Library/FinderEx/config.yaml (system wide) and ~/Library/FinderEx/config.yaml (user specific), so you can create system wide configuration available for all users as well as one for yourself. 41 | 42 | ## Disclaimer 43 | 44 | This software is free but comes without warranty in any form. 45 | I shall not be liable for any damage that it may cause to your computer, storage, life, whatever, especially if you write scripts that do dangerous things. 46 | That said, I hope this software could be useful and boost your productivity, as it is for me. 47 | 48 | --------------------------------------------------------------------------------