diff --git a/LayoutSelector.lua b/LayoutSelector.lua index f89008a..dbfa236 100644 --- a/LayoutSelector.lua +++ b/LayoutSelector.lua @@ -235,9 +235,39 @@ function selector.showLayoutActions(layoutName) text = "🗑️ Delete Layout Profile", subText = "Permanently remove the profile config file from disk", action = "delete" + }, + { + text = "───────────────────────────────────────────────────────", + subText = "📦 Captured Windows Inside Profile State File:", + action = "info" } } + -- Dynamically read layout profile file and append saved windows + local data = hs.json.read(path) + if data and data.windows and #data.windows > 0 then + for _, win in ipairs(data.windows) do + -- Verify if the application is currently running on the system server + local isRunning = hs.application.get(win.bundleID) or hs.application.get(win.appName) + local statusIndicator = isRunning and "🟢" or "🔴" + + local cleanTitle = (win.winTitle and win.winTitle ~= "") and win.winTitle or "Untitled Window" + if #cleanTitle > 60 then cleanTitle = string.sub(cleanTitle, 1, 57) .. "..." end + + table.insert(actionChoices, { + text = string.format("%s %s", statusIndicator, win.appName), + subText = string.format("↳ Title: \"%s\" | Bounds: %dx%d at (%d,%d)", cleanTitle, win.w, win.h, win.x, win.y), + action = "info" + }) + end + else + table.insert(actionChoices, { + text = "⚠️ No Saved Window Metrics Found", + subText = "This layout profile does not contain any captured windows.", + action = "info" + }) + end + if selector.actionChooser then selector.actionChooser:hide() end selector.actionChooser = hs.chooser.new(function(choice) diff --git a/WindowManager.lua b/WindowManager.lua index d6a8071..6149430 100644 --- a/WindowManager.lua +++ b/WindowManager.lua @@ -358,6 +358,7 @@ function obj.showMenu() local min = math.floor(obj.saveCountdown / 60) local sec = obj.saveCountdown % 60 + -- 1. Base Core Operational Rows local choices = { { text = string.format("⏱️ Next Autosave: %d:%02d", min, sec), @@ -378,9 +379,39 @@ function obj.showMenu() text = "🚀 Rescue Windows", subText = "Cascade active window threads onto primary laptop screen space", action = "rescue" + }, + { + text = "───────────────────────────────────────────────────────", + subText = "📦 Captured Windows Inside Profile State File:", + action = "info" } } + -- 2. Dynamically read layout file and append saved windows + local data = hs.json.read(obj.layoutFile) + if data and data.windows and #data.windows > 0 then + for _, win in ipairs(data.windows) do + -- Verify if the application is currently running on the system server + local isRunning = hs.application.get(win.bundleID) or hs.application.get(win.appName) + local statusIndicator = isRunning and "🟢" or "🔴" + + local cleanTitle = (win.winTitle and win.winTitle ~= "") and win.winTitle or "Untitled Window" + if #cleanTitle > 60 then cleanTitle = string.sub(cleanTitle, 1, 57) .. "..." end + + table.insert(choices, { + text = string.format("%s %s", statusIndicator, win.appName), + subText = string.format("↳ Title: \"%s\" | Bounds: %dx%d at (%d,%d)", cleanTitle, win.w, win.h, win.x, win.y), + action = "info" + }) + end + else + table.insert(choices, { + text = "⚠️ No Saved Window Metrics Found", + subText = "Run a Save operation to record your desktop layout profile context.", + action = "info" + }) + end + if obj.instanceChooser then obj.instanceChooser:hide() end obj.instanceChooser = hs.chooser.new(function(choice)