05-03-26
Eye-Strain Break Enforcer Script
This Lua script for Rebind hardware input enforces regular breaks to reduce eye strain. It locks input, provides warnings, and is fully configurable via the UI.
Question
Eye-strain break enforcer: lock input every 20 minutes
Rebind AI
-- rebind: name=Eye-Strain Break Enforcer
-- rebind: description=Lock input every 20 minutes to enforce breaks
local cfg = UI.Schema({
enabled = UI.Toggle(true, { label = "Enable Break Enforcer" }),
interval = UI.Slider(20, { min = 5, max = 60, label = "Break Interval", suffix = "min" }),
break_duration = UI.Slider(30, { min = 10, max = 300, label = "Break Duration", suffix = "sec" }),
warning_time = UI.Slider(60, { min = 10, max = 300, label = "Warning Before Break", suffix = "sec" }),
})
local nextBreakTime = 0
local inBreak = false
local breakEndTime = 0
local warningShown = false
function OnStart()
nextBreakTime = System.Time() + (cfg.interval * 60 * 1000)
Log.Info("Break enforcer active. First break in " .. cfg.interval .. " minutes.")
end
function OnTick()
if not cfg.enabled then
return
end
local now = System.Time()
-- Check if we're in a break
if inBreak then
if now >= breakEndTime then
inBreak = false
warningShown = false
nextBreakTime = now + (cfg.interval * 60 * 1000)
UI.Notify("Break over! Back to work.", "success")
Log.Info("Break ended. Next break in " .. cfg.interval .. " minutes.")
end
return
end
-- Check if it's time to start a break
if now >= nextBreakTime then
inBreak = true
breakEndTime = now + (cfg.break_duration * 1000)
warningShown = false
UI.Notify("Time for a break! Look away from the screen.", "warning")
Audio.Beep()
Log.Info("Break started. Duration: " .. cfg.break_duration .. " seconds.")
return
end
-- Check if we should show a warning
local timeUntilBreak = nextBreakTime - now
local warningThreshold = cfg.warning_time * 1000
if timeUntilBreak <= warningThreshold and not warningShown then
warningShown = true
UI.Notify("Break coming in " .. math.floor(timeUntilBreak / 1000) .. " seconds!", "info")
Log.Info("Warning: break in " .. math.floor(timeUntilBreak / 1000) .. " seconds.")
end
end
function OnDown(key)
if not cfg.enabled or not inBreak then
return true
end
-- Block all input during break
return false
end
function OnUp(key)
if not cfg.enabled or not inBreak then
return true
end
-- Block all input during break
return false
end
function OnScroll(delta)
if not cfg.enabled or not inBreak then
return true
end
-- Block scroll during break
return false
end
function OnMove(dx, dy)
if not cfg.enabled or not inBreak then
return true
end
-- Block mouse movement during break
return false
end
function OnStop()
Audio.StopAll()
endHow it works
This script enforces regular breaks to reduce eye strain by:
-
Tracking break intervals – Uses
OnTick()to monitor elapsed time and schedule breaks every N minutes (default 20) -
Warning notifications – Shows an alert X seconds before the break starts (default 60 seconds), giving you time to finish what you're doing
-
Input lockdown – When a break begins,
OnDown,OnUp,OnScroll, andOnMoveall returnfalse, completely blocking keyboard, mouse, and scroll input for the break duration (default 30 seconds) -
Audible alert – Plays a system beep when the break starts to grab your attention
-
Configurable via UI:
- Enable/disable enforcement
- Break interval (5–60 minutes)
- Break duration (10–300 seconds)
- Warning threshold (10–300 seconds before break)
The script logs all state changes to the Logs tab so you can track when breaks occur.
Learn more