From 93f970097c1d1f3b8369c0876c1d1894af6978d5 Mon Sep 17 00:00:00 2001 From: RanXom Date: Fri, 12 Jun 2026 23:54:53 +0530 Subject: introduce struct for current status --- src/pomo/state.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pomo/state.rs b/src/pomo/state.rs index e0faa70..83e2038 100644 --- a/src/pomo/state.rs +++ b/src/pomo/state.rs @@ -100,6 +100,13 @@ fn default_auto_switch() -> bool { true } +#[derive(Serialize)] +pub struct CurrentStatus { + pub text: String, + pub tooltip: String, + pub class: String, +} + #[derive(Serialize, Deserialize, Clone)] pub struct Task { pub title: String, -- cgit v1.2.3 From e2cd4834f116b35e0a61666368d8fc93382fc38e Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 00:00:31 +0530 Subject: add current status generator --- src/pomo/mod.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index 1d6ae34..242c1df 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -1,7 +1,10 @@ pub mod state; pub mod ui; -use crate::pomo::state::{AppScreen, Config, InputMode, Pomo, SessionMode, Task}; +use crate::pomo::{ + state::{AppScreen, Config, CurrentStatus, InputMode, Pomo, SessionMode, Task}, + ui::format_duration, +}; use crossterm::{ event::{self, Event, KeyCode}, execute, @@ -12,6 +15,26 @@ use ratatui::prelude::*; use std::{fs, io, time::Duration}; impl Pomo { + pub fn current_status(&self) -> CurrentStatus { + let class = match self.mode { + SessionMode::ShortBreak => "short-break", + SessionMode::LongBreak => "long-break", + SessionMode::Work => "work", + }; + + let tooltip = match self.mode { + SessionMode::ShortBreak => "Short Break", + SessionMode::LongBreak => "Long Break", + SessionMode::Work => "Work", + }; + + CurrentStatus { + text: format_duration(self.time_remaining), + tooltip: tooltip.to_string(), + class: class.to_string(), + } + } + pub fn save(&self) -> Result<(), Box> { let config = Config { work_time_mins: self.work_time.as_secs() / 60, -- cgit v1.2.3 From 1dd93bbb49e305a3f3081ded013b46f6be43ba94 Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 00:05:35 +0530 Subject: add export status method and call it on every tick --- src/pomo/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index 242c1df..c6bd35c 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -35,6 +35,16 @@ impl Pomo { } } + pub fn export_status(&self) -> std::io::Result<()> { + let status = self.current_status(); + + let json = serde_json::to_string(&status)?; + + // TODO: write to ~/.cache/pomoru/status.json + + Ok(()) + } + pub fn save(&self) -> Result<(), Box> { let config = Config { work_time_mins: self.work_time.as_secs() / 60, @@ -88,6 +98,7 @@ impl Pomo { tokio::select! { _ = second_tick.tick() => { self.tick(); + let _ = self.export_status(); } // Tighten poll to 16ms (~60fps feel) for input responsiveness -- cgit v1.2.3 From e63f92bc607236b11fc4f1a3bdb22da22a8e00f1 Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 00:14:20 +0530 Subject: save current status to status.json --- src/pomo/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index c6bd35c..ece7e8e 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -35,12 +35,18 @@ impl Pomo { } } - pub fn export_status(&self) -> std::io::Result<()> { + pub fn export_status(&self) -> Result<(), Box> { let status = self.current_status(); let json = serde_json::to_string(&status)?; - // TODO: write to ~/.cache/pomoru/status.json + let cache_dir = ProjectDirs::from("", "", "pomoru") + .ok_or("Could not find cache directory")? + .cache_dir() + .to_path_buf(); + + fs::create_dir_all(&cache_dir)?; + fs::write(cache_dir.join("status.json"), json)?; Ok(()) } -- cgit v1.2.3 From 76862ae6496eaad52d697fa9bd236a03cfe7321f Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 00:22:51 +0530 Subject: export on status on startup and session change --- src/pomo/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index ece7e8e..22deb4a 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -98,6 +98,8 @@ impl Pomo { let mut second_tick = tokio::time::interval(Duration::from_secs(1)); + let _ = self.export_status(); + while !self.should_quit { terminal.draw(|f| ui::render(f, self))?; @@ -114,6 +116,7 @@ impl Pomo { && key.kind == event::KeyEventKind::Press { self.handle_key(key); + let _ = self.export_status(); } } } -- cgit v1.2.3 From 447ad9dc6afc9d3efb733f4f0a8688acae54f6a6 Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 00:51:47 +0530 Subject: include session info in exported status --- src/pomo/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index 22deb4a..bff80a9 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -28,8 +28,14 @@ impl Pomo { SessionMode::Work => "Work", }; + let icon = match self.mode { + SessionMode::Work => "󰄉", + SessionMode::ShortBreak => "󰾅", + SessionMode::LongBreak => "󰒲", + }; + CurrentStatus { - text: format_duration(self.time_remaining), + text: format!("{icon} {tooltip} {}", format_duration(self.time_remaining)), tooltip: tooltip.to_string(), class: class.to_string(), } -- cgit v1.2.3 From 68deb446eb9aac4812d1dfe6d9008fdd46080931 Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 00:57:35 +0530 Subject: clear status on quit --- src/pomo/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index bff80a9..d1043e8 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -57,6 +57,21 @@ impl Pomo { Ok(()) } + pub fn clear_status(&self) -> Result<(), Box> { + let cache_dir = ProjectDirs::from("", "", "pomoru") + .ok_or("Could not find cache directory")? + .cache_dir() + .to_path_buf(); + + let status_file = cache_dir.join("status.json"); + + if status_file.exists() { + fs::remove_file(status_file)?; + } + + Ok(()) + } + pub fn save(&self) -> Result<(), Box> { let config = Config { work_time_mins: self.work_time.as_secs() / 60, @@ -129,6 +144,7 @@ impl Pomo { if self.should_quit { let _ = self.save(); + let _ = self.clear_status(); } } -- cgit v1.2.3 From cfaf07e2b8e104427b6409446a6079600b264d77 Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 01:14:54 +0530 Subject: update readme --- README.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 6b90113..197ed85 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,39 @@ +
+ # pomoru A minimalist Pomodoro TUI with a task list, written in Rust. -`pomoru` is a keyboard-driven TUI application for focused work. It combines a Pomodoro timer with a small task manager so you can track what you’re working on without leaving the terminal. +![Rust](https://img.shields.io/badge/Rust-Language-orange?logo=rust) +![ratatui](https://img.shields.io/badge/ratatui-TUI-blue) +![Tokio](https://img.shields.io/badge/Tokio-Async_Runtime-green) +![AUR](https://img.shields.io/aur/version/pomoru?logo=arch-linux) +![License](https://img.shields.io/badge/License-MIT-blue) ---- +
## Features ### Timer -* Work, short break, and long break sessions -* Customizable durations -* Desktop notifications when sessions end +- Work, short break, and long break sessions +- Customizable durations +- Desktop notifications when sessions end +- Optional automatic session switching +- Manual session progression mode ### Tasks -* Add, edit, delete tasks -* Toggle completion -* Task list persists across runs +- Add, edit, delete tasks +- Toggle completion +- Task list persists across runs ### Design -* Keyboard-only interaction -* Minimalist interface -* Dynamic theming system (for Noctalia Shell users) -* Configuration saved locally +- Keyboard-only interaction +- Minimalist interface +- Dynamic theming system (for Noctalia Shell users) +- Configuration saved locally --- @@ -39,14 +47,15 @@ A minimalist Pomodoro TUI with a task list, written in Rust. ### Timer screen -| Key | Action | -| ------- | --------------------------------- | -| `space` | Start or pause timer | -| `tab` | Change session type (when paused) | -| `e` | Edit current session time | -| `r` | Reset timer | -| `t` | Open task list | -| `q` | Quit | +| Key | Action | +| ------- | ---------------------------------- | +| `space` | Start or pause timer | +| `tab` | Change session type (when paused) | +| `a` | Toggle automatic session switching | +| `e` | Edit current session time | +| `r` | Reset timer | +| `t` | Open task list | +| `q` | Quit | ### Task screen @@ -72,12 +81,12 @@ Config file location: ```text ~/.config/pomoru/config.toml -```` +``` Saved data includes: -* Work and break durations -* Task list +- Work and break durations +- Task list Example: @@ -85,6 +94,7 @@ Example: work_time_mins = 25 short_break_mins = 5 long_break_mins = 15 +auto_switch_sessions = true [[tasks]] title = "Read documentation" @@ -93,6 +103,49 @@ is_done = false --- +## Status Export + +Pomoru exports its current state to: + +```text +~/.cache/pomoru/status.json +``` + +Example: + +```json +{ + "text": "󰄉 Work 24:31", + "tooltip": "Work", + "class": "work" +} +``` + +This can be used by: + +- Waybar +- Custom status bars +- Shell scripts +- Desktop widgets + +--- + +### Waybar + +The previously stated `status.json` can be used in Waybar as follows: + +```json +"custom/pomoru": { + "exec": "cat ~/.cache/pomoru/status.json", + "return-type": "json", + "interval": 1, + "format": "{text}", + "tooltip": true +} +``` + +--- + ## Installation ### Prebuilt binary @@ -140,12 +193,12 @@ cargo install --path . ## Built with -* Rust -* ratatui -* crossterm -* tokio -* notify-rust -* serde + toml +- Rust +- ratatui +- crossterm +- tokio +- notify-rust +- serde + toml --- -- cgit v1.2.3