Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e700691ba | ||
|
|
c29f8c5d1b | ||
|
|
ad11ff2c48 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,18 +1,5 @@
|
||||
# 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
|
||||
|
||||
### Features
|
||||
@@ -28,6 +15,7 @@
|
||||
- (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)
|
||||
|
||||
|
||||
## v1.1.0 - 2025-01-22
|
||||
|
||||
### Features
|
||||
|
||||
@@ -4,14 +4,13 @@ version = "1.2.0"
|
||||
description = "TUI to organize your time: Pomodoro, Countdown, Timer."
|
||||
edition = "2024"
|
||||
# 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"
|
||||
repository = "https://github.com/sectore/timr-tui"
|
||||
readme = "README.md"
|
||||
license = "MIT"
|
||||
keywords = ["tui", "timer", "countdown", "pomodoro"]
|
||||
categories = ["command-line-utilities"]
|
||||
exclude = [".github/*", "demo/*.tape", "result/*", "*.mp3"]
|
||||
|
||||
[dependencies]
|
||||
ratatui = "0.29.0"
|
||||
@@ -36,6 +35,5 @@ rodio = { version = "0.20.1", features = [
|
||||
], default-features = false, optional = true }
|
||||
thiserror = { version = "2.0.11", optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
sound = ["dep:rodio", "dep:thiserror"]
|
||||
|
||||
35
README.md
35
README.md
@@ -48,7 +48,7 @@ _Side note:_ Theme colors depend on your terminal preferences.
|
||||
<img alt="menu" src="demo/menu.gif" />
|
||||
</a>
|
||||
|
||||
## Local time (footer)
|
||||
## Local time
|
||||
|
||||
<a href="demo/local-time.gif">
|
||||
<img alt="menu" src="demo/local-time.gif" />
|
||||
@@ -80,15 +80,15 @@ Options:
|
||||
--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).
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
```
|
||||
|
||||
Extra option (if `--features sound` is enabled by local build only):
|
||||
|
||||
```sh
|
||||
--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
|
||||
|
||||
## Cargo
|
||||
@@ -113,10 +113,12 @@ Install [from the AUR](https://aur.archlinux.org/packages/timr/):
|
||||
paru -S timr
|
||||
```
|
||||
|
||||
|
||||
## Release binaries
|
||||
|
||||
Pre-built artifacts are available to download from [latest GitHub release](https://github.com/sectore/timr-tui/releases).
|
||||
|
||||
|
||||
# Development
|
||||
|
||||
## 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`.
|
||||
|
||||
|
||||
### Non Nix users
|
||||
|
||||
- [`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
|
||||
|
||||
Available recipes:
|
||||
default # list commands
|
||||
|
||||
[build]
|
||||
build # build app [alias: b]
|
||||
|
||||
[demo]
|
||||
default # list commands
|
||||
demo-blink # build demo: blink animation [alias: db]
|
||||
demo-countdown # build demo: countdown [alias: dc]
|
||||
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-style # build demo: styles [alias: ds]
|
||||
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]
|
||||
lint # lint [alias: l]
|
||||
|
||||
[test]
|
||||
run # run app [alias: r]
|
||||
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]
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
- Linux
|
||||
|
||||
```sh
|
||||
nix build
|
||||
# or for bulding w/ statically linked binaries
|
||||
@@ -182,17 +172,10 @@ nix build .#linuxStatic
|
||||
```
|
||||
|
||||
- Windows (cross-compilation)
|
||||
|
||||
```sh
|
||||
nix build .#windows
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
```sh
|
||||
cargo test
|
||||
```
|
||||
|
||||
# Misc.
|
||||
|
||||
## Persistant app state
|
||||
|
||||
24
flake.lock
generated
24
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1744386647,
|
||||
"narHash": "sha256-DXwQEJllxpYeVOiSlBhQuGjfvkoGHTtILLYO2FvcyzQ=",
|
||||
"lastModified": 1739936662,
|
||||
"narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "d02c1cdd7ec539699aa44e6ff912e15535969803",
|
||||
"rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -23,11 +23,11 @@
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1744231114,
|
||||
"narHash": "sha256-60gLl2rJFt6SRwqWimsTAeHgfsIE1iV0zChdJFOvx8w=",
|
||||
"lastModified": 1740378829,
|
||||
"narHash": "sha256-cwmm7F73aQFJY6YN1roNibNKwxT6FlfXkG3MEbpSp7Q=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "0ccfe532b1433da8e5a23cd513ff6847e0f6a8c2",
|
||||
"rev": "92823f1b0c919d7e2d806956aaf98e90f3761ab7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -56,11 +56,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1744463964,
|
||||
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
|
||||
"lastModified": 1740367490,
|
||||
"narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
|
||||
"rev": "0196c0175e9191c474c26ab5548db27ef5d34b05",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -81,11 +81,11 @@
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1742296961,
|
||||
"narHash": "sha256-gCpvEQOrugHWLimD1wTFOJHagnSEP6VYBDspq96Idu0=",
|
||||
"lastModified": 1740329432,
|
||||
"narHash": "sha256-eKQ7aBkNvF5AhUpyJ1cW450jxomZ4gTIaYir5qsNl7Y=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "15d87419f1a123d8f888d608129c3ce3ff8f13d4",
|
||||
"rev": "6d68c475c7aaf7534251182662456a4bf4216dfe",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
{
|
||||
file = ./rust-toolchain.toml;
|
||||
# sha256 = nixpkgs.lib.fakeSha256;
|
||||
sha256 = "sha256-X/4ZBHO3iW0fOenQ3foEvscgAPJYl2abspaBThDOukI=";
|
||||
sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU=";
|
||||
};
|
||||
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
||||
|
||||
30
justfile
30
justfile
@@ -9,21 +9,18 @@ default:
|
||||
alias b := build
|
||||
|
||||
# build app
|
||||
[group('build')]
|
||||
build:
|
||||
cargo build
|
||||
|
||||
alias t := test
|
||||
|
||||
# run tests
|
||||
[group('test')]
|
||||
test:
|
||||
cargo test
|
||||
|
||||
alias f := format
|
||||
|
||||
# format files
|
||||
[group('misc')]
|
||||
format:
|
||||
just --fmt
|
||||
cargo fmt
|
||||
@@ -31,106 +28,79 @@ format:
|
||||
alias l := lint
|
||||
|
||||
# lint
|
||||
[group('misc')]
|
||||
lint:
|
||||
cargo clippy --no-deps
|
||||
|
||||
alias r := run
|
||||
|
||||
# run app
|
||||
[group('dev')]
|
||||
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
|
||||
|
||||
# run app while sound feature is enabled. It expects a path to a sound file.
|
||||
[group('dev')]
|
||||
run-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
|
||||
|
||||
alias dp := demo-pomodoro
|
||||
|
||||
# build demo: pomodoro
|
||||
[group('demo')]
|
||||
demo-pomodoro:
|
||||
vhs demo/pomodoro.tape
|
||||
|
||||
alias dt := demo-timer
|
||||
|
||||
# build demo: timer
|
||||
[group('demo')]
|
||||
demo-timer:
|
||||
vhs demo/timer.tape
|
||||
|
||||
alias dc := demo-countdown
|
||||
|
||||
# build demo: countdown
|
||||
[group('demo')]
|
||||
demo-countdown:
|
||||
vhs demo/countdown.tape
|
||||
|
||||
alias dcm := demo-countdown-met
|
||||
|
||||
# build demo: countdown + met
|
||||
[group('demo')]
|
||||
demo-countdown-met:
|
||||
vhs demo/countdown-met.tape
|
||||
|
||||
alias ds := demo-style
|
||||
|
||||
# build demo: styles
|
||||
[group('demo')]
|
||||
demo-style:
|
||||
vhs demo/style.tape
|
||||
|
||||
alias dd := demo-decis
|
||||
|
||||
# build demo: deciseconds
|
||||
[group('demo')]
|
||||
demo-decis:
|
||||
vhs demo/decis.tape
|
||||
|
||||
alias dm := demo-menu
|
||||
|
||||
# build demo: menu
|
||||
[group('demo')]
|
||||
demo-menu:
|
||||
vhs demo/menu.tape
|
||||
|
||||
alias dlt := demo-local-time
|
||||
|
||||
# build demo: local time
|
||||
[group('demo')]
|
||||
demo-local-time:
|
||||
vhs demo/local-time.tape
|
||||
|
||||
alias drc := demo-rocket-countdown
|
||||
|
||||
# build demo: rocket countdown
|
||||
[group('demo')]
|
||||
demo-rocket-countdown:
|
||||
vhs demo/met.tape
|
||||
|
||||
alias db := demo-blink
|
||||
|
||||
# build demo: blink animation
|
||||
[group('demo')]
|
||||
demo-blink:
|
||||
vhs demo/blink.tape
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[toolchain]
|
||||
# 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"]
|
||||
targets = ["x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl"]
|
||||
profile = "minimal"
|
||||
|
||||
@@ -103,11 +103,7 @@ impl From<FromAppArgs> for App {
|
||||
initial_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown),
|
||||
// invalidate `current_value_countdown` if an initial value is set via args
|
||||
current_value_countdown: args.countdown.unwrap_or(stg.current_value_countdown),
|
||||
elapsed_value_countdown: match args.countdown {
|
||||
// reset value if countdown is set by arguments
|
||||
Some(_) => Duration::ZERO,
|
||||
None => stg.elapsed_value_countdown,
|
||||
},
|
||||
elapsed_value_countdown: stg.elapsed_value_countdown,
|
||||
current_value_timer: stg.current_value_timer,
|
||||
app_tx,
|
||||
#[cfg(feature = "sound")]
|
||||
|
||||
@@ -144,6 +144,8 @@ impl CountdownState {
|
||||
|
||||
impl TuiEventHandler for CountdownState {
|
||||
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 {
|
||||
TuiEvent::Tick => {
|
||||
if !self.clock.is_done() {
|
||||
@@ -189,9 +191,11 @@ impl TuiEventHandler for CountdownState {
|
||||
}
|
||||
// STRG + e => toggle edit time
|
||||
KeyCode::Char('e') if key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
// reset both clocks
|
||||
self.clock.reset();
|
||||
self.elapsed_clock.reset();
|
||||
// stop editing clock
|
||||
if self.clock.is_edit_mode() {
|
||||
// toggle edit mode
|
||||
self.clock.toggle_edit();
|
||||
}
|
||||
|
||||
if let Some(edit_time) = &mut self.edit_time.clone() {
|
||||
self.edit_time_done(edit_time)
|
||||
@@ -203,8 +207,18 @@ impl TuiEventHandler for CountdownState {
|
||||
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') => {
|
||||
// toggle edit mode
|
||||
self.clock.toggle_edit();
|
||||
@@ -213,38 +227,47 @@ impl TuiEventHandler for CountdownState {
|
||||
if self.elapsed_clock.is_running() {
|
||||
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();
|
||||
}
|
||||
KeyCode::Left if self.is_time_edit_mode() => {
|
||||
// safe unwrap because of previous check in `is_time_edit_mode`
|
||||
KeyCode::Left if is_edit_time => {
|
||||
// safe unwrap because of previous check in `is_edit_time`
|
||||
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();
|
||||
}
|
||||
KeyCode::Right if self.is_time_edit_mode() => {
|
||||
// safe unwrap because of previous check in `is_time_edit_mode`
|
||||
KeyCode::Right if is_edit_time => {
|
||||
// safe unwrap because of previous check in `is_edit_time`
|
||||
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();
|
||||
// whenever `clock`'s value is changed, reset `elapsed_clock`
|
||||
self.elapsed_clock.reset();
|
||||
}
|
||||
KeyCode::Up if self.is_time_edit_mode() => {
|
||||
// safe unwrap because of previous check in `is_time_edit_mode`
|
||||
KeyCode::Up if is_edit_time => {
|
||||
// safe unwrap because of previous check in `is_edit_time`
|
||||
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();
|
||||
// whenever clock value is changed, reset timer
|
||||
self.elapsed_clock.reset();
|
||||
}
|
||||
KeyCode::Down if self.is_time_edit_mode() => {
|
||||
// safe unwrap because of previous check in `is_time_edit_mode`
|
||||
KeyCode::Down if is_edit_time => {
|
||||
// safe unwrap because of previous check in `is_edit_time`
|
||||
self.edit_time.as_mut().unwrap().down();
|
||||
// whenever clock value is changed, reset timer
|
||||
self.elapsed_clock.reset();
|
||||
}
|
||||
_ => return Some(event),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user