From e2743903e300c4d5c9d749687167f8bf84bca232 Mon Sep 17 00:00:00 2001 From: relikd Date: Tue, 3 Feb 2026 19:25:06 +0100 Subject: [PATCH] feat: new flags inactive and ignore --- README.md | 11 ++++++++--- src/main.swift | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a018f4a..9511a6a 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ And of course, you can always write a script wrapper to call something else. 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`). + #### Sort Order By default, menu items are sorted in alphabetic order (case-insensitive). @@ -60,8 +64,9 @@ Flags are defined by adding a text snippet to the filename. These constant strings are defined: - __[txt]__: Execute the script and dump all output in a new `TextEdit` window (useful for reports or log files, etc.) -- __[verbose]__: Usually, script files are executed in the background. With this flag, a new `Terminal` window will open and show the activley running script (useful for continuous output like `top` or `netstat -w`, etc.) +- __[verbose]__: Usually, script files are executed in the background. + With this flag, a new `Terminal` window will open and show the activley running script (useful for continuous output like `top` or `netstat -w`, etc.) +- __[inactive]__: Make menu item non-clickable (will appear greyed out) +- __[ignore]__: Do not show menu item (no menu entry) -#### 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`). diff --git a/src/main.swift b/src/main.swift index f1ef486..cf18c12 100755 --- a/src/main.swift +++ b/src/main.swift @@ -53,6 +53,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { func menuNeedsUpdate(_ menu: NSMenu) { for entry in listDir(menu.title) { + if entry.action == .Ignore { + continue + } let itm = menu.addItem(withTitle: entry.title, action: nil, keyEquivalent: "") itm.representedObject = entry itm.image = entry.icon() @@ -60,7 +63,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { if entry.isDir { itm.submenu = NSMenu(title: entry.url.path) itm.submenu?.delegate = self - } else { + } else if entry.action != .Inactive { itm.action = #selector(menuItemCallback) } } @@ -248,11 +251,15 @@ enum ActionFlag { case Default case Text case Verbose + case Inactive + case Ignore static func from(_ filename: inout String) -> Self { for (key, flag) in [ "[txt]": ActionFlag.Text, "[verbose]": .Verbose, + "[inactive]": .Inactive, + "[ignore]": .Ignore, ] { if filename.contains(key) { filename = filename