Compare commits
2 Commits
49bafa2567
...
f13dc7f10e
| Author | SHA1 | Date | |
|---|---|---|---|
| f13dc7f10e | |||
| abad26d9d2 |
13
README.md
Normal file
13
README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# AntiDrift
|
||||||
|
|
||||||
|
Just my personal productivity tool. It asks me about my intention for the next
|
||||||
|
work session. Until I have provided an intention, duration, and start a
|
||||||
|
session, it forcefully minimizes all windows. It then records all active
|
||||||
|
windows during the session. At the end, it allows me to rate how relevant each
|
||||||
|
window was and calculates a session score from that.
|
||||||
|
|
||||||
|
To use AntiDrift, run `cargo run --release` directly, or `cargo build --release`
|
||||||
|
and copy the binary into your `PATH`.
|
||||||
|
|
||||||
|
Uses `xdotool` to get window titles and minimize windows. Currently Linux with
|
||||||
|
X11 is the only supported platform.
|
||||||
41
src/main.rs
41
src/main.rs
@@ -94,7 +94,6 @@ impl App {
|
|||||||
fn to_end(&mut self) {
|
fn to_end(&mut self) {
|
||||||
self.state = State::End;
|
self.state = State::End;
|
||||||
self.session_ratings = session_stats_as_vec(&self.session_stats);
|
self.session_ratings = session_stats_as_vec(&self.session_stats);
|
||||||
self.user_intention = "Press 1, 2, 3 to rate titles".to_string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tick_50ms(&mut self) {
|
fn tick_50ms(&mut self) {
|
||||||
@@ -271,7 +270,6 @@ fn handle_events(app: &mut App) -> Result<()> {
|
|||||||
|
|
||||||
if app.session_ratings_index >= app.session_ratings.len() {
|
if app.session_ratings_index >= app.session_ratings.len() {
|
||||||
app.state = State::InputIntention;
|
app.state = State::InputIntention;
|
||||||
app.user_intention = "Next session!".to_string();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +298,8 @@ fn ui(frame: &mut Frame, app: &App) {
|
|||||||
Constraint::Percentage(100),
|
Constraint::Percentage(100),
|
||||||
Constraint::Min(3),
|
Constraint::Min(3),
|
||||||
]);
|
]);
|
||||||
let [layout_intention, layout_duration, layout_titles, layout_status] = layout.areas(frame.size());
|
let [layout_intention, layout_duration, layout_titles, layout_status] =
|
||||||
|
layout.areas(frame.size());
|
||||||
|
|
||||||
let border_type_intention = if app.state == State::InputIntention {
|
let border_type_intention = if app.state == State::InputIntention {
|
||||||
BorderType::Thick
|
BorderType::Thick
|
||||||
@@ -348,22 +347,42 @@ fn ui(frame: &mut Frame, app: &App) {
|
|||||||
let span = Span::styled("Provide intention! ", Style::new().fg(Color::LightRed));
|
let span = Span::styled("Provide intention! ", Style::new().fg(Color::LightRed));
|
||||||
spans.push(span);
|
spans.push(span);
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.user_duration == Duration::ZERO {
|
if app.user_duration == Duration::ZERO {
|
||||||
let span = Span::styled("Provide valid duration in minutes! ", Style::new().fg(Color::LightRed));
|
let span = Span::styled(
|
||||||
|
"Provide valid duration in minutes! ",
|
||||||
|
Style::new().fg(Color::LightRed),
|
||||||
|
);
|
||||||
spans.push(span);
|
spans.push(span);
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.state == State::InProgress {
|
match app.state {
|
||||||
let span = Span::styled("Session In-Progress", Style::new().fg(Color::LightGreen));
|
State::InputIntention | State::InputDuration => {
|
||||||
spans.push(span);
|
if spans.len() == 0 {
|
||||||
|
let span = Span::styled(
|
||||||
|
"Ready to start next session.",
|
||||||
|
Style::new().fg(Color::LightGreen),
|
||||||
|
);
|
||||||
|
spans.push(span);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
State::InProgress => {
|
||||||
|
let span = Span::styled("Session In-Progress", Style::new().fg(Color::LightGreen));
|
||||||
|
spans.push(span);
|
||||||
|
}
|
||||||
|
State::ShouldQuit => {}
|
||||||
|
State::End => {
|
||||||
|
let span = Span::styled(
|
||||||
|
"Press 1, 2, 3 to rate titles!",
|
||||||
|
Style::new().fg(Color::LightBlue),
|
||||||
|
);
|
||||||
|
spans.push(span);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let input_status: Vec<Line> = vec![Line::from(spans)];
|
let input_status: Vec<Line> = vec![Line::from(spans)];
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Paragraph::new(input_status).block(
|
Paragraph::new(input_status).block(Block::bordered().title("Status")),
|
||||||
Block::bordered().title("Status"),
|
|
||||||
),
|
|
||||||
layout_status,
|
layout_status,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user