Skip to content

Add duration menu for caffeine sessions (15m/30m/1h/indefinite)#7

Open
AuthenticSm1les wants to merge 1 commit into
codevardhan:mainfrom
AuthenticSm1les:add-duration-menu
Open

Add duration menu for caffeine sessions (15m/30m/1h/indefinite)#7
AuthenticSm1les wants to merge 1 commit into
codevardhan:mainfrom
AuthenticSm1les:add-duration-menu

Conversation

@AuthenticSm1les

Copy link
Copy Markdown

Closes #6.

Replaces the plain on/off toggle with a popup menu (opened via on_press_with_rectangle + the applet's app_popup surface action) offering:

  • 15 minutes
  • 30 minutes
  • 1 hour
  • Indefinitely (previous behavior)

Picking a timed option acquires the inhibit lock as before and sets a deadline (Instant). A subscription ticks every second while a deadline is pending and releases the lock automatically once it's reached. Picking a new option while a session is already running just updates the deadline instead of re-acquiring the lock; a "Turn off" entry is shown in the menu whenever a session is active.

Selected option is check-marked in the menu for quick visual feedback.

Testing

  • cargo check — clean, no warnings.
  • Not runtime-tested against an actual COSMIC/wayland session (no compositor available in this environment) — would appreciate a manual smoke test of the popup positioning/timer before merge.

Follow-up (not in this PR)

The issue's "nice to have" — showing remaining time in the applet's tooltip/label — isn't implemented here; happy to add it as a follow-up if wanted.

Replaces the plain on/off toggle with a popup menu offering 15
minutes, 30 minutes, 1 hour, and indefinite options. Timed sessions
auto-release the inhibit lock via a 1s subscription tick that checks
against a stored deadline; picking a new duration while active resets
the timer instead of re-acquiring the lock.

Closes codevardhan#6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: menu to enable caffeine for a set duration (15m/30m/1h/indefinite)

1 participant