Added: Captured Windows Inside Profile State File
This commit is contained in:
@@ -235,9 +235,39 @@ function selector.showLayoutActions(layoutName)
|
|||||||
text = "🗑️ Delete Layout Profile",
|
text = "🗑️ Delete Layout Profile",
|
||||||
subText = "Permanently remove the profile config file from disk",
|
subText = "Permanently remove the profile config file from disk",
|
||||||
action = "delete"
|
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
|
if selector.actionChooser then selector.actionChooser:hide() end
|
||||||
|
|
||||||
selector.actionChooser = hs.chooser.new(function(choice)
|
selector.actionChooser = hs.chooser.new(function(choice)
|
||||||
|
|||||||
@@ -358,6 +358,7 @@ function obj.showMenu()
|
|||||||
local min = math.floor(obj.saveCountdown / 60)
|
local min = math.floor(obj.saveCountdown / 60)
|
||||||
local sec = obj.saveCountdown % 60
|
local sec = obj.saveCountdown % 60
|
||||||
|
|
||||||
|
-- 1. Base Core Operational Rows
|
||||||
local choices = {
|
local choices = {
|
||||||
{
|
{
|
||||||
text = string.format("⏱️ Next Autosave: %d:%02d", min, sec),
|
text = string.format("⏱️ Next Autosave: %d:%02d", min, sec),
|
||||||
@@ -378,9 +379,39 @@ function obj.showMenu()
|
|||||||
text = "🚀 Rescue Windows",
|
text = "🚀 Rescue Windows",
|
||||||
subText = "Cascade active window threads onto primary laptop screen space",
|
subText = "Cascade active window threads onto primary laptop screen space",
|
||||||
action = "rescue"
|
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
|
if obj.instanceChooser then obj.instanceChooser:hide() end
|
||||||
|
|
||||||
obj.instanceChooser = hs.chooser.new(function(choice)
|
obj.instanceChooser = hs.chooser.new(function(choice)
|
||||||
|
|||||||
Reference in New Issue
Block a user