From 805311034948ad2e3559bc4a819529c54aa89522 Mon Sep 17 00:00:00 2001 From: relikd Date: Sat, 7 Feb 2026 11:54:26 +0100 Subject: [PATCH] feat: support for .icns icons --- README.md | 2 +- src/main.swift | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9511a6a..7a0db09 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ There are a few ways to modify the menu structure: #### Menu Icon -A subdirectory can have a custom icon if the folder contains an image file named `icon.X` (where `X` is one of: `svg`, `png`, `jpg`, `jpeg`, `gif`, `ico`). +A subdirectory can have a custom icon if the folder contains an image file named `icon.X` (where `X` is one of: `svg`, `png`, `jpg`, `jpeg`, `gif`, `ico`, `icns`). #### Sort Order diff --git a/src/main.swift b/src/main.swift index cf18c12..26c4d2e 100755 --- a/src/main.swift +++ b/src/main.swift @@ -299,19 +299,18 @@ struct Entry { } func icon() -> NSImage? { - guard isDir else { - return nil - } var img: NSImage? = nil - for ext in ["svg", "png", "jpg", "jpeg", "gif", "ico"] { - let iconPath = self.url.appendingPathComponent("icon." + ext) - if FileManager.default.fileExists(atPath: iconPath.path) { - img = NSImage(contentsOf: iconPath) - break + if isDir { + for ext in ["svg", "png", "jpg", "jpeg", "gif", "ico", "icns"] { + let iconPath = self.url.appendingPathComponent("icon." + ext) + if FileManager.default.fileExists(atPath: iconPath.path) { + img = NSImage(contentsOf: iconPath) + break + } + } + if img == nil { + img = NSImage(named: NSImage.folderName) } - } - if img == nil { - img = NSImage(named: NSImage.folderName) } img?.size = NSMakeSize(16, 16) return img