Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
194029d713 | ||
|
|
62266e366e |
No files matched your search
@@ -179,7 +179,7 @@ Right-click the break timer widget in Waybar to access the context menu:
|
||||
- **Snooze**: Hide overdue breaks for 5 minutes (configurable). Does nothing if no break is due. Snoozing again restarts the 5 minutes, a break that comes due during the snooze also waits, and taking a break ends the snooze. The timers keep counting, so when the snooze ends the widget shows the true overdue amount. The icon changes to 💤 while snoozed.
|
||||
- **Toggle Reading Mode**: For reading or watching without touching the computer. While on:
|
||||
- Hands-off time counts as work instead of a break
|
||||
- Breaks only start from **Start Break**, and end on input or once the due break's length has passed
|
||||
- Breaks only start from **Start Break**, and end on input
|
||||
- The widget icon changes to 📖 (via `format-icons`)
|
||||
- **Skip Long Break**: Reset all timers (useful if you just returned from a break not tracked by the timer)
|
||||
- **Toggle Pause**: Pause or unpause the timer. While paused:
|
||||
|
||||
+6
-5
@@ -8,7 +8,7 @@ qualifying break periods to keep log small.
|
||||
|
||||
In reading mode (a "reading" flag file next to the log), automatic idle is
|
||||
ignored so hands-off reading counts as work. Breaks are started from the menu
|
||||
with start-break and end on input or after the due break's length.
|
||||
with start-break and end on input.
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -172,13 +172,14 @@ def is_paused(events: Events) -> bool:
|
||||
|
||||
|
||||
def in_break(events: Events) -> bool:
|
||||
"""Whether the last idle-related event started a break"""
|
||||
"""Whether the last idle-related event started a break. With none (e.g.
|
||||
after skip_long) there is no work period yet, so idle_end must be logged."""
|
||||
for _, event_type in reversed(events):
|
||||
if event_type in ("idle_start", "reading_break"):
|
||||
if event_type == "idle_start":
|
||||
return True
|
||||
if event_type == "idle_end":
|
||||
return False
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
COMMANDS = ("idle_start", "idle_end", "sleep", "wake", "start-break", "snooze",
|
||||
@@ -224,7 +225,7 @@ def main():
|
||||
elif not is_paused(events): # Don't log idle events when paused
|
||||
reading = reading_path.exists()
|
||||
if event_type == "start-break":
|
||||
logged = "reading_break" if reading else "idle_start"
|
||||
logged = "idle_start"
|
||||
elif event_type == "snooze":
|
||||
logged = "snoozed"
|
||||
elif event_type in ("sleep", "wake"):
|
||||
|
||||
+4
-24
@@ -157,7 +157,7 @@ def calculate_status(events: Events, config: Config) -> Status:
|
||||
active_time_since_long_break = 0
|
||||
|
||||
pause_events = [e for e in events if e[1] in ("paused", "unpaused")]
|
||||
idle_events = [e for e in events if e[1] in ("idle_start", "idle_end", "reading_break", "snoozed")]
|
||||
idle_events = [e for e in events if e[1] in ("idle_start", "idle_end", "snoozed")]
|
||||
snooze_until = None
|
||||
|
||||
# Helper to calculate paused time within a range
|
||||
@@ -200,21 +200,11 @@ def calculate_status(events: Events, config: Config) -> Status:
|
||||
snooze_until = None # Taking a break uses up the snooze
|
||||
|
||||
# Replay the log. Exactly one of active_start / idle_start_time is set once
|
||||
# the first event is seen. idle_cap is when a reading-mode break ends on
|
||||
# its own if no input arrives first.
|
||||
# the first event is seen.
|
||||
active_start = None
|
||||
idle_start_time = None
|
||||
idle_cap = None
|
||||
|
||||
def expire_cap(at: int) -> None:
|
||||
nonlocal active_start, idle_start_time, idle_cap
|
||||
if idle_cap is not None and at >= idle_cap:
|
||||
credit_break(idle_start_time, idle_cap)
|
||||
active_start, idle_start_time, idle_cap = idle_cap, None, None
|
||||
|
||||
for timestamp, event_type in idle_events:
|
||||
expire_cap(timestamp)
|
||||
|
||||
if event_type == "snoozed":
|
||||
# Only counts if a break is due; snoozing again restarts it
|
||||
pending = 0
|
||||
@@ -227,26 +217,16 @@ def calculate_status(events: Events, config: Config) -> Status:
|
||||
elif event_type == "idle_end":
|
||||
if idle_start_time is not None:
|
||||
credit_break(idle_start_time, timestamp)
|
||||
idle_start_time = idle_cap = None
|
||||
idle_start_time = None
|
||||
if active_start is None:
|
||||
active_start = timestamp
|
||||
|
||||
elif idle_start_time is not None:
|
||||
# Already on a break. Sleeping during a reading break turns it
|
||||
# into an ordinary break that lasts until input.
|
||||
if event_type == "idle_start":
|
||||
idle_cap = None
|
||||
|
||||
else:
|
||||
elif idle_start_time is None: # idle_start; ignored if already on a break
|
||||
if active_start is not None:
|
||||
add_work(active_start, timestamp)
|
||||
active_start = None
|
||||
idle_start_time = timestamp
|
||||
if event_type == "reading_break":
|
||||
long_due = active_time_since_long_break >= long_interval
|
||||
idle_cap = timestamp + (long_duration if long_due else short_duration)
|
||||
|
||||
expire_cap(current_time)
|
||||
if active_start is not None:
|
||||
add_work(active_start, current_time)
|
||||
|
||||
|
||||
Reference in new issue
Block a user