#health #computer-hygiene

bin+lib take-breath

A program that reminds you when to take a breath from your computer

6 releases

0.1.5 Aug 9, 2021
0.1.4 Aug 7, 2021

#432 in Command line utilities

MIT license

17KB
302 lines

Table of Contents

  1. Take Breath
  2. Algorithm
  3. Roadmap
  4. Building
  5. Compilation features
  6. Usage
  7. Customization
  8. License
  9. Contribution

Take Breath

Take Breath is a program that reminds you when it is time to take a breath from your computer.

Algorithm

When the program starts, it starts a work time counter. When the work time counter is greater than 45 minutes, program notifies you to take a breath and starts a computer idle time counter. When the computer idle time counter is less than 15 minutes, program notifies you that your rest is too short and you should rest more. Otherwise it starts a work time counter again.

Roadmap

  • Basic algorithm implementation
  • Handle idle while work
  • Split app into library and binary parts
  • Customization features
  • Compilation features
  • Action customization features
  • Better error handling
  • Auto-start features
  • CLI implementation
  • Documentation
  • [-] Support for various operating systems
    • Linux (X only)
    • Mac (not tested)
    • Windows (not tested)

Building

In order to compile Take Breath program you should have Rust toolchain installed. If you have, just run the following shell commands:

git clone https://github.com/markmelix/take-breath.git
cd take-breath
cargo build --release

It puts compiled take-breath file into the ./target/release directory.

You can also get compiled take-breath program without cloning the repository using the following command: "cargo install take-breath". It puts compiled take-breath file into the ~/.cargo/bin directory.

Compilation features

Compilation features allow you to use only those program features that you need. For example, if you don't use configuration files or notifications, you can disable these features. Description of each feature:

Name Description Dependencies
notify notifications notify-rust
config configuration files serde/derive, humantime-serde, toml, dirs
cli cli features clap

By default, all of these features are activated. If you want to use only specific features, add --no-default-features --features at the end of the cargo build/install command. For example:

# Activate only config and cli features. So, we can configure the program using
# configuration file (see customization section) and command arguments.
cargo build --release --no-default-features --features config,cli # if you build program manually
cargo install --no-default-features --features config,cli # if you use cargo install

# Activate only notify feature. So, we cannot configure program at all, but we
# can see notification messages to get information.
cargo build --release --no-default-features --features notify # if you build program manually
cargo install --no-default-features --features notify # if you use cargo install

Usage

Note that for now only Linux is supported by the program

Just run the following command in a terminal: "take-breath &". It executes take-breath program as a background process.

Customization

When you first start a program, it will automatically create take-breath configuration directory with config.toml file in the one of the following directories depending on the system:

Platform Value
Linux $XDG_CONFIG_HOME or $HOME/.config
macOS $HOME/Library/Application Support
Windows %USERPROFILE%\AppData\Roaming

After creation config file has the following data:

[work_time]
duration = '45m'
idle_to_pause = '2m'

[rest_time]
duration = '15m'

This file is written in the TOML format. Description of each field:

Field Description Default Value
work_time.duration Work duration 45m
work_time.idle_to_pause How much time computer have to be idle to pause work time counter 2m
rest_time.duration Rest duration 15m

License

Take Breath is provided under MIT License.

Contribution

Contributions are welcome.

Dependencies

~0–30MB
~482K SLoC