Save Guard

@xzenile / save-guardv1.0.0Public

Nudges you to hit Ctrl+S when your DAW has gone too long without a save.

Files

Version 1.0.0 (current)

daw-save-guard.luau2.2 KB

--[[
  rebind: min_sdk=3.15.0
  rebind: name=DAW 路 Save Guard
  rebind: version=1.0.0
  rebind: author=PLACEHOLDER
  rebind: description=Nudges you to hit Ctrl+S when your DAW has gone too long without a save.
  rebind: permissions=none
  rebind: instance=single
]]

-- Save Guard
--   Watches for Ctrl+S (Cmd+S on Mac) while a DAW is in front. After "Remind after"
--   minutes of work in a DAW with no save, a toast (and an optional beep) reminds you.
--   It never presses Ctrl+S for you, so it can't trigger a surprise Save As dialog.

local cfg = rb.ui.schema({
  remind_min = rb.ui.slider(10, { label = "Remind after", min = 3, max = 60, step = 1, suffix = " min",
    tooltip = "Minutes of DAW time without a save before the reminder.", group = "Behavior" }),
  daws = rb.ui.list({ "Ableton", "FL64", "reaper", "Studio One", "Cubase", "Bitwig", "Logic Pro" },
    { label = "DAW app names", placeholder = "part of the app's process name", group = "Behavior" }),
  sound = rb.ui.toggle(true, { label = "Play a beep", group = "Sound & strip" }),
})

local MIN = 60 * 1000
local unsavedMs = 0
local lastTick = rb.system.time()
local lastRemind = 0

local function inDaw()
  local p = string.lower(rb.system.window().process or "")
  for _, d in cfg.daws do
    if d ~= "" and string.find(p, string.lower(d), 1, true) then return true end
  end
  return false
end

-- Observer only: sees the S press, never blocks it, stores nothing.
rb.on("input_down", function(key)
  if string.upper(tostring(key)) == "S" then
    local m = rb.input.modifiers()
    if (m.ctrl or m.win) and inDaw() then
      unsavedMs = 0
      lastRemind = 0
    end
  end
end)

rb.timer.every(1000, function()
  local t = rb.system.time()
  local dt = t - lastTick
  lastTick = t
  if not inDaw() then return end
  unsavedMs += dt
  if unsavedMs >= cfg.remind_min * MIN and (lastRemind == 0 or t - lastRemind >= cfg.remind_min * MIN) then
    rb.overlay.toast(math.floor(unsavedMs / MIN) .. " minutes since your last save. Ctrl+S before the next crash.",
      { title = "Save Guard 馃捑", duration = 6000 })
    if cfg.sound then rb.audio.beep() end
    lastRemind = t
  end
end)

3 files, 4.1 KB.