3 Commits

Author SHA1 Message Date
jk
4e700691ba update justfile 2025-02-26 11:42:30 +01:00
jk
c29f8c5d1b update README 2025-02-26 11:42:03 +01:00
jk
ad11ff2c48 prepare v1.2.0 2025-02-26 11:41:38 +01:00
9 changed files with 65 additions and 107 deletions

View File

@@ -1,18 +1,5 @@
# Changelog # Changelog
## [Unreleased]
### Fixes
- (countdown) Reset `Mission Elapsed Time (MET)` if `countdown` is set by _cli arguments_ [#71](https://github.com/sectore/timr-tui/pull/71)
- (countdown) Reset `Mission Elapsed Time (MET)` while setting `countdown` by _local time_ [#72](https://github.com/sectore/timr-tui/pull/72)
### Misc.
- (deps) Use latest `Rust 1.86` [#73](https://github.com/sectore/timr-tui/pull/73)
- (cargo) Exclude files for packaging [e7a5a1b](https://github.com/sectore/timr-tui/commit/e7a5a1b2da7a7967f2602a0b92f391ac768ca638)
- (just) `group` commands [#70](https://github.com/sectore/timr-tui/pull/70)
## v1.2.0 - 2025-02-26 ## v1.2.0 - 2025-02-26
### Features ### Features
@@ -28,6 +15,7 @@
- (extension) Use `set_panic_hook` for better error handling [#67](https://github.com/sectore/timr-tui/pull/67) - (extension) Use `set_panic_hook` for better error handling [#67](https://github.com/sectore/timr-tui/pull/67)
- (deps) Use latest `Rust 1.85` and `Rust 2024 Edition`. Refactor `flake` to consider `rust-toolchain.toml` etc. [#68](https://github.com/sectore/timr-tui/pull/68) - (deps) Use latest `Rust 1.85` and `Rust 2024 Edition`. Refactor `flake` to consider `rust-toolchain.toml` etc. [#68](https://github.com/sectore/timr-tui/pull/68)
## v1.1.0 - 2025-01-22 ## v1.1.0 - 2025-01-22
### Features ### Features

View File

@@ -4,14 +4,13 @@ version = "1.2.0"
description = "TUI to organize your time: Pomodoro, Countdown, Timer." description = "TUI to organize your time: Pomodoro, Countdown, Timer."
edition = "2024" edition = "2024"
# Reminder: Always keep `channel` in `rust-toolchain.toml` in sync with `rust-version`. # Reminder: Always keep `channel` in `rust-toolchain.toml` in sync with `rust-version`.
rust-version = "1.86.0" rust-version = "1.85.0"
homepage = "https://github.com/sectore/timr-tui" homepage = "https://github.com/sectore/timr-tui"
repository = "https://github.com/sectore/timr-tui" repository = "https://github.com/sectore/timr-tui"
readme = "README.md" readme = "README.md"
license = "MIT" license = "MIT"
keywords = ["tui", "timer", "countdown", "pomodoro"] keywords = ["tui", "timer", "countdown", "pomodoro"]
categories = ["command-line-utilities"] categories = ["command-line-utilities"]
exclude = [".github/*", "demo/*.tape", "result/*", "*.mp3"]
[dependencies] [dependencies]
ratatui = "0.29.0" ratatui = "0.29.0"
@@ -36,6 +35,5 @@ rodio = { version = "0.20.1", features = [
], default-features = false, optional = true } ], default-features = false, optional = true }
thiserror = { version = "2.0.11", optional = true } thiserror = { version = "2.0.11", optional = true }
[features] [features]
sound = ["dep:rodio", "dep:thiserror"] sound = ["dep:rodio", "dep:thiserror"]

View File

@@ -48,7 +48,7 @@ _Side note:_ Theme colors depend on your terminal preferences.
<img alt="menu" src="demo/menu.gif" /> <img alt="menu" src="demo/menu.gif" />
</a> </a>
## Local time (footer) ## Local time
<a href="demo/local-time.gif"> <a href="demo/local-time.gif">
<img alt="menu" src="demo/local-time.gif" /> <img alt="menu" src="demo/local-time.gif" />
@@ -80,7 +80,6 @@ Options:
--blink <BLINK> Toggle blink mode to animate a clock when it reaches its finished mode. [possible values: on, off] --blink <BLINK> Toggle blink mode to animate a clock when it reaches its finished mode. [possible values: on, off]
--log [<LOG>] Directory to store log file. If not set, standard application log directory is used (check README for details). --log [<LOG>] Directory to store log file. If not set, standard application log directory is used (check README for details).
-h, --help Print help -h, --help Print help
-V, --version Print version
``` ```
Extra option (if `--features sound` is enabled by local build only): Extra option (if `--features sound` is enabled by local build only):
@@ -89,6 +88,7 @@ Extra option (if `--features sound` is enabled by local build only):
--sound <SOUND> Path to sound file (.mp3 or .wav) to play as notification. Experimental. --sound <SOUND> Path to sound file (.mp3 or .wav) to play as notification. Experimental.
``` ```
# Installation # Installation
## Cargo ## Cargo
@@ -113,10 +113,12 @@ Install [from the AUR](https://aur.archlinux.org/packages/timr/):
paru -S timr paru -S timr
``` ```
## Release binaries ## Release binaries
Pre-built artifacts are available to download from [latest GitHub release](https://github.com/sectore/timr-tui/releases). Pre-built artifacts are available to download from [latest GitHub release](https://github.com/sectore/timr-tui/releases).
# Development # Development
## Requirements ## Requirements
@@ -127,6 +129,7 @@ Pre-built artifacts are available to download from [latest GitHub release](https
If you have [`direnv`](https://direnv.net) installed, run `direnv allow` once to install dependencies. In other case run `nix develop`. If you have [`direnv`](https://direnv.net) installed, run `direnv allow` once to install dependencies. In other case run `nix develop`.
### Non Nix users ### Non Nix users
- [`Rust`](https://www.rust-lang.org/learn/get-started) - [`Rust`](https://www.rust-lang.org/learn/get-started)
@@ -140,12 +143,8 @@ If you have [`direnv`](https://direnv.net) installed, run `direnv allow` once to
just just
Available recipes: Available recipes:
default # list commands
[build]
build # build app [alias: b] build # build app [alias: b]
default # list commands
[demo]
demo-blink # build demo: blink animation [alias: db] demo-blink # build demo: blink animation [alias: db]
demo-countdown # build demo: countdown [alias: dc] demo-countdown # build demo: countdown [alias: dc]
demo-countdown-met # build demo: countdown + met [alias: dcm] demo-countdown-met # build demo: countdown + met [alias: dcm]
@@ -156,25 +155,16 @@ Available recipes:
demo-rocket-countdown # build demo: rocket countdown [alias: drc] demo-rocket-countdown # build demo: rocket countdown [alias: drc]
demo-style # build demo: styles [alias: ds] demo-style # build demo: styles [alias: ds]
demo-timer # build demo: timer [alias: dt] demo-timer # build demo: timer [alias: dt]
[dev]
run # run app [alias: r]
run-args args # run app with arguments. It expects arguments as a string (e.g. "-c 5:00"). [alias: ra]
run-sound path # run app while sound feature is enabled. It expects a path to a sound file. [alias: rs]
run-sound-args path args # run app while sound feature is enabled by adding a path to a sound file and other arguments as string (e.g. "-c 5:00"). [alias: rsa]
[misc]
format # format files [alias: f] format # format files [alias: f]
lint # lint [alias: l] lint # lint [alias: l]
run # run app [alias: r]
[test] run-sound path # run app while sound feature is enabled. It expects a path to a sound file. [alias: rs]
test # run tests [alias: t] test # run tests [alias: t]
``` ```
### Build ### Build
- Linux - Linux
```sh ```sh
nix build nix build
# or for bulding w/ statically linked binaries # or for bulding w/ statically linked binaries
@@ -182,17 +172,10 @@ nix build .#linuxStatic
``` ```
- Windows (cross-compilation) - Windows (cross-compilation)
```sh ```sh
nix build .#windows nix build .#windows
``` ```
### Run tests
```sh
cargo test
```
# Misc. # Misc.
## Persistant app state ## Persistant app state

24
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": { "nodes": {
"crane": { "crane": {
"locked": { "locked": {
"lastModified": 1744386647, "lastModified": 1739936662,
"narHash": "sha256-DXwQEJllxpYeVOiSlBhQuGjfvkoGHTtILLYO2FvcyzQ=", "narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "d02c1cdd7ec539699aa44e6ff912e15535969803", "rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -23,11 +23,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1744231114, "lastModified": 1740378829,
"narHash": "sha256-60gLl2rJFt6SRwqWimsTAeHgfsIE1iV0zChdJFOvx8w=", "narHash": "sha256-cwmm7F73aQFJY6YN1roNibNKwxT6FlfXkG3MEbpSp7Q=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "0ccfe532b1433da8e5a23cd513ff6847e0f6a8c2", "rev": "92823f1b0c919d7e2d806956aaf98e90f3761ab7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -56,11 +56,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1744463964, "lastModified": 1740367490,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=", "narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650", "rev": "0196c0175e9191c474c26ab5548db27ef5d34b05",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -81,11 +81,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1742296961, "lastModified": 1740329432,
"narHash": "sha256-gCpvEQOrugHWLimD1wTFOJHagnSEP6VYBDspq96Idu0=", "narHash": "sha256-eKQ7aBkNvF5AhUpyJ1cW450jxomZ4gTIaYir5qsNl7Y=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "15d87419f1a123d8f888d608129c3ce3ff8f13d4", "rev": "6d68c475c7aaf7534251182662456a4bf4216dfe",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -24,7 +24,7 @@
{ {
file = ./rust-toolchain.toml; file = ./rust-toolchain.toml;
# sha256 = nixpkgs.lib.fakeSha256; # sha256 = nixpkgs.lib.fakeSha256;
sha256 = "sha256-X/4ZBHO3iW0fOenQ3foEvscgAPJYl2abspaBThDOukI="; sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU=";
}; };
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain; craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;

View File

@@ -9,21 +9,18 @@ default:
alias b := build alias b := build
# build app # build app
[group('build')]
build: build:
cargo build cargo build
alias t := test alias t := test
# run tests # run tests
[group('test')]
test: test:
cargo test cargo test
alias f := format alias f := format
# format files # format files
[group('misc')]
format: format:
just --fmt just --fmt
cargo fmt cargo fmt
@@ -31,106 +28,79 @@ format:
alias l := lint alias l := lint
# lint # lint
[group('misc')]
lint: lint:
cargo clippy --no-deps cargo clippy --no-deps
alias r := run alias r := run
# run app # run app
[group('dev')]
run: run:
cargo run cargo run
alias ra := run-args
# run app with arguments. It expects arguments as a string (e.g. "-c 5:00").
[group('dev')]
run-args args:
cargo run -- {{ args }}
alias rs := run-sound alias rs := run-sound
# run app while sound feature is enabled. It expects a path to a sound file. # run app while sound feature is enabled. It expects a path to a sound file.
[group('dev')]
run-sound path: run-sound path:
cargo run --features sound -- --sound={{ path }} cargo run --features sound -- --sound={{ path }}
alias rsa := run-sound-args
# run app while sound feature is enabled by adding a path to a sound file and other arguments as string (e.g. "-c 5:00").
[group('dev')]
run-sound-args path args:
cargo run --features sound -- --sound={{ path }} {{ args }}
# demos # demos
alias dp := demo-pomodoro alias dp := demo-pomodoro
# build demo: pomodoro # build demo: pomodoro
[group('demo')]
demo-pomodoro: demo-pomodoro:
vhs demo/pomodoro.tape vhs demo/pomodoro.tape
alias dt := demo-timer alias dt := demo-timer
# build demo: timer # build demo: timer
[group('demo')]
demo-timer: demo-timer:
vhs demo/timer.tape vhs demo/timer.tape
alias dc := demo-countdown alias dc := demo-countdown
# build demo: countdown # build demo: countdown
[group('demo')]
demo-countdown: demo-countdown:
vhs demo/countdown.tape vhs demo/countdown.tape
alias dcm := demo-countdown-met alias dcm := demo-countdown-met
# build demo: countdown + met # build demo: countdown + met
[group('demo')]
demo-countdown-met: demo-countdown-met:
vhs demo/countdown-met.tape vhs demo/countdown-met.tape
alias ds := demo-style alias ds := demo-style
# build demo: styles # build demo: styles
[group('demo')]
demo-style: demo-style:
vhs demo/style.tape vhs demo/style.tape
alias dd := demo-decis alias dd := demo-decis
# build demo: deciseconds # build demo: deciseconds
[group('demo')]
demo-decis: demo-decis:
vhs demo/decis.tape vhs demo/decis.tape
alias dm := demo-menu alias dm := demo-menu
# build demo: menu # build demo: menu
[group('demo')]
demo-menu: demo-menu:
vhs demo/menu.tape vhs demo/menu.tape
alias dlt := demo-local-time alias dlt := demo-local-time
# build demo: local time # build demo: local time
[group('demo')]
demo-local-time: demo-local-time:
vhs demo/local-time.tape vhs demo/local-time.tape
alias drc := demo-rocket-countdown alias drc := demo-rocket-countdown
# build demo: rocket countdown # build demo: rocket countdown
[group('demo')]
demo-rocket-countdown: demo-rocket-countdown:
vhs demo/met.tape vhs demo/met.tape
alias db := demo-blink alias db := demo-blink
# build demo: blink animation # build demo: blink animation
[group('demo')]
demo-blink: demo-blink:
vhs demo/blink.tape vhs demo/blink.tape

View File

@@ -1,6 +1,6 @@
[toolchain] [toolchain]
# Reminder: Always keep `rust-version` in `Cargo.toml` in sync with `channel`. # Reminder: Always keep `rust-version` in `Cargo.toml` in sync with `channel`.
channel = "1.86.0" channel = "1.85.0"
components = ["clippy", "rustfmt", "rust-src", "rust-analyzer"] components = ["clippy", "rustfmt", "rust-src", "rust-analyzer"]
targets = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl"] targets = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl"]
profile = "minimal" profile = "minimal"

View File

@@ -103,11 +103,7 @@ impl From<FromAppArgs> for App {
initial_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown), initial_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown),
// invalidate `current_value_countdown` if an initial value is set via args // invalidate `current_value_countdown` if an initial value is set via args
current_value_countdown: args.countdown.unwrap_or(stg.current_value_countdown), current_value_countdown: args.countdown.unwrap_or(stg.current_value_countdown),
elapsed_value_countdown: match args.countdown { elapsed_value_countdown: stg.elapsed_value_countdown,
// reset value if countdown is set by arguments
Some(_) => Duration::ZERO,
None => stg.elapsed_value_countdown,
},
current_value_timer: stg.current_value_timer, current_value_timer: stg.current_value_timer,
app_tx, app_tx,
#[cfg(feature = "sound")] #[cfg(feature = "sound")]

View File

@@ -144,6 +144,8 @@ impl CountdownState {
impl TuiEventHandler for CountdownState { impl TuiEventHandler for CountdownState {
fn update(&mut self, event: TuiEvent) -> Option<TuiEvent> { fn update(&mut self, event: TuiEvent) -> Option<TuiEvent> {
let is_edit_clock = self.clock.is_edit_mode();
let is_edit_time = self.edit_time.is_some();
match event { match event {
TuiEvent::Tick => { TuiEvent::Tick => {
if !self.clock.is_done() { if !self.clock.is_done() {
@@ -189,9 +191,11 @@ impl TuiEventHandler for CountdownState {
} }
// STRG + e => toggle edit time // STRG + e => toggle edit time
KeyCode::Char('e') if key.modifiers.contains(KeyModifiers::CONTROL) => { KeyCode::Char('e') if key.modifiers.contains(KeyModifiers::CONTROL) => {
// reset both clocks // stop editing clock
self.clock.reset(); if self.clock.is_edit_mode() {
self.elapsed_clock.reset(); // toggle edit mode
self.clock.toggle_edit();
}
if let Some(edit_time) = &mut self.edit_time.clone() { if let Some(edit_time) = &mut self.edit_time.clone() {
self.edit_time_done(edit_time) self.edit_time_done(edit_time)
@@ -203,8 +207,18 @@ impl TuiEventHandler for CountdownState {
max: self.max_time_to_edit(), max: self.max_time_to_edit(),
})); }));
} }
// stop `clock`
if self.clock.is_running() {
self.clock.toggle_pause();
} }
// e => toggle edit clock
// stop `elapsed_clock`
if self.elapsed_clock.is_running() {
self.elapsed_clock.toggle_pause();
}
}
// STRG + e => toggle edit clock
KeyCode::Char('e') => { KeyCode::Char('e') => {
// toggle edit mode // toggle edit mode
self.clock.toggle_edit(); self.clock.toggle_edit();
@@ -213,38 +227,47 @@ impl TuiEventHandler for CountdownState {
if self.elapsed_clock.is_running() { if self.elapsed_clock.is_running() {
self.elapsed_clock.toggle_pause(); self.elapsed_clock.toggle_pause();
} }
// finish `edit_time` and continue for using `clock`
if let Some(edit_time) = &mut self.edit_time.clone() {
self.edit_time_done(edit_time);
} }
KeyCode::Left if self.is_clock_edit_mode() => { }
KeyCode::Left if is_edit_clock => {
self.clock.edit_next(); self.clock.edit_next();
} }
KeyCode::Left if self.is_time_edit_mode() => { KeyCode::Left if is_edit_time => {
// safe unwrap because of previous check in `is_time_edit_mode` // safe unwrap because of previous check in `is_edit_time`
self.edit_time.as_mut().unwrap().next(); self.edit_time.as_mut().unwrap().next();
} }
KeyCode::Right if self.is_clock_edit_mode() => { KeyCode::Right if is_edit_clock => {
self.clock.edit_prev(); self.clock.edit_prev();
} }
KeyCode::Right if self.is_time_edit_mode() => { KeyCode::Right if is_edit_time => {
// safe unwrap because of previous check in `is_time_edit_mode` // safe unwrap because of previous check in `is_edit_time`
self.edit_time.as_mut().unwrap().prev(); self.edit_time.as_mut().unwrap().prev();
} }
KeyCode::Up if self.is_clock_edit_mode() => { KeyCode::Up if is_edit_clock => {
self.clock.edit_up(); self.clock.edit_up();
// whenever `clock`'s value is changed, reset `elapsed_clock` // whenever `clock`'s value is changed, reset `elapsed_clock`
self.elapsed_clock.reset(); self.elapsed_clock.reset();
} }
KeyCode::Up if self.is_time_edit_mode() => { KeyCode::Up if is_edit_time => {
// safe unwrap because of previous check in `is_time_edit_mode` // safe unwrap because of previous check in `is_edit_time`
self.edit_time.as_mut().unwrap().up(); self.edit_time.as_mut().unwrap().up();
// whenever `clock`'s value is changed, reset `elapsed_clock`
self.elapsed_clock.reset();
} }
KeyCode::Down if self.is_clock_edit_mode() => { KeyCode::Down if is_edit_clock => {
self.clock.edit_down(); self.clock.edit_down();
// whenever clock value is changed, reset timer // whenever clock value is changed, reset timer
self.elapsed_clock.reset(); self.elapsed_clock.reset();
} }
KeyCode::Down if self.is_time_edit_mode() => { KeyCode::Down if is_edit_time => {
// safe unwrap because of previous check in `is_time_edit_mode` // safe unwrap because of previous check in `is_edit_time`
self.edit_time.as_mut().unwrap().down(); self.edit_time.as_mut().unwrap().down();
// whenever clock value is changed, reset timer
self.elapsed_clock.reset();
} }
_ => return Some(event), _ => return Some(event),
}, },