From 53158d29ce73b82dfd28362c1b744ab98938d698 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 2 Jan 2025 14:54:56 -0800 Subject: created a high level overview --- lua/sleep.lua | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/lua/sleep.lua b/lua/sleep.lua index 462e6e1..d84480e 100644 --- a/lua/sleep.lua +++ b/lua/sleep.lua @@ -1,13 +1,68 @@ --- this is executed when the user invokes it through gesturing -local function foo() - mp.osd_message("Hello World!", 2) +local timer = { + minutes = 25, + active = false, + format = "%02d:%02d:%02d", -- (HH:MM:SS) + remaining = nil, + prev_state = { + timestamp = nil, + was_active = false, + }, + config_file = "sleep.json" +} + +local gesture_state = { + last_trigger_sec = 0, + trigger_count = 0, + latency = 3, -- seconds +} + +local function reinstate_tstamp() + -- call read_config and grab the exported time stamp, then seek to that position in the file +end + +local function read_config() + -- if failed, then return mock/default settings defined here +end + +local function export_time() + -- we should retrieve the current time stamp and export it to sleep.json + -- at this point, mpv should be paused or terminated. +end + +local function stop_timer() +end + +local function reset_timer() +end + +local function format_time(seconds) + -- return string format hours minutes seconds +end + +local function set_timer() + timer.minutes = read_config() or timer.minutes + timer.active = true + mp.osd_message("Timer has been set for " .. timer.minutes .. " minutes.", 3) +end + +local function display_time() +end + +-- user calls this +local function handle_gesture() + mp.osd_message("Gesture Received.", 3) + set_timer() + + -- the firs time handle_gestures() is called, timer should be set + -- if handle_gestures() is called a second time within a short period, then we should cycle timer off + -- if handle_gestures() is called again a third time within a short period, then we should reinstate the last time export + -- should include debouncing logic for clean gesture input (eg. ignore calls made within some tiny time before each other) end --- this is called immediately upon opening a file -local function init() - mp.msg.info("Sleep timer script initialized") +-- called immediately upon opening a media file +function main() mp.osd_message("Sleep timer script initialized!", 3) end -mp.add_key_binding(nil, "sleep", foo) -init() +mp.add_key_binding(nil, "sleep", handle_gesture) -- the user invokes this by gesturing (user-set in input.conf) +main() -- this is run upon opening a media file -- cgit v1.2.3