tock

Crates.iotock
lib.rstock
version1.0.1
sourcesrc
created_at2019-06-17 03:53:47.449681
updated_at2023-10-13 00:28:33.876935
descriptionDigital clock for the terminal
homepagehttps://github.com/nwtnni/tock
repositoryhttps://github.com/nwtnni/tock
max_upload_size
id141664
size140,038
Newton Ni (nwtnni)

documentation

README

tock

A digital clock for the terminal, inspired by tty-clock. Unfortunately only works on UNIX systems due to the use of the termios and sigaction related function calls.

Note: emulating all features of tty-clock is not a goal of this project.

Features

  • Efficient bitmap and diff-based drawing
  • Timezone support via the TZ environment variable and tzselect utility
  • Military time and second display toggling
  • Color customization using ANSI, 8-bit, or 24-bit color values
  • Arbitrary date formatting
  • Positioned or centered clock
  • Adjustable display size
  • Synchronization with system clock seconds
  • Minimal syscalls (about one read, write, nanosleep per second)

Screenshots

Screenshot of clock

asciicast of multiple clocks

Installation

Currently requires a Rust installation with version >= 1.70.0 (due to the IsTerminal trait, and is only available from either:

  1. crates.io using cargo-install
cargo install tock
  1. Building from source
git clone https://github.com/nwtnni/tock.git
cargo build --release
./target/release/tock

Usage

A digital clock for the terminal.

Usage: tock [OPTIONS]

Options:
  -x, --x <X>            Horizontal 0-indexed position of top-left corner [default: 0]
  -y, --y <Y>            Vertical 0-indexed position of top-left corner [default: 0]
  -W, --width <WIDTH>    Font width in characters per tile [default: 2]
  -H, --height <HEIGHT>  Font height in characters per tile [default: 1]
  -s, --second           Display seconds
  -m, --military         Display military (24-hour) time
  -c, --center           Center the clock in the terminal. Overrides manual positioning
  -C, --color <COLOR>    Change the color of the time [default: 2]
  -f, --format <FORMAT>  Change the date format [default: "%F | %Z"]
  -h, --help             Print help (see more with '--help')

Currently compiles with the interactive feature flag set by default, which polls stdin for user input once per second. Available commands with this feature flag set are:

  • q or Q or <ESC>: Exit.
  • s: Toggle second display.
  • m: Toggle military (24H) time.
  • 0..=7: Change to corresponding ANSI color.

References

Commit count: 88

cargo fmt