diff --git a/WindowManager.lua b/WindowManager.lua index 68b220d..8a14b66 100644 --- a/WindowManager.lua +++ b/WindowManager.lua @@ -30,6 +30,7 @@ if cfgData then end obj.saveInterval = 300 +obj.saveCountdown = obj.saveInterval obj.isRescued = false obj.isTransitioning = false obj.isRestoring = false @@ -227,18 +228,17 @@ end -- ========================================== -- MENUBAR & WATCHERS -- ========================================== -local saveCountdown = obj.saveInterval local timerMenu = hs.menubar.new() function updateMenu() if timerMenu then local screens = hs.screen.allScreens() - timerMenu:setTitle(string.format("๐Ÿ’  %d:%02d", math.floor(saveCountdown / 60), saveCountdown % 60)) + timerMenu:setTitle(string.format("๐Ÿ’  %d:%02d", math.floor(obj.saveCountdown / 60), obj.saveCountdown % 60)) local menuTable = { { title = "๐Ÿ“… Last Saved: " .. (obj.lastSavedTime or "Never"), disabled = true }, { title = ((#screens > 1) and "๐Ÿ–ฅ๏ธ Docked" or "๐Ÿ’ป Laptop") .. " (" .. #screens .. " Screens)", disabled = true }, { title = "-" }, - { title = "๐Ÿ“ธ Save Layout (โ‡งโŒ˜W)", fn = function() obj.saveLayout(false); saveCountdown = obj.saveInterval end }, + { title = "๐Ÿ“ธ Save Layout (โ‡งโŒ˜W)", fn = function() obj.saveLayout(false); obj.saveCountdown = obj.saveInterval end }, { title = "๐Ÿ”„ Restore Layout (โ‡งโŒ˜R)", fn = function() obj.restoreLayout() end }, { title = "๐Ÿš€ Rescue Windows (Cascade on Laptop) (โ‡งโŒ˜โŒƒL)", fn = obj.rescueWindowsToLaptop }, { title = "-" }, @@ -266,7 +266,7 @@ obj.powerWatcher = hs.caffeinate.watcher.new(function(event) if obj.autoSaveTimer then obj.autoSaveTimer:stop() end elseif event == hs.caffeinate.watcher.systemDidWake or event == hs.caffeinate.watcher.screensDidWake or event == hs.caffeinate.watcher.screensDidUnlock then log("POWER: Wake event.") - saveCountdown = obj.saveInterval + obj.saveCountdown = obj.saveInterval if obj.autoSaveTimer then obj.autoSaveTimer:start() end if obj.wakeTimer then obj.wakeTimer:stop() end @@ -289,7 +289,7 @@ obj.powerWatcher = hs.caffeinate.watcher.new(function(event) end end):start() -hs.hotkey.bind({"shift", "cmd"}, "W", function() obj.saveLayout(false); saveCountdown = obj.saveInterval end) +hs.hotkey.bind({"shift", "cmd"}, "W", function() obj.saveLayout(false); obj.saveCountdown = obj.saveInterval end) hs.hotkey.bind({"shift", "cmd"}, "R", function() obj.restoreLayout() end) hs.hotkey.bind({"shift", "cmd", "ctrl"}, "L", obj.rescueWindowsToLaptop) @@ -326,12 +326,12 @@ end):start() obj.autoSaveTimer = hs.timer.doEvery(obj.saveInterval, function() obj.saveLayout(true) - saveCountdown = obj.saveInterval + obj.saveCountdown = obj.saveInterval end) obj.clockTimer = hs.timer.doEvery(1, function() - saveCountdown = saveCountdown - 1 - if saveCountdown < 0 then saveCountdown = obj.saveInterval end + obj.saveCountdown = obj.saveCountdown - 1 + if obj.saveCountdown < 0 then obj.saveCountdown = obj.saveInterval end updateMenu() end) @@ -341,7 +341,15 @@ updateMenu() -- RAYCAST INTERACTIVE CHOOSER MENU -- ========================================== function obj.showMenu() + local min = math.floor(obj.saveCountdown / 60) + local sec = obj.saveCountdown % 60 + local choices = { + { + text = string.format("โฑ๏ธ Next Autosave: %d:%02d", min, sec), + subText = "๐Ÿ“… Last Saved Profile State: " .. obj.lastSavedTime, + action = "info" + }, { text = "๐Ÿ“ธ Save State Layout", subText = "Snapshot active positions to saved_layout.json (Resets auto-timer)", @@ -365,7 +373,7 @@ function obj.showMenu() if choice then if choice.action == "save" then obj.saveLayout(false) - saveCountdown = obj.saveInterval + obj.saveCountdown = obj.saveInterval elseif choice.action == "restore" then obj.restoreLayout() elseif choice.action == "rescue" then @@ -374,7 +382,7 @@ function obj.showMenu() end end) - obj.instanceChooser:placeholderText("Workspace Manager Actions...") + obj.instanceChooser:placeholderText("Select a background workspace operation...") obj.instanceChooser:choices(choices) obj.instanceChooser:show() end